<repo_name>sandianshiduofen/Szwechat<file_sep>/Szwechat/line.md
login

/login/login_tel.html		注册验证电话
/login/login_addr.html 	注册填写基本信息
/login/login_ok.html		注册成功


order

/order/self_help_order.html	自助下单
/order/order_succeed.html	运单提交成功
/order/send_out.html		发货记录
/order/receive.html		收货记录
/order/branch_info.html		网点详细信息
/order/share.html		运单提交成功
/order/logistics.html		发货查看物流
/order/logistics2.html		收货查看物流
/order/collection_info.html	代收款信息


ucenter

/ucenter/common_tel_edit.html	编辑常用收货电话
/ucenter/common_use_tel.html	常用收货电话
/ucenter/complain.html		网点详细信息
/ucenter/consigner_edit.html	编辑发货方
/ucenter/edit_info.html		编辑基本信息
/ucenter/qr_code.html		我的二维码
/ucenter/receiving_edit.html	编辑收货方
/ucenter/receiving_party.html	收货地址薄
/ucenter/ship_address.html	发货地址薄
/ucenter/ticket.html		运费券
/ucenter/ucenter.html		个人中心
/ucenter/select_address.html	选择常用发货地址
/ucenter/receiving_party.html	收货地址薄

<file_sep>/Szwechat/activity/common/js/store_nav.js
(function(window){
	// 方法
	window.incident={
		// 样式
		allStyle:{
			navStyle:{
				'height': '0.48rem',
				'width':'100%',
			},
			liStyle:{
				'display':'table-cell'
			},
			spanStyle:{
				'width':'80px',
				'margin':'0 auto',
				'display':'flex',
				'height':'40px',
				'background': '#ffbd1f',
				'text-shadow': '1px 1px 0 #ee950d',
				'font-size':'0.14rem',
				'color':'#fff',
				'align-items': 'center',
				'justify-content':'center',
				'border-radius':'5px'
			}
		},
		GetQueryString:function(name){//获取参数
		    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
		    var r = window.location.search.substr(1).match(reg);
		    if(r!=null)return  unescape(r[2]); return null;
		},
		requestTokenId:function(num){//随机数
			len =num||32;
			var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';
			var maxPos = $chars.length;
			var pwd = '';
			for (i = 0; i < len; i++) {
			　　pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
			}
			return 'wx_tms_'+pwd;
		},
		userInfo:function(id){
			// 创建Dom
			var html='<div style="position: fixed;bottom:0;left:0;right:0;width:100%;"><ul style="display:table;width:100%"><li><span id="chitchat">聊天</span></li><li><span id="phone">拨打电话</span></li><li><span id="baguette">进店</span></li></ul></div>';
			var navFooter=document.createElement('div');
			navFooter.setAttribute('class', 'navFooter');
			navFooter.setAttribute('id', 'navFooter');
			navFooter.innerHTML=html;
			// 添加样式
			var navSting="";
			var liSting="";
			var spanSting="";
			var navStyle=this.allStyle.navStyle;
			var liStyle=this.allStyle.liStyle;
			var spanStyle=this.allStyle.spanStyle;
			for (var i in navStyle) {
				navSting+=i+':'+navStyle[i]+";"
			};
			for (var i in liStyle) {
				liSting+=i+':'+liStyle[i]+";"
			};
			for (var i in spanStyle) {
				spanSting+=i+':'+spanStyle[i]+";"
			};
			navFooter.setAttribute('style', navSting);
			var liDom=navFooter.children[0].children[0].children;
			for (var i = 0; i < liDom.length; i++) {
				liDom[i].setAttribute('style', liSting);
				var spanDom=liDom[i].children[0];
				spanDom.setAttribute('style', spanSting);
			};
			// 添加到底部
			if (incident.GetQueryString('appCode')) {
				document.getElementsByTagName('body')[0].appendChild(navFooter);
			}

			ajax({
				method: 'POST',
				url: 'http://weixinapi.3zqp.com/api/wx/login/findSupplier',
				// url: 'http://192.168.0.158:8193/api/wx/login/findSupplier',
				data: {
				    id:id,
				    garageId:incident.GetQueryString('garageId'),
				    requestTokenId:incident.requestTokenId()
				},
				success: function (response) {
					var data=(typeof response == "string")?JSON.parse(response):response;
					console.log(data)
					if (data.returnCode==200) {
						console.log(data.info)
						var userinfo=JSON.stringify(data.info);
						document.getElementById('chitchat').onclick=function () {
							window.depot.jumpDealerFromJs(userinfo,1);
						}
						document.getElementById('phone').onclick=function () {
							window.depot.jumpDealerFromJs(userinfo,2);
						}
						document.getElementById('baguette').onclick=function () {
							console.log(userinfo);
							window.depot.jumpDealerFromJs(userinfo,3);
						}
						var allPhoneBtn=document.getElementsByClassName('tel_btn');
						for (var i = 0; i < allPhoneBtn.length; i++) {
							allPhoneBtn[i].setAttribute('href', 'javascript:;');
							allPhoneBtn[i].onclick=function(){
								window.depot.jumpDealerFromJs(userinfo,2);
							}
						};
					}else{
						document.getElementById('chitchat').setAttribute('onclick', 'alert("'+data.message+'")')
						document.getElementById('phone').setAttribute('onclick', 'alert("'+data.message+'")')
						document.getElementById('baguette').setAttribute('onclick', 'alert("'+data.message+'")')
					};
					
				}
			 });
		},

	}
	

	function ajax(opt) {
		opt = opt || {};
		opt.method = opt.method.toUpperCase() || 'POST';
		opt.url = opt.url || '';
		opt.async = opt.async || true;
		opt.data = opt.data || null;
		opt.success = opt.success || function () {};
		opt.error = opt.error || function () {};
		var xmlHttp = null;
		if (XMLHttpRequest) {
		    xmlHttp = new XMLHttpRequest();
		}
		else {
		    xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
		}var params = [];
		for (var key in opt.data){
		    params.push(key + '=' + opt.data[key]);
		}
		var postData = params.join('&');
		if (opt.method.toUpperCase() === 'POST') {
		    xmlHttp.open(opt.method, opt.url, opt.async);
		    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=utf-8');
		    xmlHttp.send(postData);
		}
		else if (opt.method.toUpperCase() === 'GET') {
		    xmlHttp.open(opt.method, opt.url + '?' + postData, opt.async);
		    xmlHttp.send(null);
		} 
		xmlHttp.onreadystatechange = function () {
		    if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
		        opt.success(xmlHttp.responseText);
		    }
		};
	}
})(window)<file_sep>/src/js/addBook.js
 'use strict';

/*以下为发货地址薄*/
/*发货地址薄列表（默认）*/
function shipAddress(){
	$('.header_title,.header_goback').attr('onclick', 'window.location.href="../ucenter/ucenter.html"');
	loading('loading...');
	$.ajax({
		url: apiL+'/api/wx/address/find',
		type: 'get',
		dataType: 'json',
		timeout : 10000,
		data: {userId:userId(),type:1,requestTokenId:requestTokenId()},
		success:function(data){
			loadingRemove();
			if (data.success) {
				if (data.info.length) {
					shipAddrList(data);
				}else{
					noshipsearch();
				};
			}else{
				alert(data.message)
			};
		},
        complete : function(XMLHttpRequest,status){
            loadingRemove();
    　　　　if(status=='error'){
     　　　　　 noResultErr($('.record_list'),400,'请求超时，请点击重新获取','shipAddress()');
    　　　　}else if(status=='timeout'){
                noResultErr($('.record_list'),400,'请求超时，请点击重新获取','shipAddress()');
            }
    　　}
	});
}
/*没有地址列表*/
function noshipsearch(name){
	if (name) {
		$('.record_list').html('<div class="ship_nofind"><span><img src="../skin/images/no_find.png" alt=""></span><p>对不起，没有找到“'+name+'”，请重新输入</p></div>')
	}else{
		$('.record_list').html('<div class="ship_nofind"><span><img src="../skin/images/no_find.png" alt=""></span><p>对不起，您还没有添加地址</p></div>')
	};
}
/*发货地址薄内容{默认} */

function shipAddrList(data){
	var info = data.info;
	var html="";
	for(var i = 0; i < info.length; i++){
		if (info[i].isDefault) {
			html+='<div class="record_li ship_li" data-id="'+info[i].id+'">'
			+'<table width="w100">'
				+'<col width="74%">'
				+'<col width="20%">'
				+'<tr><td>发 货 方：'+info[i].company+'</td><td class="t_r moren"><span class="red">默认发货</span></td></tr>'
				if (info[i].contact) {
					html+='<tr><td colspan="2">联 系 人：'+info[i].contact+'</td></tr>'
				};
				html+='<tr><td colspan="2">电&#x3000;&#x3000;话：'+info[i].phone+'<br></td></tr>'
				+'<tr><td colspan="2">发货地址：'+info[i].proName+''+info[i].cityName+''+info[i].areaName+''+info[i].detailed+'<br></td></tr></table>'
			+'<div class="show_details ov_h">'
				+'<label class="ship_moren"></label>'
				+'<a class="f_r f14" href="javascript:;" onclick="del_addr($(this),'+info[i].id+')">删除</a>'
				+'<a class="f_r f14" href="../ucenter/consigner_edit.html?edit='+info[i].id+'">编辑</a>'
			+'</div>'
		+'</div>'
		}else{
			html+='<div class="record_li ship_li"  data-id="'+info[i].id+'">'
				+'<table width="w100" >'
					+'<col width="74%">'
					+'<col width="20%">'
					+'<tr><td>发 货 方：'+info[i].company+'</td><td class="t_r moren"></td></tr>'
				if (info[i].contact) {
					html+='<tr><td colspan="2">联 系 人：'+info[i].contact+'</td></tr>'
				};
				html+='<tr><td colspan="2">电&#x3000;&#x3000;话：'+info[i].phone+'<br></td></tr>'
				+'<tr><td colspan="2">发货地址：'+info[i].proName+''+info[i].cityName+''+info[i].areaName+''+info[i].detailed+'<br></td></tr></table>'
				+'</table>'
				+'<div class="show_details ov_h">'
					+'<label class="ship_moren"><input type="radio" name="default"><span class="radio"></span>设置为默认发货方</label>'
					+'<a class="f_r f14" href="javascript:;" onclick="del_addr($(this),'+info[i].id+')">删除</a>'
					+'<a class="f_r f14" href="../ucenter/consigner_edit.html?edit='+info[i].id+'">编辑</a>'
				+'</div>'
			+'</div>'
		};
	};
	$('.record_list').html(html);
};

/*发货地址搜索（默认）*/
function receiveSearch(){
	var search=$('.search_input').val();
	loading('查询中...');
	var data={
		userId:userId(),
		type:1,
		searchParam:search,
		requestTokenId:requestTokenId()
	};
	if (search){
		$.ajax({
			url: api+'/api/wx/address/find',
			type: 'get',
			dataType: 'json',
			timeout : 10000,
			data: data,
			success:function(data){
				loadingRemove();
				if (data.success) {
					if (data.info.length) {
						shipAddrList(data);
					}else{
						noshipsearch(search);
					};
					
				}else{
					alert(data.message)
				};
			},
	        complete : function(XMLHttpRequest,status){
	            loadingRemove();
	    　　　　if(status=='error'){
	     　　　　　 noResultErr($('.record_list'),400,'请求超时，请点击重新获取','receiveSearch()');
	    　　　　}else if(status=='timeout'){
	                noResultErr($('.record_list'),400,'请求超时，请点击重新获取','receiveSearch()');
	            }
	    　　}
		});
	}else{
		$.ajax({
			url: apiL+'/api/wx/address/find',
			type: 'get',
			timeout : 10000,
			dataType: 'json',
			data: {userId:userId(),type:1,requestTokenId:requestTokenId()},
			success:function(data){
				loadingRemove();
				if (data.success) {
					if (data.info.length) {
						shipAddrList(data);
					}else{
						noshipsearch();
					};
				}else{
					alert(data.message)
				};
			},
	        complete : function(XMLHttpRequest,status){
	            loadingRemove();
	    　　　　if(status=='error'){
	     　　　　　 noResultErr($('.record_list'),400,'请求超时，请点击重新获取','shipAddress()');
	    　　　　}else if(status=='timeout'){
	                noResultErr($('.record_list'),400,'请求超时，请点击重新获取','shipAddress()');
	            }
	    　　}
		});
	};
}
/*发货地址内容（自助下单）*/
function selfshipAddr(data){
	var html="";
	for (var i = 0; i < data.info.length; i++) {
		if (data.info[i].isDefault) {
			html+='<div class="record_li ship_li" data-id="'+data.info[i].id+'">'
			+'<table width="w100"  onclick=addrTrue('+data.info[i].id+')>'
				+'<col width="74%"><col width="20%">'
				+'<tr><td>发 货 方：'+data.info[i].company+'</td><td class="t_r moren"><span class="red">默认发货</span></td></tr>'
				if (data.info[i].contact) {
					html+='<tr><td colspan="2">联 系 人：'+data.info[i].contact+'</td></tr>'
				};
				html+='<tr><td colspan="2">电&#x3000;&#x3000;话：'+data.info[i].phone+'<br></td></tr>'
				+'<tr><td colspan="2">发货地址：'+data.info[i].proName+''+data.info[i].cityName+''+data.info[i].areaName+''+data.info[i].detailed+'<br></td></tr></table>'
			+'<div class="show_details ov_h">'
				+'<label class="ship_moren"></label>'
				+'<a class="f_r f14" href="javascript:;" onclick="del_addr($(this),'+data.info[i].id+')">删除</a>'
				+'<a class="f_r f14" onclick="consignerEdit('+data.info[i].id+')" href="javascript:;">编辑</a>'
			+'</div>'
		+'</div>'
		}else{
			html+='<div class="record_li ship_li" data-id="'+data.info[i].id+'">'
			+'<table width="w100"   onclick=addrTrue('+data.info[i].id+')>'
				+'<col width="74%"><col width="20%">'
				+'<tr><td>发 货 方：'+data.info[i].company+'</td><td class="t_r moren"></td></tr>'
				if (data.info[i].contact) {
					html+='<tr><td colspan="2">联 系 人：'+data.info[i].contact+'</td></tr>'
				};
				html+='<tr><td colspan="2">电&#x3000;&#x3000;话：'+data.info[i].phone+'<br></td></tr>'
				+'<tr><td colspan="2">发货地址：'+data.info[i].proName+''+data.info[i].cityName+''+data.info[i].areaName+''+data.info[i].detailed+'<br></td></tr></table>'
			+'</table>'
			+'<div class="show_details ov_h">'
				+'<label class="ship_moren"><input type="radio" ><span class="radio"></span>设置为默认发货方</label>'
				+'<a class="f_r f14" href="javascript:;" onclick="del_addr($(this),'+data.info[i].id+')">删除</a>'
				+'<a class="f_r f14" onclick="consignerEdit('+data.info[i].id+')" href="javascript:;">编辑</a>'
			+'</div>'
		+'</div>'
		};
	};
	$('.record_list').html(html);
}

/*发货地址薄搜索（自助下单）*/
/*function selfAddrsearch(){
	var search=$('.search_input').val();
	var data={
		userId:userId(),
		type:1,
		searchParam:search,
		requestTokenId:requestTokenId()
	}
	if (search){
		$.ajax({
			url: api+'/api/wx/address/find',
			type: 'get',
			dataType: 'json',
			data: data,
			success:function(data){
				if (data.success) {
					if (data.info.length) {
						selfshipAddr(data)
					}else{
						noshipsearch(search);
					};
				}else{
					alert(data.message)
				};
			}
		});
	}else{
		$.ajax({
			url: apiL+'/api/wx/address/find',
			type: 'get',
			dataType: 'json',
			data: {userId:userId(),type:1,requestTokenId:requestTokenId()},
			success:function(data){
				if (data.success) {
					if (data.info.length) {
						selfshipAddr(data)
					}else{
						noshipsearch();
					}
				}else{
					alert(data.message)
				};
			}
		});
	};
}*/
/*以上为发货地址薄*/

/*以下为收货地址薄*/
/*收货地址列表*/
function receivingParty(){
	$('.header_title,.header_goback').attr('onclick', 'window.location.href="../ucenter/ucenter.html"');
	loading('loading...');
	$.ajax({
		url: apiL+'/api/wx/address/find',
		type: 'get',
		dataType: 'json',
		timeout : 10000,
		data: {userId:userId(),type:2,requestTokenId:requestTokenId()},
		success:function(data){
			loadingRemove();
			if (data.success) {
				if (data.info.length) {
					// console.log(data);
					shipReceList(data);
				}else{
					noshipsearch();
				};
			}else{
				alert(data.message)
			};
		},
        complete : function(XMLHttpRequest,status){
            loadingRemove();
    　　　　if(status=='error'){
     　　　　　 noResultErr($('.record_list'),400,'请求超时，请点击重新获取','receivingParty()');
    　　　　}else if(status=='timeout'){
                noResultErr($('.record_list'),400,'请求超时，请点击重新获取','receivingParty()');
            }
    　　}
	});
}
/*收货地址筛选搜索(默认)*/
function searchRec(){
	loading('loading...');
	var search=$('.search_input').val();
	var data={
		userId:userId(),
		type:2,
		searchParam:search,
		requestTokenId:requestTokenId()
	}
	if (search){
		$.ajax({
			url: api+'/api/wx/address/find',
			type: 'post',
			timeout : 10000,
			dataType: 'json',
			data: data,
			success:function(data){
				loadingRemove();
				if (data.success) {
					if (data.info.length) {
						shipReceList(data);
					}else{
						noshipsearch(search);
					};
				}else{
					alert(data.message)
				};
			},
	        complete : function(XMLHttpRequest,status){
	            loadingRemove();
	    　　　　if(status=='error'){
	     　　　　　 noResultErr($('.record_list'),400,'请求超时，请点击重新获取','searchRec()');
	    　　　　}else if(status=='timeout'){
	                noResultErr($('.record_list'),400,'请求超时，请点击重新获取','searchRec()');
	            }
	    　　}
		});
	}else{
		$.ajax({
			url: apiL+'/api/wx/address/find',
			type: 'get',
			timeout : 10000,
			dataType: 'json',
			data: {userId:userId(),type:2,requestTokenId:requestTokenId()},
			success:function(data){
				loadingRemove();
				if (data.success) {
					if (data.info.length) {
						selfReceAddr(data)
					}else{
						noshipsearch();
					}
				}else{
					alert(data.message)
				};
			},
	        complete : function(XMLHttpRequest,status){
	            loadingRemove();
	    　　　　if(status=='error'){
	     　　　　　 noResultErr($('.record_list'),400,'请求超时，请点击重新获取','searchRec()');
	    　　　　}else if(status=='timeout'){
	                noResultErr($('.record_list'),400,'请求超时，请点击重新获取','searchRec()');
	            }
	    　　}
		});
	};
}
/*收货地址列表内容（默认）*/
function shipReceList(data){
	var html="";
	for (var i = 0; i < data.info.length; i++) {
		html+='<div class="record_li ship_li"  data-id="'+data.info[i].id+'">'
			+'<table width="w100">'
				+'<tr><td>收&nbsp; 货 方：'+data.info[i].company+'</td></tr>'
				if (data.info[i].contact) {
					html+='<tr><td colspan="2">联&nbsp; 系 人：'+data.info[i].contact+'</td></tr>'
				};
				html+='<tr><td colspan="2">电&#x3000;&#x3000;话：'+data.info[i].phone+'<br></td></tr>'
				+'<tr><td colspan="2">收货地址：'+data.info[i].proName+''+data.info[i].cityName+''+data.info[i].areaName+''+data.info[i].detailed+'<br></td></tr>'
			+'</table>'
			+'<div class="show_details ov_h">'
				+'<a class="f_r f14" href="javascript:;" onclick="del_rec($(this),'+data.info[i].id+')">删除</a>'
				+'<a class="f_r f14" href="../ucenter/receiving_edit.html?edit='+data.info[i].id+'">编辑</a>'
			+'</div>'
		+'</div>'
	};
	$('.record_list').html(html);
}

/*收货地址内容（自助下单）*/
function selfReceAddr(data){
	var html="";
	for (var i = 0; i < data.info.length; i++) {
		html+='<div class="record_li ship_li" data-id="'+data.info[i].id+'">'
			+'<table width="w100" onclick=recTrue("'+data.info[i].id+'")>'
				+'<tr><td>收&nbsp; 货 方：'+data.info[i].company+'</td></tr>';
				if (data.info[i].contact) {
					html+='<tr><td colspan="2">联&nbsp; 系 人：'+data.info[i].contact+'</td></tr>'
				};
				html+='<tr><td colspan="2">电&#x3000;&#x3000;话：'+data.info[i].phone+'<br></td></tr>'
				+'<tr><td colspan="2">收货地址：'+data.info[i].proName+''+data.info[i].cityName+''+data.info[i].areaName+''+data.info[i].detailed+'<br></td></tr>'
			+'</table>'
			+'<div class="show_details ov_h">'
				+'<a class="f_r f14" href="javascript:;" onclick="del_rec($(this),'+data.info[i].id+')">删除</a>'
				+'<a class="f_r f14" onclick="recrivingEdit('+data.info[i].id+')" href="javascript:;">编辑</a>'
			+'</div>'
		+'</div>'
	};
	$('.record_list').html(html);
}
/*收货地址搜索（自助下单）*/
function selfRecsearch(){
	var search=$('.search_input').val();
	if (search){
		var data={
			userId:userId(),
			type:2,
			searchParam:search,
			requestTokenId:requestTokenId()
		};
		$.ajax({
			url: api+'/api/wx/address/find',
			type: 'get',
			dataType: 'json',
			data: data,
			success:function(data){
				if (data.success) {
					if (data.info.length) {
						selfReceAddr(data);
					}else{
						noshipsearch(search);
					};
				}else{
					alert(data.message)
				};
			}
		});
	}else{
		$.ajax({
			url: apiL+'/api/wx/address/find',
			type: 'get',
			dataType: 'json',
			data: {userId:userId(),type:2,requestTokenId:requestTokenId()},
			success:function(data){
				if (data.success) {
					if (data.info.length) {
						selfReceAddr(data);
					}else{
						noshipsearch();
					}
				}else{
					alert(data.message)
				};
			}
		});
	};
}
/*以上为收货地址薄*/

/*发货地址簿删除*/
function del_addr(e,id){
	$.MsgBox.ConfirmL("确定要删除吗？",'取消','确定',function(){
		$.ajax({
			url: apiL+'/api/wx/address/findedit',
			type: 'post',
			dataType: 'json',
			data: {id:id,type:1,requestTokenId:requestTokenId()},
			success:function(data){
				var isDefault=data.info.isDefault;
				if (data.success) {
					$.ajax({
						url: apiL+'/api/wx/address/delete',
						type: 'post',
						dataType: 'json',
						data: {type:1,id:id,userId:userId,isDefault:isDefault,requestTokenId:requestTokenId()},
						success:function(data1){
							if (data1.success) {
								shipAddress();
								e.parents('.record_li').remove();	
							}else{
								alert(data1.message);
							};
						},
				        complete : function(XMLHttpRequest,status){
				            loadingRemove();
				    　　　　if(status=='error'){
				    			fubottom('删除失败，请重试');
				    　　　　}else if(status=='timeout'){
				    			fubottom('删除失败，请重试');
				            }
				    　　}
					});
				}else{
					alert(data.message);
				};
			},
	        complete : function(XMLHttpRequest,status){
	            loadingRemove();
	    　　　　if(status=='error'){
	    			fubottom('删除失败，请重试');
	    　　　　}else if(status=='timeout'){
	    			fubottom('删除失败，请重试');
	            }
	    　　}
		});
    },function(){
        return false;
    })
};
/*收地址簿删除*/
function del_rec(e,id){
	$.MsgBox.ConfirmL("确定要删除吗？",'取消','确定',function(){
		loading('删除中...');
		$.ajax({
			url: apiL+'/api/wx/address/delete',
			type: 'post',
			dataType: 'json',
			data: {type:2,id:id,userId:userId(),isDefault:0,requestTokenId:requestTokenId()},
			success:function(data){
				loadingRemove();
				if (data.success) {
					e.parents('.record_li').remove();
					if ($('.ship_li').length==0) {
						$('.record_list').html('<div class="ship_nofind"><span><img src="../skin/images/no_find.png" alt=""></span><p>对不起，您还没有添加地址</p></div>')
					};
				}else{
					alert(data.message);
				};
			},
	        complete : function(XMLHttpRequest,status){
	            loadingRemove();
	    　　　　if(status=='error'){
	    			fubottom('删除失败，请重试');
	    　　　　}else if(status=='timeout'){
	    			fubottom('删除失败，请重试');
	            }
	    　　}
		});
    },function(){
        return false;
    })
};
function addrTrue(id){
	$.ajax({
		url: apiL+'/api/wx/address/findedit',
		type: 'get',
		dataType: 'json',
		data: {type:1,id:id,requestTokenId:requestTokenId()},
		success:function(data){
			if (data.success) {
				sessionStorage.consigner='{"company":"'+data.info.company+'","tel":'+data.info.phone+',"provs":"'+data.info.proName+'","city":"'+data.info.cityName+'","dists":"'+data.info.areaName+'","detail":"'+data.info.detailed+'","name":"'+data.info.contact+'","citynum":"'+data.info.proNumber+','+data.info.cityNumber+','+data.info.areaNumber+'"}';
				if (!GetQueryString('waybill')) {
					window.location.href="../order/self_help_order.html";
				}else{
					window.location.href="../order/self_help_order.html?waybill="+GetQueryString('selfHp')+"&amend=1";
				};
			}else{
				alert(data.message);
			};
		}
	});
}
function recTrue(id){
	$.ajax({
		url: apiL+'/api/wx/address/findedit',
		type: 'get',
		dataType: 'json',
		data: {type:2,id:id,requestTokenId:requestTokenId()},
		success:function(data){
			if (data.success) {
				sessionStorage.delivery='{"company":"'+data.info.company+'","tel":'+data.info.phone+',"provs":"'+data.info.proName+'","city":"'+data.info.cityName+'","dists":"'+data.info.areaName+'","detail":"'+data.info.detailed+'","name":"'+data.info.contact+'","citynum":"'+data.info.proNumber+','+data.info.cityNumber+','+data.info.areaNumber+'"}';
				if (!GetQueryString('waybill')) {
					window.location.href="../order/self_help_order.html";
				}else{
					window.location.href="../order/self_help_order.html?waybill="+GetQueryString('selfHp')+"&amend=1";
				};
			}else{
				alert(data.message)
			};
		}
	});
}<file_sep>/src/js/help_self.js
'use strict';
$(function() {
	/*返回退出*/
	/*if (!GetQueryString('waybill')) {
		var ua = navigator.userAgent.toLowerCase();
		if (/android/.test(ua)) {
			popstate();
		};
	};*/
	if (userId()) {
		selfLoading();
	}else if(!GetQueryString('code')){
		document.write('<p style="text-align:center;line-height:4rem;font-size:20px;">请在微信三真驿道公众号菜单中打开</p>')
	}
	
	$('label').on('change', '.pay_way2', function(event) {
		if ($(this).attr('checked')) {
			/*如果绑定银行卡的操作*/
			$('[name="have_coll"]').attr('onclick', 'price_open()');
			price_open();
		}else{
			$('[name="have_coll"]').val('').removeAttr('onclick');
			$('[name="goodsAmount"]').val('0');
			if ($('[name="payType"]').eq(2).attr('checked')) {
				$('[name="payType"]').eq(2).removeAttr('checked');
			};
		};
		self_btn_show()
	});

	/*自助下单货物件数初始化*/
	addno();

	/*当附近的网点只有一个时，默认转中状态*/
	var nearby_li=$('.nearby ul li');
	if (nearby_li.length==1) {
		nearby_li.find('.pay_way').attr('checked', 'checked');
	};

	$('table').on('click', '[name="payType"]:eq(2)', function(event) {
		if ($('[name="goodsAmount"]').val()<=0) {
			alert('未选择代收货款，选择回单付必须要有代收货款哦！');
			return false;
		}
	});
	
	/*判断是修改还是新增*/
	

	/*付款方式变化*/
	$('[name="payType"]').change(function(event) {
		self_btn_show();
	});
	/*包裹数量变化*/
	$('[name="goodsQuantity"]').change(function(event) {
		self_btn_show();
	});
	/*货物名称变化*/
	$('[name="goodsName"]').keyup(function(event) {
		self_btn_show();
	});
	/*网点变化*/
	$('.nearby').on('click', '[name="inputDotId"]', function(event) {
		self_btn_show();
	});

	setTimeout(function(){
		self_btn_show();
	}, 100);

});

function selfLoading(){
	if (GetQueryString("waybill")) {
		$('[name="senderId"]').val(number());
		$('[name="senderRegisterMobile"]').val(userName());
		loading('loading...');
		document.title='修改运单';
		$('#selfSubmit').attr('onclick', 'auto_help_edit()');
		var waybill=GetQueryString("waybill");
		$.ajax({
			url: apiAn+'/api/wx/waybill/getWaybill',
			type: 'POST',
			timeout: 10000,
			dataType: 'json',
			data: {waybillNo:waybill,requestTokenId:requestTokenId()},
			success:function(data){
				loadingRemove();
				if (data.success) {
					var info=data.info;
					console.log(info);
					// bannceEdit(info.senderCityId,info.senderAreaId,info.receiverAreaId,info.inputDotId);
					$('#selfSubmit').attr('onclick', 'auto_help_edit()');
					/*发货地址*/
					$('[name="receiverName"]').val(info.receiverName);
					$('[name="receiverLinkman"]').val(info.receiverLinkman);
					$('[name="receiverMobile"]').val(info.receiverMobile);
					$('[name="receiverProvinceName"]').val(info.receiverProvinceName);
					$('[name="receiverCityName"]').val(info.receiverCityName);
					$('[name="receiverAreaName"]').val(info.receiverAreaName);
					$('[name="receiverProvinceId"]').val(info.receiverProvinceId);
					$('[name="receiverCityId"]').val(info.receiverCityId);
					$('[name="receiverAreaId"]').val(info.receiverAreaId);
					$('[name="receiverAddress"]').val(info.receiverAddress);
					$('[name="receiverId"]').val(info.receiverId);
					$('[name="receiverRegisterCompany"]').val(info.receiverName);
					if (info.receiverLinkman) {
						var receiverLinkman=info.receiverLinkman;
					}else{
						var receiverLinkman='';
					};
					var receiverhtml='<p id="addr_receiver"> '+info.receiverName+' <br> '+receiverLinkman+' '+info.receiverMobile+'  <br>'+info.receiverProvinceName+' '+info.receiverCityName+' '+info.receiverAreaName+' '+info.receiverAddress+'</p>';
					$('.delivery_edit a').html(receiverhtml);
					/*发货地址*/
					$('[name="senderName"]').val(info.senderName);
					$('[name="senderLinkman"]').val(info.senderLinkman);
					$('[name="senderMobile"]').val(info.senderMobile);
					$('[name="senderProvinceName"]').val(info.senderProvinceName);
					$('[name="senderCityName"]').val(info.senderCityName);
					$('[name="senderAreaName"]').val(info.senderAreaName);
					$('[name="senderProvinceId"]').val(info.senderProvinceId);
					$('[name="senderCityId"]').val(info.senderCityId);
					$('[name="senderAreaId"]').val(info.senderAreaId);
					$('[name="senderAddress"]').val(info.senderAddress);
					if (info.senderLinkman) {
						var senderLinkman=info.senderLinkman;
					}else{
						var senderLinkman='';
					};
					var senderhtml='<p id="addr_consigner"> '+info.senderName+' <br> '+senderLinkman+' '+info.senderMobile+'  <br>'+info.senderProvinceName+' '+info.senderCityName+' '+info.senderAreaName+' '+info.senderAddress+'</p>';
					$('.consigner_edit a').html(senderhtml);
					/*商品名称*/
					$('[name="goodsName"]').val(info.goodsName);
					/*商品数量*/
					$('[name="goodsQuantity"]').val(info.goodsQuantity);
					if (info.goodsQuantity>1) {
						$('#reduce').removeClass('no');
					};
					if (info.goodsQuantity>=999) {
						$('#increase').addClass('no');
					};
					/*代收款金额*/
					if (info.goodsAmount) {
						$('[name="collection"]').attr('checked', 'checked');
						var APrice=parseFloat(info.goodsAmount).toFixed(2);
						var ADian=outputmoney(APrice);
						$('[name="goodsAmount"]').val(info.goodsAmount);
						$('[name="have_coll"]').val(ADian).attr('onclick', 'price_open()');
					};
					/*支付方式*/
					$('[name="payType"]').eq(info.payType-1).attr('checked', 'checked');

					/*判断是不是已发货*/
					if (data.info.status >=1) {
						bannceEdit(info.senderCityId,info.senderAreaId,info.receiverAreaId,info.inputDotId,data.info.status);
						$('.consigner_edit a').removeAttr('onclick').parents('tr').css('background', '#f5f5f5');
						$('.delivery_edit a').removeAttr('onclick').parents('tr').css('background', '#f5f5f5');
						$('.addr_book_btn').remove();
						$('[name="goodsName"]').addClass('lost').attr('readonly', 'readonly');
						$('[name="goodsQuantity"]').attr('readonly', 'readonly').css({
							background: '#f1f1f1',
							borderColor: '#ccc',
							color:'#999'
						});
						$('.have_coll_a').css('background', '#fff');
						$('span#reduce').removeAttr('onclick').css('background-image', 'url(../skin/images/jian2.png)');
						$('span#increase').removeAttr('onclick').css('background-image', 'url(../skin/images/jia2.png)');
						$('[name="payType"]').attr('disabled', 'disabled');
						$('#selfSubmit').attr('onclick', 'auto_help_coll()');

						$('.payment:checked+span').css('border-color', '#999');
						$('.payment:checked+span b').css('background', '#999');
					}else{
						bannceEdit(info.senderCityId,info.senderAreaId,info.receiverAreaId,info.inputDotId);
					};
				}else{
					alert(data.message)
				};
			},
			complete : function(XMLHttpRequest,status){
	            loadingRemove();
	    　　　　if(status=='error'){
	    			$('a').removeAttr('onclick');
	     　　　　　 alert('请求超时，请刷新重新获取');
	    　　　　}else if(status=='timeout'){
	    			$('a').removeAttr('onclick');
	     　　　　　 alert('请求超时，请刷新重新获取');
	            }
	    　　}
		});
	}else{
		if (userId()) {
			self_load();
		};
	};
}
/*返回*/
function selfHeaderGoback(){
	history.back(-1);
}

/*自助下单初始化包裹*/
function addno(){
	var val=parseInt($('.parcel_num').val());
	if (val<=1) {
		$('#reduce').addClass('no');
	}else if (val>=100) {
		$('#increase').addClass('no');
	}else{
		return true;
	};
}
/*自助下单加载*/
function self_load(){
	/*默认一个发货方地址*/
	if (userId()) {
		loading('加载中...');
		$.ajax({
			url: api+'/api/wx/login/finduser',
			type: 'POST',
			dataType: 'json',
			timeout : 10000,
			data: {id:userId(),requestTokenId:requestTokenId()},
			success:function(data){
				if (data.success) {
					if (!data.info.company) {
						window.location.href='/login/login_addr.html?unionid='+data.info.unionid;
					}else{
						$.ajax({
							url: apiL+'/api/wx/address/find',
							type: 'post',
							timeout : 10000,
							dataType: 'json',
							data: {type:1,userId:userId(),requestTokenId:requestTokenId()},
							success:function(data){
								if (data.success) {
									var html="";
									for (var i = 0; i < data.info.length; i++) {
										if (data.info[i].isDefault==1) {
											if (data.info[i].contact) {
												var contact=data.info[i].contact;
											}else{
												var contact="";
											};
											html='<p id="addr_consigner"> '+data.info[i].company+' <br> '+contact+' '+data.info[i].phone+'  <br>'+data.info[i].proName+' '+data.info[i].cityName+' '+data.info[i].areaName+' '+data.info[i].detailed+'</p>';
											$('.consigner_edit a').html(html);
											$('[name="senderAddId"]').val(data.info[i].id);
											$('[name="senderAddIsDf"]').val(data.info[i].isDefault);
											$('[name="senderName"]').val(data.info[i].company);
											$('[name="senderLinkman"]').val(data.info[i].contact);
											$('[name="senderMobile"]').val(data.info[i].phone);
											$('[name="senderProvinceName"]').val(data.info[i].proName);
											$('[name="senderCityName"]').val(data.info[i].cityName);
											$('[name="senderAreaName"]').val(data.info[i].areaName);
											$('[name="senderProvinceId"]').val(data.info[i].proNumber);
											$('[name="senderCityId"]').val(data.info[i].cityNumber);
											$('[name="senderAreaId"]').val(data.info[i].areaNumber);
											$('[name="senderAddress"]').val(data.info[i].detailed);
										};
									};
								}else{
									alert(data.message)
								};
							},
							complete : function(XMLHttpRequest,status){
					            loadingRemove();
								if(status=='error'){
									$.MsgBox.Confirmt("默认发货地址获取失败，重新获取？",'重新获取','我自己选',function(){
										return false;
								    },function(){
								        self_load();
								    });
								}else if(status=='timeout'){
					            	
					            }
							}
						});
					};
				}else{
					alert(data.message);
				};
			},
	        complete : function(XMLHttpRequest,status){
	            loadingRemove();
				if(status=='error'){
					document.write('请求失败,请返回公众号重新进入');
				}else if(status=='timeout'){
	                document.write('请求失败,请返回公众号重新进入');
	            }
			}
		});
		$('[name="senderId"]').val(number());
		$('[name="senderRegisterMobile"]').val(userName());
		
		if ($('[name="senderName"]').val()) {
			var sendCompany=$('[name="senderName"]').val();
			var sendContact=$('[name="senderLinkman"]').val();
			var sendPhone=$('[name="senderMobile"]').val();
			var sendProName=$('[name="senderProvinceName"]').val();
			var sendCityName=$('[name="senderCityName"]').val();
			var sendAreaName=$('[name="senderAreaName"]').val();
			var sendProNumber=$('[name="senderProvinceId"]').val();
			var sendCityNumber=$('[name="senderCityId"]').val();
			var sendAreaNumber=$('[name="senderAreaId"]').val();
			var sendDetailed=$('[name="senderAddress"]').val();
			var html='<p id="addr_consigner"> '+sendCompany+' <br> '+sendContact+' '+sendPhone+'  <br>'+sendProName+' '+sendCityName+' '+sendAreaName+' '+sendDetailed+'</p>';
			$('.consigner_edit a').html(html);
		};
		if ($('[name="receiverName"]').val()) {
			var receCompany=$('[name="receiverName"]').val();
			var receContact=$('[name="receiverLinkman"]').val();
			var recePhone=$('[name="receiverMobile"]').val();
			var receProName=$('[name="receiverProvinceName"]').val();
			var receCityName=$('[name="receiverCityName"]').val();
			var receAreaName=$('[name="receiverAreaName"]').val();
			var receProNumber=$('[name="receiverProvinceId"]').val();
			var receCityNumber=$('[name="receiverCityId"]').val();
			var receAreaNumber=$('[name="receiverAreaId"]').val();
			var receDetailed=$('[name="receiverAddress"]').val();
			var html='<p id="addr_receiver"> '+receCompany+' <br> '+receContact+' '+recePhone+'  <br>'+receProName+' '+receCityName+' '+receAreaName+' '+receDetailed+'</p>';
			$('.delivery_edit a').html(html);
		};
	};
}
/*修改发货人*/
function consigner(){
	if (!$('[name="consigner"]').val()) {
		window.location.href="../ucenter/consigner_edit.html?add=selfH";
	}else{
		if (GetQueryString('waybill')) {
			window.location.href="../ucenter/consigner_edit.html?edit=1&from=selfH&waybill=selfH&order="+GetQueryString('waybill');
		}else{
			window.location.href="../ucenter/consigner_edit.html?edit=1&from=selfH&order="+GetQueryString('waybill');
		};
	};
}
/*修改收货人*/
function delivery(){
	if (!$('[name="delivery"]').val()) {
		window.location.href="../ucenter/receiving_edit.html?add=selfH";
	}else{
		var csgId=$('[name="delivery"]').val();
		if (GetQueryString('waybill')) {
			window.location.href="../ucenter/receiving_edit.html?edit=1&from=selfH&waybill=selfH&order="+GetQueryString('waybill');
		}else{
			window.location.href="../ucenter/receiving_edit.html?edit=1&from=selfH&order="+GetQueryString('waybill');
		};
	};
}
/*代收价格*/
function price_open(){
	if ($('[name="goodsAmount"]').val()>0) {
		var haveColl=$('[name="goodsAmount"]').val();
	}else{
		var haveColl='';
	};
	var html='<div class="receive_pop_w agency_fund">'
			+'<div class="receive_pop">'
				+'<div class="receive_pop_c">'
					+'<div class="receive_pop_close" onclick="receive_close()"></div>'
					+'<div class="uc_cou_bot">'
						+'<div class="receive_pop_tit">'
							+'<span onclick="receive_close()"></span>'
						+'</div>'
						+'<div class="uc_cou_con collection_pop">'
							+'<input class="price_coll" type="number" placeholder="输入代收货款金额" onblur="coll_price($(this))" oninput="if(value.length>9)value=value.slice(0,9);">'
							+'<p class="msg"></p>'
							+'<p>请认真核对代收款金额，运单未签收前您可自助修改金额</p>'
							+'<footer>'
							+'<a class="footer_btn" href="javascript:;" onclick="coll_submit()">确定</a>'
							+'</footer></div></div></div></div></div>'
	$('body').append(html);
	var priceA=parseFloat(haveColl).toFixed(2);
	/*var dianA=outputmoney(priceA);*/
	$('.price_coll').val(priceA).focus();
}
function receive_close(){
	$('.agency_fund').remove();
	if (parseFloat($('[name="goodsAmount"]').val())<5) {
		$('[name="collection"]').removeAttr('checked');
		$('[name="have_coll"]').removeAttr('onclick');
	};
}
/*提交收货款金额*/
function coll_submit(){
	if (coll_price($('.price_coll'))) {
		var val=$('.price_coll').val();
		var price=parseFloat(val).toFixed(2);
		var dian=outputmoney(price);
		$('#have_coll').val(dian);
		$('[name="goodsAmount"]').val(price);
		$('.agency_fund').remove();
	}else{
		coll_price($('.price_coll'))
	};
	
}

/*以下为金额转化为三个字符一个“，”逗号*/
function outputmoney(number) {
	number = number.replace(/\,/g, "");
	if(isNaN(number) || number == "")return "";
	number = Math.round(number * 100) / 100;
	    if (number < 0)
	        return '-' + outputdollars(Math.floor(Math.abs(number) - 0) + '') + outputcents(Math.abs(number) - 0);
	    else
	        return outputdollars(Math.floor(number - 0) + '') + outputcents(number - 0);
} 
/*格式化金额*/
function outputdollars(number) {
    if (number.length <= 3)
        return (number == '' ? '0' : number);
    else {
        var mod = number.length % 3;
        var output = (mod == 0 ? '' : (number.substring(0, mod)));
        for (var i = 0; i < Math.floor(number.length / 3); i++) {
            if ((mod == 0) && (i == 0))
                output += number.substring(mod + 3 * i, mod + 3 * i + 3);
            else
                output += ',' + number.substring(mod + 3 * i, mod + 3 * i + 3);
        }
        return (output);
    }
}
function outputcents(amount) {
    amount = Math.round(((amount) - Math.floor(amount)) * 100);
    return (amount < 10 ? '.0' + amount : '.' + amount);
}
/*以上为金额转化为三个字符一个“，”逗号*/

/*验证输入有代收款是否正确*/
function coll_price(e){
	var price_val=e.val();
	if (price_val) {
		if (!isverify(price_val)) {
			$('.msg').html('<span class="red">小数点后最多保留两位小数,代收货款需低于100万</span>');
			return false;
		}else{
			if (parseFloat(price_val)<2) {
				$('.msg').html('<span class="red">代收货款金额最低为2元</span>');
				return false;
			}else{
				$('.msg').html('');
				return true;
			};
		};
	}else{
		$('.msg').html('<span class="red">请输入正确的代收货款金额</span>');
		return false;
	};
}

/*验证价格*/
function isverify(verify) {
	var pattern = /^\d{1,6}(\.\d{1,2})?$/;
 	return pattern.test(verify);
}
/*货物件数变化时限制*/
function num_change(e){
	if (e.val()<=1) {
		e.val('1');
		$('#reduce').addClass('no');
		$('#increase').removeClass('no');
		return false;
	}else if(e.val()>=999){
		e.val('999');
		$('#reduce').removeClass('no');
		$('#increase').addClass('no');
		return false;
	}else{
		$('#reduce').removeClass('no');
		$('#increase').removeClass('no');
	}
	if(!/^\d+$/.test(e.val())){
		var intval=parseInt(e.val())
		if (!isNaN(intval)) {
			e.val(intval);
			if (intval==1) {
				$('#reduce').addClass('no');
				$('#increase').removeClass('no');
			}
		}else{
			e.val(1);
			$('#reduce').addClass('no');
			$('#increase').removeClass('no');
		};
	}
	self_btn_show();
}
/*减少包裹*/
function reduce(e){
	var val=parseInt(e.siblings('.parcel_num').val());
	if (val<=1) {
		e.addClass('no');
	}else{
		val--;
		if (val==1) {
			e.addClass('no');
		};
		$('#increase').removeClass('no');
	};
	e.siblings('.parcel_num').val(val);
}
/*增加包裹*/
function increase(e){
	var val=parseInt(e.siblings('.parcel_num').val());
	if (val>=999) {
		e.addClass('no');
	}else{
		val++;
		if (val==999) {
			e.addClass('no');
		};
		$('#reduce').removeClass('no');
	};
	e.siblings('.parcel_num').val(val);
}

/*提交运单*/
function self_submit(){
	var consigner=$('input[name="senderName"]').val();
	var delivery=$('input[name="receiverName"]').val();
	var goodsName=$('input[name="goodsName"]').val();
	var branch=$('input[name="inputDotId"]:checked').val();
	var pay_way=$('input[name="payType"]:checked').val();
	var have_coll="1";
	if ($('.pay_way2').attr('checked')) {
		have_coll=$('.have_coll').val();
	}
	if (!consigner) {
		$.MsgBox.Alert("请填写发货人的联系方式和详细信息",'确定');
	}else if(!delivery){
		$.MsgBox.Alert("请填写收货人的联系方式和详细信息",'确定');
	}else if(!goodsName){
		$.MsgBox.Alert("请填写货物信息",'确定');
	}/*else if(!pay_way){
		$.MsgBox.Alert("请选择付款方式",'确定');
	}*/else if(!have_coll){
		$.MsgBox.Alert("请输入代收货款金额",'确定');
	}else if(!branch){
		$.MsgBox.Alert("请选择发货网点",'确定');
	}else{
		protocol();
	};
}

function self_btn_show(){
	var consigner=$('input[name="senderName"]').val();
	var delivery=$('input[name="receiverName"]').val();
	var goodsName=trim($('input[name="goodsName"]').val());
	var branch=$('input[name="inputDotId"]:checked').val();
	// var pay_way=$('input[name="payType"]:checked').val();
	var goodsQuantity=$('input[name="goodsQuantity"]').val();
	if (consigner&&delivery&&goodsName&&branch&&goodsQuantity/*&&pay_way*/) {
		$('.footer_self .footer_btn').removeClass('hui').removeAttr('disabled');
	}else{
		$('.footer_self .footer_btn').addClass('hui').attr('disabled', 'disabled');
	};
}
/*提交后弹出协议*/
function protocol(){
	$('.protocol_w').css('display', 'block');
}
/*提交关闭协议*/
function protocol_close(){
	$('.protocol_w').css('display', 'none');
}
/*协议确认提交*/
function auto_help_ok(){
	loading('提交中...');
	$.ajax({
		url: apiAn+'/api/wx/waybill/insertWaybill',
		type: 'POST',
		timeout : 10000,
		dataType: 'json',
		data: $('#selfHelpOrder').serialize(),
		success:function(data){
			loadingRemove();
			if (data.success) {
			    $('#selfSubmit').attr('disabled', 'disabled');
				var timer=setTimeout(function(){
					clearTimeout(timer);
					$('#selfSubmit').removeAttr('disabled');
				}, 5000);
				var order=data.info;
				window.location.href='../order/order_succeed.html?order='+order;
			}else{
				alert(data.message);
			};
		},
        complete : function(XMLHttpRequest,status){
        	$('[name="requestTokenId"]').val(requestTokenId());
			loadingRemove();
			if(status=='error'){
				alert('提交失败，请重试');
			}else if(status=='timeout'){
				alert('提交失败，请重试');
			}
    　　}
    });
}

/*自助下单修改*/
function auto_help_edit(){
	loading('提交中...');
	var waybillNo=GetQueryString('waybill');
	$.ajax({
		url: apiAn+'/api/wx/waybill/editWaybill',
		type: 'POST',
		timeout : 10000,
		dataType: 'json',
		data: $('#selfHelpOrder').serialize()+'&no='+waybillNo,
		success:function(data){
			loadingRemove();
			if (data.success) {
			    $('#selfSubmit').attr('disabled', 'disabled').css('background', '#999');
				var timer=setTimeout(function(){
					clearTimeout(timer);
					$('#selfSubmit').removeAttr('disabled').css('background', '#52BB03');
				}, 5000);
				var order=data.info;
				window.location.href='../order/scan.html?order='+order;
			}else{
				alert(data.message);
			};
		},
        complete : function(XMLHttpRequest,status){
        	$('[name="requestTokenId"]').val(requestTokenId());
			loadingRemove();
			if(status=='error'){
				fubottom('修改失败，请重试');
    　　　　}else if(status=='timeout'){
				fubottom('修改失败，请重试');
			}
		}
    });
}
/*自助下单修改*/
function auto_help_coll(){
	loading('提交中...');
	var goodsAmount=$('[name="goodsAmount"]').val();
	var waybillNo=GetQueryString('waybill');
	var data={
		no:waybillNo,
		waybillNo:waybillNo,
		goodsAmount:goodsAmount,
		requestTokenId:requestTokenId()
	};
	$.ajax({
		url: apiAn+'/api/wx/waybill/editWaybillGoodsAmount',
		type: 'POST',
		timeout : 10000,
		dataType: 'json',
		data: data,
		success:function(data){
			loadingRemove();
			if (data.success) {
				$('#selfSubmit').attr('disabled', 'disabled').css('background', '#999');
				var timer=setTimeout(function(){
					clearTimeout(timer);
					$('#selfSubmit').removeAttr('disabled').css('background', '#52BB03');
				}, 5000);
				var order=data.info;
				window.location.href='../order/scan.html?order='+order;
			}else{
				alert(data.message);
			};
		},
        complete : function(XMLHttpRequest,status){
			loadingRemove();
			if(status=='error'){
				fubottom('修改失败，请重试');
    　　　　}else if(status=='timeout'){
				fubottom('修改失败，请重试');
			}
		}
	});
}


/*附近网点列表*/
function bannce(cityId,areaId,receiverAreaId){
	if (areaId) {
		$.ajax({
			url: apiAn+'/api/wx/dot/getListByArea',
			type: 'POST',
			timeout : 10000,
			dataType: 'json',
			data: {cityId:cityId,areaId:areaId,receiverAreaId:receiverAreaId,requestTokenId:requestTokenId()},
			success:function(data){
				if (data.success) {
					// console.log(data);
					if (data.info.length>0) {
						var html='<h6>附近可揽货网点：共为您匹配到<span class="red">'+data.info.length+'</span>家可揽货网点</h6>';
						html+='<ul>';
						var nowData=new Date();
						for (var i = 0; i < data.info.length; i++) {
							var startBusinessHour=(data.info[i].startBusinessHour).slice(0,5);
							var endBusinessHour=(data.info[i].endBusinessHour).slice(0,5);

							if (data.info[i].inBusiness) {
								html+='<li data-id="'+data.info[i].id+'">';
							}else{
								html+='<li class="branch_close" data-id="'+data.info[i].id+'">';
							};
							html+='<label><div class="branch_w">'
										+'<div class="branch_l">'
										+'<p><input class="pay_way branch" id="branch'+data.info[i].id+'" type="radio" name="inputDotId"  value="'+data.info[i].id+'"><span><b></b></span>'+ data.info[i].name+'</p>'
											+'<p>&nbsp;</p>'
										+'</div>'
										+'<div class="branch_r">'
											+'<span>揽货时间：<br>'+ startBusinessHour+'--'+ endBusinessHour+'</span>'
										+'</div>'
									+'</div>'
									+'<p>营业地址：'+ data.info[i].province+''+ data.info[i].city+''+ data.info[i].area+''+ data.info[i].address+'</p>'
								+'</label><a href="tel:'+data.info[i].tel1+'" class="blue DotTel">'+ data.info[i].tel1+'</a>'
							+'</li>';
						};
						html+='</ul>';
						$('.nearby').html(html);
					}else{
						var html='<h6>附近可揽货网点：共为您匹配到<span class="red">'+data.info.length+'</span>家可揽货网点</h6>';
						$('.nearby').html(html);
						$.MsgBox.Alert(data.message,'确定');
					};
				}else{
					alert(data.message);
				};
			},
	        complete : function(XMLHttpRequest,status){
	            loadingRemove();
	            if(status=='error'){
	                noResultErr($('.nearby'),200,'获取网点失败，请点击重新获取','bannce('+cityId+','+areaId+','+receiverAreaId+')');
	            }else if(status=='timeout'){
	                noResultErr($('.nearby'),200,'获取网点失败，请点击重新获取','bannce('+cityId+','+areaId+','+receiverAreaId+')');
	            }
	        }
	    });
		return true;
	};
	
}
/*附近网点列表*/
function bannceEdit(cityId,areaId,receiverAreaId,id,status){
	var statu=status;
	if (areaId) {
		$.ajax({
			url: apiAn+'/api/wx/dot/getListByArea',
			type: 'POST',
			timeout : 10000,
			dataType: 'json',
			data: {cityId:cityId,areaId:areaId,receiverAreaId:receiverAreaId,requestTokenId:requestTokenId()},
			success:function(data){
				if (data.success) {
					if (!status) {
						var html='<h6>附近可揽货网点：共为您匹配到<span class="red">'+data.info.length+'</span>家可揽货网点</h6>';
						html+='<ul>';
						var nowData=new Date();
						for (var i = 0; i < data.info.length; i++) {
							var startBusinessHour=(data.info[i].startBusinessHour).slice(0,5);
							var endBusinessHour=(data.info[i].endBusinessHour).slice(0,5);
							if (data.info[i].inBusiness) {
								html+='<li data-id="'+data.info[i].id+'">';
							}else{
								html+='<li class="branch_close" data-id="'+data.info[i].id+'">';
							};
							html+='<label><div class="branch_w">'
										+'<div class="branch_l">';
											html+='<p><input class="pay_way branch" id="branch'+data.info[i].id+'" type="radio" name="inputDotId"  value="'+data.info[i].id+'"><span><b></b></span>'+ data.info[i].name+'</p>';
											html+='<p>&nbsp;</p>'
										+'</div>'
										+'<div class="branch_r">'
											+'<span>揽货时间：<br>'+ startBusinessHour+'--'+ endBusinessHour+'</span>'
										+'</div>'
									+'</div>'
									+'<p>营业地址：'+ data.info[i].province+''+ data.info[i].city+''+ data.info[i].area+''+ data.info[i].address+'</p>'
								+'</label><a href="tel:'+data.info[i].tel1+'" class="blue DotTel">'+ data.info[i].tel1+'</a>'
							+'</li>';
						};
					}else{
						var html='<h6>附近可揽货网点：共为您匹配到<span class="red">1</span>家可揽货网点</h6>';
						html+='<ul>';
						var nowData=new Date();
						$.ajax({
							url: apiAn+'/api/wx/dot/getDotById',
							type: 'post',
							timeout : 10000,
							dataType: 'json',
							async:false,
							data: {dotId:id,requestTokenId:requestTokenId()},
							success:function(data){
								// console.log(data);
								if (data.success) {
									var info=data.info;
									var startBusinessHour=(info.startBusinessHour).slice(0,5);
									var endBusinessHour=(info.endBusinessHour).slice(0,5);
									if (info.inBusiness) {
										html+='<li data-id="'+info.id+'">';
									}else{
										html+='<li class="branch_close" data-id="'+info.id+'">';
									};
									html+='<label><div class="branch_w">'
												+'<div class="branch_l">';
												html+='<p><input class="pay_way branch" id="branch'+info.id+'" type="radio" name="inputDotId"  value="'+info.id+'" disabled="disabled"><span><b></b></span>'+ info.name+'</p>';
													html+='<p>&nbsp;</p>'
												+'</div>'
												+'<div class="branch_r">'
													+'<span>揽货时间：<br>'+ startBusinessHour+'--'+ endBusinessHour+'</span>'
												+'</div>'
											+'</div>'
											+'<p>营业地址：'+ info.province+''+ info.city+''+ info.area+''+ info.address+'</p>'
										+'</label><a href="tel:'+data.info[i].tel1+'" class="blue DotTel">'+ data.info[i].tel1+'</a>'
									+'</li>';
								}else{
									alert(data.message)
								}
							},
					 		complete : function(XMLHttpRequest,status){
								loadingRemove();
								if(status=='error'){
									noResultErr($('.nearby'),200,'获取网点失败，请点击重新获取','bannceEdit('+cityId+','+areaId+','+receiverAreaId+','+id+','+statu+')');
								}else if(status=='timeout'){
									noResultErr($('.nearby'),200,'获取网点失败，请点击重新获取','bannceEdit('+cityId+','+areaId+','+receiverAreaId+','+id+','+statu+')');
								}
							}
						});
					};
					html+='</ul>';
					$('.nearby').html(html);
					$('#branch'+id).attr('checked', 'checked');
					if (status) {
						$('.branch:checked+span').css('border-color', '#999');
						$('.branch:checked+span b').css('background', '#999');
					};
					self_btn_show();
				}else{
					alert(data.message);
				};
			},
	        complete : function(XMLHttpRequest,status){
	            loadingRemove();
	            if(status=='error'){
	                noResultErr($('.nearby'),200,'获取网点失败，请点击重新获取','bannceEdit('+cityId+','+areaId+','+receiverAreaId+','+id+','+statu+')');
	            }else if(status=='timeout'){
	                noResultErr($('.nearby'),200,'获取网点失败，请点击重新获取','bannceEdit('+cityId+','+areaId+','+receiverAreaId+','+id+','+statu+')');
	            }
	        }
	    });
	};
}


/*附近网点列表*/
function bannceEdit(cityId,areaId,receiverAreaId,id,status){
	var statu=status;
	if (areaId) {
		if (!status) {
			$.ajax({
				url: apiAn+'/api/wx/dot/getListByArea',
				type: 'POST',
				timeout : 10000,
				dataType: 'json',
				data: {cityId:cityId,areaId:areaId,receiverAreaId:receiverAreaId,requestTokenId:requestTokenId()},
				success:function(data){
					if (data.success) {
							var html='<h6>附近可揽货网点：共为您匹配到<span class="red">'+data.info.length+'</span>家可揽货网点</h6>';
							html+='<ul>';
							var nowData=new Date();
							for (var i = 0; i < data.info.length; i++) {
								var startBusinessHour=(data.info[i].startBusinessHour).slice(0,5);
								var endBusinessHour=(data.info[i].endBusinessHour).slice(0,5);
								if (data.info[i].inBusiness) {
									html+='<li data-id="'+data.info[i].id+'">';
								}else{
									html+='<li class="branch_close" data-id="'+data.info[i].id+'">';
								};
								html+='<label><div class="branch_w">'
											+'<div class="branch_l">';
												html+='<p><input class="pay_way branch" id="branch'+data.info[i].id+'" type="radio" name="inputDotId"  value="'+data.info[i].id+'"><span><b></b></span>'+ data.info[i].name+'</p>';
												html+='<p>&nbsp;</p>'
											+'</div>'
											+'<div class="branch_r">'
												+'<span>揽货时间：<br>'+ startBusinessHour+'--'+ endBusinessHour+'</span>'
											+'</div>'
										+'</div>'
										+'<p>营业地址：'+ data.info[i].province+''+ data.info[i].city+''+ data.info[i].area+''+ data.info[i].address+'</p>'
									+'</label><a href="tel:'+data.info[i].tel1+'" class="blue DotTel">'+ data.info[i].tel1+'</a>'
								+'</li>';
							};
						
						html+='</ul>';
						$('.nearby').html(html);
						$('#branch'+id).attr('checked', 'checked');
						if (status) {
							$('.branch:checked+span').css('border-color', '#999');
							$('.branch:checked+span b').css('background', '#999');
						};
						self_btn_show();
					}else{
						alert(data.message);
					};
				},
		        complete : function(XMLHttpRequest,status){
		            loadingRemove();
		            if(status=='error'){
		                noResultErr($('.nearby'),200,'获取网点失败，请点击重新获取','bannceEdit('+cityId+','+areaId+','+receiverAreaId+','+id+','+statu+')');
		            }else if(status=='timeout'){
		                noResultErr($('.nearby'),200,'获取网点失败，请点击重新获取','bannceEdit('+cityId+','+areaId+','+receiverAreaId+','+id+','+statu+')');
		            }
		        }
		    });
		}else{
			$.ajax({
				url: apiAn+'/api/wx/dot/getDotById',
				type: 'post',
				timeout : 10000,
				dataType: 'json',
				async:false,
				data: {dotId:id,requestTokenId:requestTokenId()},
				success:function(data){
					// console.log(data);
					if (data.success) {
						var html='<h6>附近可揽货网点：共为您匹配到<span class="red">1</span>家可揽货网点</h6>';
						html+='<ul>';
						var nowData=new Date();
						var info=data.info;
						var startBusinessHour=(info.startBusinessHour).slice(0,5);
						var endBusinessHour=(info.endBusinessHour).slice(0,5);
						if (info.inBusiness) {
							html+='<li data-id="'+info.id+'">';
						}else{
							html+='<li class="branch_close" data-id="'+info.id+'">';
						};
						html+='<label><div class="branch_w">'
									+'<div class="branch_l">';
									html+='<p><input class="pay_way branch" id="branch'+info.id+'" type="radio" name="inputDotId"  value="'+info.id+'" disabled="disabled"><span><b></b></span>'+ info.name+'</p>';
										html+='<p><a href="tel:'+info.tel1+'" class="blue">'+ info.tel1+'</a></p>'
									+'</div>'
									+'<div class="branch_r">'
										+'<span>揽货时间：<br>'+ startBusinessHour+'--'+ endBusinessHour+'</span>'
									+'</div>'
								+'</div>'
								+'<p>营业地址：'+ info.province+''+ info.city+''+ info.area+''+ info.address+'</p>'
							+'</label>'
							+'</li>';
						html+='</ul>';
						$('.nearby').html(html);
						$('#branch'+id).attr('checked', 'checked');
						if (status) {
							$('.branch:checked+span').css('border-color', '#999');
							$('.branch:checked+span b').css('background', '#999');
						};
						self_btn_show();
					}else{
						alert(data.message)
					}
				},
		 		complete : function(XMLHttpRequest,status){
					loadingRemove();
					if(status=='error'){
						noResultErr($('.nearby'),200,'获取网点失败，请点击重新获取','bannceEdit('+cityId+','+areaId+','+receiverAreaId+','+id+','+statu+')');
					}else if(status=='timeout'){
						noResultErr($('.nearby'),200,'获取网点失败，请点击重新获取','bannceEdit('+cityId+','+areaId+','+receiverAreaId+','+id+','+statu+')');
					}
				}
			});
		};
	};
}
/*发货地址薄*/
function consignerBook(){
	if (!GetQueryString('waybill')) {
		window.location.href="../ucenter/ship_address.html?selfHp="+GetQueryString('waybill');
	}else{
		window.location.href="../ucenter/ship_address.html?selfHp="+GetQueryString('waybill')+"&waybill=1";
	};
}
/*收货地址薄*/
function deliveryBook(){
	if (!GetQueryString('waybill')) {
		window.location.href="../ucenter/receiving_party.html?selfHp="+GetQueryString('waybill');
	}else{
		window.location.href="../ucenter/receiving_party.html?selfHp="+GetQueryString('waybill')+"&waybill=addr";
	};
}

/*移除浮层*/
function selfFaEdit(e){
	e.parents('.self_help_w').remove();


}
/*移除浮层*/
function selfShouEdit(e){
	e.parents('.self_help_w').remove();
}

/*发货地址提交*/
function selfShipSubmit(){
	if (!noNullfa($('[name="client"]'),'单位名称')) {
		noNullfa($('[name="client"]'),'单位名称');
		return false;
	}else if(!telNo($('[name="tel"]'))){
		telNo($('[name="tel"]'))
		return false;
	}else if(!noNull($('[name="aeraNum"]'),'所在省、市、区')){
		noNull($('[name="aeraNum"]'),'所在省、市、区');
		return false;
	}else if(!noNullfa($('[name="detail"]'),'详细地址')){
		noNullfa($('[name="detail"]'),'详细地址');
		return false;
	}else{
		loading('提交中...');
		var senderAddId=$('[name="senderAddId"]').val();
		var senderAddIsDf=$('[name="senderAddIsDf"]').val();
		var company=trim($('[name="client"]').val());
		var contact=trim($('[name="name"]').val());
		var phone=trim($('[name="tel"]').val());
		var aera=$('#addr_aera').html();
		var aeraNum=$('[name="aeraNum"]').val();
		var detailed=trim($('[name="detail"]').val());
		var aeraArr=aera.split(' ');
		var aeraNumArr=aeraNum.split(',');
		if (senderAddIsDf==1) {
			var isDefault=1;
		}else{
			var isDefault=0;
		};
		// console.log(isDefault);
		
		if (Recdistinctive()) {
			if (!senderAddId) {
				AMap.service('AMap.Geocoder',function(){
			    var geocoder = new AMap.Geocoder({});
			    geocoder.getLocation(aeraArr[0]+""+aeraArr[1]+""+aeraArr[2]+""+detailed, function(status, result) {
			    	loadingRemove();
				    if (status === 'complete' && result.info === 'OK') {
				        loading('提交中...');
			    		var data={
							userId:userId(),
							type:1,
							company:company,
							contact:contact,
							phone:phone,
							proName:aeraArr[0],
							proNumber:aeraNumArr[0],
							cityName:aeraArr[1],
							cityNumber:aeraNumArr[1],
							areaName:aeraArr[2],
							areaNumber:aeraNumArr[2],
							detailed:detailed,
							lat:result.geocodes[0].location.lat,
							lng:result.geocodes[0].location.lng,
							isDefault:isDefault,
							requestTokenId:requestTokenId()
						};
						$.ajax({
							url: apiL+'/api/wx/address/add',
							type: 'get',
							timeout : 10000,
							dataType: 'json',
							data: data,
							success:function(data){
								loadingRemove();
								if (data.success) {
									// console.log(data)
									$('[name="senderAddId"]').val(data.info.id);
									$('[name="senderAddIsDf"]').val(data.info.isDefault);
									$('[name="senderName"]').val(company);
									$('[name="senderLinkman"]').val(contact);
									$('[name="senderMobile"]').val(phone);
									$('[name="senderProvinceName"]').val(aeraArr[0]);
									$('[name="senderCityName"]').val(aeraArr[1]);
									$('[name="senderAreaName"]').val(aeraArr[2]);
									$('[name="senderProvinceId"]').val(aeraNumArr[0]);
									$('[name="senderCityId"]').val(aeraNumArr[1]);
									$('[name="senderAreaId"]').val(aeraNumArr[2]);
									$('[name="senderAddress"]').val(detailed);
									var html='<p id="addr_consigner"> '+company+' <br> '+contact+' '+phone+'  <br>'+aeraArr[0]+' '+aeraArr[1]+' '+aeraArr[2]+' '+detailed+'</p>';
									$('.consigner_edit a').html(html);
									$('.self_fa_edit').remove();
									var receiverAreaId=$('[name="receiverAreaId"]').val();
									if (receiverAreaId) {
										if (bannce(aeraNumArr[1],aeraNumArr[2],receiverAreaId)) {
											setTimeout(function(){
												self_btn_show();
											}, 100);
										};
									};
								}else{
									alert(data.message);
								};
							},
					        complete : function(XMLHttpRequest,status){
					            loadingRemove();
					            if(status=='error'){
					            	$('.selfShipSubmit').removeAttr('disabled');
					                fubottom('提交失败，请重试');
					            }else if(status=='timeout'){
					            	$('.selfShipSubmit').removeAttr('disabled');
					                fubottom('提交失败，请重试');
					            }
					        }
						});
						/*防止多次提交*/
						$('.selfShipSubmit').attr('disabled', 'disabled');
						setTimeout(function(){
							$('.selfShipSubmit').removeAttr('disabled');
						}, 5000);
				    }else{
				        AMap.service('AMap.Geocoder',function(){//回调函数
						    //实例化Geocoder
						    var geocoder = new AMap.Geocoder({
						        // city: "010"//城市，默认：“全国”
						    });
						    geocoder.getLocation(aeraArr[0]+""+aeraArr[1]+""+aeraArr[2], function(status, result) {
						    	loadingRemove();
							    if (status === 'complete' && result.info === 'OK') {
							        loading('提交中...');
						    		var data={
										userId:userId(),
										type:1,
										company:company,
										contact:contact,
										phone:phone,
										proName:aeraArr[0],
										proNumber:aeraNumArr[0],
										cityName:aeraArr[1],
										cityNumber:aeraNumArr[1],
										areaName:aeraArr[2],
										areaNumber:aeraNumArr[2],
										detailed:detailed,
										lat:result.geocodes[0].location.lat,
										lng:result.geocodes[0].location.lng,
										isDefault:isDefault,
										requestTokenId:requestTokenId()
									};
									$.ajax({
										url: apiL+'/api/wx/address/add',
										type: 'get',
										timeout : 10000,
										dataType: 'json',
										data: data,
										success:function(data){
											loadingRemove();
											if (data.success) {
												// console.log(data)
												$('[name="senderAddId"]').val(data.info.id);
												$('[name="senderAddIsDf"]').val(data.info.isDefault);
												$('[name="senderName"]').val(company);
												$('[name="senderLinkman"]').val(contact);
												$('[name="senderMobile"]').val(phone);
												$('[name="senderProvinceName"]').val(aeraArr[0]);
												$('[name="senderCityName"]').val(aeraArr[1]);
												$('[name="senderAreaName"]').val(aeraArr[2]);
												$('[name="senderProvinceId"]').val(aeraNumArr[0]);
												$('[name="senderCityId"]').val(aeraNumArr[1]);
												$('[name="senderAreaId"]').val(aeraNumArr[2]);
												$('[name="senderAddress"]').val(detailed);
												var html='<p id="addr_consigner"> '+company+' <br> '+contact+' '+phone+'  <br>'+aeraArr[0]+' '+aeraArr[1]+' '+aeraArr[2]+' '+detailed+'</p>';
												$('.consigner_edit a').html(html);
												$('.self_fa_edit').remove();
												var receiverAreaId=$('[name="receiverAreaId"]').val();
												if (receiverAreaId) {
													if (bannce(aeraNumArr[1],aeraNumArr[2],receiverAreaId)) {
														setTimeout(function(){
															self_btn_show();
														}, 100);
													};
												};
											}else{
												alert(data.message);
											};
										},
								        complete : function(XMLHttpRequest,status){
								            loadingRemove();
								            if(status=='error'){
								            	$('.selfShipSubmit').removeAttr('disabled');
								                fubottom('提交失败，请重试');
								            }else if(status=='timeout'){
								            	$('.selfShipSubmit').removeAttr('disabled');
								                fubottom('提交失败，请重试');
								            }
								        }
									});
									/*防止多次提交*/
									$('.selfShipSubmit').attr('disabled', 'disabled');
									setTimeout(function(){
										$('.selfShipSubmit').removeAttr('disabled');
									}, 5000);
							    }else{
							        $.MsgBox.Alert("地址获取失败，请重试或修改地址后再试",'确定');
							    }
							});
						})
				    }
				});
			})
			}else{
				AMap.service('AMap.Geocoder',function(){
					loadingRemove();
				    var geocoder = new AMap.Geocoder({});
				    geocoder.getLocation(aeraArr[0]+""+aeraArr[1]+""+aeraArr[2]+""+detailed, function(status, result) {
					    if (status === 'complete' && result.info === 'OK1') {
					    	loading('提交中...');
					        var data={
								userId:userId(),
								type:1,
								id:senderAddId,
								company:company,
								contact:contact,
								phone:phone,
								proName:aeraArr[0],
								proNumber:aeraNumArr[0],
								cityName:aeraArr[1],
								cityNumber:aeraNumArr[1],
								areaName:aeraArr[2],
								areaNumber:aeraNumArr[2],
								detailed:detailed,
								lat:result.geocodes[0].location.lat,
								lng:result.geocodes[0].location.lng,
								isDefault:isDefault,
								requestTokenId:requestTokenId()
							}
							// console.log(data);
							$.ajax({
								url: apiL+'/api/wx/address/edit',
								type: 'get',
								timeout : 10000,
								dataType: 'json',
								data: data,
								success:function(data){
									loadingRemove();
									if (data.success) {
										// console.log(data)
										$('[name="senderName"]').val(company);
										$('[name="senderLinkman"]').val(contact);
										$('[name="senderMobile"]').val(phone);
										$('[name="senderProvinceName"]').val(aeraArr[0]);
										$('[name="senderCityName"]').val(aeraArr[1]);
										$('[name="senderAreaName"]').val(aeraArr[2]);
										$('[name="senderProvinceId"]').val(aeraNumArr[0]);
										$('[name="senderCityId"]').val(aeraNumArr[1]);
										$('[name="senderAreaId"]').val(aeraNumArr[2]);
										$('[name="senderAddress"]').val(detailed);
										var html='<p id="addr_consigner"> '+company+' <br> '+contact+' '+phone+'  <br>'+aeraArr[0]+' '+aeraArr[1]+' '+aeraArr[2]+' '+detailed+'</p>';
										$('.consigner_edit a').html(html);
										$('.self_fa_edit').remove();
										var receiverAreaId=$('[name="receiverAreaId"]').val();
										if (receiverAreaId) {
											if (bannce(aeraNumArr[1],aeraNumArr[2],receiverAreaId)) {
												setTimeout(function(){
													self_btn_show();
												}, 100);
											};
										};
									}else{
										alert(data.message);
									};
								},
						        complete : function(XMLHttpRequest,status){
						            loadingRemove();
						            if(status=='error'){
						            	$('.selfShipSubmit').removeAttr('disabled');
						                fubottom('提交失败，请重试');
						            }else if(status=='timeout'){
						            	$('.selfShipSubmit').removeAttr('disabled');
						                fubottom('提交失败，请重试');
						            }
						        }
							});
					    }else{
					        AMap.service('AMap.Geocoder',function(){//回调函数
							    //实例化Geocoder
							    var geocoder = new AMap.Geocoder({
							        // city: "010"//城市，默认：“全国”
							    });
							    geocoder.getLocation(aeraArr[0]+""+aeraArr[1]+""+aeraArr[2], function(status, result) {
							    	loadingRemove();
								    if (status === 'complete' && result.info === 'OK') {
								        loading('提交中...');
										var data={
											userId:userId(),
											type:1,
											id:senderAddId,
											company:company,
											contact:contact,
											phone:phone,
											proName:aeraArr[0],
											proNumber:aeraNumArr[0],
											cityName:aeraArr[1],
											cityNumber:aeraNumArr[1],
											areaName:aeraArr[2],
											areaNumber:aeraNumArr[2],
											detailed:detailed,
											lat:result.geocodes[0].location.lat,
											lng:result.geocodes[0].location.lng,
											isDefault:isDefault,
											requestTokenId:requestTokenId()
										}
										// console.log(data);
										$.ajax({
											url: apiL+'/api/wx/address/edit',
											type: 'get',
											timeout : 10000,
											dataType: 'json',
											data: data,
											success:function(data){
												loadingRemove();
												if (data.success) {
													// console.log(data)
													$('[name="senderName"]').val(company);
													$('[name="senderLinkman"]').val(contact);
													$('[name="senderMobile"]').val(phone);
													$('[name="senderProvinceName"]').val(aeraArr[0]);
													$('[name="senderCityName"]').val(aeraArr[1]);
													$('[name="senderAreaName"]').val(aeraArr[2]);
													$('[name="senderProvinceId"]').val(aeraNumArr[0]);
													$('[name="senderCityId"]').val(aeraNumArr[1]);
													$('[name="senderAreaId"]').val(aeraNumArr[2]);
													$('[name="senderAddress"]').val(detailed);
													var html='<p id="addr_consigner"> '+company+' <br> '+contact+' '+phone+'  <br>'+aeraArr[0]+' '+aeraArr[1]+' '+aeraArr[2]+' '+detailed+'</p>';
													$('.consigner_edit a').html(html);
													$('.self_fa_edit').remove();
													var receiverAreaId=$('[name="receiverAreaId"]').val();
													if (receiverAreaId) {
														if (bannce(aeraNumArr[1],aeraNumArr[2],receiverAreaId)) {
															setTimeout(function(){
																self_btn_show();
															}, 100);
														};
													};
												}else{
													alert(data.message);
												};
											},
											complete : function(XMLHttpRequest,status){
												loadingRemove();
												if(status=='error'){
													$('.selfShipSubmit').removeAttr('disabled');
												    fubottom('提交失败，请重试');
												}else if(status=='timeout'){
													$('.selfShipSubmit').removeAttr('disabled');
												    fubottom('提交失败，请重试');
												}
									        }
										});
								    }else{
								        $.MsgBox.Alert("地址获取失败，请重试或修改地址后再试",'确定');
								    }
								});
							})
					    }
					});
				})
			};
		}
	
	}
}

/*显示发货添加*/
function selfConsigner(){
	var html=template('self_fa_edit');
	$('body').append(html);
	$('.self_help_w').animate({right:0}, 300);
	var senderName=$('[name="senderName"]').val();
	var senderLinkman=$('[name="senderLinkman"]').val();
	var senderMobile=$('[name="senderMobile"]').val();
	var senderProvinceName=$('[name="senderProvinceName"]').val();
	var senderCityName=$('[name="senderCityName"]').val();
	var senderAreaName=$('[name="senderAreaName"]').val();
	var senderProvinceId=$('[name="senderProvinceId"]').val();
	var senderCityId=$('[name="senderCityId"]').val();
	var senderAreaId=$('[name="senderAreaId"]').val();
	var senderAddress=$('[name="senderAddress"]').val();
	if (senderName) {
		$('.consigner_t [name="client"]').val(senderName);
		$('.consigner_t [name="name"]').val(senderLinkman);
		$('.consigner_t [name="tel"]').val(senderMobile);
		$('.consigner_t #addr_aera').html(senderProvinceName+' '+senderCityName+' '+senderAreaName).removeClass('c999');
		$('.consigner_t [name="aeraNum"]').val(senderProvinceId+','+senderCityId+','+senderAreaId);
		$('.consigner_t [name="detail"]').val(senderAddress);
		addr_aera2(senderProvinceId,senderCityId,senderAreaId);
	}else{
		addr_aera2();
	};
}
/*收货添加提交*/
function selfRedSubmit(){
	if (!noNullfa($('[name="client"]'),'单位名称')) {
		noNullfa($('[name="client"]'),'单位名称');
		return false;
	}else if(!telNo($('[name="tel"]'))){
		telNo($('[name="tel"]'))
		return false;
	}else if(!noNull($('[name="aeraNum"]'),'所在省、市、区')){
		noNull($('[name="aeraNum"]'),'所在省、市、区');
		return false;
	}else if(!noNullfa($('[name="detail"]'),'详细地址')){
		noNullfa($('[name="detail"]'),'详细地址');
		return false;
	}else{
		
		var company=trim($('[name="client"]').val());
		var contact=trim($('[name="name"]').val());
		var phone=trim($('[name="tel"]').val());
		var aera=$('#addr_aera').html();
		var aeraNum=$('[name="aeraNum"]').val();
		var detailed=trim($('[name="detail"]').val());
		var receiverRegisterCompany=$('[name="receiverRegisterCompany"]').val();
		var receiverRegisterMobile=$('[name="receiverRegisterMobile"]').val();
		var registerTelLin=$('[name="registerTelLin"]').val();
		var registerConLin=$('[name="registerConLin"]').val();
		var receiverIdLin=$('[name="receiverIdLin"]').val();
		var aeraArr=aera.split(' ');
		var aeraNumArr=aeraNum.split(',');
		var isDefault=0;
		if (senddistinctive()) {
			$('[name="receiverRegisterCompany"]').val(company);
			if (registerTelLin) {
				if (registerConLin==company) {
					$('[name="receiverRegisterMobile"]').val(registerTelLin);
				}else{
					$('[name="receiverRegisterMobile"]').val('');
				}
			}else{
				$('[name="receiverRegisterMobile"]').val('');
			};
			/*检索的客户档案号*/
			if (registerConLin==company) {
				$('[name="receiverId"]').val(receiverIdLin);
			}else{
				$('[name="receiverId"]').val('');
			};
			
			$('[name="receiverName"]').val(company);
			$('[name="receiverLinkman"]').val(contact);
			$('[name="receiverMobile"]').val(phone);
			$('[name="receiverProvinceName"]').val(aeraArr[0]);
			$('[name="receiverCityName"]').val(aeraArr[1]);
			$('[name="receiverAreaName"]').val(aeraArr[2]);
			$('[name="receiverProvinceId"]').val(aeraNumArr[0]);
			$('[name="receiverCityId"]').val(aeraNumArr[1]);
			$('[name="receiverAreaId"]').val(aeraNumArr[2]);
			$('[name="receiverAddress"]').val(detailed);
			var html='<p id="addr_receiver"> '+company+' <br> '+contact+' '+phone+'  <br>'+aeraArr[0]+' '+aeraArr[1]+' '+aeraArr[2]+' '+detailed+'</p>';
			$('.delivery_edit a').html(html);
			$('.self_shou_edit,.self_shou_add').remove();
			$('.self_shou_edit').remove();
			var senderCityId=$('[name="senderCityId"]').val();
			var senderAreaId=$('[name="senderAreaId"]').val();
			if (senderAreaId) {
				if (bannce(senderCityId,senderAreaId,aeraNumArr[2])) {
					setTimeout(function(){
						self_btn_show();
					}, 100);
				};
			};
		};
		
	}
}

/*发开添加编辑收货地址*/
function selfDelivery(){
	var html=template('self_shou_add');
	$('body').append(html);
	$('.self_help_w').animate({right:0}, 300);
	var receiverName=$('[name="receiverName"]').val();
	var receiverLinkman=$('[name="receiverLinkman"]').val();
	var receiverMobile=$('[name="receiverMobile"]').val();
	var receiverProvinceName=$('[name="receiverProvinceName"]').val();
	var receiverCityName=$('[name="receiverCityName"]').val();
	var receiverAreaName=$('[name="receiverAreaName"]').val();
	var receiverProvinceId=$('[name="receiverProvinceId"]').val();
	var receiverCityId=$('[name="receiverCityId"]').val();
	var receiverAreaId=$('[name="receiverAreaId"]').val();
	var receiverAddress=$('[name="receiverAddress"]').val();
	var receiverRegisterMobile=$('[name="receiverRegisterMobile"]').val();
	var receiverRegisterCompany=$('[name="receiverRegisterCompany"]').val();
	var receiverId=$('[name="receiverId"]').val();
	if (receiverName) {
		$('.consigner_t [name="client"]').val(receiverName);
		$('.consigner_t [name="name"]').val(receiverLinkman);
		$('.consigner_t [name="tel"]').val(receiverMobile);
		$('.consigner_t #addr_aera').html(receiverProvinceName+' '+receiverCityName+' '+receiverAreaName).removeClass('c999');
		$('.consigner_t [name="aeraNum"]').val(receiverProvinceId+','+receiverCityId+','+receiverAreaId);
		$('.consigner_t [name="detail"]').val(receiverAddress);
		$('.consigner_t [name="registerTelLin"]').val(receiverRegisterMobile);
		$('.consigner_t [name="registerConLin"]').val(receiverRegisterCompany);
		$('.consigner_t [name="receiverIdLin"]').val(receiverId);
		addr_aera2(receiverProvinceId,receiverCityId,receiverAreaId);
	}else{
		addr_aera2();
	};
}

/*发货地址内容（自助下单）*/
function selfshipAddr(data){
	var html="";
	for (var i = 0; i < data.info.length; i++) {
		if (data.info[i].isDefault) {
			html+='<div class="record_li ship_li" data-id="'+data.info[i].id+'">'
			+'<table width="w100"  onclick=addrTrue('+data.info[i].id+')>'
				+'<col width="74%"><col width="20%">'
				+'<tr><td>发 货 方：'+data.info[i].company+'</td><td class="t_r moren"><span class="red">默认发货</span></td></tr>'
				if (data.info[i].contact) {
					html+='<tr><td colspan="2">联 系 人：'+data.info[i].contact+'</td></tr>'
				};
				html+='<tr><td colspan="2">电&#x3000;&#x3000;话：'+data.info[i].phone+'<br></td></tr>'
				+'<tr><td colspan="2">发货地址：'+data.info[i].proName+''+data.info[i].cityName+''+data.info[i].areaName+''+data.info[i].detailed+'<br></td></tr></table>'
			+'<div class="show_details ov_h">'
				+'<label class="ship_moren"></label>'
				+'<a class="f_r f14" href="javascript:;" onclick="del_addr($(this),'+data.info[i].id+')">删除</a>'
				+'<a class="f_r f14" onclick="selfConsignerEdit('+data.info[i].id+')" href="javascript:;">编辑</a>'
			+'</div>'
		+'</div>'
		}else{
			html+='<div class="record_li ship_li" data-id="'+data.info[i].id+'">'
			+'<table width="w100"   onclick=addrTrue('+data.info[i].id+')>'
				+'<col width="74%"><col width="20%">'
				+'<tr><td>发 货 方：'+data.info[i].company+'</td><td class="t_r moren"></td></tr>'
				if (data.info[i].contact) {
					html+='<tr><td colspan="2">联 系 人：'+data.info[i].contact+'</td></tr>'
				};
				html+='<tr><td colspan="2">电&#x3000;&#x3000;话：'+data.info[i].phone+'<br></td></tr>'
				+'<tr><td colspan="2">发货地址：'+data.info[i].proName+''+data.info[i].cityName+''+data.info[i].areaName+''+data.info[i].detailed+'<br></td></tr></table>'
			+'</table>'
			+'<div class="show_details ov_h">'
				+'<label class="ship_moren"><input type="radio"  name="default"><span class="radio"></span>设置为默认发货方</label>'
				+'<a class="f_r f14" href="javascript:;" onclick="del_addr($(this),'+data.info[i].id+')">删除</a>'
				+'<a class="f_r f14" onclick="selfConsignerEdit('+data.info[i].id+')" href="javascript:;">编辑</a>'
			+'</div>'
		+'</div>'
		};
	};
	$('.record_list').html(html);
}

/*发货地址薄搜索（自助下单）*/
function selfAddrsearch(){
	if (userId()) {
		loading('loading...');
		var search=$('.search_input').val();
		var data={
			userId:userId(),
			type:1,
			searchParam:search,
			requestTokenId:requestTokenId()
		}
		if (search){
			$.ajax({
				url: api+'/api/wx/address/find',
				type: 'get',
				timeout : 10000,
				dataType: 'json',
				data: data,
				success:function(data){
					if (data.success) {
						if (data.info.length) {
							selfshipAddr(data)
						}else{
							noshipsearch(search);
						};
					}else{
						alert(data.message)
					};
				},
		        complete : function(XMLHttpRequest,status){
		            loadingRemove();
		    　　　　if(status=='error'){
		     　　　　　 noResultErr($('.record_list'),400,'请求超时，请点击重新获取','selfAddrsearch()');
		    　　　　}else if(status=='timeout'){
		                noResultErr($('.record_list'),400,'请求超时，请点击重新获取','selfAddrsearch()');
		            }
		    　　}
			});
		}else{
			$.ajax({
				url: apiL+'/api/wx/address/find',
				type: 'get',
				timeout : 10000,
				dataType: 'json',
				data: {userId:userId(),type:1,requestTokenId:requestTokenId()},
				success:function(data){
					if (data.success) {
						if (data.info.length) {
							selfshipAddr(data)
						}else{
							noshipsearch();
						}
					}else{
						alert(data.message)
					};
				},
		        complete : function(XMLHttpRequest,status){
		            loadingRemove();
		    　　　　if(status=='error'){
		     　　　　　 noResultErr($('.record_list'),400,'请求超时，请点击重新获取','selfAddrsearch()');
		    　　　　}else if(status=='timeout'){
		                noResultErr($('.record_list'),400,'请求超时，请点击重新获取','selfAddrsearch()');
		            }
		    　　}
			});
		};
	}else{
		document.write('请求失败,请返回公众号重新进入');
	}
}
/*以上为发货地址薄*/

/*发货方地址列表*/
function selfConsignerBook(){
	var html=template('self_fa_book');
	$('body').append(html);
	$('.self_help_w').animate({right:0}, 300);
	if (userId()) {
		selfConsignerBookA();
	}else{
		document.write('请求失败,请返回公众号重新进入');
	}
}
function selfConsignerBookA(){
	loading('loading...');
	$.ajax({
		url: apiL+'/api/wx/address/find',
		type: 'get',
		timeout : 10000,
		dataType: 'json',
		data: {userId:userId(),type:1,requestTokenId:requestTokenId()},
		success:function(data){
			if (data.success) {
				if (data.info.length) {
					selfshipAddr(data);
				}else{
					noshipsearch();
				};
			}else{
				alert(data.message)
			};
		},
        complete : function(XMLHttpRequest,status){
            loadingRemove();
    　　　　if(status=='error'){
     　　　　　 noResultErr($('.record_list'),400,'请求超时，请点击重新获取','selfConsignerBookA()');
    　　　　}else if(status=='timeout'){
                noResultErr($('.record_list'),400,'请求超时，请点击重新获取','selfConsignerBookA()');
            }
    　　}
	});
}
/*没有地址列表*/
function noshipsearch(name){
	if (name) {
		$('.record_list').html('<div class="ship_nofind"><span><img src="../skin/images/no_find.png" alt=""></span><p>对不起，没有找到“'+name+'”，请重新输入</p></div>')
	}else{
		$('.record_list').html('<div class="ship_nofind"><span><img src="../skin/images/no_find.png" alt=""></span><p>对不起，您还没有添加地址</p></div>')
	};
}
/*列表选择发货方*/
function addrTrue(id){
	loading('loading...');
	$.ajax({
		url: apiL+'/api/wx/address/findedit',
		type: 'get',
		timeout : 10000,
		dataType: 'json',
		data: {type:1,id:id,requestTokenId:requestTokenId()},
		success:function(data){
			loadingRemove();
			if (data.success) {
				var info=data.info;
				if (info.company==$('[name="receiverName"]').val()) {
					$.MsgBox.Alert("发货方与收货方名称不能相同",'确定');
					return false;
				};
				/*if (info.phone==$('[name="receiverMobile"]').val()) {
					$.MsgBox.Alert("发货方电话不能与收货方电话相同",'确定');
					return false;
				};*/
				if (info.contact) {
					var contact=info.contact;
				}else{
					var contact='';
				};
				$('[name="senderAddId"]').val(id);
				$('[name="senderAddIsDf"]').val(info.isDefault);
				$('[name="senderName"]').val(info.company);
				$('[name="senderLinkman"]').val(contact);
				$('[name="senderMobile"]').val(info.phone);
				$('[name="senderProvinceName"]').val(info.proName);
				$('[name="senderCityName"]').val(info.cityName);
				$('[name="senderAreaName"]').val(info.areaName);
				$('[name="senderProvinceId"]').val(info.proNumber);
				$('[name="senderCityId"]').val(info.cityNumber);
				$('[name="senderAreaId"]').val(info.areaNumber);
				$('[name="senderAddress"]').val(info.detailed);
				var html='<p id="addr_consigner"> '+info.company+' <br> '+contact+' '+info.phone+'  <br>'+info.proName+' '+info.cityName+' '+info.areaName+' '+info.detailed+'</p>';
				$('.consigner_edit a').html(html);

				$('.self_fa_book').remove();
				var receiverAreaId=$('[name="receiverAreaId"]').val();
				if (receiverAreaId) {
					if (bannce(info.cityNumber,info.areaNumber,receiverAreaId)) {
						setTimeout(function(){
							self_btn_show();
						}, 100);
					};
				};
			}else{
				alert(data.message);
			};
		},
		complete : function(XMLHttpRequest,status){
			loadingRemove();
			if(status=='error'){
				fubottom('选取失败，请重试');
			}else if(status=='timeout'){
				fubottom('选取失败，请重试');
			}
        }
	});
}
/*选择列表选择收货方*/
function recTrue(id){
	loading('loading...');
	$.ajax({
		url: apiL+'/api/wx/address/findedit',
		type: 'get',
		timeout : 10000,
		dataType: 'json',
		data: {type:2,id:id,requestTokenId:requestTokenId()},
		success:function(data){
			loadingRemove();
			if (data.success) {
				var info=data.info;
				if (info.company==$('[name="senderName"]').val()) {
					$.MsgBox.Alert("收货方与发货方单位名称不能相同",'确定');
					return false;
				};
				/*if (info.phone==$('[name="senderMobile"]').val()) {
					$.MsgBox.Alert("收货方电话不能与发货方电话相同",'确定');
					return false;
				};*/
				$('[name="receiverName"]').val(info.company);
				$('[name="receiverLinkman"]').val(info.contact);
				$('[name="receiverMobile"]').val(info.phone);
				$('[name="receiverProvinceName"]').val(info.proName);
				$('[name="receiverCityName"]').val(info.cityName);
				$('[name="receiverAreaName"]').val(info.areaName);
				$('[name="receiverProvinceId"]').val(info.proNumber);
				$('[name="receiverCityId"]').val(info.cityNumber);
				$('[name="receiverAreaId"]').val(info.areaNumber);
				$('[name="receiverAddress"]').val(info.detailed);
				$('[name="receiverRegisterMobile"]').val('');
				$('[name="receiverRegisterCompany"]').val('');
				$('[name="receiverId"]').val('');
				var html='<p id="addr_receiver"> '+info.company+' <br> ';
					if (info.contact) {
						html+=info.contact+' ';
					};
					html+=info.phone+'  <br>'+info.proName+' '+info.cityName+' '+info.areaName+' '+info.detailed+'</p>';
				$('.delivery_edit a').html(html);
				$('.self_shou_book').remove();
				/*获取网点*/
				var senderCityId=$('[name="senderCityId"]').val();
				var senderAreaId=$('[name="senderAreaId"]').val();
				if (senderAreaId) {
					if (bannce(senderCityId,senderAreaId,info.areaNumber)) {
						setTimeout(function(){
							self_btn_show();
						}, 100);
					};
				};
			}else{
				alert(data.message);
			};
		},
		complete : function(XMLHttpRequest,status){
			loadingRemove();
			if(status=='error'){
				fubottom('选取失败，请重试');
			}else if(status=='timeout'){
				fubottom('选取失败，请重试');
			}
        }
	});
}

/*发货地址簿删除*/
function del_addr(e,id){
	$.MsgBox.ConfirmL("确定要删除吗？",'取消','确定',function(){
		loading('删除中...');
		$.ajax({
			url: apiL+'/api/wx/address/findedit',
			type: 'post',
			timeout : 10000,
			dataType: 'json',
			data: {id:id,type:1,requestTokenId:requestTokenId()},
			success:function(data){
				loadingRemove();
				var isDefault=data.info.isDefault;
				if (data.success) {
					$.ajax({
						url: apiL+'/api/wx/address/delete',
						type: 'post',
						timeout : 10000,
						dataType: 'json',
						data: {type:1,id:id,userId:userId(),isDefault:isDefault,requestTokenId:requestTokenId()},
						success:function(data1){
							if (data1.success) {
								$.ajax({
									url: apiL+'/api/wx/address/find',
									type: 'get',
									dataType: 'json',
									data: {userId:userId(),type:1,requestTokenId:requestTokenId()},
									success:function(data){
										if (data.success) {
											var html="";
											for (var i = 0; i < data.info.length; i++) {
												if (data.info[i].isDefault==1) {
													html='<p id="addr_consigner"> '+data.info[i].company+' <br> '+data.info[i].contact+' '+data.info[i].phone+'  <br>'+data.info[i].proName+' '+data.info[i].cityName+' '+data.info[i].areaName+' '+data.info[i].detailed+'</p>';
													$('.consigner_edit a').html(html);
													$('[name="senderAddId"]').val(data.info[i].id);
													$('[name="senderAddIsDf"]').val(data.info[i].isDefault);
													$('[name="senderName"]').val(data.info[i].company);
													$('[name="senderLinkman"]').val(data.info[i].contact);
													$('[name="senderMobile"]').val(data.info[i].phone);
													$('[name="senderProvinceName"]').val(data.info[i].proName);
													$('[name="senderCityName"]').val(data.info[i].cityName);
													$('[name="senderAreaName"]').val(data.info[i].areaName);
													$('[name="senderProvinceId"]').val(data.info[i].proNumber);
													$('[name="senderCityId"]').val(data.info[i].cityNumber);
													$('[name="senderAreaId"]').val(data.info[i].areaNumber);
													$('[name="senderAddress"]').val(data.info[i].detailed);
													/*默认网点*/
													var receiverAreaId=$('[name="receiverAreaId"]').val();
													if (receiverAreaId) {
														bannce(data.info[i].cityNumber,data.info[i].areaNumber,receiverAreaId)
													};
												};
											};
											if (data.info.length==0) {
												$('[name="senderAddId"]').val('');
												$('[name="senderAddIsDf"]').val('');
											};
											if (data.info.length) {
												selfshipAddr(data);
											}else{
												noshipsearch();
											}
										}else{
											alert(data.message)
										};
									}
								});

							}else{
								alert(data1.message);
							};
						},
						complete : function(XMLHttpRequest,status){
							loadingRemove();
							if(status=='error'){
								fubottom('删除失败，请重试');
							}else if(status=='timeout'){
								fubottom('删除失败，请重试');
							}
				        }
					});
				}else{
					alert(data.message);
				};
			},
			complete : function(XMLHttpRequest,status){
				loadingRemove();
				if(status=='error'){
					fubottom('删除失败，请重试');
				}else if(status=='timeout'){
					fubottom('删除失败，请重试');
				}
	        }
		});
    },function(){
        return false;
    })
};
/*收地址簿删除*/
function del_rec(e,id){
	$.MsgBox.ConfirmL("确定要删除吗？",'取消','确定',function(){
		loading('删除中...');
		$.ajax({
			url: apiL+'/api/wx/address/delete',
			type: 'post',
			timeout : 10000,
			dataType: 'json',
			data: {type:2,id:id,userId:userId(),isDefault:0,requestTokenId:requestTokenId()},
			success:function(data){
				loadingRemove();
				if (data.success) {
					e.parents('.record_li').remove();
				}else{
					alert(data.message);
				};
			},
			complete : function(XMLHttpRequest,status){
				loadingRemove();
				if(status=='error'){
					fubottom('删除失败，请重试');
				}else if(status=='timeout'){
					fubottom('删除失败，请重试');
				}
	        }
		});
	},function(){
        return false;
    })
};
/*编辑发货列表地址获取*/
function selfConsignerEdit(id){
	/*$('.self_fa_book').remove();*/
	var html=template('self_fa_edit');
	$('body').append(html);
	$('.self_help_w').animate({right:0}, 300);
	$('.selfShipSubmit').attr('onclick', 'selfShipEditSubmit('+id+')');
	$('.tacitly_approve').html('<label><input type="checkbox" name="default"><span class="checkbox"></span><b id="">设为默认发货方</b></label>');
	loading('获取中...');
	$.ajax({
		url: apiL+'/api/wx/address/findedit',
		type: 'get',
		timeout : 10000,
		dataType: 'json',
		data: {type:1,id:id,requestTokenId:requestTokenId()},
		success:function(data){
			if (data.success) {
				var info=data.info;
				$('.consigner_t [name="client"]').val(info.company);
				$('.consigner_t [name="name"]').val(info.contact);
				$('.consigner_t [name="tel"]').val(info.phone);
				$('.consigner_t #addr_aera').html(info.proName+' '+info.cityName+' '+info.areaName).removeClass('c999');
				$('.consigner_t [name="aeraNum"]').val(info.proNumber+','+info.cityNumber+','+info.areaNumber);
				$('.consigner_t [name="detail"]').val(info.detailed);
				addr_aera2(info.proNumber,info.cityNumber,info.areaNumber);
				if (info.isDefault) {
					$('[name="default"]').attr('checked', 'checked');
				};
			}else{
				alert(data.message);
			};
		},
        complete : function(XMLHttpRequest,status){
            loadingRemove();
    　　　　if(status=='error'){
    			$.MsgBox.Alert("获取信息失败，请点击关闭重试",'好的');
    　　　　}else if(status=='timeout'){
    			$.MsgBox.Alert("获取信息失败，请点击关闭重试",'好的');
            }
    　　}
	});
}
/*编辑发货列表地址提交*/
function selfShipEditSubmit(id){
	if (!noNullfa($('[name="client"]'),'单位名称')) {
		noNullfa($('[name="client"]'),'单位名称');
		return false;
	}else if(!nameLen($('[name="name"]').val())){
		nameLen($('[name="name"]').val());
		return false;
	}else if(!telNo($('[name="tel"]'))){
		telNo($('[name="tel"]'))
		return false;
	}else if(!noNull($('[name="aeraNum"]'),'所在省、市、区')){
		noNull($('[name="aeraNum"]'),'所在省、市、区');
		return false;
	}else if(!noNullfa($('[name="detail"]'),'详细地址')){
		noNullfa($('[name="detail"]'),'详细地址');
		return false;
	}else{
		loading('获取中...');
		var company=trim($('[name="client"]').val());
		var contact=trim($('[name="name"]').val());
		var phone=trim($('[name="tel"]').val());
		var aera=$('#addr_aera').html();
		var aeraNum=$('[name="aeraNum"]').val();
		var detailed=trim($('[name="detail"]').val());
		var aeraArr=aera.split(' ');
		var aeraNumArr=aeraNum.split(',');
		var isDefault="";
		if ($('[name="default"]:checked').length>0) {
			isDefault=1;
		}else{
			isDefault=0;
		};
		AMap.service('AMap.Geocoder',function(){
		    var geocoder = new AMap.Geocoder({});
		    geocoder.getLocation(aeraArr[0]+""+aeraArr[1]+""+aeraArr[2]+""+detailed, function(status, result) {
		    	loadingRemove();
			    if (status === 'complete' && result.info === 'OK') {
			    	loading('获取中...');
			        var data={
						userId:userId(),
						type:1,
						id:id,
						company:company,
						contact:contact,
						phone:phone,
						proName:aeraArr[0],
						proNumber:aeraNumArr[0],
						cityName:aeraArr[1],
						cityNumber:aeraNumArr[1],
						areaName:aeraArr[2],
						areaNumber:aeraNumArr[2],
						detailed:detailed,
						lat:result.geocodes[0].location.lat,
						lng:result.geocodes[0].location.lng,
						isDefault:isDefault,
						requestTokenId:requestTokenId()
					}
					$.ajax({
						url: apiL+'/api/wx/address/edit',
						type: 'get',
						timeout : 10000,
						dataType: 'json',
						data: data,
						success:function(data){
							loadingRemove();
							if (data.success) {
								if ($('[name="senderAddId"]').val()==id) {
									if(Recdistinctive()){
										$.ajax({
											url: apiL+'/api/wx/address/findedit',
											type: 'get',
											timeout : 10000,
											dataType: 'json',
											data: {type:1,id:id,requestTokenId:requestTokenId()},
											success:function(data){
												if (data.success) {
													var info=data.info;
													$('[name="senderAddIsDf"]').val(info.isDefault);
													$('[name="senderName"]').val(info.company);
													$('[name="senderLinkman"]').val(info.contact);
													$('[name="senderMobile"]').val(info.phone);
													$('[name="senderProvinceName"]').val(info.proName);
													$('[name="senderCityName"]').val(info.cityName);
													$('[name="senderAreaName"]').val(info.areaName);
													$('[name="senderProvinceId"]').val(info.proNumber);
													$('[name="senderCityId"]').val(info.cityNumber);
													$('[name="senderAreaId"]').val(info.areaNumber);
													$('[name="senderAddress"]').val(info.detailed);
													var contact="";
													info.contact?contact=info.contact:contact='';
													var html='<p id="addr_consigner"> '+info.company+' <br> '+contact+' '+info.phone+'  <br>'+info.proName+' '+info.cityName+' '+info.areaName+' '+info.detailed+'</p>';
													$('.consigner_edit a').html(html);
													var receiverAreaId=$('[name="receiverAreaId"]').val();
													if (receiverAreaId) {
														if (bannce(info.cityNumber,info.areaNumber,receiverAreaId)) {
															setTimeout(function(){
																self_btn_show();
															}, 100);
														};
													};
													$('.self_fa_edit').remove();
												}else{
													alert(data.message);
												};
											},
									        complete : function(XMLHttpRequest,status){
									            loadingRemove();
									    　　　　if(status=='error'){
									     　　　　　 fubottom('保存失败，请重试');
									    　　　　}else if(status=='timeout'){
									                fubottom('保存失败，请重试');
									            }
									            return false;
									    　　}
										});
										$.ajax({
											url: apiL+'/api/wx/address/find',
											type: 'get',
											timeout : 10000,
											dataType: 'json',
											data: {userId:userId(),type:1,requestTokenId:requestTokenId()},
											success:function(data){
												if (data.success) {
													if (data.info.length) {
														selfshipAddr(data);
													}else{
														noshipsearch();
													};
												}else{
													alert(data.message)
												};
											},
									        complete : function(XMLHttpRequest,status){
									            loadingRemove();
									    　　　　if(status=='error'){
									    			noResultErr($('.record_list'),400,'获取列表失败，请点击重新获取','selfConsignerBookA()');
									    　　　　}else if(status=='timeout'){
									    			noResultErr($('.record_list'),400,'获取列表失败，请点击重新获取','selfConsignerBookA()');
									            }
									    　　}
										});
									}
								}else{
									$('.self_fa_edit').remove();
									$.ajax({
										url: apiL+'/api/wx/address/find',
										type: 'get',
										timeout : 10000,
										dataType: 'json',
										data: {userId:userId(),type:1,requestTokenId:requestTokenId()},
										success:function(data){
											if (data.success) {
												if (data.info.length) {
													selfshipAddr(data);
												}else{
													noshipsearch();
												};
											}else{
												alert(data.message)
											};
										},
								        complete : function(XMLHttpRequest,status){
								            loadingRemove();
								    　　　　if(status=='error'){
								    			noResultErr($('.record_list'),400,'获取列表失败，请点击重新获取','selfConsignerBookA()');
								    　　　　}else if(status=='timeout'){
								    			noResultErr($('.record_list'),400,'获取列表失败，请点击重新获取','selfConsignerBookA()');
								            }
								    　　}
									});
								}
								
							}else{
								alert(data.message);
							};
						},
				        complete : function(XMLHttpRequest,status){
							loadingRemove();
							if(status=='error'){
								fubottom('保存失败，请重试');
							}else if(status=='timeout'){
								fubottom('保存失败，请重试');
				            }
						}
					});
			    }else{
			        AMap.service('AMap.Geocoder',function(){//回调函数
					    //实例化Geocoder
					    var geocoder = new AMap.Geocoder({
					        // city: "010"//城市，默认：“全国”
					    });
					    geocoder.getLocation(aeraArr[0]+""+aeraArr[1]+""+aeraArr[2], function(status, result) {
					    	loadingRemove();
						    if (status === 'complete' && result.info === 'OK') {
						        loading('获取中...');
						        var data={
									userId:userId(),
									type:1,
									id:id,
									company:company,
									contact:contact,
									phone:phone,
									proName:aeraArr[0],
									proNumber:aeraNumArr[0],
									cityName:aeraArr[1],
									cityNumber:aeraNumArr[1],
									areaName:aeraArr[2],
									areaNumber:aeraNumArr[2],
									detailed:detailed,
									lat:result.geocodes[0].location.lat,
									lng:result.geocodes[0].location.lng,
									isDefault:isDefault,
									requestTokenId:requestTokenId()
								}
								$.ajax({
									url: apiL+'/api/wx/address/edit',
									type: 'get',
									timeout : 10000,
									dataType: 'json',
									data: data,
									success:function(data){
										loadingRemove();
										if (data.success) {
											if ($('[name="senderAddId"]').val()==id) {
												if(Recdistinctive()){
													$.ajax({
														url: apiL+'/api/wx/address/findedit',
														type: 'get',
														timeout : 10000,
														dataType: 'json',
														data: {type:1,id:id,requestTokenId:requestTokenId()},
														success:function(data){
															if (data.success) {
																var info=data.info;
																$('[name="senderAddIsDf"]').val(info.isDefault);
																$('[name="senderName"]').val(info.company);
																$('[name="senderLinkman"]').val(info.contact);
																$('[name="senderMobile"]').val(info.phone);
																$('[name="senderProvinceName"]').val(info.proName);
																$('[name="senderCityName"]').val(info.cityName);
																$('[name="senderAreaName"]').val(info.areaName);
																$('[name="senderProvinceId"]').val(info.proNumber);
																$('[name="senderCityId"]').val(info.cityNumber);
																$('[name="senderAreaId"]').val(info.areaNumber);
																$('[name="senderAddress"]').val(info.detailed);
																var contact="";
																info.contact?contact=info.contact:contact='';
																var html='<p id="addr_consigner"> '+info.company+' <br> '+contact+' '+info.phone+'  <br>'+info.proName+' '+info.cityName+' '+info.areaName+' '+info.detailed+'</p>';
																$('.consigner_edit a').html(html);
																var receiverAreaId=$('[name="receiverAreaId"]').val();
																if (receiverAreaId) {
																	if (bannce(info.cityNumber,info.areaNumber,receiverAreaId)) {
																		setTimeout(function(){
																			self_btn_show();
																		}, 100);
																	};
																};
																$('.self_fa_edit').remove();
															}else{
																alert(data.message);
															};
														},
												        complete : function(XMLHttpRequest,status){
												            loadingRemove();
												    　　　　if(status=='error'){
												     　　　　　 fubottom('保存失败，请重试');
												    　　　　}else if(status=='timeout'){
												                fubottom('保存失败，请重试');
												            }
												            return false;
												    　　}
													});
													$.ajax({
														url: apiL+'/api/wx/address/find',
														type: 'get',
														timeout : 10000,
														dataType: 'json',
														data: {userId:userId(),type:1,requestTokenId:requestTokenId()},
														success:function(data){
															if (data.success) {
																if (data.info.length) {
																	selfshipAddr(data);
																}else{
																	noshipsearch();
																};
															}else{
																alert(data.message)
															};
														},
												        complete : function(XMLHttpRequest,status){
												            loadingRemove();
												    　　　　if(status=='error'){
												    			noResultErr($('.record_list'),400,'获取列表失败，请点击重新获取','selfConsignerBookA()');
												    　　　　}else if(status=='timeout'){
												    			noResultErr($('.record_list'),400,'获取列表失败，请点击重新获取','selfConsignerBookA()');
												            }
												    　　}
													});
												}
											}else{
												$('.self_fa_edit').remove();
												$.ajax({
													url: apiL+'/api/wx/address/find',
													type: 'get',
													timeout : 10000,
													dataType: 'json',
													data: {userId:userId(),type:1,requestTokenId:requestTokenId()},
													success:function(data){
														if (data.success) {
															if (data.info.length) {
																selfshipAddr(data);
															}else{
																noshipsearch();
															};
														}else{
															alert(data.message)
														};
													},
											        complete : function(XMLHttpRequest,status){
											            loadingRemove();
											    　　　　if(status=='error'){
											    			noResultErr($('.record_list'),400,'获取列表失败，请点击重新获取','selfConsignerBookA()');
											    　　　　}else if(status=='timeout'){
											    			noResultErr($('.record_list'),400,'获取列表失败，请点击重新获取','selfConsignerBookA()');
											            }
											    　　}
												});
											}
											
										}else{
											alert(data.message);
										};
									},
							        complete : function(XMLHttpRequest,status){
										loadingRemove();
										if(status=='error'){
											fubottom('保存失败，请重试');
										}else if(status=='timeout'){
											fubottom('保存失败，请重试');
							            }
									}
								});
						    }else{
						        $.MsgBox.Alert("地址获取失败，请重试或修改地址后再试",'确定');
						    }
						});
					})
			    }
			});
		})
	}
}	
/*添加发货地址*/
function addFaEdit(){
	var html=template('self_fa_edit');
	$('body').append(html);
	$('.self_help_w').animate({right:0}, 300);
	/*$('.tacitly_approve').html('<label><input type="checkbox" name="default"><span class="checkbox"></span><b id="">设为默认收货方</b></label>')*/
	$('.selfShipSubmit').attr('onclick', 'selfAddShipSubmit()');
	addr_aera2();
}
/*添加发货地址列表提交*/
function selfAddShipSubmit(){
	if (!noNullfa($('[name="client"]'),'单位名称')) {
		noNullfa($('[name="client"]'),'单位名称');
		return false;
	}else if(!telNo($('[name="tel"]'))){
		telNo($('[name="tel"]'))
		return false;
	}else if(!noNull($('[name="aeraNum"]'),'所在省、市、区')){
		noNull($('[name="aeraNum"]'),'所在省、市、区');
		return false;
	}else if(!noNullfa($('[name="detail"]'),'详细地址')){
		noNullfa($('[name="detail"]'),'详细地址');
		return false;
	}else{
		loading('提交中...');
		var company=trim($('[name="client"]').val());
		var contact=trim($('[name="name"]').val());
		var phone=trim($('[name="tel"]').val());
		var aera=$('#addr_aera').html();
		var aeraNum=$('[name="aeraNum"]').val();
		var detailed=trim($('[name="detail"]').val());
		var aeraArr=aera.split(' ');
		var aeraNumArr=aeraNum.split(',');
		var isDefault=0;
		if ($('[name="default"]:checked').length>0) {
			isDefault=1;
		}else{
			isDefault=0;
		};
		AMap.service('AMap.Geocoder',function(){
		    var geocoder = new AMap.Geocoder({});
		    geocoder.getLocation(aeraArr[0]+""+aeraArr[1]+""+aeraArr[2]+""+detailed, function(status, result) {
		    	loadingRemove();
			    if (status === 'complete' && result.info === 'OK') {
			        loading('提交中...');
		    		var data={
						userId:userId(),
						type:1,
						company:company,
						contact:contact,
						phone:phone,
						proName:aeraArr[0],
						proNumber:aeraNumArr[0],
						cityName:aeraArr[1],
						cityNumber:aeraNumArr[1],
						areaName:aeraArr[2],
						areaNumber:aeraNumArr[2],
						detailed:detailed,
						lat:result.geocodes[0].location.lat,
						lng:result.geocodes[0].location.lng,
						isDefault:isDefault,
						requestTokenId:requestTokenId()
					};
					$.ajax({
						url: apiL+'/api/wx/address/add',
						type: 'get',
						timeout : 10000,
						dataType: 'json',
						data: data,
						success:function(data){
							loadingRemove();
							if (data.success) {
								$('.self_fa_edit').remove();
								$.ajax({
									url: apiL+'/api/wx/address/find',
									type: 'get',
									timeout : 10000,
									dataType: 'json',
									data: {userId:userId(),type:1,requestTokenId:requestTokenId()},
									success:function(data){
										if (data.success) {
											if (data.info.length) {
												selfshipAddr(data);
											}else{
												noshipsearch();
											};
										}else{
											alert(data.message)
										};
									},
							        complete : function(XMLHttpRequest,status){
							            loadingRemove();
							    　　　　if(status=='error'){
							    			noResultErr($('.record_list'),400,'获取列表失败，请点击重新获取','selfConsignerBookA()');
							    　　　　}else if(status=='timeout'){
							    			noResultErr($('.record_list'),400,'获取列表失败，请点击重新获取','selfConsignerBookA()');
							            }
							    　　}
								});
								/*selfConsignerBook();*/
							}else{
								alert(data.message);
							};
						},
				        complete : function(XMLHttpRequest,status){
							loadingRemove();
							if(status=='error'){
								fubottom('保存失败，请5秒后重试');
							}else if(status=='timeout'){
								fubottom('保存失败，请5秒后重试');
				            }
						}
					});
			    }else{
			        AMap.service('AMap.Geocoder',function(){//回调函数
					    //实例化Geocoder
					    var geocoder = new AMap.Geocoder({
					        // city: "010"//城市，默认：“全国”
					    });
					    geocoder.getLocation(aeraArr[0]+""+aeraArr[1]+""+aeraArr[2], function(status, result) {
					    	loadingRemove();
						    if (status === 'complete' && result.info === 'OK') {
						        loading('提交中...');
					    		var data={
									userId:userId(),
									type:1,
									company:company,
									contact:contact,
									phone:phone,
									proName:aeraArr[0],
									proNumber:aeraNumArr[0],
									cityName:aeraArr[1],
									cityNumber:aeraNumArr[1],
									areaName:aeraArr[2],
									areaNumber:aeraNumArr[2],
									detailed:detailed,
									lat:result.geocodes[0].location.lat,
									lng:result.geocodes[0].location.lng,
									isDefault:isDefault,
									requestTokenId:requestTokenId()
								};
								$.ajax({
									url: apiL+'/api/wx/address/add',
									type: 'get',
									timeout : 10000,
									dataType: 'json',
									data: data,
									success:function(data){
										loadingRemove();
										if (data.success) {
											$('.self_fa_edit').remove();
											$.ajax({
												url: apiL+'/api/wx/address/find',
												type: 'get',
												timeout : 10000,
												dataType: 'json',
												data: {userId:userId(),type:1,requestTokenId:requestTokenId()},
												success:function(data){
													if (data.success) {
														if (data.info.length) {
															selfshipAddr(data);
														}else{
															noshipsearch();
														};
													}else{
														alert(data.message)
													};
												},
										        complete : function(XMLHttpRequest,status){
										            loadingRemove();
										    　　　　if(status=='error'){
										    			noResultErr($('.record_list'),400,'获取列表失败，请点击重新获取','selfConsignerBookA()');
										    　　　　}else if(status=='timeout'){
										    			noResultErr($('.record_list'),400,'获取列表失败，请点击重新获取','selfConsignerBookA()');
										            }
										    　　}
											});
											/*selfConsignerBook();*/
										}else{
											alert(data.message);
										};
									},
							        complete : function(XMLHttpRequest,status){
										loadingRemove();
										if(status=='error'){
											fubottom('保存失败，请5秒后重试');
										}else if(status=='timeout'){
											fubottom('保存失败，请5秒后重试');
							            }
									}
								});
						    }else{
						    	$.MsgBox.Alert("地址获取失败，请重试或修改地址后再试",'确定');
						    }
						});
					})
			    }
			});
		})
		
		$('.selfShipSubmit').attr('disabled', 'disabled').css('background', '#999');
		setTimeout(function(){
			$('.selfShipSubmit').removeAttr('disabled').css('background', '#52BB03');
		}, 5000);

	}
}
/*收货方地址列表*/
function selfDeliveryBook(){
	var html=template('self_shou_book');
	$('body').append(html);
	$('.self_help_w').animate({right:0}, 300);
	if (userId()) {
		selfDeliveryBookA();
	}else{
		document.write('请求失败,请返回公众号重新进入');
	};
}

function selfDeliveryBookA(){
	loading('loading...');
	$.ajax({
		url: apiL+'/api/wx/address/find',
		type: 'get',
		timeout : 10000,
		dataType: 'json',
		data: {userId:userId(),type:2,requestTokenId:requestTokenId()},
		success:function(data){
			if (data.success) {
				if (data.info.length) {
					selfReceAddr(data);
				}else{
					noshipsearch();
				};
			}else{
				alert(data.message);
			};
		},
        complete : function(XMLHttpRequest,status){
            loadingRemove();
    　　　　if(status=='error'){
     　　　　　 noResultErr($('.record_list'),400,'请求超时，请点击重新获取','selfDeliveryBookA()');
    　　　　}else if(status=='timeout'){
                noResultErr($('.record_list'),400,'请求超时，请点击重新获取','selfDeliveryBookA()');
            }
    　　}
	});
}


/*收货地址搜索（自助下单）*/
function selfAddrShouSearch(){
	var search=$('.search_input').val();
	loading('loading...');
	if (search){
		var data={
			userId:userId(),
			type:2,
			searchParam:search,
			requestTokenId:requestTokenId()
		};
		$.ajax({
			url: api+'/api/wx/address/find',
			type: 'get',
			timeout : 10000,
			dataType: 'json',
			data: data,
			success:function(data){
				loadingRemove();
				if (data.success) {
					if (data.info.length) {
						selfReceAddr(data);
					}else{
						noshipsearch(search);
					};
				}else{
					alert(data.message);
				};
			},
	        complete : function(XMLHttpRequest,status){
	            loadingRemove();
	    　　　　if(status=='error'){
	    			noResultErr($('.record_list'),400,'获取列表失败，请点击重新获取','selfAddrShouSearch()');
	    　　　　}else if(status=='timeout'){
	    			noResultErr($('.record_list'),400,'获取列表失败，请点击重新获取','selfAddrShouSearch()');
	            }
	    　　}
		});
	}else{
		$.ajax({
			url: apiL+'/api/wx/address/find',
			type: 'get',
			timeout : 10000,
			dataType: 'json',
			data: {userId:userId(),type:2,requestTokenId:requestTokenId()},
			success:function(data){
				loadingRemove();
				if (data.success) {
					if (data.info.length) {
						selfReceAddr(data);
					}else{
						noshipsearch();
					}
				}else{
					alert(data.message);
				};
			},
	        complete : function(XMLHttpRequest,status){
	            loadingRemove();
	    　　　　if(status=='error'){
	    			noResultErr($('.record_list'),400,'获取列表失败，请点击重新获取','selfAddrShouSearch()');
	    　　　　}else if(status=='timeout'){
	    			noResultErr($('.record_list'),400,'获取列表失败，请点击重新获取','selfAddrShouSearch()');
	            }
	    　　}
		});
	};
}

/*收货地址内容（自助下单）*/
function selfReceAddr(data){
	var html="";
	for (var i = 0; i < data.info.length; i++) {
		html+='<div class="record_li ship_li" data-id="'+data.info[i].id+'">'
			+'<table width="w100" onclick=recTrue("'+data.info[i].id+'")>'
				+'<tr><td>收&nbsp; 货 方：'+data.info[i].company+'</td></tr>'
				if (data.info[i].contact) {
					html+='<tr><td colspan="2">联&nbsp; 系 人：'+data.info[i].contact+'</td></tr>'
				};
				html+='<tr><td colspan="2">电&#x3000;&#x3000;话：'+data.info[i].phone+'<br></td></tr>'
				+'<tr><td colspan="2">收货地址：'+data.info[i].proName+''+data.info[i].cityName+''+data.info[i].areaName+''+data.info[i].detailed+'<br></td></tr>'
			+'</table>'
			+'<div class="show_details ov_h">'
				+'<a class="f_r f14" href="javascript:;" onclick="del_rec($(this),'+data.info[i].id+')">删除</a>'
				+'<a class="f_r f14" onclick="selfrecrivingEdit('+data.info[i].id+')" href="javascript:;">编辑</a>'
			+'</div>'
		+'</div>'
	};
	$('.record_list').html(html);
}

/*编辑收货列表地址获取*/
function selfrecrivingEdit(id){
	/*$('.self_shou_book').remove();*/
	var html=template('self_shou_edit');
	$('body').append(html);
	$('.self_help_w').animate({right:0}, 300);
	/*$('.tacitly_approve').remove();*/
	$('.selfRedSubmit').attr('onclick', 'selfRedEditSubmit('+id+')');
	$.ajax({
		url: apiL+'/api/wx/address/findedit',
		type: 'get',
		timeout : 10000,
		dataType: 'json',
		data: {type:2,id:id,requestTokenId:requestTokenId()},
		success:function(data){
			if (data.success) {
				var info=data.info;
				// console.log(info)
				$('.consigner_t [name="client"]').val(info.company);
				$('.consigner_t [name="name"]').val(info.contact);
				$('.consigner_t [name="tel"]').val(info.phone);
				$('.consigner_t #addr_aera').html(info.proName+' '+info.cityName+' '+info.areaName).removeClass('c999');
				$('.consigner_t [name="aeraNum"]').val(info.proNumber+','+info.cityNumber+','+info.areaNumber);
				$('.consigner_t [name="detail"]').val(info.detailed);
				addr_aera2(info.proNumber,info.cityNumber,info.areaNumber);
			}else{
				alert(data.message);
			};
		},
        complete : function(XMLHttpRequest,status){
            loadingRemove();
    　　　　if(status=='error'){
    			$.MsgBox.Alert("获取信息失败，请点击关闭重试",'好的');
    　　　　}else if(status=='timeout'){
    			$.MsgBox.Alert("获取信息失败，请点击关闭重试",'好的');
            }
    　　}
	});
	
}
/*编辑收货列表地址提交*/
function selfRedEditSubmit(id){
	if (!noNullfa($('[name="client"]'),'单位名称')) {
		noNullfa($('[name="client"]'),'单位名称');
		return false;
	}else if(!nameLen($('[name="name"]').val())){
		nameLen($('[name="name"]').val());
		return false;
	}else if(!telNo($('[name="tel"]'))){
		telNo($('[name="tel"]'));
		return false;
	}else if(!noNull($('[name="aeraNum"]'),'所在省、市、区')){
		noNull($('[name="aeraNum"]'),'所在省、市、区');
		return false;
	}else if(!noNullfa($('[name="detail"]'),'详细地址')){
		noNullfa($('[name="detail"]'),'详细地址');
		return false;
	}else{
		loading('提交中...');
		var company=trim($('[name="client"]').val());
		var contact=trim($('[name="name"]').val());
		var phone=trim($('[name="tel"]').val());
		var aera=$('#addr_aera').html();
		var aeraNum=$('[name="aeraNum"]').val();
		var detailed=trim($('[name="detail"]').val());
		var aeraArr=aera.split(' ');
		var aeraNumArr=aeraNum.split(',');

		AMap.service('AMap.Geocoder',function(){
		    var geocoder = new AMap.Geocoder({});
		    geocoder.getLocation(aeraArr[0]+""+aeraArr[1]+""+aeraArr[2]+""+detailed, function(status, result) {
		    	loadingRemove();
			    if (status === 'complete' && result.info === 'OK') {
			        loading('提交中...');
		    		var data={
						userId:userId(),
						type:2,
						id:id,
						company:company,
						contact:contact,
						phone:phone,
						proName:aeraArr[0],
						proNumber:aeraNumArr[0],
						cityName:aeraArr[1],
						cityNumber:aeraNumArr[1],
						areaName:aeraArr[2],
						areaNumber:aeraNumArr[2],
						detailed:detailed,
						lat:result.geocodes[0].location.lat,
						lng:result.geocodes[0].location.lng,
						isDefault:0,
						requestTokenId:requestTokenId()
					}
					$.ajax({
						url: apiL+'/api/wx/address/edit',
						type: 'get',
						timeout : 10000,
						dataType: 'json',
						data: data,
						success:function(data){
							loadingRemove();
							if (data.success) {
								$('.self_shou_edit').remove();
								/*selfDeliveryBook();*/
								$.ajax({
									url: apiL+'/api/wx/address/find',
									type: 'get',
									timeout : 10000,
									dataType: 'json',
									data: {userId:userId(),type:2,requestTokenId:requestTokenId()},
									success:function(data){
										if (data.success) {
											if (data.info.length) {
												selfReceAddr(data);
											}else{
												noshipsearch();
											};
										}else{
											alert(data.message);
										};
									},
							        complete : function(XMLHttpRequest,status){
							            loadingRemove();
							    　　　　if(status=='error'){
							     　　　　　 noResultErr($('.record_list'),400,'请求超时，请点击重新获取','selfDeliveryBookA()');
							    　　　　}else if(status=='timeout'){
							                noResultErr($('.record_list'),400,'请求超时，请点击重新获取','selfDeliveryBookA()');
							            }
							    　　}
								});
							}else{
								alert(data.message)
							};
						},
				        complete : function(XMLHttpRequest,status){
				            loadingRemove();
							if(status=='error'){
								fubottom('保存失败，请重试');
							}else if(status=='timeout'){
								fubottom('保存失败，请重试');
							}
							return false;
						}
					});
			    }else{
			        AMap.service('AMap.Geocoder',function(){//回调函数
					    //实例化Geocoder
					    var geocoder = new AMap.Geocoder({
					        // city: "010"//城市，默认：“全国”
					    });
					    geocoder.getLocation(aeraArr[0]+""+aeraArr[1]+""+aeraArr[2], function(status, result) {
					    	loadingRemove();
						    if (status === 'complete' && result.info === 'OK') {
						        loading('提交中...');
					    		var data={
									userId:userId(),
									type:2,
									id:id,
									company:company,
									contact:contact,
									phone:phone,
									proName:aeraArr[0],
									proNumber:aeraNumArr[0],
									cityName:aeraArr[1],
									cityNumber:aeraNumArr[1],
									areaName:aeraArr[2],
									areaNumber:aeraNumArr[2],
									detailed:detailed,
									lat:result.geocodes[0].location.lat,
									lng:result.geocodes[0].location.lng,
									isDefault:0,
									requestTokenId:requestTokenId()
								}
								$.ajax({
									url: apiL+'/api/wx/address/edit',
									type: 'get',
									timeout : 10000,
									dataType: 'json',
									data: data,
									success:function(data){
										loadingRemove();
										if (data.success) {
											$('.self_shou_edit').remove();
											$.ajax({
												url: apiL+'/api/wx/address/find',
												type: 'get',
												timeout : 10000,
												dataType: 'json',
												data: {userId:userId(),type:2,requestTokenId:requestTokenId()},
												success:function(data){
													if (data.success) {
														if (data.info.length) {
															selfReceAddr(data);
														}else{
															noshipsearch();
														};
													}else{
														alert(data.message);
													};
												},
										        complete : function(XMLHttpRequest,status){
										            loadingRemove();
										    　　　　if(status=='error'){
										     　　　　　 noResultErr($('.record_list'),400,'请求超时，请点击重新获取','selfDeliveryBookA()');
										    　　　　}else if(status=='timeout'){
										                noResultErr($('.record_list'),400,'请求超时，请点击重新获取','selfDeliveryBookA()');
										            }
										    　　}
											});
										}else{
											alert(data.message)
										};
									},
							        complete : function(XMLHttpRequest,status){
							            loadingRemove();
										if(status=='error'){
											fubottom('保存失败，请重试');
										}else if(status=='timeout'){
											fubottom('保存失败，请重试');
										}
										return false;
									}
								});
						    }else{
						        $.MsgBox.Alert("地址获取失败，请重试或修改地址后再试",'确定');
						    }
						});
					})
			    }
			});
		})
	}
}
/*添加收货地址*/
function addshouEdit(){
	/*$('.self_shou_book').remove();*/
	var html=template('self_shou_edit');
	$('body').append(html);
	$('.self_help_w').animate({right:0}, 300);
	$('[name="addBook"]').attr('checked', 'checked');
	$('.selfRedSubmit').attr('onclick', 'selfAddRedSubmit()');
	addr_aera2();
}

/*添加收货地址列表提交*/
function selfAddRedSubmit(){
	if (!noNullfa($('[name="client"]'),'单位名称')) {
		noNullfa($('[name="client"]'),'单位名称');
		return false;
	}else if(!telNo($('[name="tel"]'))){
		telNo($('[name="tel"]'))
		return false;
	}else if(!noNull($('[name="aeraNum"]'),'所在省、市、区')){
		noNull($('[name="aeraNum"]'),'所在省、市、区');
		return false;
	}else if(!noNullfa($('[name="detail"]'),'详细地址')){
		noNullfa($('[name="detail"]'),'详细地址');
		return false;
	}else{
		loading('提交中...');
		var company=trim($('[name="client"]').val());
		var contact=trim($('[name="name"]').val());
		var phone=trim($('[name="tel"]').val());
		var aera=$('#addr_aera').html();
		var aeraNum=$('[name="aeraNum"]').val();
		var detailed=trim($('[name="detail"]').val());
		var aeraArr=aera.split(' ');
		var aeraNumArr=aeraNum.split(',');
		AMap.service('AMap.Geocoder',function(){
		    var geocoder = new AMap.Geocoder({});
		    geocoder.getLocation(aeraArr[0]+""+aeraArr[1]+""+aeraArr[2]+""+detailed, function(status, result) {
		    	loadingRemove();
			    if (status === 'complete' && result.info === 'OK') {
			    	loading('提交中...');
		    		var data={
						userId:userId(),
						type:2,
						company:company,
						contact:contact,
						phone:phone,
						proName:aeraArr[0],
						proNumber:aeraNumArr[0],
						cityName:aeraArr[1],
						cityNumber:aeraNumArr[1],
						areaName:aeraArr[2],
						areaNumber:aeraNumArr[2],
						detailed:detailed,
						lat:result.geocodes[0].location.lat,
						lng:result.geocodes[0].location.lng,
						isDefault:0,
						requestTokenId:requestTokenId()
					};
					// console.log(data)
					$.ajax({
						url: apiL+'/api/wx/address/add',
						type: 'post',
						timeout : 10000,
						dataType: 'json',
						data: data,
						success:function(data){
							loadingRemove();
							if (data.success) {
								$('.self_shou_edit').remove();
								$.ajax({
									url: apiL+'/api/wx/address/find',
									type: 'get',
									timeout : 10000,
									dataType: 'json',
									data: {userId:userId(),type:2,requestTokenId:requestTokenId()},
									success:function(data){
										if (data.success) {
											if (data.info.length) {
												selfReceAddr(data);
											}else{
												noshipsearch();
											};
										}else{
											alert(data.message);
										};
									},
							        complete : function(XMLHttpRequest,status){
										loadingRemove();
										if(status=='error'){
											noResultErr($('.record_list'),400,'请求超时，请点击重新获取','selfDeliveryBookA()');
										}else if(status=='timeout'){
											noResultErr($('.record_list'),400,'请求超时，请点击重新获取','selfDeliveryBookA()');
										}
									}
								});
							}else{
								alert(data.message);
							};
						},
				        complete : function(XMLHttpRequest,status){
							loadingRemove();
							if(status=='error'){
								fubottom('保存失败，请5秒后重试');
							}else if(status=='timeout'){
								fubottom('保存失败，请5秒后重试');
				            }
						}
					});
			    }else{
			        AMap.service('AMap.Geocoder',function(){//回调函数
					    //实例化Geocoder
					    var geocoder = new AMap.Geocoder({
					        // city: "010"//城市，默认：“全国”
					    });
					    geocoder.getLocation(aeraArr[0]+""+aeraArr[1]+""+aeraArr[2], function(status, result) {
					    	loadingRemove();
						    if (status === 'complete' && result.info === 'OK') {
						    	loading('提交中...');
					    		var data={
									userId:userId(),
									type:2,
									company:company,
									contact:contact,
									phone:phone,
									proName:aeraArr[0],
									proNumber:aeraNumArr[0],
									cityName:aeraArr[1],
									cityNumber:aeraNumArr[1],
									areaName:aeraArr[2],
									areaNumber:aeraNumArr[2],
									detailed:detailed,
									lat:result.geocodes[0].location.lat,
									lng:result.geocodes[0].location.lng,
									isDefault:0,
									requestTokenId:requestTokenId()
								};
								// console.log(data)
								$.ajax({
									url: apiL+'/api/wx/address/add',
									type: 'post',
									timeout : 10000,
									dataType: 'json',
									data: data,
									success:function(data){
										loadingRemove();
										if (data.success) {
											$('.self_shou_edit').remove();
											$.ajax({
												url: apiL+'/api/wx/address/find',
												type: 'get',
												timeout : 10000,
												dataType: 'json',
												data: {userId:userId(),type:2,requestTokenId:requestTokenId()},
												success:function(data){
													if (data.success) {
														if (data.info.length) {
															selfReceAddr(data);
														}else{
															noshipsearch();
														};
													}else{
														alert(data.message);
													};
												},
										        complete : function(XMLHttpRequest,status){
													loadingRemove();
													if(status=='error'){
														noResultErr($('.record_list'),400,'请求超时，请点击重新获取','selfDeliveryBookA()');
													}else if(status=='timeout'){
														noResultErr($('.record_list'),400,'请求超时，请点击重新获取','selfDeliveryBookA()');
													}
												}
											});
										}else{
											alert(data.message);
										};
									},
							        complete : function(XMLHttpRequest,status){
										loadingRemove();
										if(status=='error'){
											fubottom('保存失败，请5秒后重试');
										}else if(status=='timeout'){
											fubottom('保存失败，请5秒后重试');
							            }
									}
								});
						    }else{
						        $.MsgBox.Alert("地址获取失败，请重试或修改地址后再试",'确定');
						    }
						});
					})
			    }
			});
		})

		$('.selfRedSubmit').attr('disabled', 'disabled').css('background', '#999');
		setTimeout(function(){
			$('.selfRedSubmit').removeAttr('disabled').css('background', '#52BB03');
		}, 5000);

	}
}

function senddistinctive(){
	var companyName=$('[name="client"]').val();
	var phone=$('[name="tel"]').val();
	if (companyName==$('[name="senderName"]').val()) { 
		loadingRemove();
		$.MsgBox.Alert("收货方与发货方单位名称不能相同",'确定');
		return false;
	};
	/*if (phone==$('[name="senderMobile"]').val()) {
		loadingRemove();
		$.MsgBox.Alert("收货方电话不能与发货方电话相同",'确定');
		return false;
	};*/
	return true;
}

function Recdistinctive(){
	var companyName=$('[name="client"]').val();
	var phone=$('[name="tel"]').val();
	if (companyName==$('[name="receiverName"]').val()) {
		loadingRemove();
		$.MsgBox.Alert("发货方与收货方单位名称不能相同",'确定');
		return false;
	};
	/*if (phone==$('[name="receiverMobile"]').val()) {
		loadingRemove();
		$.MsgBox.Alert("发货方电话不能与收货方电话相同",'确定');
		return false;
	};*/
	return true;
}

function sendKeysEnt(){
	if (event.keyCode==13){
		$('.search_input').blur();
		selfAddrsearch()
	}
}
function recKeysEnt(){
	if (event.keyCode==13){
		$('.search_input').blur();
		selfAddrShouSearch();
	}
}

function popping(value){
	if (value.length==0) {
		$('.shouTelSearchBg,.shouTelSearch').css('display', 'block');
		$('.searchTel').focus();
	};
}
function shouTelClose(){
	$('.searchTel').val('');
	$('.shouTelSearchBg,.shouTelSearch').css('display', 'none');
}
// 收货筛选
function shouTelSearch(){
	if (telNo($('[name="tel"]'))) {
		loading('搜索中...');
		var tel=$('[name="tel"]').val();
		var base = new Base64();
		var result = base.decode(sess.info);
		var json=JSON.parse(result);
		/*var cityId=json.cityNumber;
		var areaId=json.areaNumber;*/
		var cityId=$('[name="senderCityId"]').val();
		var areaId=$('[name="senderAreaId"]').val();
		if (cityId) {
			$.ajax({
				url: apiAnY+'/api/wx/guest/list/search',
				type: 'get',
				timeout : 10000,
				dataType: 'json',
				data: {tel:tel,areaId:areaId,cityId:cityId,requestTokenId:requestTokenId()},
				success:function(data){
					loadingRemove();
					if (data.success) {
						var info=data.info;
						// console.log(data);
						if (info instanceof Array) {
							if (info.length==0) {
								$.MsgBox.Alert("未检索到收货方信息<br/>您可修改电话重新搜索，或者直接填写收货方信息",'我知道了');
							}else{
								var html=template('self_shou_list',data);
								$('body').append(html);
							$('.self_help_w').animate({right:0}, 300);
								$('.findNum span').html(info.length);
							};
						}else{
							$.MsgBox.Alert("未检索到收货方信息<br/>您可修改电话重新搜索，或者直接填写收货方信息",'我知道了');
						};
					}else{
						alert(data.message)
					};
				},
		        complete : function(XMLHttpRequest,status){
					loadingRemove();
					if(status=='error'){
						fubottom('请求超时，请重试');
		    　　　　}else if(status=='timeout'){
						fubottom('请求超时，请重试');
					}
				}
			});
		}else{
			loadingRemove();
			$.MsgBox.Alert("请先填写发货方信息！",'我知道了');
		};
		
	};
}
function clientele(data){
	$('.self_shou_add').remove();
	var html=template('self_shou_add');
	$('body').append(html);
	$('.self_help_w').css('right', '0');
	$('.consigner_t [name="client"]').val(data.guestName);
	$('.consigner_t [name="name"]').val(data.linkman);
	$('.consigner_t [name="tel"]').val(data.tel);
	$('.consigner_t #addr_aera').html(data.provinceName+' '+data.cityName+' '+data.areaName).removeClass('c999');
	$('.consigner_t [name="aeraNum"]').val(data.provinceId+','+data.cityId+','+data.areaId);
	$('.consigner_t [name="detail"]').val(data.address);
	$('.consigner_t [name="registerTelLin"]').val(data.registerMobile);
	$('.consigner_t [name="registerConLin"]').val(data.guestName);
	$('.consigner_t [name="receiverIdLin"]').val(data.receiverId);
	$('.self_shou_list').remove();
	addr_aera2(data.provinceId,data.cityId,data.areaId);
}
<file_sep>/src/js/ucenter.js
'use strict';
/*信息修改提交验证*/
function editInfoSubmit(){
	if (!noNullfa($('[name="company"]'),'单位名称')) {
		noNullfa($('[name="company"]'),'单位名称');
		return false;
	}else if(!noNull($('[name="addrAera"]'),'所在省、市、区')){
		noNull($('[name="addrAera"]'),'所在省、市、区');
		return false;
	}else if(!noNullfa($('[name="detail"]'),'详细地址')){
		noNullfa($('[name="detail"]'),'详细地址');
		return false;
	}else{
		var company=trim($('[name="company"]').val());
		var name=trim($('[name="name"]').val());
		var addrAera=$('[name="addrAera"]').val();
		var addrAeraNum=$('[name="addrAeraNum"]').val();
		var addrDetail=trim($('[name="detail"]').val());
		addrAera=addrAera.split(' ');
		addrAeraNum=addrAeraNum.split(',');
		var data={
			userId:userId(),
			company:company,
			proName: addrAera[0],
			proNumber: addrAeraNum[0],
			cityName: addrAera[1],
			cityNumber: addrAeraNum[1],
			areaName: addrAera[2],
			areaNumber: addrAeraNum[2],
			detailed: addrDetail,
			contact: name,
			userName: name,
			account:account(),
			type:type(),
			requestTokenId:requestTokenId()
		};
		$.ajax({
			url: apiL+'/api/wx/login/edituser',
			type: 'POST',
			dataType: 'json',
			data: data,
			success:function(data){
				if (data.success) {
					window.location.href="../ucenter/ucenter.html";
				}else{
					alert(data.message)
				};
			}
		});
	}
}
/*保存常用联系人*/
function comTelSubmit(){
	if (!GetQueryString('id')) {
		var inp=$('[name="tel"]');
		var codeDom=$('[name="code"]');
		if (!PhoneNo(inp)) {
			PhoneNo(inp)
		}else if(!verify(codeDom)){
			verify(codeDom)
		}else{
			loading('保存中...');
			var phone=inp.val();
			var code=codeDom.val();
			$.ajax({
				url: apiL+'/api/wx/contacts/add_v1',
				type: 'POST',
				dataType: 'json',
				data: {userId:userId,phone:phone,code:code,number:number(),requestTokenId:requestTokenId()},
				success:function(data){
					loadingRemove();
					if (data.success) {
						$.MsgBox.AlertL("添加成功",'确定',function(){
					       window.location.href="../ucenter/common_use_tel.html"
					    });
					}else{
						alert(data.message);
					};
				},
		        complete : function(XMLHttpRequest,status){
		            loadingRemove();
					if(status=='error'){
		     　　　　　 fubottom('保存失败，请重试');
					}else if(status=='timeout'){
		                fubottom('保存失败，请重试');
					}
		    　　}
			});
		};
	}else{
		var id=GetQueryString('id');
		var inp=$('[name="tel"]');
		var codeDom=$('[name="code"]');
		if (!PhoneNo(inp)) {
			PhoneNo(inp)
		}else if(!verify(codeDom)){
			verify(codeDom)
		}else{
			loading('保存中...');
			var phone=inp.val();
			var code=codeDom.val();
			$.ajax({
				url: apiL+'/api/wx/contacts/edit_v1',
				type: 'POST',
				dataType: 'json',
				data: {userId:userId,phone:phone,code:code,id:id,number:number(),requestTokenId:requestTokenId()},
				success:function(data){
					loadingRemove();
					if (data.success) {
						$.MsgBox.AlertL("修改成功",'确定',function(){
					       window.location.href="../ucenter/common_use_tel.html"
					    });
					}else{
						alert(data.message)
					};
				},
		        complete : function(XMLHttpRequest,status){
		            loadingRemove();
		    　　　　if(status=='error'){
		     　　　　　 fubottom('保存失败，请重试');
		    　　　　}else if(status=='timeout'){
		                fubottom('保存失败，请重试');
		            }
		    　　}
			});
		}
	};
}
function delPhone(e,id){
	console.log('x')
	$.MsgBox.ConfirmL("确定要删除吗？",'取消','确定',function(){
		loading('删除中...');
		$.ajax({
			url: apiL+'/api/wx/contacts/delete',
			type: 'POST',
			dataType: 'json',
			data: {id:id,number:number(),requestTokenId:requestTokenId()},
			success:function(data){
				loadingRemove();
				if(data.success) {
					e.parents('li').remove();
					var liLen=$('#telList').children('li').length;
					if(liLen<10 && $('footer').length==0) {
						$('body').append('<footer><a class="footer_btn" href="../ucenter/common_tel_edit.html">添加</a></footer>');
					};
					if(liLen==0) {
						noResult($('.telListBox'),400,'您还没有添加常用联系电话');
					};
				}else{
					alert(data.message)
				};
			},
	        complete : function(XMLHttpRequest,status){
	            loadingRemove();
	    　　　　if(status=='error'){
	     　　　　　 fubottom('删除失败，请重试');
	    　　　　}else if(status=='timeout'){
	                fubottom('删除失败，请重试');
	            }
	    　　}
		});
	},function(){
		return false;
	})
}
/*选择上传图片预览*/
function previewImage(file,imgNum){
	
	var div = document.getElementById('preview'+imgNum);
	if (file.files && file.files[0]){
		complainAdd();

		div.innerHTML ='<img id=imghead'+imgNum+'>';
		var img = document.getElementById('imghead'+imgNum+'');
		var reader = new FileReader();
		reader.onload = function(evt){img.src = evt.target.result;}
		reader.readAsDataURL(file.files[0]);
		var preview=$('#preview'+imgNum);
		var img_close_w=preview.parents('.yanzRight').children('.img_close_w');

		if (!img_close_w.html()) {
			var close='<span class="img_close" onclick="complainDelDmg($(this))"></span>';
			img_close_w.html(close);
		}
  	}else{
	    var sFilter='filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="';
	    file.select();
	    var src = document.selection.createRange().text;
	    div.innerHTML = '<img id=imghead'+imgNum+'>';
	    var img = document.getElementById('imghead'+imgNum);
	    img.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = src;
	    div.innerHTML = "<div id=divhead"+imgNum+sFilter+src+"\"'></div>";
  	}
}

/*添加图片站位*/
function complainAdd(){
	var len=$('.yanzRight').length;
	var yanzNum=$('.yanzRight').eq(len-1).attr('data-num');
	var flag=1;
	for (var i = 0; i < len; i++) {
		var img_src=$('.yanzRight').eq(i).find('img').attr('src');
		if (img_src) {
			flag++;
		};
	};
	if (len<3&&flag==len) {
		var k=parseInt(yanzNum)+1;
		var html='<div class="yanzRight" data-num="'+k+'"><form class="formUp"><label>'
                    +'<input class="images" name="file" onchange="previewImage(this,'+(k)+')" type="file"/><input type="hidden" class="imgsrc">'
                    +'<div class="img_show" id="preview'+k+'">'
                    	 +'<img id="imghead'+k+'" style="display:none;"/>'
                    	 +'</div></label></form><div class="img_close_w"></div></div>';

        $('.complain_img').append(html)
	};
}

/*删除图片*/
function complainDelDmg(e){
	e.parents('.yanzRight').remove();
	var len=$('.yanzRight').length;
	var yanzNum=$('.yanzRight').eq(len-1).attr('data-num');
	var flag=1;
	for (var i = 0; i < len; i++) {
		var img_src=$('.yanzRight').eq(i).find('img').attr('src');
		if (img_src) {
			flag++;
		};
	};
	if (len==2&&flag==3) {
		var k=parseInt(yanzNum)+1;
		var html='<div class="yanzRight" data-num="'+k+'"><form class="formUp"><label>'
                    +'<input class="images" name="file" onchange="previewImage(this,'+(k)+')" type="file"/><input type="hidden" class="imgsrc">'
                    +'<div class="img_show" id="preview'+k+'">'
                    	 +'<img id="imghead'+k+'" style="display:none;"/>'
                    	 +'</div></label></form><div class="img_close_w"></div></div>';
        $('.complain_img').append(html)
	};
	
}

/*反馈信息不能为空*/
function conNoNull(e,msg){
	var val=e.val();
	if (val.length==0) {
		e.parents('.comment_input').next('.msg').html('<span class="red">'+msg+'不能为空</span>');
		e.focus();
		return false;
	}else{
		e.parents('.comment_input').next('.msg').html('');
		return true;
	}
}

/*反馈提交*/
function complainSubmit(){
	if (!conNoNull($('[name="type"]'),'问题类型')) {
		conNoNull($('[name="type"]'),'问题类型');
		return false;
	}else if(!conNoNull($('[name="content"]'),'投诉内容')){
		conNoNull($('[name="content"]'),'投诉内容');
		return false;
	}else if(!comPhoneNo($('[name="phone"]'))){
		comPhoneNo($('[name="phone"]'));
		return false;
	}else{
		var type=$('[name="type"]').val();
		var content=$('[name="content"]').val();
		var phone=$('[name="phone"]').val();
		var imgArr=[];
		for (var i = 0; i < $('.imgsrc').length; i++) {
			var img=$('.imgsrc').eq(i).val();
			if (img) {
				imgArr.push(img);
			};
		};
		var imgsUrl=imgArr.toString()
		var data={
			userId:userId,
			type:type,
			content:content,
			phone:phone,
			image:imgsUrl,
			requestTokenId:requestTokenId()
		}
		$.ajax({
			url: apiL+'/api/wx/feedback/add',
			type: 'POST',
			dataType: 'json',
			data: data,
			success:function(data){
				if (data.success) {
					window.location.href="../ucenter/ucenter.html";
				}else{
					alert(data.message)
				};
			}
		});
	}
}

/*运费券弹框弹出*/
function tickedQrOpen(num,amount){
	loading('加载中...');
	$.ajax({
		url: apiZhao+'/api/platform/coupon/getno',
		type: 'POST',
		dataType: 'json',
		data: {userId:userId(),id:num,requestTokenId:requestTokenId()},
		success:function(data){
			loadingRemove();
			if (data.success) {
				// console.log(data);
				var html='<div class="ticked_wrap">'
				+'<div class="ticked">'
				+'<div class="ticked_pop_c"><span id="tickedQrClose"></span>'
				+'<div class="share_details"><p>运费抵扣券金额：<b class="red">'+amount+'</b>元</p>'
				+'<div><div id="qrcode"></div></div><p class="c999">此二维码有效期为20秒，<b class="blue" id="daoTime">20</b>秒后会对此券号重新生成二维码</p>'
						+'</div></div></div></div>';
				$('body').append(html);
				jQuery('#qrcode').qrcode({text:data.info});
				daoTime(num);
			}else{
				alert(data.message);
				$('.ticked_wrap').remove();
				tickedList();
			};
		}
	});
}
function daoTime(num){
	var motime=20;
	var timer=setInterval(function(){
		motime--;
		if (motime<=0) {
			$.ajax({
				url: apiZhao+'/api/platform/coupon/getno',
				type: 'POST',
				dataType: 'json',
				data: {userId:userId(),id:num,requestTokenId:requestTokenId()},
				success:function(data){
					if (data.success) {
						// console.log(data.info);
						$('#qrcode').html('');
						jQuery('#qrcode').qrcode({text:data.info});
					}else{
						alert(data.message);
						$('.ticked_wrap').remove();
						tickedList();
						clearInterval(timer);
					};
				}
			});
			motime=20
		}
		$('#daoTime').html(motime);
	}, 1000);
	$('#tickedQrClose').click(function(event) {
		$('.ticked_wrap').remove();
		tickedList();
		clearInterval(timer);
	});
}

function exitUser(){
	if (sess.info) {
		var base = new Base64();
		var result = base.decode(sess.info);
		var json=JSON.parse(result);
		var unionid=json.unionid;
		$.MsgBox.Confirmt("<h3 style='margin-bottom:0.05rem'>解除绑定</h3>您确定要解除与该微信的绑定吗？",'确定','取消',function(){
			return true;
	    },function(){
			loading('解除绑定中...');
	        $.ajax({
				url: apiL+'/api/wx/login/unboundwechat',
				type: 'POST',
				dataType: 'json',
				data: {unionid:unionid,requestTokenId:requestTokenId()},
				success:function(data){
					if (data.success) {
						console.log(data);
						sessionStorage.removeItem("info");
						sessionStorage.removeItem("code");
						$.MsgBox.AlertL("解绑成功",'好的',function(){
					        window.location.href='https://open.weixin.qq.com/connect/oauth2/authorize?appid='+appid+'&redirect_uri='+redirect_uri+'/ucenter/ucenter.html&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect'
					    });
					}else{
						alert(data.message);
					};
				},
		        complete : function(XMLHttpRequest,status){
		            loadingRemove();
		    　　　　if(status=='error'){
		    			$.MsgBox.Alert("<h3>解除失败</h3><br /><p style='text-align: left;'>原因：可能是请求服务器失败或者网络出了小差错<br/>1、您可以再次解绑试一试<br />2、退出公众号重新再进入试一试<br />如仍未解决，；联系客服：4001821200</p>",'我知道了');
		    　　　　}else if(status=='timeout'){
		                $.MsgBox.Alert("<h3>解除失败</h3><br /><p style='text-align: left;'>原因：可能是请求服务器失败或者网络出了小差错<br/>1、您可以再次解绑试一试<br />2、退出公众号重新再进入试一试<br />如仍未解决，联系客服：4001821200</p>",'我知道了');
		            }
		    　　}
			});
	    });
		
	};
}

function headImgUpdate(){
	var headUrl=$('[name="headImgShow"]').val();
	if (headUrl) {
		$.ajax({
			url: apiL+'/api/wx/hand/add',
			type: 'POST',
			dataType: 'json',
			data: {userId:userId(),headUrl:headUrl,requestTokenId:requestTokenId()},
			success:function(data){
				if (data.success) {
					alert('上传成功');
					window.location.href='../../ucenter/ucenter.html';
				}else{
					alert(data.message);
				};
			}
		});
	}else{
		window.location.href='../../ucenter/ucenter.html';
	};
	
}<file_sep>/src/js/main.js
/* 
* @Author: 三点十多分
* @Date:   2017-07-12 15:11:55
* @Last Modified by:   szyg
* @Last Modified time: 2018-06-04 14:11:27
*/

var api=apiL=wxApi(),apiAn=wxApiAn(),apiAnY=wxApiAnY(),wxApiHai=wxApiHai(),apiZhao=wxApiZhao(),apiHaiL=apiHaiL(),sess=sessionStorage,appid=appid(),redirect_uri=redirectUri();
$(function() {
	wecatLoading();

	/*用微信打开*/
	var shou=window.location.pathname;
	if(!isWeiXin()&&shou!='/order/share.html'){
		window.location.href='../login/not_login.html';
	}else if(!isWeiXin()&&shou=='/order/share.html'){ 
		$('.header_box').remove();
	}

	/*除了分享页面，去掉网页右上角菜单*/
	if (shou!='/order/share.html'&&shou!='/shop/share.html') {
		document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
		    // 通过下面这个API隐藏右上角按钮
		    WeixinJSBridge.call('hideOptionMenu');
		});
	};
	/*定义ios手机没有返回按钮*/
	var u = navigator.userAgent, app = navigator.appVersion; 
    var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1;
    var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
    if (isIOS) {
        $('.header_box').remove();
    }

	$('input[readonly]').on('focus', function() {
	    $(this).trigger('blur');
	});
});
function wecatLoading(){
	var code=GetQueryString('code');
	if (code) {
		if (!sess.code) {
			var callbackUrl=window.location.pathname;
			sess.loginUrl=callbackUrl;
			loading('加载中...'); 
			$.ajax({
				url: api+'/api/wx/login/applogin',
				type: 'POST',
				dataType: 'json',
				timeout : 10000,
				data: {code:code,requestTokenId:requestTokenId()},
				success:function(data){
					if (data.success) {
						sess.code=code;
						var info=data.info;
						if (data.info!=null) {
							if (info.user=='null') {
								var base = new Base64();
								var Nickname = base.encode(info.Nickname);
								window.location.href="../../login/login_select.html?Headimgurl="+info.Headimgurl+"&Nickname="+Nickname+"&unionid="+info.unionid;
							}else{
								if (info.user) {
									var user=JSON.parse(info.user);
									// console.log(user);
									if (user.userState==1&&user.accountState==1) {
										$.MsgBox.Confirmt("对不起，您的账号异常，暂不能登录，请联系客服：4001-821200",'拨打电话','关闭',function(){
											WeixinJSBridge.call('closeWindow');
									    },function(){
									        window.location.href='tel:4001821200';
											WeixinJSBridge.call('closeWindow');
									    });
										return false;
									}else{
										if (user.userState==1&&callbackUrl!='/ucenter/ucenter.html') {
											$.MsgBox.Confirmt("对不起，您的账号已被封停，封停原因："+user.userFreezeReason+"，如有疑问，请联系客服：4001-821200",'拨打电话','关闭',function(){
												WeixinJSBridge.call('closeWindow');
										    },function(){
										        window.location.href='tel:4001821200';
												WeixinJSBridge.call('closeWindow');
										    });
											return false;
										}else{
											var base = new Base64();
											var result = base.encode(info.user);
											sess.info=result;
											// return false;
											if (window.location.pathname=='/ucenter/ucenter.html') {
												loading('loading...');
												finduser();
											}else if(window.location.pathname=='/order/send_out.html'){
												sendLoginAddr();
											}else if(window.location.pathname=='/order/self_help_order.html'){
												self_load();
											}else{
												window.location.href=sess.loginUrl;
											};
										};
									};
									
								}else{
									$('.previewimg').remove();
									document.write('登录失败，请关闭重新登录');
								};
							};
						}else{
		        			window.location.href='../login/not_login.html'
						}
					}else{
						alert(data.message);
					};
				},
		        complete : function(XMLHttpRequest,status){
		            loadingRemove();
		    　　　　if(status=='error'){
		    			noResultErr($('body'),400,'请求超时，请返回重新再试','wecatLoading()');
		    　　　　}else if(status=='timeout'){
		    			noResultErr($('body'),400,'请求超时，请返回重新再试','wecatLoading()');
		            }
		    　　}
			});
		}else{
			
		}
	}
}
 
function fengting(){
	var userFreezeReason=$('[name="userFreezeReason"]').val();
	$.MsgBox.Confirmt("对不起，您的账号已被封停，封停原因："+userFreezeReason+"，如有疑问，请联系客服：4001-821200",'拨打电话','关闭',function(){
		return false;
    },function(){
        window.location.href='tel:4001821200';
    });
}
/*返回退出微信页面开始*/
function pushHistory(){
    var state = {
        title: "title",  
        url: "#"  
    };  
    window.history.pushState(state, "title", "");
};
function popstate(){
	pushHistory();
	var bool=false;
	setTimeout(function(){
		bool=true;
    },1000);
    window.addEventListener("popstate", function(e) {  
		if(bool)
		{
			WeixinJSBridge.call('closeWindow');
		}
		pushHistory();
	}, false);
}
function popstateUc(){
	pushHistory();
	var bool=false;
	setTimeout(function(){
		bool=true;
    },1000);
    window.addEventListener("popstate", function(e) {  
		if(bool)
		{
			window.location.href='../../ucenter/account.html'
		}
		pushHistory();
	}, false);
}
function popstateUcenter(){
	pushHistory();
	var bool=false;
	setTimeout(function(){
		bool=true;
    },1000);
    window.addEventListener("popstate", function(e) {  
		if(bool)
		{
			window.location.href='../../ucenter/ucenter.html'
		}
		pushHistory();
	}, false);
}
/*返回退出微信页面结束*/

/*测试*/
/*function wxApi(){
	// 测试
	var wxApi='http://192.168.0.138:8193';
	// 刘本地 
	// var wxApi='http://192.168.0.64:8193';
	// 200 
	// var wxApi='http://192.168.0.138:18193';
	return wxApi;
}
function wxApiAn(){
	// 测试
	// var wxApiAn='http://192.168.0.241:8191';
	// var wxApiAn='http://192.168.0.206:9191';
	var wxApiAn='http://tms.3zqp.com';
	// var wxApiAn='http://192.168.0.61:8191';
	// 200
	// var wxApiAn='http://192.168.0.138:19191'; 
	return wxApiAn;
}
function wxApiAnY(){
	// 本地
	var wxApiAnY='http://tms.3zqp.com';
	// var wxApiAnY='http://192.168.0.61:8191';
	// 138
	// var wxApiAn='http://192.168.0.138:9191';
	return wxApiAnY;
}
function wxApiHai(){
	// var wxApiHai='http://192.168.0.138:9196';
	var wxApiHai='http://tmsimg.3zqp.com';
	return wxApiHai;
}
function wxApiZhao(){
	// var wxApiZhao='http://appapi.3zqp.com';
	// 138
	var wxApiZhao='http://192.168.0.138:8192';
	// 本地
	// var wxApiZhao='http://192.168.0.82:8192';
	return wxApiZhao;
}
function apiHaiL(){
	var apiHaiL='http://acc.3zqp.com';
	// 138
	// var apiHaiL='http://192.168.0.138:9199';
	// 本地
	// var apiHaiL='http://192.168.0.206:9199';
	return apiHaiL;
}
function imgShowApi(){
	// var imgShowApi='https://img3zxg.oss-cn-beijing.aliyuncs.com/';
	var imgShowApi='https://3zxgimg.oss-cn-beijing.aliyuncs.com/';
	return imgShowApi;
}
function appid(){
	var appid='wx9475251f4c74eccd';
	return appid;
}
function redirectUri(){
	var redirectUri='http://192.168.0.73';
	return redirectUri;
}*/

/*线上*/
/*function wxApi(){var wxApi='http://weixinapi.3zqp.com';return wxApi;}
function wxApiAn(){var wxApiAn='http://tms.3zqp.com';return wxApiAn;}
function wxApiAnY(){var wxApiAnY='http://tms.3zqp.com';return wxApiAnY;}
function wxApiHai(){var wxApiHai='http://tmsimg.3zqp.com';return wxApiHai;}
function imgShowApi(){var imgShowApi='https://3zxgimg.oss-cn-beijing.aliyuncs.com/';return imgShowApi;}
function wxApiZhao(){var wxApiZhao='http://appapi.3zqp.com';return wxApiZhao;}
function apiHaiL(){var apiHaiL='http://acc.3zqp.com';return apiHaiL;}
function appid(){var appid='wx6da56d9844be9ca1';return appid;}
function redirectUri(){var redirectUri='http://weixinweb.3zqp.com';return redirectUri;}
*/

/*准生产*/
function wxApi(){var wxApi='http://pweixinapi.3zqp.com';return wxApi;}
function wxApiAn(){var wxApiAn='http://ptms.3zqp.com';return wxApiAn;}
function wxApiAnY(){var wxApiAnY='http://ptms.3zqp.com';return wxApiAnY;}
function wxApiHai(){var wxApiHai='http://ptmsimg.3zqp.com';return wxApiHai;}
function imgShowApi(){var imgShowApi='https://3zxgimg.oss-cn-beijing.aliyuncs.com/';return imgShowApi;}
function wxApiZhao(){var wxApiZhao='http://pappapi.3zqp.com';return wxApiZhao;}
function apiHaiL(){var apiHaiL='http://pacc.3zqp.com';return apiHaiL;}
function appid(){var appid='wx9d37162460f921d8';return appid;}
function redirectUri(){var redirectUri='http://192.168.0.73';return redirectUri;}


/*测试*/
/*function wxApi(){var wxApi='http://tweixinapi.3zqp.com';return wxApi;}
function wxApiAn(){var wxApiAn='http://ttms.3zqp.com';return wxApiAn;}
function wxApiAnY(){var wxApiAnY='http://ttms.3zqp.com';return wxApiAnY;}
function wxApiHai(){var wxApiHai='http://ttmsimg.3zqp.com';return wxApiHai;}
function imgShowApi(){var imgShowApi='https://3zxgimg.oss-cn-beijing.aliyuncs.com/';return imgShowApi;}
function wxApiZhao(){var wxApiZhao='http://tappapi.3zqp.com';return wxApiZhao;}
function apiHaiL(){var apiHaiL='http://tacc.3zqp.com';return apiHaiL;}
function appid(){var appid='wx9d37162460f921d8';return appid;}
function redirectUri(){var redirectUri='http://192.168.0.73';return redirectUri;}*/

/*微信用户*/
function isWeiXin(){ 
	var ua = window.navigator.userAgent.toLowerCase();
	if(ua.match(/MicroMessenger/i) == 'micromessenger'){
		return true;
	}else{
		return false; 
	}
}

function userId(){
	if (sess.info) {
		var base = new Base64();
		var result = base.decode(sess.info);
		var json=JSON.parse(result);
		var userId=json.id;
		return userId;
	}
};

function userTel(){
	if (sess.info) {
		var base = new Base64();
		var result = base.decode(sess.info);
		var json=JSON.parse(result);
		var userTel=json.tel;
		return userTel;
	}
};
function userName(){
	if (sess.info) {
		var base = new Base64();
		var result = base.decode(sess.info);
		var json=JSON.parse(result);
		var userName=json.userName;
		return userName;
	}
};
function number(){
	if (sess.info) {
		var base = new Base64();
		var result = base.decode(sess.info);
		var json=JSON.parse(result);
		var number=json.number;
		return number;
	};
};
function account(){
	if (sess.info) {
		var base = new Base64();
		var result = base.decode(sess.info);
		var json=JSON.parse(result);
		var account=json.account;
		return account;
	};
};
function type(){
	if (sess.info) {
		var base = new Base64();
		var result = base.decode(sess.info);
		var json=JSON.parse(result);
		var type=json.type;
		return type;
	};
};
function requestTokenId(num){
	len =num||32;
	var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';
	var maxPos = $chars.length;
	var pwd = '';
	for (i = 0; i < len; i++) {
		pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
	}
	return 'wx_tms_'+pwd;
}
function requestTokenInput(){
	var html='<input name="requestTokenId" type="hidden" value="'+requestTokenId()+'">';
	$('form').append(html);
};

/*详情页复制*/
function clipboard(){
	var clipboard = new Clipboard('.details_btn');
	clipboard.on('success', function(e) {
	   $('.waybill_wrap').css('display', 'none');
	});
	clipboard.on('error', function(e) {
	   alert('失败');
	});
}

/*返回*/
function headerGoback(){
	history.back(-1);
}

function showRem(msg){
	$('.reminder').remove();
	$('body').append('<div class="reminder"><p>'+msg+'</p></div>');
	var timer=setTimeout(function(){
		clearTimeout(timer);
		$('.reminder').fadeOut(500);
		$('.reminder').remove();
	}, 3000);
};

/*获取地址*/
function addr_aera2(pNum,cNum,dNum){
	var city_picker = new mui.PopPicker({layer:3});
	city_picker.setData(provs);
	if (pNum&&cNum&&dNum) {
	    for (var i = 0; i < provs.length; i++) {
	    	var PIndex=i;
	    	if (provs[i].value==pNum) {
	    		for (var j = 0; j < provs.length; j++) {
	    			var cIndex=j;
		    		if (cNum==provs[i].child[j].value) {
		    			for (var k = 0; k < provs[i].child[j].child.length; k++) {
			    			var dIndex=k;
				    		if (dNum==provs[i].child[j].child[k].value) {
				    			break;
				    		};
			    		};
		    			break;
		    		};
	    		};
	    		break;
	    	}
	    };
	    city_picker.pickers[0].setSelectedIndex(PIndex);
		city_picker.pickers[1].setSelectedIndex(cIndex);
		city_picker.pickers[2].setSelectedIndex(dIndex);
	};
	$("#addr_aera").on("tap", function(){
		$('input').blur();
		setTimeout(function(){
			city_picker.show(function(items){
				$("#addr_value").val((items[0] || {}).value + "," + (items[1] || {}).value + "," + (items[2].value || items[1].value));//该ID为接收城市ID字段
				$("#addr_aera").removeClass('c999').html((items[0] || {}).text + " " + (items[1] || {}).text + " " + (items[2].text || items[1].text));
			});
		},200);
	});
}
/*以下是注册页面开始*/
/*获取验证码*/
function sub_tel(e){
	if (PhoneNo($('[name="tel"]'))) {
		loading('获取中...');
		var lonin_tel=$('[name="tel"]').val();
		$.ajax({
			url: apiL+'/api/wx/validation/getcode',
			type: 'POST',
			dataType: 'json',
			data: {phone:lonin_tel,type:0,requestTokenId:requestTokenId()},
			success:function(data){
				loadingRemove();
				if (data.success) {
					e.removeAttr('onclick').html('<span id="dao_time">60</span>秒再次获取');
					countDown('#dao_time',60);
				}else{
					alert(data.message);
				};
			}
		});
	};
}
/*验证倒计时*/
function countDown(e,num){
	var num=num;
	var timer=setInterval(function(){
		num--;
		$(e).html(num);
		if (num==0) {
			$('.gain').attr('onclick', 'sub_tel($(this))').html('获取验证码');
			clearInterval(timer);
		};
	}, 1000);
}
/*手机号提交验证*/
function telSubmit(){
	if (!PhoneNo($('.tel'))) {
		PhoneNo($('.tel'));
		return false;
	}else if(!verify($('.yzm'))){
		verify($('.yzm'));
		return false;
	}else if(!password($('[name="password"]'))){
		password($('[name="password"]'));
		return false;
	}else if(!password2($('[name="password2"]'))){
		password2($('[name="password2"]'));
		return false;
	}else if($('[name="protocol"]:checked').length<1){
		alert('请您先勾选同意《三真车联平台注册协议》');
		return false;
	}else{
		/*防止重复提交*/
		$('.footer_btn').attr('disabled', 'disabled');
		var timer=setTimeout(function(){
			clearTimeout(timer);
			$('.footer_btn').removeAttr('disabled');
		}, 5000);

		loading('提交中...');
		var login_tel=$('[name="tel"]').val();
		var login_code=$('[name="code"]').val();
		var login_psw=$("[name=password]").val();
		var unionid=GetQueryString('uid');
		var data={
			unionid: unionid,
			phone: login_tel,
			code: login_code,
			password: <PASSWORD>,
			username:login_tel,
			registerType:3,
			requestTokenId:requestTokenId(),
		};
		$.ajax({
			url: api+'/api/wx/login/register',
			type: 'POST',
			dataType: 'json',
			data: data,
			success:function(data){
				loadingRemove();
				if (data.success) {
					if (data.message) {
						alert(data.message)
					}else{
						console.log(data);
						var base = new Base64();
						var info = base.encode(JSON.stringify(data.info));
						sess.info=info;


						var base = new Base64();
						var result = base.decode(sess.info);
						var json=JSON.parse(result);


						console.log(json)
						// return false;
						window.location.href="../login/login_addr.html?unionid="+unionid;
					}
				}else{
					alert(data.message);
				};
			},
			complete : function(XMLHttpRequest,status){
	            loadingRemove();
	            if(status=='error'){
	            	$('.footer_btn').removeAttr('disabled');
	                fubottom('提交失败，请重试');
	            }else if(status=='timeout'){
	            	$('.footer_btn').removeAttr('disabled');
	                fubottom('提交失败，请重试');
	            }
	        }
		});
	}
}

function protocolClose(){
	$('.protocol_wrap').css('display', 'none');
}

function protocolSelect(){
	$('[name="protocol"]').attr('checked', 'checked');
	$('.protocol_wrap').css('display', 'none');
}
/*地址详情提交验证*/
function addrSubmit(){
	if (!noNullfa($('.company'),'公司名称')) {
		noNullfa($('.company'),'公司名称');
		return false;
	}else if(!nameLen($('[name="name"]').val())){
		nameLen($('[name="name"]').val());
		return false;
	}else if(!noNull($('#addr_value'),'所在地址')){
		noNull($('#addr_value'),'所在地址');
		return false;
	}else if(!noNullfa($('.addr_detail'),'详细地址')){
		noNullfa($('.addr_detail'),'详细地址');
		return false;
	}else{
		/*防止重复提交*/
		$('.footer_btn').attr('disabled', 'disabled');
		var timer=setTimeout(function(){
			clearTimeout(timer);
			$('.footer_btn').removeAttr('disabled');
		}, 5000);

		loading('提交中...');
		var company=trim($('[name="company"]').val());
		var name=trim($('[name="name"]').val());
		var addrAera=$('#addr_aera').html();
		var addrAeraNum=$('[name="addrAeraNum"]').val();
		var addrDetail=trim($('[name="addrDetail"]').val());
		addrAera=addrAera.split(' ');
		addrAeraNum=addrAeraNum.split(',');
		var tel=userName();
		AMap.service('AMap.Geocoder',function(){
		    var geocoder = new AMap.Geocoder({});
		    geocoder.getLocation(addrAera[0]+""+addrAera[1]+""+addrAera[2]+""+addrDetail, function(status, result) {
		    	loadingRemove();
			    if (status === 'complete' && result.info === 'OK') {
			    	loading('提交中...');
			        var data={
						id:userId(),
						company:company,
						proName: addrAera[0],
						proNumber: addrAeraNum[0],
						cityName: addrAera[1],
						cityNumber: addrAeraNum[1],
						areaName: addrAera[2],
						areaNumber: addrAeraNum[2],
						detailed: addrDetail,
						lat:result.geocodes[0].location.lat,
						lng:result.geocodes[0].location.lng,
						contact: name,
						tel: userTel(),
						type:3,
						account:account(),
						number:number(),
						userName:userName(),
						unionid:GetQueryString('unionid'),
						requestTokenId:requestTokenId()
					};
			    	console.log(data)
		    		$.ajax({
						url: apiL+'/api/wx/login/adduser',
						type: 'POST',
						dataType: 'json',
						data: data,
						success:function(data){
							loadingRemove();
							// console.log(data);
							if (data.success) {
								var info=data.info;
								if (info!=null) {
									info=JSON.stringify(info);
									var base = new Base64();
									var result = base.encode(info);
									sess.info=result;
								};
								window.location.href="../login/login_ok.html";
							}else{
								alert(data.message);
							};
						},
						complete : function(XMLHttpRequest,status){
				            loadingRemove();
				            if(status=='error'){
				            	$('.footer_btn').removeAttr('disabled');
				                fubottom('提交失败，请重试');
				            }else if(status=='timeout'){
				            	$('.footer_btn').removeAttr('disabled');
				                fubottom('提交失败，请重试');
				            }
				        }
					});
			    }else{
			        AMap.service('AMap.Geocoder',function(){//回调函数
					    //实例化Geocoder
					    var geocoder = new AMap.Geocoder({
					        // city: "010"//城市，默认：“全国”
					    });
					    geocoder.getLocation(addrAera[0]+""+addrAera[1]+""+addrAera[2], function(status, result) {
					    	loadingRemove();
						    if (status === 'complete' && result.info === 'OK') {
						    	loading('提交中...');
						        var data={
									id:userId(),
									company:company,
									proName: addrAera[0],
									proNumber: addrAeraNum[0],
									cityName: addrAera[1],
									cityNumber: addrAeraNum[1],
									areaName: addrAera[2],
									areaNumber: addrAeraNum[2],
									detailed: addrDetail,
									lat:result.geocodes[0].location.lat,
									lng:result.geocodes[0].location.lng,
									contact: name,
									tel: userTel(),
									type:3,
									account:account(),
									number:number(),
									userName:userName(),
									unionid:GetQueryString('unionid'),
									requestTokenId:requestTokenId()
								};
					    		$.ajax({
									url: apiL+'/api/wx/login/adduser',
									type: 'POST',
									dataType: 'json',
									data: data,
									success:function(data){
										loadingRemove();
										// console.log(data);
										if (data.success) {
											var info=data.info;
											if (info!=null) {
												info=JSON.stringify(info);
												var base = new Base64();
												var result = base.encode(info);
												sess.info=result;
											};
											window.location.href="../login/login_ok.html";
										}else{
											alert(data.message);
										};
									}
								});
						    }else{
						        $.MsgBox.Alert("地址获取失败，请重试或修改地址后再试",'确定');
						    }
						});
					})
			    }
			});
		})
	}
}
/*注册完成页面倒计时跳转*/
function login_ok(e,time){
	if (!userId()) {
		window.location.href="../login/login_tel.html"
	};
	var i=parseFloat(time)/1000;
	if (i>0) {
		setInterval(function(){
			i--;
			e.html(i);
		}, 1000);
	}else{
		e.html(0);
	};
	setTimeout(function(){
		window.location.href=sess.loginUrl;
	}, time)
}
/*绑定登录*/
function loginBindSubmit(){
	var callbackUrl=sess.loginUrl;
	if (!noNull($('[name="account"]'),'账号')) {
		$('.msg').html('<span class="red">账号不能为空</span>')
	}else if(!noNull($('[name="password"]'),'密码')){
		$('.msg').html('<span class="red">密码不能为空</span>')
	}else{
		loading('绑定中...');
		var login_tel=$('[name="account"]').val();
		var login_psw=$('[name="password"]').val();
		$.ajax({
			url: api+'/api/wx/login/relation',
			type: 'POST',
			dataType: 'json',
			data: {username:login_tel,password:<PASSWORD>,unionid:GetQueryString('uid'),requestTokenId:requestTokenId()},
			success:function(data){
				loadingRemove();
				if (data.success) {
					// console.log(data);
					if (data.message) {
						alert(data.message);
					}else{
						var user=data.info;
						// console.log(user)
						if (user.userState==1&&user.accountState==1) {
							$.MsgBox.Confirmt("对不起，您的账号异常，暂不能登录，请联系客服：4001-821200",'拨打电话','关闭',function(){
								WeixinJSBridge.call('closeWindow');
						    },function(){
						        window.location.href='tel:4001821200';
								WeixinJSBridge.call('closeWindow');
						    });
							return false;
						}else{
							if (user.userState==1&&callbackUrl!='/ucenter/ucenter.html') {
								var base = new Base64();
								var result = base.encode(JSON.stringify(data.info));
								sess.info=result;
								alert('绑定成功');
								$.MsgBox.Confirmt("对不起，您的账号已被封停，封停原因："+user.userFreezeReason+"。您可以进入<a class='blue' href='/ucenter/ucenter.html'>个人中心</a>。如有疑问，请联系客服：4001-821200",'拨打电话','关闭',function(){
									WeixinJSBridge.call('closeWindow');
							    },function(){
							        window.location.href='tel:4001821200';
									WeixinJSBridge.call('closeWindow');
							    });
								return false;
							}else{
								var base = new Base64();
								var result = base.encode(JSON.stringify(data.info));
								sess.info=result;
								window.location.href=sess.loginUrl;
							};
						};
					};
				}else{
					alert(data.message);
				};
			}
		});
		
	};
}
/*验证不能为空*/
function noNull(e,msg){
	var val=trim(e.val());
	if (val.length==0) {
		$('.msg').html('<span class="red">'+msg+'不能为空</span>');
		return false;
	}else{
		$('.msg').html('');
		return true;
	}
}
/*验证不能为空*/
function noNullfa(e,msg){
	var val=trim(e.val());
	if (val.length==0) {
		$('.msg').html('<span class="red">'+msg+'不能为空</span>');
		return false;
	}else if(notdot(val)){
		$('.msg').html('<span class="red">'+msg+'不能输入非法字符</span>');
		return false;
	}else{
		$('.msg').html('');
		return true;
	}
}
/*删除左右两端的空格*/
function trim(str){
 	return str.replace(/ /g,'');
}

function nameLen(value){
	if (value) {
		if (!hanEng(value)) {
			$('.msg').html('<span class="red">联系人姓名只能中英文</span>');
			return false;
		}else{
			if (value.length<2||value.length>20) {
				$('.msg').html('<span class="red">联系人需输入2-20个字</span>');
				return false;
			}else{
				$('.msg').html('');
				return true;
			};
		};
	}else{
		$('.msg').html('');
		return true;
	};
}
/*验证密码*/
function password(e){
	var val=e.val();
	var val2=$('[name="password2"]').val();
	if (val.length==0) {
		$('.msg').html('<span class="red">密码不能为空</span>');
		return false;
	}else{
		if (!ispsw(val)) {
			$('.msg').html('<span class="red">请输入6-16位数字和字母的组合密码</span>');
			return false;
		}else if((val2.length!=0) && (val2!=val)){
			$('.msg').html('<span class="red">两次输入的密码不一致</span>');
			return false;
		}else{
			$('.msg').html('');
			return true;
		};
	};
}
/*二次密码*/
function password2(e){
	var val=e.val();
	var val2=$('[name="password"]').val();
	if (val.length==0) {
		$('.msg').html('<span class="red">重复密码不能为空</span>');
		return false;
	}else{
		if (!ispsw(val)) {
			$('.msg').html('<span class="red">请输入重复6-16位数字和字母的组合密码</span>');
			return false;
		}else if((val2.length!=0) && (val2!=val)){
			$('.msg').html('<span class="red">两次输入的密码不一致</span>');
			return false;
		}else{
			$('.msg').html('');
			return true;
		};
	};
}
/*验证电话*/
function telNo(e){
	var val=trim(e.val());
	if (!isNumberTel(val)) {
		loadingRemove();
		$('.msg').html('<span class="red">请输入7-12位的手机号或固话</span>');
		return false;
	}else{
		$('.msg').html('');
		return true;
	};
}
function telNoFa(e){
	var val=trim(e.val());
	if (!isNumberTel(val)) {
		loadingRemove();
		$('.msg_fuInputTel').html('<span class="red">请输入7-12位的手机号或固话</span>');
		return false;
	}else{
		$('.msg_fuInputTel').html('');
		return true;
	};
}
/*验证手机号*/
function PhoneNo(e){
	var val=e.val();
	if (val.length==0) {
		$('.msg').html('<span class="red">手机号不能为空</span>');
		return false;
	}else{
		if (!isPhoneNo(val)) {
			$('.msg').html('<span class="red">请输入正确的手机号</span>');
			return false;
		}else{
			$('.msg').html('');
			return true;
		};
	};
}
/*常用联系人验证手机号*/
function comPhoneNo(e){
	var val=trim(e.val());
	if (val.length==0) {
		e.parents('.comment_input').siblings('.msg').html('<span class="red">手机号不能为空</span>');
		return false;
	}else{
		if (!isPhoneNo(val)) {
			e.parents('.comment_input').siblings('.msg').html('<span class="red">请输入正确的手机号</span>');
			return false;
		}else{
			e.parents('.comment_input').siblings('.msg').html('');
			return true;
		};
	};
}
/*验证码*/
function verify(e){
	var val=e.val();
	if (val.length==0) {
		$('.msg').html('<span class="red">验证码不能为空</span>');
		return false;
	}else{
		if (!istelverify(val)) {
			$('.msg').html('<span class="red">请输入正确的验证码</span>');
			return false;
		}else{
			$('.msg').html('');
			return true;
		};
	};
}
/*验证手机号*/
function isPhoneNo(phone) {
 	var pattern = /^1\d{10}$/;
	return pattern.test(phone);
}
/*验证验证码*/
function istelverify(verify) { 
	var pattern = /^\d{4,7}$/;
 	return pattern.test(verify);
}
function isNumberTel(tel){
	var pattern = /^\d{7,12}$/;
	return pattern.test(tel);
}
/*判断密码为6-16位*/
/*function ispsw(psw) {
	var pattern = /^(?![\d]+$)(?![a-zA-Z]+$)(?![\(\)\（\）\，\,\.\、\-\/\\\~\_\&\*\#]+$)[\da-zA-Z\(\)\（\）\，\,\.\、\-\/\\\~\_\&\*\#]{6,16}$/;
 	return pattern.test(psw);
}*/
function ispsw(psw) {
	var pattern = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{6,16}$/;
 	return pattern.test(psw);
}
/*判断密码为6-16位*/
function hanEng(psw) {
	var pattern = /^[\u4E00-\u9FA5A-Za-z]+$/;
 	return pattern.test(psw);
}
/*判断不能为非法字符*/
function notdot(stry) {
	var pattern = new RegExp("[`~!@#$^&*=|{}':;',\\[\\].<>/?！@#￥……&*|{}‘；：”“'。，？]");
 	return pattern.test(stry);
}
/*以上是注册页面结束*/

/*自助下单发货编辑链接*/
function consignerEdit(id){
	if (!GetQueryString('waybill')) {
		window.location.href="../ucenter/consigner_edit.html?edit="+id+"&from=addr&order="+GetQueryString('selfHp');
	}else{
		window.location.href="../ucenter/consigner_edit.html?edit="+id+"&from=addr&waybill=addr&order="+GetQueryString('selfHp');
	};
}
/*自助下单收货编辑链接*/
function recrivingEdit(id){
	if (!GetQueryString('waybill')) {
		window.location.href="../ucenter/receiving_edit.html?edit="+id+"&from=addr&order="+GetQueryString('selfHp');
	}else{
		window.location.href="../ucenter/receiving_edit.html?edit="+id+"&from=addr&waybill=addr&order="+GetQueryString('selfHp');
	};
}


/*获取链接参数*/
function GetQueryString(name)
{
     var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
     var r = window.location.search.substr(1).match(reg);
     if(r!=null)return  unescape(r[2]); return null;
}
function GetQueryString2(name){
     var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
     var r = window.location.search.substr(1).match(reg);
     if(r!=null)return  unescape(r[1]); return null;
}

function getRequest(){
   var url = window.location.search;
   var theRequest = new Object();
   if (url.indexOf("?") != -1) {
      var str = url.substr(1);
      strs = str.split("&");
      for(var i = 0; i < strs.length; i ++) {
         theRequest[strs[i].split("=")[0]]=decodeURI(strs[i].split("=")[1]);
      }   
   }
   return theRequest;   
}

function loading(text){
	var html='<div class="loadingZhuan"><div class="loadingZ"><img src="../skin/images/zhuan.gif"><p>'+text+'</p></div></div>';
	$('body').append(html);
}
function loadingRemove(){
	$('.loadingZhuan').remove();
}

/*弹出浮层*/
function displayB(e){
	e.css('display', 'flex');
}
function displayN(e){
	e.css('display', 'none');
}
/*保留小数点后两位*/
function toDecimal2(x) {    
    var f = parseFloat(x);    
    if (isNaN(f)) {    
        return false;    
    }    
    var f = Math.round(x*100)/100;    
    var s = f.toString();    
    var rs = s.indexOf('.');    
    if (rs < 0) {    
        rs = s.length;    
        s += '.';    
    }    
    while (s.length <= rs + 2) {    
        s += '0';    
    }    
    return s;    
}


/*时间转换*/
Date.prototype.format = function(format) {
	var date = {
		"M+": this.getMonth() + 1,
		"d+": this.getDate(),
		"h+": this.getHours(),
		"m+": this.getMinutes(),
		"s+": this.getSeconds(),
		"q+": Math.floor((this.getMonth() + 3) / 3),
		"S+": this.getMilliseconds()
	};
	if (/(y+)/i.test(format)) {
	  	format = format.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length));
	}
	for (var k in date) {
		  if (new RegExp("(" + k + ")").test(format)) {
		        format = format.replace(RegExp.$1, RegExp.$1.length == 1
		                ? date[k] : ("00" + date[k]).substr(("" + date[k]).length));
		  }
	}
	return format;
};

/*三秒消失提示*/
var timerBottom;
function fubottom(text) {
	clearTimeout(timerBottom);
	if ($('body .fubottom').length>0) {
		$('.fubottom').fadeOut().remove();
		var html='<div class="fubottom">'+text+'</div>';
		$('body').append(html).fadeIn();
	}else{
		var html='<div class="fubottom">'+text+'</div>';
		$('body').append(html).fadeIn();
	};
	timerBottom=setTimeout(function(){
		$('.fubottom').fadeOut().remove();
	}, 2000);
}


function noResult(boxDot,height,text){
	boxDot.html('<div class="noResult_flex" style="height:'+height+'px"><div class="noResult_flex"><div class="noResult_c"><span><img src="../skin/images/no_find.png" alt=""></span><p>'+text+'</p></div></div>');
}
function noResultErr(boxDot,height,text,func){
	boxDot.html('<div class="noResult_flex" style="height:'+height+'px"><div class="noResult_flex" onclick="'+func+'"><div class="noResult_c"><span><img src="../skin/images/loading_erro.png" alt=""></span><p>'+text+'</p></div></div>');
}
<file_sep>/src/js/record.js
'use strict';

// 发货列表
function sendOutList(page){
	loading('加载中...');
	var search=GetQueryString('search');
	var state=GetQueryString('status');
	var startTimeCuo=GetQueryString('startTime');
	var endTimeCuo=GetQueryString('endTime');
	/*获取当前以及一个月前的时间*/
	var dataTime=new Date();
	var curYear=dataTime.getFullYear();
	var curMonth=addZero(dataTime.getMonth()+1);
	var curDays=addZero(dataTime.getDate());
	var curTime=curYear+'/'+curMonth+'/'+curDays;
	var curSerTime=curYear+'-'+curMonth+'-'+curDays;
	/*var prevData=new Date(dataTime-2592000000);
	var prevYear=prevData.getFullYear();
	var prevMonth=addZero(prevData.getMonth()+1);
	var prevDays=addZero(prevData.getDate());
	var prevTime=prevYear+'/'+prevMonth+'/'+prevDays;
	var prevSerTime=prevYear+'-'+prevMonth+'-'+prevDays;*/
	// 获取筛选时间
	if (startTimeCuo&&endTimeCuo) {
		var startTime = new Date();
		startTime.setTime(startTimeCuo);
		var startTimeShow=startTime.format('yyyy/MM/dd');
		var startTimeChange=startTime.format('yyyy-MM-dd');
		var endTime = new Date();
		endTime.setTime(endTimeCuo);
		var endTimeShow=endTime.format('yyyy/MM/dd');
		var endTimeChange=endTime.format('yyyy-MM-dd');

	}
	var searchhtml="";
	if (startTime && endTime) {
		searchhtml='<span class="swiper-slide">'+startTimeShow+'-'+endTimeShow+'</span>';
	};
	/*状态*/
	if (state===0||state) {
		var stateArr=state.split(',');
		var selestStatus="";
		var selestStatusArr=[];
		for (var i = 0; i < stateArr.length; i++) {
			if (stateArr[i]=='0') {
				selestStatus="待揽货";
			}else if(stateArr[i]==1){
				selestStatus="已揽货";
			}else if(stateArr[i]==2){
				selestStatus="运输中";
			}else if(stateArr[i]==3){
				selestStatus="配送中";
			}else if(stateArr[i]==6){
				selestStatus="已签收";
			}else if(stateArr[i]==4){
				selestStatus="取消发货";
			}else if(stateArr[i]==5){
				selestStatus="已退货";
			}else if(stateArr[i]==7){
				selestStatus="已驳回";
			};
			selestStatusArr.push(selestStatus);
		};

		for (var i = 0; i < selestStatusArr.length; i++) {
			searchhtml+='<span  class="swiper-slide">'+selestStatusArr[i]+'</span>';
		};
	};

	$('.swiper-wrapper').html(searchhtml);
	

	if (((startTimeCuo&&endTimeCuo)||state===0||state)) {
		if (stateArr) {
			for (var i = 0; i < stateArr.length; i++) {
				$('.filtrateTop ul [value="'+stateArr[i]+'"]').attr('checked', 'checked');
			};
		};
		$('#date_start').val(startTimeChange);
		$('#date_end').val(endTimeChange);
		var data={
			senderId:number(),
			pageSize:15,
			currentPage:page,
			status:state,
			startTime:startTimeCuo,
			endTime:endTimeCuo,
			requestTokenId:requestTokenId()
		};
		$.ajax({
			url: apiAn+'/api/wx/waybill/selectWaybillForSender',
			type: 'POST',
			dataType: 'json',
			timeout : 10000,
			data: data,
			success:function(data){
				if (data.success) {
					loadingRemove();
					sess.sendPages=data.info.pages
					correspCon(data.info,startTimeChange,endTimeChange,state);
				}else{
					alert(data.message)
				};
			},
	        complete : function(XMLHttpRequest,status){
	            loadingRemove();
	    　　　　if(status=='error'){
	    			sess.nowSendPage=1;
	     　　　　　 noResultErr($('.record_list'),400,'请求超时，请点击重新获取','sendOutList(1)');
	     			$('.loading').html('');
	    　　　　}else if(status=='timeout'){
	    			sess.nowSendPage=1;
	                noResultErr($('.record_list'),400,'请求超时，请点击重新获取','sendOutList(1)');
	     			$('.loading').html('');
	            }
	    　　}
		});
	}else{
		$.ajax({
			url: apiAn+'/api/wx/waybill/selectWaybillForSender',
			type: 'POST',
			dataType: 'json',
			timeout : 10000,
			data: {senderId:number(),pageSize:15,currentPage:page,requestTokenId:requestTokenId()},
			success:function(data){
				loadingRemove();
				if (data.success) {
					// console.log(data);
					sess.sendPages=data.info.pages
					correspCon(data.info);
				}else{
					alert(data.message);
				};
			},
	        complete : function(XMLHttpRequest,status){
	            loadingRemove();
	    　　　　if(status=='error'){
	    			sess.nowSendPage=1;
	     　　　　　 noResultErr($('.record_list'),400,'请求超时，请点击重新获取','sendOutList(1)');
	     			$('.loading').html('');
	    　　　　}else if(status=='timeout'){
	    			sess.nowSendPage=1;
	                noResultErr($('.record_list'),400,'请求超时，请点击重新获取','sendOutList(1)');
	     			$('.loading').html('');
	            }
	    　　}
		});
	};
	var swiper = new Swiper('.swiper-container', {
		scrollbar: '.swiper-scrollbar',
		scrollbarHide: true,
		slidesPerView: 'auto',
		// centeredSlides: true,
		// spaceBetween: 10,
		grabCursor: true
	});
	return true;
}

/*收发货搜索列表*/
function corresponSearch(current){
	/*获取当前以及一个月前的时间*/
	var dataTime=new Date();
	var curYear=dataTime.getFullYear();
	var curMonth=addZero(dataTime.getMonth()+1);
	var curDays=addZero(dataTime.getDate());
	var curTime=curYear+'/'+curMonth+'/'+curDays;
	/*var prevData=new Date(dataTime-2592000000);
	var prevYear=prevData.getFullYear();
	var prevMonth=addZero(prevData.getMonth()+1);
	var prevDays=addZero(prevData.getDate());
	var prevTime=prevYear+'/'+prevMonth+'/'+prevDays;*/

	/*获取选中的状态*/
	var statu=$('[name="state"]');
	var statuArr=[];
	for (var i = 0; i < statu.length; i++) {
		if (statu.eq(i).attr('checked')) {
			statuArr.push(statu.eq(i).val());
		};
	};
	var status=statuArr.toString();
	
	/*当状态为待揽货时*/
	if (status===0) {
		var statusJ=true;
	};

	var startTime=$('#date_start').val();
	var endTime=$('#date_end').val();
	var startArr=startTime.split('-');
	var endArr=endTime.split('-');
	var searchhtml="";
	
	/*开始结束时间搓*/
	var startTimeT=new Date(startArr[0],startArr[1]-1,startArr[2]);
	var EndTimeT=new Date(endArr[0],endArr[1]-1,endArr[2],23,59,59);
	var startTimeCuo=startTimeT.getTime();
	var endTimecuo=EndTimeT.getTime();
	if (!startTimeCuo) {
		startTimeCuo="";
	};
	if (!endTimecuo) {
		endTimecuo="";
	};
	if(!startTimeCuo&&endTimecuo){
		alert('请选择开始日期');
		return false;
	}else if(startTimeCuo&&!endTimecuo){
		alert('请选择截止日期');
		return false;
	}

	/*当为搜索的时候*/
	if ((startTimeCuo&&endTimecuo)||statusJ||status) {
		if ((startTimeCuo&&endTimecuo)&&parseInt(endTimecuo)<parseInt(startTimeCuo)) {
			alert('结束日期不可大于开始日期');
			$('#date_start').val($('#date_end').val());
		}else{
			var data={
				senderId:number(),
				pageSize:15,
				currentPage:current,
				status:status,
				startTime:startTimeCuo,
				endTime:endTimecuo
			}
			window.location.href=window.location.pathname+'?search=1&status='+status+'&startTime='+startTimeCuo+'&endTime='+endTimecuo;
		};
	}else{
		window.location.href=window.location.pathname;
	};
}


/*发货列表内容*/
function correspCon(info,startTime,endTime,state){
	var html="";
	var ahtml="";
	if (info.list) {
		for(var i = 0; i < info.list.length; i++){
			var status=info.list[i].status;
			var statusShow="";
			if (status=='0') {
				statusShow="待揽货";
			}else if(status==1){
				statusShow="已揽货";
			}else if(status==2){
				statusShow="运输中";
			}else if(status==3){
				statusShow="配送中";
			}else if(status==6){
				statusShow="已签收";
			}else if(status==4){
				statusShow="取消发货";
			}else if(status==5){
				statusShow="已退货";
			}else if(status==7){
				statusShow="已驳回";
			};
			html+='<div class="record_li" data-id="'+info.list[i].id+'"><table>'
				+'<col width="52%"><col width="24%"><col width="17%">'
				+'<tr><td colspan="2">揽货网点：'+info.list[i].inputDotName+'</td>'
					+'<td class="t_r"><span class="red">'+statusShow+'</span></td>'
				+'</tr><tr>'
					+'<td>运单编号：'+info.list[i].no+'</td>'
					+'<td colspan="2">货物件数：'+info.list[i].goodsQuantity+'</td>'
				+'</tr><tr>'
					+'<td colspan="2">收 货 方：<b>'+info.list[i].receiverName+'</b></td>'
					+'<td><a href="tel:'+info.list[i].receiverMobile+'"><img src="../skin/images/tel.png" alt="电话"></a></td>'
				+'</tr></table>'
			+'<div class="show_details ov_h">';
				if (info.list[i].status==0) {
					html+='<a class="f_r f14" href="../order/scan.html?order='+info.list[i].no+'">运单条码</a>'
				};
				html+='<a class="f_r f14" href="../order/logistics.html?order='+info.list[i].no+'">运单详情</a>'
				if (info.list[i].status<4) {
					html+='<a class="f_r f14" href="../order/self_help_order.html?waybill='+info.list[i].no+'">修改运单</a>'
				};
			html+='</div></div>';
		};
		if (info.currentPage==1) {
			$('#record_list').html(html);
		}else{
			$('#record_list').append(html);
		};
	}else{
		$('.loading').html('');
		if (state===0) {
			var statusJ=true;
		};
		if ((startTime&&endTime) || statusJ||state) {
			if (!(startTime&&endTime)) {
				startTime="";
				endTime="";
			};
			if (state.length<1) {
				state="";
			};
			var statuArr=state.split(',');
			var stateA=[];
			var statu="";
			for (var i = 0; i < statuArr.length; i++) {
				if (statuArr[i]=='0') {
					statu="待揽货";
				}else if(statuArr[i]==1){
					statu="已揽货";
				}else if(statuArr[i]==2){
					statu="运输中";
				}else if(statuArr[i]==3){
					statu="配送中";
				}else if(statuArr[i]==6){
					statu="已签收";
				}else if(statuArr[i]==4){
					statu="取消发货";
				}else if(statuArr[i]==5){
					statu="已退货";
				}else if(statuArr[i]==7){
					statu="已驳回";
				};
				stateA.push(statu);
			};
			var statusStr=stateA.toString();
			$('#record_list').html('<div class="ship_nofind"><span><img src="../skin/images/no_find.png" alt=""></span><p>对不起，没有找到“'+statusStr+''+startTime+' '+endTime+'”的</br>相关信息，请重新输入。</p></div>');
		}else{
			$('#record_list').html('<div class="ship_nofind"><span><img src="../skin/images/no_find.png" alt=""></span><p>您还没有发货记录</p></div>');
		};
	}
}


// 收货列表
function recordOutList(page){
	loading('加载中...');
	var search=GetQueryString('search');
	var state=GetQueryString('status');
	var startTimeCuo=GetQueryString('startTime');
	var endTimeCuo=GetQueryString('endTime');
	/*获取当前以及一个月前的时间*/
	var dataTime=new Date();
	var curYear=dataTime.getFullYear();
	var curMonth=addZero(dataTime.getMonth()+1);
	var curDays=addZero(dataTime.getDate());
	var curTime=curYear+'/'+curMonth+'/'+curDays;
	var curSerTime=curYear+'-'+curMonth+'-'+curDays;
	/*var prevData=new Date(dataTime-2592000000);
	var prevYear=prevData.getFullYear();
	var prevMonth=addZero(prevData.getMonth()+1);
	var prevDays=addZero(prevData.getDate());
	var prevTime=prevYear+'/'+prevMonth+'/'+prevDays;
	var prevSerTime=prevYear+'-'+prevMonth+'-'+prevDays;*/
	// 获取筛选时间
	if (startTimeCuo&&endTimeCuo) {
		var startTime = new Date();
		startTime.setTime(startTimeCuo);
		var startTimeShow=startTime.format('yyyy/MM/dd');
		var startTimeChange=startTime.format('yyyy-MM-dd');
		var endTime = new Date();
		endTime.setTime(endTimeCuo);
		var endTimeShow=endTime.format('yyyy/MM/dd');
		var endTimeChange=endTime.format('yyyy-MM-dd');
	}
	/*var startCurTimeCuo=Date.parse(prevData);
	var endCurTimeCuo=Date.parse(dataTime);*/

	var searchhtml="";
	if (startTime && endTime) {
		searchhtml+='<span class="swiper-slide">'+startTimeShow+'-'+endTimeShow+'</span>';
	}/*else{
		searchhtml+='<span class="swiper-slide">'+prevTime+'-'+curTime+'</span>';
	};*/
	/*状态*/
	if (state===0||state) {
		var stateArr=state.split(',');
		var selestStatus="";
		var selestStatusArr=[];
		for (var i = 0; i < stateArr.length; i++) {
			if (stateArr[i]=='0') {
				selestStatus="待揽货";
			}else if(stateArr[i]==1){
				selestStatus="已揽货";
			}else if(stateArr[i]==2){
				selestStatus="运输中";
			}else if(stateArr[i]==3){
				selestStatus="配送中";
			}else if(stateArr[i]==6){
				selestStatus="已签收";
			}else if(stateArr[i]==4){
				selestStatus="取消发货";
			}else if(stateArr[i]==5){
				selestStatus="已退货";
			}else if(stateArr[i]==7){
				selestStatus="已驳回";
			};
			selestStatusArr.push(selestStatus);
		};
		for (var i = 0; i < selestStatusArr.length; i++) { 
			searchhtml+='<span class="swiper-slide">'+selestStatusArr[i]+'</span>';
		};
	};
	$('.swiper-wrapper').html(searchhtml);
	/*$('#date_start').val(prevSerTime);
	$('#date_end').val(curSerTime);*/

	if (((startTimeCuo&&endTimeCuo)||state=='0'||state)) {
		if (stateArr) {
			for (var i = 0; i < stateArr.length; i++) {
				$('.filtrateTop ul [value="'+stateArr[i]+'"]').attr('checked', 'checked');
			};
		};
		
		$('#date_start').val(startTimeChange);
		$('#date_end').val(endTimeChange);
		
		var data={
			pageSize:15,
			currentPage:page,
			status:state,
			startTime:startTimeCuo,
			endTime:endTimeCuo,
			// receiverMobile:userName(),
			receiverId:number(),
			requestTokenId:requestTokenId()
		};

		$.ajax({
			url: apiAn+'/api/wx/waybill/list/receiver',
			type: 'POST',
			timeout : 10000,
			dataType: 'json',
			data: data,
			success:function(data){
				if (data.success) {
					loadingRemove();
					sess.recordPages=data.info.pages;
					console.log(data)
					receiveCon(data.info,state,startTimeChange,endTimeChange);
				}else{
					alert(data.message);
				};
			},
	        complete : function(XMLHttpRequest,status){
	            loadingRemove();
	    　　　　if(status=='error'){
	    			sess.nowRecPage=1;
	     　　　　　 noResultErr($('.record_list'),400,'请求超时，请点击重新获取','recordOutList(1)');
	     			$('.loading').html('');
	    　　　　}else if(status=='timeout'){
	    			sess.nowRecPage=1;
	                noResultErr($('.record_list'),400,'请求超时，请点击重新获取','recordOutList(1)');
	     			$('.loading').html('');
	            }
	    　　}
		});
	}else{
		$.ajax({
			url: apiAn+'/api/wx/waybill/list/receiver',
			type: 'POST',
			timeout : 10000,
			dataType: 'json',
			data: {
				receiverId:number(),
				pageSize:15,
				currentPage:page,
				requestTokenId:requestTokenId()
			},
			success:function(data){
				if (data.success) {
					loadingRemove();
					console.log(data)
					sess.recordPages=data.info.pages;
					receiveCon(data.info);
				}else{
					alert(data.message);
				};
			},
	        complete : function(XMLHttpRequest,status){
	            loadingRemove();
	    　　　　if(status=='error'){
	    			sess.nowRecPage=1;
	     　　　　　 noResultErr($('.record_list'),400,'请求超时，请点击重新获取','recordOutList(1)');
	     			$('.loading').html('');
	    　　　　}else if(status=='timeout'){
	    			sess.nowRecPage=1;
	                noResultErr($('.record_list'),400,'请求超时，请点击重新获取','recordOutList(1)');
	     			$('.loading').html('');
	            }
	    　　}
		});
	};
	var swiper = new Swiper('.swiper-container', {
		scrollbar: '.swiper-scrollbar',
		scrollbarHide: true,
		slidesPerView: 'auto',
		// spaceBetween: 10,
		grabCursor: true
	});
	return true;
}

/*收货列表内容*/
function receiveCon(info,status,startTime,endTime){
	var pages=info.pages;
	var html="";
	var ahtml="";
	if (info.list) {
		for(var i = 0; i < info.list.length; i++){
			var status=info.list[i].status;
			switch(status){
				case 0:
					status="待揽货"
					break;
				case 1:
					status="已揽货"
					break;
				case 2:
					status="运输中"
					break;
				case 3:
					status="配送中"
					break;
				case 4:
					status="取消发货"
					break;
				case 5:
					status="已退货"
					break;
				case 6:
					status="已签收"
					break;
				case 7:
					status="已驳回"
					break;
			};
			html+='<div class="record_li"><table><col width="52%"><col width="24%"><col width="17%">'
					+'<tr><td colspan="2">运单编号：'+info.list[i].no+'</td>'
						+'<td class="t_r"><span class="red">'+status+'</span></td></tr>'
					+'<tr><td colspan="3">货物件数：'+info.list[i].goodsQuantity+'</td></tr>'
						+'<tr><td colspan="2">发 货 方：<b>'+info.list[i].senderName+'</b></td>'
						+'<td><a href="tel:'+info.list[i].senderMobile+'"><img src="../skin/images/tel.png" alt="电话"></a></td></tr></table>'
				+'<div class="show_details ov_h"><a class="f_r f14" href="../order/logistics2.html?order='+info.list[i].no+'">运单详情</a></div>'
			+'</div>';
		};
		if (info.currentPage==1) {
			$('#record_list').html(html);
		}else{
			$('#record_list').append(html);
		};
	}else{
		$('.loading').html('');
		if ((startTime&&endTime) || status) {
			if (!(startTime&&endTime)) {
				startTime="";
				endTime="";
			};
			if (status.length<1) {
				status="";
			};
			var statuArr=status.split(',');
			var state=[];
			var statu="";
			for (var i = 0; i < statuArr.length; i++) {
				if(statuArr[i]=='0'){
					statu="未揽货";
				}else if(statuArr[i]==1){
					statu="已揽货";
				}else if(statuArr[i]==2){
					statu="运输中";
				}else if(statuArr[i]==3){
					statu="配送中";
				}else if(statuArr[i]==6){
					statu="已签收";
				}else if(statuArr[i]==4){
					statu="取消发货";
				}else if(statuArr[i]==5){
					statu="已退货";
				}else if(statuArr[i]==7){
					statu="已驳回";
				}else{
					statu="";
				};
				state.push(statu);
			};
			status=state.toString();
			$('#record_list').html('<div class="ship_nofind"><span><img src="../skin/images/no_find.png" alt=""></span><p>对不起，没有找到“'+status+''+startTime+' '+endTime+'”的</br>相关信息，请重新输入。</p></div>');
			$('#Pagination').html('');
		}else{
			$('#record_list').html('<div class="ship_nofind"><span><img src="../skin/images/no_find.png" alt=""></span><p>您还没有收货记录</p></div>');
			$('#Pagination').html('');
		};
	}
}


/*关闭筛选*/
function filetrsHide(){
	$('.protocol_pop_send_w').fadeOut(400);
	$('.protocol_pop_send').animate({right:'-90%'}, 400);
}

function filetrShow(){
	$('.protocol_pop_send_w').fadeIn(400);
	$('.protocol_pop_send').animate({right:0}, 400);
}

/*筛选重置*/
function filetrsReset(){
	$('[name="state"]').removeAttr('checked');
	$('.filetrsTime').val('');
}

/*日期为两位数*/
function addZero(input){
	if (input<10) {
		return '0'+input;
	}else{
		return input;
	};
}
/*开始时间不能大于当前时间*/
function startTime(value){
	// var startTime=$('#date_start').val();
	var startArr=value.split('-');
	var startTimeT=new Date(startArr[0],startArr[1]-1,startArr[2]);
	/*开始结束时间搓*/
	var startTimeCuo=startTimeT.getTime();

	var dataTime=new Date();
	var curYear=dataTime.getFullYear();
	var curMonth=addZero(dataTime.getMonth()+1);
	var curDays=addZero(dataTime.getDate());
	var curTimeT=new Date(curYear,curMonth,curDays);
	var curTime=curYear+'-'+curMonth+'-'+curDays;
	/*结束时间搓*/
	var curTimeCuo=curTimeT.getTime();
	if (startTimeCuo>curTimeCuo) {
		$('#date_start').val(curTime);
	};
}
/*结束日期不能大于当前时间*/
function endTime(value){
	// var endTime=$('#date_end').val();
	var endArr=value.split('-');
	var endTimeT=new Date(endArr[0],endArr[1]-1,endArr[2]);
	/*开始结束时间搓*/
	var endTimeCuo=endTimeT.getTime();

	var dataTime=new Date();
	var curYear=dataTime.getFullYear();
	var curMonth=addZero(dataTime.getMonth()+1);
	var curDays=addZero(dataTime.getDate());
	var curTimeT=new Date(curYear,curMonth,curDays);
	var curTime=curYear+'-'+curMonth+'-'+curDays;
	/*结束时间搓*/
	var curTimeCuo=curTimeT.getTime();
	if (endTimeCuo>curTimeCuo) {
		$('#date_end').val(curTime);
	};
}