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

	var self = plus.webview.currentWebview();
	//console.log(self);
	orderIds = self.orderIds;
	shopId = self.shopId;
	if ('undefined' != typeof self.orderId) {
		id = self.orderId
	}
	if (id > 0) { //bianji
		JZL.ajax(qlgUrl('app/shopOrders/getCertificateInfo'), {
			shopId: shopId,
			id: id
		}, function(data) {
			//console.log(data);	
			$('#content').val(data.data.content);
			$('#img').attr('src', hyhImgUrl(data.data.imgUrl))
			$('#imgUrl').val(data.data.imgUrl)
		})
	}
	// 上传图片
	$(".oneImg").on("tap", '#img', function() {
		// UP.init("accountBookImg", "test", "accountBookImgTag")
		UP.init("imgUrl", "test", "img")
		openCamera()
	})

	var click = false;
	$(".con").on("tap", '.bc_btn', function() {
		if (true == click) return;
		click = true;
		var params = JZL.getParams(".inp");
		params.orderIds = orderIds;
		params.shopId = shopId;
		if (id > 0) {
			params.id = id;
		}
		if ('' == $.trim($('#content').val())) {
			mui.alert("请输入凭证说明")
			return;
		}
		if ('' == $('#imgUrl').val()) {
			mui.alert("请上传凭证图片")
			return;
		}
		JZL.ajax(qlgUrl('app/Shoporders/uploadCertificate'), params, function(data) {
			//console.log(data);
			if (-1 == data.status) {
				mui.alert(data.msg)
				mui.back();
			} else {
				mui.alert(data.msg)
			}
		})
	})
})
