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

	if (qrbbid >0) {
		$('.header .title').html("编辑亲人报备信息")
		JZL.ajax(qlgUrl('app/auth/getAuthFamilyReportInfo'), {id: qrbbid}, function(data) {
			//console.log(data);
			 if (data.status == 1) {
				 var data = data.data
				$('#familyName').val(data.familyName);
				$('#familyIdCard').val(data.familyIdCard);
				$('#familyRelations').val(data.familyRelations);
// 			   var html='<img data-src="' +data.familyRelationsImg + '" src="' + hyhImgUrl(data.familyRelationsImg)+ '" />';
// 			   $('#ossfile').html(html); 
$('#familyRelationsImg').val(data.familyRelationsImg)
$('#familyRelations1').attr('src',hyhImgUrl(data.familyRelationsImg))
			 } else {
 				 mui.alert(data.msg);
			 }
		})
	}else{
		$('.header .title').html("添加亲人报备信息")

	}
var click = false;

	$(".bc_btn").on('tap', function() {
		if(click ==true) return;
		
		click=true;
		
		var pargams = JZL.getParams('.inp');
		if (pargams.familyName == '') {
			mui.alert('姓名不能为空！');
			return;
		}
		if (pargams.familyIdCard == '') {
			mui.alert('身份证号不能为空！');
			return;
		}
		if (pargams.familyRelations == '') {
			mui.alert('与户主关系不能为空！');
			return;
		}
			if (pargams.familyRelationsImg == '') {
			mui.alert('请上传与户主关系照！');
			return;
		}
		 // $('.bc_btn').attr('disabled','disabled');
		 if (qrbbid >0) {
			 //console.log(qrbbid);
			 pargams.id=qrbbid
		 }
		 
		 JZL.ajax(qlgUrl('app/auth/setAuthFamilyReport'),pargams,function(data){
			 
			 //console.log(data);
			 	var data = toJson(data);
			 if(data.status == 1) {
			 	mui.back();
			 } else {
			 	// mui.alert('发生错误请刷新后重试！');
			 	//							location.reload();
			 mui.alert(data.msg)
			 }
		 })
		 
		 click = false
		
	})
//上传图片
		$('.renzhengphoto').on('tap','.familyRelations',function () {
			UP.init("familyRelationsImg", "test", "familyRelations1")
			openCamera()
		})
			
	})

