mui.init({})
var UserCode = helper.cookies.get("usercode");
var openid = helper.cookies.get("openid");
var areaID = helper.request.queryString("areaID");
//var openid = "oXF5e1mWpX5DajW5_yjNLPKb8ThE";
$(function() {
//	投诉咨询切换
	$('.order_type').find('input[type="radio"]').on('change', function() {
			if($(this).val() === "1") { //投诉
				$('#consult').show();  //receive
				$('#complaint').hide();
				$('#spot').hide();
			} else if($(this).val() === "2"){
				$('#complaint').show();
				$('#consult').hide();
				$('#spot').hide();
			}else if($(this).val() === "3"){
				$('#spot').show();
				$('#consult').hide();
				$('#complaint').hide();
			}
		});
// 完结不完结切换		
$('.wjbwj').find('input[type="radio"]').on('change', function() {
			if($(this).val() === "1") { //投诉
			  //receive
				$('#zhipaiyin').hide();
				$('#wanji').show();
                $('#zhipaaa').hide();
                $('#submit').hide();
			} else if($(this).val() === "2"){
				$('#zhipaiyin').show();
				$('#wanji').hide();
                $('#zhipaaa').hide();
                $('#submit').hide();
			}
		});
// 指派切换		
$('.zhipp').find('input[type="radio"]').on('change', function() {
			if($(this).val() === "3") { //投诉
			  //receive
				$('#zhipaaa').show();
				$('#buzp').show();
                $('#submit').hide();
                $('#wanji').hide();
			} else if($(this).val() === "4"){
				$('#zhipaaa').hide();
				$('#buzp').hide();
                $('#submit').show();
                $('#wanji').hide();
			}
		});
	//工单有效性 
	$('#order_valid').find('input[type="radio"]').on('change', function() {
		//是否有效工单项(0有效，1无效)
		if($(this).val() === "1") { //无效
			$('.order_note').show();
		} else {
			$('.order_note').hide();
		}
	});
	//提交按钮
	$('#submit').on('tap', function() {
//		var myreg = /^[1][3,4,5,7,8][0-9]{9}$/;
		var myreg11 = /^(([0\+]\d{2,3}-)?((0\d{2,3}))?(-)?)?(\d{7,8})(-(\d{3,}))?$/;
		var str = $("#order_tel").val();
		if($('#order_name').val() == '') {
			mui.alert('请输入客户姓名！') //请输入工单类型
		} else if($('#order_reception').val() == '') {
			mui.alert('请输入问题描述！') //请输入问题描述
		}    else {
			$.ajax({
				type: "post",
				dataType: 'json',
				url: huayi.config.callcenter_url + '/WxLogin/Add',
				async: true,
				data: {
					F_Source: $('#order_source').attr('data-index'), //工单来源
					F_Type: $('.order_type').find('input[type="radio"]:checked').val(), //工单类型
					F_CusName: $('#order_name').val(), //客户姓名
					F_CusPhone: $('#order_phone').val(), //否	string	客户电话
//					F_CompanyName: $("#order_tel").val(), //公司名称
                    F_Canal:$('#manager').attr('data-index'),
					F_IncidentDetailed: $("#order_tower").val(), //详细地址
					F_Description: $("#order_reception").val(), //问题描述
					F_WxOpenId: openid, //微信openid,				
				},
				success: function(data) {
					if(data.state == "success") {
						debugger
						window.location.href = "../fisrt_comprehensive/tourist.html";
					} else {
						mui.toast(data.message);
					}
				}
			});
		}
	})




function getDepts() {}
	

//渠道类型
var  keee = [];
	$.ajax({
		type: "get",
		url: huayi.config.callcenter_url + 'Dictionary/GetDicValueListByFlagWx',
		async: false,
		data: {
			flag: 'QDLX'
		},
		dataType: 'json',
		success: function(data) {
			var key_data = data.data;
//			console.log(key_data);
			$(key_data).each(function(i, n) {
				var obj = {};
				obj.value = n.F_DictionaryValueId;
				obj.text = n.F_Name;
				keee.push(obj)
//				console.log(ke);
			})
		}
	});






	
	


	
	(function($, doc) {
		$.init();
		$.ready(function() {
					
		
			//游客渠道类型
			var citye = new $.PopPicker();
				citye.setData(keee);
				var showCityPickerButt = doc.getElementById('trench');
				var cityResultion = doc.getElementById('manager');
				showCityPickerButt.addEventListener('tap', function(event) {
					citye.show(function(items) {
						cityResultion.value = items[0].text;
						cityResultion.setAttribute("data-index", items[0].text);
						//返回 false 可以阻止选择框的关闭
						//return false;
					});
			}, false);
			
			

			
		})
	})(mui, document);

})









//})
