address_list.html 8.91 KB
<!DOCTYPE html >
<html>

<head>
	<meta name="Generator" content="tpshop" />
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width">
	<title>地址列表-{$tpshop_config['shop_info_store_title']}</title>
	<meta http-equiv="keywords" content="{$tpshop_config['shop_info_store_keyword']}" />
	<meta name="description" content="{$tpshop_config['shop_info_store_desc']}" />
	<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
	<link rel="stylesheet" href="__STATIC__/css/public.css">
	<link rel="stylesheet" href="__STATIC__/css/user.css">
	<script src="__STATIC__/js/layer.js"></script>
	<script type="text/javascript" src="__STATIC__/js/jquery.js"></script>
	<script src="__PUBLIC__/js/global.js"></script>
	<script src="__PUBLIC__/js/mobile_common.js"></script>
</head>
<style>

	.list_footers a{
		display: block;
		width: 50%;
		border-radius: 20px;
		height: 30px;
		line-height: 30px;
		background:rgb(239, 22, 51) ;
		font-size: 16px;
		margin: auto;
		color: #fff;
		text-align: center;
	}
	.address_add{
		width: 100%;
		padding: 15px 20px;
	}
	.address_add dl{
		border-bottom: none;
		width: 81%;
	}
	.address_add dl dt em{
		float: none;
		font-weight: bold;
	}
	.morendizhi{
		background:rgb(239, 22, 51);
		padding: 2px 5px;
		color: #fff;
		text-align: center;
		border-radius: 5px;
		font-size: 10px;
	}
	.address_add dl dt span{
		width: 50px;
	}

	.addressmone .add_def, .operation .add_def{width: 20px;height: 20px;border: 1px solid #eee!important;background-color: #fff;
		border-radius: 50%;-moz-border-radius:50%;-webkit-border-radius: 50%; vertical-align: middle;display: inline-block;*display: inline;*zoom: 1;}
	.address_add dl dd {
		line-height: 15px;
	}
	.operation-frame{
		margin: 0px 0px;
		border-bottom: 1px solid #eee;
	}
	.add_class{
		max-height: 28px;
		height: auto;
		margin-bottom: 10px;
	}
	.operationBtn{
		padding-top: 10px;
	}
	.list_footers{
		width: 100%;
		height: 75px;
		background: #FFF;
		position: fixed;
		bottom: 0px;
		max-width: 720px;
	}


</style>

<body style="overflow-x: hidden;">

<include file="public/menu" />
<include file="public/navBall" />
<div id="tbh5v0" style="overflow-x: hidden;">
	<dl style="line-height: 40px; border-bottom: #eee solid 1px;background: url(__STATIC__/images/distribut/left.png) no-repeat 95% center;background-size: 11px 20px; display: none"  id="btnwxaddress">

		<img src="__STATIC__/images/user/wximg.png" style="width: 20px;height: 20px; padding-left: 5px;" />
		<span>获取微信收货地址</span>

	</dl>
	<!--没有地址时显示-->
	<div class="map">
		<img src="__STATIC__/images/user/map.png" />
		<p>您还没有添加收货地址</p>
	</div>
	<div id="ajaxreturn">

		<volist name="lists" id="list">
			<div class="address_add flex ai_center operation-frame" aid="{$list.address_id}">
			<!--	<div class="operation" aid="{$list.address_id}">
					&lt;!&ndash;<div class="add_def <if condition='$list.is_default eq 1'>add_def_on</if>"></div>&ndash;&gt;
				</div>-->
				<div class="flex ai_center" style="width: 95%">
					<dl class="operation" aid="{$list[address_id]}">
						<dt class="flex ai_center"><span>{$list.consignee}</span><em>{$list.mobile}</em> <if condition='$list.is_default eq 1'><div class="morendizhi">默认地址</div></if></dt>
						<dd class="ellipsis-2 add_class">{$list.more_address}<br/>{$list.address}</dd>
					</dl>
					<div class="operationBtn">
						<a href="{:U('/Mobile/User/edit_address',array('stoid'=>$Think.request.stoid,'id'=>$list[address_id],'source'=>$Request.param.source))}">
							<img src="__STATIC__/images/user_card/zantian.png" style="width:20px;" />
						</a>
						<!--<a onclick="deladdress(this)" aid="{$list.address_id}">
						<img src="__STATIC__/images/user/del.png" style="width: 19px;height: 20px;" /><i>删除</i>
						</a>-->
					</div>
					<p class="clear"></p>
				</div>
			</div>
		</volist>



	</div>
</div>

<div style=" width:100%; height:50px;"></div>
<div class="list_footers flex ai_center">
	<a href="{:U('/Mobile/User/add_address',array('stoid'=>$Think.request.stoid,'source'=>$Request.param.source,'stoid'=>$Think.request.stoid))}">+新建收货地址</a>
</div>
<input id="fstoid" type="hidden" value="{$Think.request.stoid}"/>
<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script>
	var wxstoid={$Think.request.stoid};
	$(function() {

		var str = $(".address_add").text();
		if (str.length == 0) {
			$(".map").removeClass("dn");
		} else {
			$(".map").addClass("dn");
		}


		if(isWeiXin()){

			$.ajax({
				type : "POST",
				url:"/index.php?m=Mobile&c=Index&a=ajaxGetWxConfig&stoid="+wxstoid+"&t="+Math.random(),
				data:{'askUrl':encodeURIComponent(location.href.split('#')[0])},
				dataType:'JSON',
				success: function(res)
				{
					wx.config({
						debug: false,
						appId: res.appId,
						timestamp: res.timestamp,
						nonceStr: res.nonceStr,
						signature: res.signature,
						jsApiList: ['openAddress'] // 功能列表,我们要使用JS-SDK的什么功能
					});
					$("#btnwxaddress").show();

					wx.ready(function () {
						$('#btnwxaddress').click(function(){
							wx.openAddress({
								success: function (res) {
									var userName = res.userName; // 收货人姓名
									var postalCode = res.postalCode; // 邮编
									var provinceName = res.provinceName; // 国标收货地址第一级地址(省)
									var cityName = res.cityName; // 国标收货地址第二级地址(市)
									var countryName = res.countryName; // 国标收货地址第三级地址(国家)
									var detailInfo = res.detailInfo; // 详细收货地址信息
									var nationalCode = res.nationalCode; // 收货地址国家码
									var telNumber = res.telNumber; // 收货人手机号码

									//
									var mm=layer.open({content:'加载中',time:2});
									$.ajax({
										type: "POST",
										url: '/index.php/Mobile/user/addwx_address/stoid/'+wxstoid,
										data: {'userName':userName,'postalCode':postalCode,'provinceName':provinceName,'cityName':cityName,'countryName':countryName,'detailInfo':detailInfo,'telNumber':telNumber},
										dataType: "json",
										success: function (data) {
											layer.close(mm);
											if (data.code ==0) {
												window.location.href=window.location.href;

											}else{
												layer.open({content:data.msg,time:2});
											}

										},
										error: function () {
											layer.close(mm);
											layer.open({
												content: '网络异常',
												time: 2
											});
										}
									});
									//

								}
							});
						});


					});


				},
				error:function(){
					return false;
				}
			});

		}

	});

	$(".operation").click(function(){
		var ooj=$(this);
		var id=ooj.attr("aid");
		var mm = layer.open({
			type: 2
		});
		$.ajax({
			type: "POST",
			url: '/index.php/Mobile/user/set_default/stoid/' + $("#fstoid").val() +"/id/"+id,
			data: $('#cart2_form').serialize(),
			dataType: "json",
			success: function (data) {
				layer.close(mm);
				if (data.code ==0) {
					$(".add_def").removeClass("add_def_on");
					$(".operation i").removeClass("red");
					$(".operation i").addClass("def");
					$(".operation i").text("设为默认");
					ooj.find(".add_def").addClass("add_def_on");
					ooj.find("i").removeClass("def");
					ooj.find("i").addClass("red");
					ooj.find("i").text("默认地址");
					window.location.href=window.location.href;

				}else{
					layer.open({content:data.msg,time:2});
				}

			},
			error: function () {
				layer.open({
					content: '网络异常',
					time: 2
				});
			}
		});
	});

	function goTop() {
		$('html,body').animate({
			'scrollTop': 0
		}, 600);
	}
	
	/*--删除地址--*/
	function deladdress(ob) {
		var id=$(ob).attr("aid");

		var ii = layer.open({
			type: 2,
			content: '正在删除',
			shadeClose: false
		});
		$.ajax({
			type: "POST",
			url: '/index.php/Mobile/user/deladdress/stoid/' + $("#fstoid").val() +"/id/"+id,
			dataType: "json",
			success: function (data) {
				layer.close(ii);
				var ii2 = layer.open({
					type: 2,
					shadeClose: false
				});
				$.ajax({
					type: "POST",
					url: '/index.php/Mobile/user/ajaxaddressreturn/stoid/' + $("#fstoid").val(),
					dataType: "json",
					success: function (data) {
						layer.close(ii2);
						$("#ajaxreturn").html(data);
						if($.trim(data)==""){
							$(".map").removeClass("dn");
						}
						window.location.href=window.location.href;
					},
					error: function () {
						layer.close(ii2);
						layer.open({content: '网络异常',time: 2});
					}
				});

			},
			error: function () {
				layer.open({
					content: '网络异常',
					time: 2
				});
			}
		});

	}



	function isWeiXin(){
		var ua = window.navigator.userAgent.toLowerCase();
		if(ua.match(/MicroMessenger/i) == 'micromessenger'){
			return true;
		}else{
			return false;
		}
	}
</script>
<a href="javascript:goTop();" class="gotop"><img src="__STATIC__/images/topup.png"></a>
</div>
</body>
</html>