mui.init({})
var UserCode = helper.cookies.get("usercode");
var openid = helper.cookies.get("openid");
(function($) {
	$.init();
	var result = $('#start_data')[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);
	});
	var result1 = $('#end_data')[0];
	var btns1 = $('.btn1');
	btns1.each(function(i, btn) {
		btn.addEventListener('tap', function() {
			var optionsJson = this.getAttribute('data-options') || '{}';
			var options1 = JSON.parse(optionsJson);
			var id = this.getAttribute('id');
			var picker = new $.DtPicker(options1);
			picker.show(function(rs) {
				result1.value = rs.text;
				picker.dispose();
			});
		}, false);
	});
	
})(mui);

//搜索
$('.return').on('tap', function() {
	window.location.href ="../client-side/Setting-1.html";

});
//搜索
$('.submit').on('tap', function() {
	
	keywords = $("#keyword").val();  //关键词
	Complaint = $("#complaint").attr('data-index'); //投诉类型
	State = $("#state").attr('data-index');  //工单状态
	Start_data = $("#start_data").val(); //开始日期
	End_data = $("#end_data").val(); //结束日期
//	window.location.href = "editWorkolder.html?id=" + id+'&itype='+itype;
	var start = new Date(Start_data.replace("-", "/").replace("-", "/"));
	var end = new Date(End_data.replace("-", "/").replace("-", "/"));
	//alert(keywords)
//	alert(start);
//	alert(end);
	if(start<end){
		window.location.href = "inquire.html?Keyword=" + decodeURI(keywords)+'&Complaint='+Complaint+'&State='+State+'&Start_data='+Start_data+'&End_data='+End_data;
	}else if(start>end){
		alert("开始时间大于结束时间，请重新选择");
		return
	}
	window.location.href = "inquire.html?Keyword=" + decodeURI(keywords)+'&Complaint='+Complaint+'&State='+State+'&Start_data='+Start_data+'&End_data='+End_data;
});




$(function() {
	//房东关系
	var keyList = [];
	console.log(keyList);
	$.ajax({
		type: "get",
		url: huayi.config.callcenter_url + 'Dictionary/GetDicValueListByFlagWx',
		async: false,
		data: {
			flag: 'GDLX'
		},
		dataType: 'json',
		success: function(data) {
			var key_data = data.data;
			console.log(data.data);
			$(key_data).each(function(i, n) {
				var obj = {};
				obj.value = n.F_DictionaryValueId;
				obj.text = n.F_Name;
				keyList.push(obj)
			})
		}
	});
	
	(function($, doc) {
		$.init();
		
		$.ready(function() {
//			投诉类型
			var cityPicker3 = new $.PopPicker();
			cityPicker3.setData(keyList);
			var showCityPickerButton = doc.getElementById('showCityPicker3');
			var cityResult3 = doc.getElementById('complaint');
			showCityPickerButton.addEventListener('tap', function(event) {
				cityPicker3.show(function(items) {
					cityResult3.value = items[0].text;
					cityResult3.setAttribute("data-index", items[0].value);
					//返回 false 可以阻止选择框的关闭
					//return false;
				});
			}, false);
//			工单状态
			var cityPicker = new $.PopPicker();
			cityPicker.setData(
					[{	value: '0',
					text: '待派单'},{
						value: '2',
						text: '待完成'
					},{
						value: '3',
						text: '已完成'
					},{
						value: '5',
						text: '超期工单'
					}]);
			var showCityPickerButton = doc.getElementById('showCityPicker');
			var cityResult = doc.getElementById('state');
			showCityPickerButton.addEventListener('tap', function(event) {
				cityPicker.show(function(items) {
					cityResult.value = items[0].text;
					cityResult.setAttribute("data-index", items[0].value);
					//返回 false 可以阻止选择框的关闭
					//return false;
				});
			}, false);
		})
	})(mui, document);

})

