263 lines
		
	
	
		
			5.3 KiB
		
	
	
	
		
			Vue
		
	
	
	
			
		
		
	
	
			263 lines
		
	
	
		
			5.3 KiB
		
	
	
	
		
			Vue
		
	
	
	
| <template>
 | |
| 	<view v-if="!loadding">
 | |
| 		<view v-if="listData.length > 0" class="pbenv">
 | |
| 			<view class="address-list">
 | |
| 				<view class="address-item" v-for="(item, index) in listData" :key="index">
 | |
| 					<view class="info flex-1 mb10">
 | |
| 						<view class="user f32 d-b-c">
 | |
| 							<text>{{ item.recName }}</text>
 | |
| 							<text class="ml20 gray3 f28">{{ item.recPhone }}</text>
 | |
| 						</view>
 | |
| 						<view class="pt20 f26 gray3" style="line-height: 1.5;">
 | |
| 							<view>{{ item.recArea }}</view>
 | |
| 							<view class="gray6">{{ item.recAddress }}</view>
 | |
| 						</view>
 | |
| 					</view>
 | |
| 					<view class="d-b-c">
 | |
| 						<view class="radio d-s-c">
 | |
| 							<radio style="transform:scale(0.6)" color="#FB3024" :checked="item.isDefault == 1" @click="radioChange(item.pkId)" />
 | |
| 							<text class="">{{ $t('w_0074') }}</text>
 | |
| 						</view>
 | |
| 						<view class="d-s-c">
 | |
| 							<view class="icon-box plus d-c-c ml30" @click="editAddress(item.pkId)">
 | |
| 								<image class="add_icon_img edit" src="/static/icon/add-edit.png" mode="aspectFill"></image>
 | |
| 							</view>
 | |
| 							<view class="icon-box plus d-c-c ml30" @click="delAddress(item.pkId)">
 | |
| 								<image class="add_icon_img delete" src="/static/icon/add-delete.png" mode="aspectFill"></image>
 | |
| 							</view>
 | |
| 						</view>
 | |
| 					</view>
 | |
| 				</view>
 | |
| 			</view>
 | |
| 			<view class="normal-sub-btn" @click="addAddress()">{{ $t('PER_DA_24') }}</view>
 | |
| 		</view>
 | |
| 		<view v-else>
 | |
| 			<view class="none_add"><image class="no_add" src="/static/no_adress.png" mode="aspectFill"></image></view>
 | |
| 			<view class="tc mb30 gray9 f28">{{ $t('w_0203') }}</view>
 | |
| 			<view class="normal-sub-btn" @click="addAddress()">{{ $t('w_0203') }}</view>
 | |
| 		</view>
 | |
| 	</view>
 | |
| </template>
 | |
| 
 | |
| <script>
 | |
| export default {
 | |
| 	data() {
 | |
| 		return {
 | |
| 			/*是否加载完成*/
 | |
| 			loadding: true,
 | |
| 			indicatorDots: true,
 | |
| 			autoplay: true,
 | |
| 			interval: 2000,
 | |
| 			duration: 500,
 | |
| 			/*数据*/
 | |
| 			listData: [],
 | |
| 			/*默认地址id*/
 | |
| 			default_id: '0',
 | |
| 			options: {}
 | |
| 		};
 | |
| 	},
 | |
| 	onLoad: function(options) {
 | |
| 		this.options = options;
 | |
| 	},
 | |
| 	onShow: function() {
 | |
| 		uni.showLoading({
 | |
| 			title:this.$t('MN_F_6')
 | |
| 		});
 | |
| 		/*获取地址列表*/
 | |
| 		this.getData();
 | |
| 	},
 | |
| 	methods: {
 | |
| 		/*获取数据*/
 | |
| 		getData() {
 | |
| 			let self = this;
 | |
| 			let dataType = self.dataType;
 | |
| 			self.loadding = true;
 | |
| 			self._get('member/api/member-address/list', {}, function(res) {
 | |
| 				self.listData = res.data;
 | |
| 				// self.default_id = res.data.default_id + '';
 | |
| 				self.loadding = false;
 | |
| 				uni.hideLoading();
 | |
| 			});
 | |
| 		},
 | |
| 
 | |
| 		/*跳转页面*/
 | |
| 		addAddress() {
 | |
| 			let delta = 1;
 | |
| 			if (this.options.source === 'order') {
 | |
| 				delta = 2;
 | |
| 			}
 | |
| 			this.gotoPage('/pages/user/address/add?delta=' + delta);
 | |
| 		},
 | |
| 
 | |
| 		/*点击单选*/
 | |
| 		radioChange(e) {
 | |
| 			console.log(e)
 | |
| 			let self = this;
 | |
| 			// self.default_id = e;
 | |
| 			self._put(
 | |
| 				'member/api/member-address/default/',
 | |
| 				e,
 | |
| 				function(res) {
 | |
| 					if (self.options.source === 'order') {
 | |
| 						// #ifndef H5
 | |
| 						uni.navigateBack();
 | |
| 						// #endif
 | |
| 						// #ifdef H5
 | |
| 						history.go(-1);
 | |
| 						// #endif
 | |
| 					} else {
 | |
| 						// self.listData=[];
 | |
| 						self.getData();
 | |
| 					}
 | |
| 				}
 | |
| 			);
 | |
| 			return false;
 | |
| 		},
 | |
| 
 | |
| 		/*编辑地址*/
 | |
| 		editAddress(e) {
 | |
| 			this.gotoPage('/pages/user/address/edit?pkId=' + e);
 | |
| 		},
 | |
| 
 | |
| 		/*删除地址*/
 | |
| 		delAddress(e) {
 | |
| 			let self = this;
 | |
| 			uni.showModal({
 | |
| 				title: self.$t('w_0034'),
 | |
| 				content: self.$t('w_0088'),
 | |
| 				success: function(o) {
 | |
| 					if (o.confirm) {
 | |
| 						uni.showLoading({
 | |
| 							title: 'Loading....'
 | |
| 						})
 | |
| 						self._delete(
 | |
| 							'member/api/member-address/'+e,{},
 | |
| 							function(result) {
 | |
| 								uni.hideLoading();
 | |
| 								uni.showToast({
 | |
| 									title: self.$t('w_0089'),
 | |
| 									duration: 2000
 | |
| 								});
 | |
| 								self.listData = [];
 | |
| 								self.getData();
 | |
| 							}, err => {
 | |
| 								uni.hideLoading();
 | |
| 							}
 | |
| 						);
 | |
| 					}
 | |
| 				}
 | |
| 			});
 | |
| 		}
 | |
| 	}
 | |
| };
 | |
| </script>
 | |
| 
 | |
| <style lang="scss">
 | |
| page {
 | |
| 	background: #f2f2f2;
 | |
| }
 | |
| 
 | |
| .address-list {
 | |
| 	padding-bottom: 90rpx;
 | |
| }
 | |
| 
 | |
| .address-item {
 | |
| 	background: #ffffff;
 | |
| 	border-radius: 0;
 | |
| 	padding: 28rpx 30rpx;
 | |
| 	margin-bottom: 21rpx;
 | |
| }
 | |
| 
 | |
| .foot-btns {
 | |
| 	padding: 0;
 | |
| }
 | |
| 
 | |
| .foot-btns .btn-red {
 | |
| 	width: 100%;
 | |
| 	height: 90rpx;
 | |
| 	line-height: 90rpx;
 | |
| 	border-radius: 0;
 | |
| }
 | |
| 
 | |
| .none_add {
 | |
| 	padding: 214rpx 0 60rpx 0;
 | |
| }
 | |
| 
 | |
| .no_add {
 | |
| 	width: 362rpx;
 | |
| 	height: 285rpx;
 | |
| 	margin: 0 auto;
 | |
| }
 | |
| 
 | |
| .no_add_add {
 | |
| 	width: 320rpx;
 | |
| 	height: 80rpx;
 | |
| 	border: 2rpx solid #fb3024;
 | |
| 	border-radius: 15rpx;
 | |
| 	text-align: center;
 | |
| 	line-height: 80rpx;
 | |
| 	font-size: 32rpx;
 | |
| 	font-family: PingFang SC;
 | |
| 	font-weight: 500;
 | |
| 	border-color: #fb3024;
 | |
| 	color: #fb3024;
 | |
| 	margin: 0 auto;
 | |
| }
 | |
| 
 | |
| .add_add {
 | |
| 	height: 64rpx;
 | |
| 	line-height: 64rpx;
 | |
| 	font-size: 26rpx;
 | |
| 	font-family: PingFang SC;
 | |
| 	font-weight: 500;
 | |
| 	color: #fb3024;
 | |
| 	padding: 0 35rpx;
 | |
| 	border-bottom: 1rpx solid #fb3024;
 | |
| }
 | |
| 
 | |
| .defaul_add {
 | |
| 	background: #fb3024;
 | |
| 	font-size: 22rpx;
 | |
| 	font-family: PingFang SC;
 | |
| 	font-weight: 500;
 | |
| 	color: #ffffff;
 | |
| }
 | |
| 
 | |
| .add_icon_img.edit {
 | |
| 	width: 34rpx;
 | |
| 	height: 34rpx;
 | |
| }
 | |
| 
 | |
| .add_icon_img.delete {
 | |
| 	width: 34rpx;
 | |
| 	height: 34rpx;
 | |
| }
 | |
| 
 | |
| .none_line {
 | |
| 	width: 1rpx;
 | |
| 	height: 44rpx;
 | |
| 	background: #d9d9d9;
 | |
| }
 | |
| 
 | |
| .add_add-btn {
 | |
| 	position: fixed;
 | |
| 	bottom: calc(env(safe-area-inset-bottom) + 20rpx);
 | |
| 	width: 690rpx;
 | |
| 	margin: 20rpx 30rpx;
 | |
| 	box-sizing: border-box;
 | |
| 	font-size: 28rpx;
 | |
| 	height: 80rpx;
 | |
| 	border-radius: 15rpx;
 | |
| 	display: flex;
 | |
| 	justify-content: center;
 | |
| 	align-items: center;
 | |
| 	background-color: #fb3024;
 | |
| 	color: #fff;
 | |
| }
 | |
| 
 | |
| .pbenv {
 | |
| 	padding-bottom: calc(env(safe-area-inset-bottom) + 120rpx);
 | |
| 	box-sizing: border-box;
 | |
| }
 | |
| </style>
 |