quanwei
2025-10-29 76ed09d116f484b261d44219de300b79eb2013b3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
<template>
    <view v-if="!loadding" :data-theme='theme()' :class="theme() || ''">
        <view v-if="listData.length>0" class="pbenv">
            <view class="address-list bg-white">
                <view class="tr add_add" @click="addAddress()">新增收货地址</view>
                <view class="address p-30-0 d-s-c border-b-d" v-for="(item,index) in listData" :key="index">
                    <view class="radio">
                        <radio style="transform:scale(0.8)" color='#F6220C' :value="item.address_id+''" :checked="default_id==item.address_id+''"
                         @click="radioChange(item.address_id)" />
                    </view>
                    <view class="info flex-1 ml20" @click="radioChange(item.address_id)">
                        <view class="user f32">
                            <text>{{item.name}}</text>
                            <text class="ml20 gray9 f26">{{item.phone}}</text>
                            <text class="ml20 defaul_add" v-if="default_id==item.address_id">默认</text>
                        </view>
                        <view class="pt20 f26 gray3">
                            {{item.region.province}}{{item.region.city}}{{item.region.region}}{{item.detail}}
                        </view>
                    </view>
                    <view class="icon-box plus d-c-c ml30" @click="delAddress(item.address_id)">
                        <image class="add_icon_img" src="../../../static/icon/delete.png" mode=""></image>
                    </view>
                    <view class="none_line ml30"></view>
                    <view class="icon-box plus d-c-c ml30 mr40" @click="editAddress(item.address_id)">
                        <image class="add_icon_img" src="../../../static/icon/edit.png" mode=""></image>
                    </view>
 
                </view>
            </view>
        </view>
        <view v-else>
            <view class="none_add">
                <image class="no_add" src="../../../static/no_adress.png" mode=""></image>
            </view>
            <view class="no_add_add" @click="addAddress()">新增收货地址</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.getData();
        },
        methods: {
            /*获取数据*/
            getData() {
                let self = this;
                let dataType = self.dataType;
                self._get('user.address/lists', {}, function(res) {
                    self.listData = res.data.list;
                    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/add?delta=' + delta);
            },
 
            /*点击单选*/
            radioChange(e) {
                let self = this;
                self.default_id = e;
                self._post('user.address/setDefault', {
                    address_id: e,
                }, function(res) {
                    if (self.options.source === 'order') {
                        // #ifndef H5
                        uni.navigateBack();
                        // #endif
                        // #ifdef H5
                        history.go(-1);
                        // #endif
                    }
                });
                return false;
 
            },
 
            /*编辑地址*/
            editAddress(e) {
                let delta = 1;
                if (this.options.source === 'order') {
                    delta = 2;
                }
                this.gotoPage('/pages/user/address/edit/edit?address_id=' + e + '&delta=' + delta);
            },
 
            /*删除地址*/
            delAddress(e) {
                let self = this;
                wx.showModal({
                    title: "提示",
                    content: "您确定要移除当前收货地址吗?",
                    success: function(o) {
                        o.confirm && self._get('user.address/delete', {
                            address_id: e
                        }, function(result) {
                            if (result.code == 1) {
                                uni.showToast({
                                    title: '删除成功',
                                    duration: 2000
                                });
                                self.getData();
                            }
 
                        });
                    }
                });
 
            }
        }
    }
</script>
 
<style lang="scss">
    page {
        background-color: #FFFFFF;
    }
 
    .address-list {
        border-top: 16rpx solid #F2F2F2;
        padding: 0 20rpx;
        padding-bottom: 90rpx;
    }
 
    .foot-btns {
        padding: 0;
    }
 
    .foot-btns .btn-red {
        width: 100%;
        height: 90rpx;
        line-height: 90rpx;
        border-radius: 0;
    }
 
    .none_add {
        padding: 314rpx 214rpx 60rpx 214rpx;
    }
 
    .no_add {
        width: 322rpx;
        height: 180rpx;
    }
 
    .no_add_add {
        width: 320rpx;
        height: 80rpx;
        border: 2rpx solid #FFB7B7;
        border-radius: 40rpx;
        text-align: center;
        line-height: 80rpx;
        font-size: 32rpx;
        font-family: PingFang SC;
        font-weight: 500;
        @include font_color('font_color');
        @include border_color('border_color');
        margin: 0 auto;
    }
 
    .add_add {
        height: 64rpx;
        line-height: 64rpx;
        font-size: 26rpx;
        font-family: PingFang SC;
        font-weight: 500;
        color: #0777CD;
        padding: 0 35rpx;
        border-bottom: 1rpx solid #D9D9D9;
    }
 
    .defaul_add {
        padding: 9rpx 14rpx 10rpx 15rpx;
        @include background_color('bg-op');
        font-size: 22rpx;
        font-family: PingFang SC;
        font-weight: 500;
        color: #F6220C;
        @include font_color('font_color');
    }
 
    .add_icon_img {
        width: 30rpx;
        height: 30rpx;
    }
 
    .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: 40rpx;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    .pbenv{
        padding-bottom: calc(env(safe-area-inset-bottom) + 120rpx);
        box-sizing: border-box;
    }
</style>