
var UserCode = helper.cookies.get("usercode");
var openid = helper.cookies.get("openid");
var custome = helper.request.queryString("custome");
(function($) {
	$.init();
	var result = $('#result')[0];
	var btns = $('.btn');
	btns.each(function(i, btn) {
		btn.addEventListener('tap', function() {
			var optionsJson = this.getAttribute('data-options') || '{}';
			var options = JSON.parse(optionsJson);
			var id = this.getAttribute('id');
			var picker = new $.DtPicker(options);
			picker.show(function(rs) {
				result.value = rs.text;
				picker.dispose();
			});
		}, false);
	});
})(mui);
$('.return').on('tap', function() {
	// + '&itype=' + itype
	window.location.href = "tenant_edit.html?custome="+ custome;
});
$(function() {
	
	//提交按钮
	$('#submit').on('tap', function() {
		var sex =$('.order_sex').find('input[type="radio"]:checked').val();
		var tax =$('.order_tax').find('input[type="radio"]:checked').val();
		if (sex==0) {
			sexSt="男"
		} else{
			sexSt="女"
		}
		if (tax==0) {
			taxSt="已婚"
		} else{
			taxSt="未婚"
		}
		
		if($('#order_name').val() == '') {
			mui.alert('请输入姓名！') //请输入姓名
		} else if($('#order_tel').val() == '') {
			mui.alert('请输入电话！') //请输入电话
		} else{
			$.ajax({
				type: "post",
				dataType: 'json',
				url: huayi.config.callcenter_url + '/WxLogin/AddCustomer',
				async: true,
				data: {
					//F_CustomerId	是	string	用户ID
					F_CustomerName: $('#order_name').val(), //客户姓名  string	
					F_Mobile: $('#order_tel').val(), //否	string	联系电话   string	
					F_CustomerEName: sexSt, //性别   string	性别（男，女）
					F_TaxID: taxSt, //婚姻状况
					F_CustomerPym: $('#result').val(), //出生年月
					F_LegalRepresentativeCardID: $('#order_ID').val(), //身份证号   string	
					F_Nature: $('#order_Nature').val(), //籍贯  string
					F_Kind: $('#order_Kind').val(), //车牌号 string
					F_Notes: $('#order_Notes').val(), //备注信息 string
					openid: openid,
				},
				success: function(data) {
					if(data.state == "success") {
						debugger
						//alert($('#order_Notes').val()), //描述详情
						mui.toast('投诉成功');
						$('#order_name').val(''), //客户姓名
						$('#order_tel').val(''), //否	string	联系电话
						$("#order_rengin").attr(''), //区域名称
						$("#order_pro").attr(''), //项目名称
						$("#order_floor").attr(''), //楼号
						$('#order_room').val(''), //房间号
						$('#order_Notes').attr(''), //房东关系
						window.location.href="tenant_edit.html?custome="+custome;
									
						
					} else {
						mui.toast(data.message);
					}
				}
			});
		}
	})

				
	

})

