Blame view
src/pages/address/addressList.vue
5.71 KB
7d6833f2c 地址列表 |
1 2 3 4 5 6 7 8 9 |
<template> <view class="content"> <view v-if="addressList.length !== 0" class="list" > <view v-for="(item, index) in addressList" :key="index" |
7d6833f2c 地址列表 |
10 |
class="order-user" |
323398550 若干功能添加 |
11 |
@tap="toOrder(item.add_id)" |
081c50da0 取消订单返回修改 |
12 |
@longpress="delAddress(item.add_id)" |
7d6833f2c 地址列表 |
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
> <view class="order-user-head"> <view class="name"> <view v-if="item.default === '1'" class="default" ><text>默认</text></view>{{item.name}} </view> <text class="mobile">{{item.mobile}}</text> </view> <view class="order-user-body"> <image src="../../static/myorder-paying-location.png"></image> <text class="address">{{item.address.replace(/[-]/g,' ')}} {{item.add_detail}}</text> </view> <image |
ba260b3f9 修改 |
29 |
@click.stop="toEditAddress(item.add_id)" |
7d6833f2c 地址列表 |
30 31 32 33 34 |
v-if="item.default === '1'" class="arrow" src="../../static/right.png" ></image> <image |
ba260b3f9 修改 |
35 |
@click.stop="toEditAddress(item.add_id)" |
7d6833f2c 地址列表 |
36 37 38 39 40 41 42 43 44 45 46 47 |
v-else class="arrow pen" src="../../static/icon-pen.png" ></image> </view> </view> <view v-else class="empty" > 暂无收货地址 </view> |
081c50da0 取消订单返回修改 |
48 49 50 51 |
<button @tap="toAddAddress" class="add" >新建收货地址</button> |
7d6833f2c 地址列表 |
52 53 54 55 56 57 58 59 60 61 62 63 |
</view> </template> <script> import store from '@/store' export default { data () { return {} }, computed: { addressList () { return this.$store.state.address.list |
081c50da0 取消订单返回修改 |
64 |
}, |
7d6833f2c 地址列表 |
65 |
}, |
323398550 若干功能添加 |
66 67 68 69 |
onLoad ({ edit }) { if (edit) { this.edit = true } |
7301fd560 添加购物车默认样式 |
70 |
// store.dispatch('address/list') |
7d6833f2c 地址列表 |
71 |
}, |
ba260b3f9 修改 |
72 73 74 |
onShow() { store.dispatch('address/list') }, |
7d6833f2c 地址列表 |
75 |
methods: { |
4e9d88ff7 新建地址修改 |
76 77 78 79 80 81 |
toAddAddress() { console.log('aaaaa-a') uni.navigateTo({ url: 'addAddress', fail: (error) => { console.error('跳转出现错误', error) |
081c50da0 取消订单返回修改 |
82 |
}, |
4e9d88ff7 新建地址修改 |
83 84 |
}) }, |
081c50da0 取消订单返回修改 |
85 |
toEditAddress(addId) { |
7d6833f2c 地址列表 |
86 87 88 89 90 |
console.log('addId', addId) uni.navigateTo({ url: `addAddress?addId=${addId}`, fail: (error) => { console.error('跳转出现错误', error) |
081c50da0 取消订单返回修改 |
91 |
}, |
7d6833f2c 地址列表 |
92 |
}) |
323398550 若干功能添加 |
93 |
}, |
081c50da0 取消订单返回修改 |
94 |
toOrder(addId) { |
323398550 若干功能添加 |
95 |
if (this.edit) { |
081c50da0 取消订单返回修改 |
96 97 98 99 100 101 |
const pages = getCurrentPages() const prevPage = pages[pages.length - 2] // 上一个页面 const addressId = addId // console.log(addressId) prevPage.onShow(addressId) uni.navigateBack() |
ba260b3f9 修改 |
102 103 104 105 106 107 |
// uni.navigateTo({ // url: `../confirmOrder/confirmOrder?addressId=${addId}`, // fail: (error) => { // console.error('跳转出现错误', error) // } // }) |
323398550 若干功能添加 |
108 |
} |
081c50da0 取消订单返回修改 |
109 110 |
}, delAddress(addId) { |
c516ea051 删除地址修改 |
111 |
const that = this |
081c50da0 取消订单返回修改 |
112 113 114 115 116 |
uni.showModal({ title: '提示', content: '是否删除该条地址', success: function (res) { if (res.confirm) { |
c516ea051 删除地址修改 |
117 |
if (that.addressList.length > 1) { |
081c50da0 取消订单返回修改 |
118 119 120 121 122 123 124 125 126 127 128 129 |
store.dispatch('address/delete', { add_id: addId, }).then(() => { store.dispatch('address/list') uni.showToast({ title: '删除成功', duration: 1000, }) }) } else { uni.showToast({ title: '请保留至少一条地址信息', |
c516ea051 删除地址修改 |
130 |
icon: 'none', |
081c50da0 取消订单返回修改 |
131 132 133 134 135 136 137 138 |
duration: 1000, }) } } }, }) }, }, |
7d6833f2c 地址列表 |
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
} </script> <style lang="scss"> .content { min-height: 100vh; background-color: #f2f2f2; padding-top: 20rpx; padding-bottom: 112rpx; .order-user { width: 670rpx; height: 228rpx; background: #ffffff; border-radius: 14rpx; margin: 0 auto; margin-bottom: 20rpx; position: relative; .order-user-head { display: flex; height: 108rpx; width: 100%; align-items: center; |
ba260b3f9 修改 |
161 |
padding-left: 126rpx; |
081c50da0 取消订单返回修改 |
162 |
box-sizing: border-box; |
7d6833f2c 地址列表 |
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
.name { display: flex; justify-content: space-between; font-size: 14px; color: #333333; letter-spacing: -0.26px; margin-right: 20rpx; .default { height: 40rpx; width: 80rpx; background-color: #4a90e2; border-radius: 13px; border-radius: 13px; text-align: center; margin-right: 20rpx; text { |
156736a2e 样式修改 |
179 180 181 |
display: flex; justify-content: center; align-items: center; |
7d6833f2c 地址列表 |
182 183 184 |
font-size: 12px; color: #ffffff; letter-spacing: -0.23px; |
c516ea051 删除地址修改 |
185 |
line-height: 40rpx; |
7d6833f2c 地址列表 |
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 |
} } } .mobile { font-size: 14px; color: #999999; letter-spacing: -0.26px; } } .order-user-body { display: flex; width: 100%; image { width: 24px; height: 26px; margin: 12rpx 32rpx 0 40rpx; } .address { font-weight: bold; font-size: 14px; color: #333333; letter-spacing: -0.26px; } } .arrow { |
156736a2e 样式修改 |
211 |
width: 12px; |
7d6833f2c 地址列表 |
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 |
height: 12px; position: absolute; right: 40rpx; bottom: 104rpx; } } .empty { color: #666; font-size: 16px; text-align: center; padding-top: 30vh; } .add { position: fixed; bottom: 0; left: 0; height: 112rpx; width: 100%; background-color: #ff6b4a; display: flex; justify-content: center; align-items: center; font-size: 16px; color: #ffffff; letter-spacing: -0.3px; } } </style> |