mui.init({
	beforeback: function() { //获得父页面的webview
		var list = plus.webview.currentWebview().opener(); //触发父页面的自定义事件(refresh),从而进行刷新
		mui.fire(list, 'reload');
		//返回true,继续页面关闭逻辑
		return true;
	}
});

mui.plusReady(function() {
	//获取数值 
	$('.bg').css("display", 'none')
	var self = plus.webview.currentWebview()
	var shopId = self.id;
	var totlemoney = "";
	JZL.ajax(qlgUrl('app/users/getMoney'), {
		type: 3
	}, function(data) {
		if (1 == data.status) {
			var data = data.data;
			totlemoney = data.wangNum;
			// $('.idc-total span').html('￥'+data.wangNum)
			$('#money').val(totlemoney)
		} else {
			mui.alert(data.msg)
		}
		$('.btns').on('tap', '.sqtx', function() {
			if ($('#money').val() > totlemoney) {
				mui.alert("超过最大提现金额")
				return;
			} else if ('' == $('#money').val()) {
				mui.alert("请输入提现金额")
				return;
			} else if (1 > $('#money').val()) {
				mui.alert("提现金额不能小于1")
				return;
			}
			$('.bg').css('display', 'block');
			$('.footer').hide();
			JZL.ajax(qlgUrl('app/shops/getBank'), {
				shopId: shopId
			}, function(data) {
				//console.log(data);
				if (1 == data.status) {
					var data = data.data
					$('#bankUserName').val(data.accountName)
					// $('.bankname').prepend('<option value="' + data.bankName + '">' + data.bankName + '</option>')
					$('.bankname').val(data.bankName)
					$('#cardnum').val(data.bankNo)
					$('#money').on('focus', function() {
						$('.bg').css('display', 'none');
						$('.footer').show();
					})

				} else {
					mui.alert(data.msg)
				}
			})
		})
		$('.bg').on('tap', '.qrtx', function() {
			// mui.prompt("请输入操作密码:")
			mui.prompt('请输入操作密码', '', '全亮共商城', ['取消', '忘记密码', '确定'], function(e) {
				//console.log(e);
				if (2 == e.index) {
					var payPwd = e.value;
					if ('' == payPwd) {
						mui.alert('密码不能为空')
						return;
					}
					var money = $('#money').val();
					JZL.ajax(qlgUrl('app/shops/withdrawal'), {
						payPwd: payPwd,
						money: money,
						shopId: shopId
					}, function(data) {
						//console.log(data);
						if (1 == data.status) {
							mui.toast(data.msg)
							mui.back()
						} else {
							mui.alert(data.msg)
						}
					})
				} else if (1 == e.index) {
					JZL.openWindow('setting_fogetPwd.html', 'setting_fogetPwd.html')
				}

			}, 'div')
			document.querySelector('.mui-popup-input input').type = 'password'

			// 		var mark=mui.prompt("请输入操作密码:")
			// //console.log(document.querySelector('.mui-popup-input input').value)
			// 		if(null!=mark){
			// 		  var payPwd =document.getElementById('mark') 
			//            //console.log(payPwd);
			// 			}
		})
		$('.bg').on('tap', '.mui-icon-left-nav', function() {
			$('.bg').css('display', 'none');
			$('.footer').show();
		})
	})

	$('.btns').on('tap', '.ckmx', function() {
		JZL.openWindow("vouchers.html", "vouchers.html", {
			data_href: "wang",
			isExpected: 1
		})
	})
})
