You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							211 lines
						
					
					
						
							5.0 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							211 lines
						
					
					
						
							5.0 KiB
						
					
					
				
								<template>
							 | 
						|
								<view id="address-list">
							 | 
						|
								    <view class="list-box">
							 | 
						|
								        <view class="list-item" :data-info="JSON.stringify(item)" :data-id="item.id" v-for="(item, index) in list" :key="index">
							 | 
						|
								            <!-- <view class="user">
							 | 
						|
								                <view class="name">
							 | 
						|
								                    <text>{{item.accept_name}}</text>
							 | 
						|
								                    <text class="phone">{{item.mobile}}</text>
							 | 
						|
								                </view>
							 | 
						|
								                <view class="default" v-if="item.is_default">
							 | 
						|
								                    默认
							 | 
						|
								                </view>
							 | 
						|
								            </view>
							 | 
						|
								            <view class="address">{{item.address_name}} {{item.address}}</view> -->
							 | 
						|
											
							 | 
						|
											<view class="lf-font-28 user-item" @tap="setInfo(item)">
							 | 
						|
												<text class="lf-color-black lf-font-bold">{{item.accept_name}}</text>
							 | 
						|
												<text class="lf-color-777 lf-m-l-20">{{item.mobile}}</text>
							 | 
						|
											</view>
							 | 
						|
											<view class="address-item lf-line-2" @tap="setInfo(item)">
							 | 
						|
												<text>{{item.address_name}}</text>
							 | 
						|
												<text>{{item.address}}</text>
							 | 
						|
											</view>
							 | 
						|
											<view class="menu-item lf-row-between lf-m-t-30">
							 | 
						|
												<view class="lf-row-center">
							 | 
						|
													<checkbox></checkbox>
							 | 
						|
													<text class="lf-m-l-15 lf-font-24 lf-color-777">默认地址</text>
							 | 
						|
												</view>
							 | 
						|
												<view class="lf-row-between">
							 | 
						|
													<view>
							 | 
						|
														<text class="lf-iconfont icon--1"></text>
							 | 
						|
														<text class="lf-m-l-10">编辑</text>
							 | 
						|
													</view>
							 | 
						|
													<view class="lf-m-l-50">
							 | 
						|
														<text class="lf-iconfont icon--1"></text>
							 | 
						|
														<text class="lf-m-l-10">删除</text>
							 | 
						|
													</view>
							 | 
						|
												</view>
							 | 
						|
											</view>
							 | 
						|
								        </view>
							 | 
						|
								    </view>
							 | 
						|
									
							 | 
						|
									<view class="add-address" @tap="add">
							 | 
						|
									    <view class="small-btn">
							 | 
						|
									    	<text class="lf-iconfont icon--2"></text>
							 | 
						|
									    	<text class="lf-m-l-10">新增收货地址</text>
							 | 
						|
									    </view>
							 | 
						|
									</view>
							 | 
						|
								</view>
							 | 
						|
								
							 | 
						|
								</template>
							 | 
						|
								<script>
							 | 
						|
								import {pageLogin, getUrl,config,is} from '@/common/js/utils.js';
							 | 
						|
								
							 | 
						|
								export default {
							 | 
						|
								  data() {
							 | 
						|
								    return {
							 | 
						|
								      list: [{
							 | 
						|
										  accept_name: '加号',
							 | 
						|
										  mobile: '12373873873',
							 | 
						|
										  address_name: '广西南宁',
							 | 
						|
										  address: '细丝里流向17号',
							 | 
						|
										  is_default: true
							 | 
						|
									  },{
							 | 
						|
										  accept_name: '加号',
							 | 
						|
										  mobile: '12373873873',
							 | 
						|
										  address_name: '广西南宁',
							 | 
						|
										  address: '细丝里流向17号',
							 | 
						|
										  is_default: true
							 | 
						|
									  }],
							 | 
						|
								      order_no: '',
							 | 
						|
								      url: '',
							 | 
						|
									  id:''
							 | 
						|
								    };
							 | 
						|
								  },
							 | 
						|
								
							 | 
						|
								  onShow() {
							 | 
						|
								    this.queryAddressList(); // let app =getApp(); 暂时注释
							 | 
						|
									
							 | 
						|
								    // app.isBirthday().then(()=>{
							 | 
						|
								    //     if(this.$cookieStorage.get("birthday_gift")){
							 | 
						|
								    //         var giftData=this.$cookieStorage.get("birthday_gift").data;
							 | 
						|
								    //         new app.ToastPannel().__page.showText(giftData);
							 | 
						|
								    //     }
							 | 
						|
								    // });
							 | 
						|
								  },
							 | 
						|
								
							 | 
						|
								  onLoad(e) {
							 | 
						|
									  // 暂时注释
							 | 
						|
								    pageLogin(getUrl());
							 | 
						|
								    this.setData({
							 | 
						|
								      order_no: e.order_no,
							 | 
						|
								      url: e.url
							 | 
						|
								    });
							 | 
						|
								  },
							 | 
						|
								
							 | 
						|
								  components: {},
							 | 
						|
								  props: {},
							 | 
						|
								  methods: {
							 | 
						|
								    setInfo(e) {
							 | 
						|
								      // var from = e.currentTarget.dataset.info;
							 | 
						|
									  var from = e;
							 | 
						|
								      var data = this.$cookieStorage.get('order_form');
							 | 
						|
									  // var from=JSON.parse(from);
							 | 
						|
									 
							 | 
						|
								      if (!data) {
							 | 
						|
								        return this.view(from.id);
							 | 
						|
								      }
							 | 
						|
								
							 | 
						|
								      var order_no = this.order_no;
							 | 
						|
								
							 | 
						|
								      if (order_no && data.order_no === order_no) {
							 | 
						|
								        data.address = from;
							 | 
						|
								        this.$cookieStorage.set('order_form', data);
							 | 
						|
								        wx.navigateBack({
							 | 
						|
								          url: '/' + this.url
							 | 
						|
								        });
							 | 
						|
								      } else {
							 | 
						|
								        return this.view(from.id);
							 | 
						|
								      }
							 | 
						|
								    },
							 | 
						|
								
							 | 
						|
								    view(id) {
							 | 
						|
								      wx.navigateTo({
							 | 
						|
								        url: '/pages/address/add/add?id=' + id
							 | 
						|
								      });
							 | 
						|
								    },
							 | 
						|
								
							 | 
						|
								    add() {
							 | 
						|
								      wx.navigateTo({
							 | 
						|
								        url: '/pages/address/add/add'
							 | 
						|
								      });
							 | 
						|
								    },
							 | 
						|
								
							 | 
						|
								    // 查询收货地址列表
							 | 
						|
								    queryAddressList() {
							 | 
						|
								      var token = this.$cookieStorage.get('user_token');
							 | 
						|
								      this.$http.get({
							 | 
						|
								        api: 'api/address',
							 | 
						|
								        header: {
							 | 
						|
								          Authorization: token
							 | 
						|
								        }
							 | 
						|
								      }).then(res => {
							 | 
						|
								        if (res.statusCode == 200) {
							 | 
						|
								          res = res.data;
							 | 
						|
								
							 | 
						|
								          if (res.status) {
							 | 
						|
								            this.setData({
							 | 
						|
								              list: res.data
							 | 
						|
								            });
							 | 
						|
								          } else {
							 | 
						|
								            wx.showToast({
							 | 
						|
								              title: res.message,
							 | 
						|
								              image: '../../../static/error.png'
							 | 
						|
								            });
							 | 
						|
								          }
							 | 
						|
								        } else {
							 | 
						|
								          wx.showToast({
							 | 
						|
								            title: '获取信息失败',
							 | 
						|
								            image: '../../../static/error.png'
							 | 
						|
								          });
							 | 
						|
								        }
							 | 
						|
								      });
							 | 
						|
								    },
							 | 
						|
								
							 | 
						|
								    setData: function (obj) {
							 | 
						|
								      let that = this;
							 | 
						|
								      let keys = [];
							 | 
						|
								      let val, data;
							 | 
						|
								      Object.keys(obj).forEach(function (key) {
							 | 
						|
								        keys = key.split('.');
							 | 
						|
								        val = obj[key];
							 | 
						|
								        data = that.$data;
							 | 
						|
								        keys.forEach(function (key2, index) {
							 | 
						|
								          if (index + 1 == keys.length) {
							 | 
						|
								            that.$set(data, key2, val);
							 | 
						|
								          } else {
							 | 
						|
								            if (!data[key2]) {
							 | 
						|
								              that.$set(data, key2, {});
							 | 
						|
								            }
							 | 
						|
								          }
							 | 
						|
								
							 | 
						|
								          data = data[key2];
							 | 
						|
								        });
							 | 
						|
								      });
							 | 
						|
								    }
							 | 
						|
								  },
							 | 
						|
								  computed: {},
							 | 
						|
								  watch: {}
							 | 
						|
								};
							 | 
						|
								</script>
							 | 
						|
								
							 | 
						|
								<style>
							 | 
						|
									page{
							 | 
						|
										background-color: #F8F8F8;
							 | 
						|
									}
							 | 
						|
								</style>
							 | 
						|
								<style rel="stylesheet/less" lang="less">
							 | 
						|
								    @import "list";
							 | 
						|
									
							 | 
						|
									.user-item, .menu-item{
							 | 
						|
										height: 50rpx;
							 | 
						|
										width: 100%;
							 | 
						|
									}
							 | 
						|
									.address-item{
							 | 
						|
										width: 100%;
							 | 
						|
										margin-top: 10rpx;
							 | 
						|
										font-size: 28rpx;
							 | 
						|
										color: #333333;
							 | 
						|
									}
							 | 
						|
								</style>
							 |