Commit 081c50da0c980cda815ab8a67a9304d9cc091194
1 parent
c00c258098
Exists in
master
取消订单返回修改
Showing
7 changed files
with
138 additions
and
50 deletions
Show diff stats
src/pages/address/addressList.vue
... | ... | @@ -9,6 +9,7 @@ |
9 | 9 | :key="index" |
10 | 10 | class="order-user" |
11 | 11 | @tap="toOrder(item.add_id)" |
12 | + @longpress="delAddress(item.add_id)" | |
12 | 13 | > |
13 | 14 | <view class="order-user-head"> |
14 | 15 | <view class="name"> |
... | ... | @@ -43,7 +44,10 @@ |
43 | 44 | > |
44 | 45 | 暂无收货地址 |
45 | 46 | </view> |
46 | - <button @tap="toAddAddress" class="add">新建收货地址</button> | |
47 | + <button | |
48 | + @tap="toAddAddress" | |
49 | + class="add" | |
50 | + >新建收货地址</button> | |
47 | 51 | </view> |
48 | 52 | </template> |
49 | 53 | |
... | ... | @@ -56,7 +60,7 @@ export default { |
56 | 60 | computed: { |
57 | 61 | addressList () { |
58 | 62 | return this.$store.state.address.list |
59 | - } | |
63 | + }, | |
60 | 64 | }, |
61 | 65 | onLoad ({ edit }) { |
62 | 66 | if (edit) { |
... | ... | @@ -74,26 +78,26 @@ export default { |
74 | 78 | url: 'addAddress', |
75 | 79 | fail: (error) => { |
76 | 80 | console.error('跳转出现错误', error) |
77 | - } | |
81 | + }, | |
78 | 82 | }) |
79 | 83 | }, |
80 | - toEditAddress (addId) { | |
84 | + toEditAddress(addId) { | |
81 | 85 | console.log('addId', addId) |
82 | 86 | uni.navigateTo({ |
83 | 87 | url: `addAddress?addId=${addId}`, |
84 | 88 | fail: (error) => { |
85 | 89 | console.error('跳转出现错误', error) |
86 | - } | |
90 | + }, | |
87 | 91 | }) |
88 | 92 | }, |
89 | - toOrder (addId) { | |
93 | + toOrder(addId) { | |
90 | 94 | if (this.edit) { |
91 | - let pages = getCurrentPages(); | |
92 | - let prevPage = pages[pages.length - 2]; //上一个页面 | |
93 | - const addressId=addId | |
94 | - // console.log(addressId) | |
95 | - prevPage.onShow(addressId); | |
96 | - uni.navigateBack(); | |
95 | + const pages = getCurrentPages() | |
96 | + const prevPage = pages[pages.length - 2] // 上一个页面 | |
97 | + const addressId = addId | |
98 | + // console.log(addressId) | |
99 | + prevPage.onShow(addressId) | |
100 | + uni.navigateBack() | |
97 | 101 | // uni.navigateTo({ |
98 | 102 | // url: `../confirmOrder/confirmOrder?addressId=${addId}`, |
99 | 103 | // fail: (error) => { |
... | ... | @@ -101,8 +105,34 @@ export default { |
101 | 105 | // } |
102 | 106 | // }) |
103 | 107 | } |
104 | - } | |
105 | - } | |
108 | + }, | |
109 | + delAddress(addId) { | |
110 | + uni.showModal({ | |
111 | + title: '提示', | |
112 | + content: '是否删除该条地址', | |
113 | + success: function (res) { | |
114 | + if (res.confirm) { | |
115 | + if (this.addressList.length > 1) { | |
116 | + store.dispatch('address/delete', { | |
117 | + add_id: addId, | |
118 | + }).then(() => { | |
119 | + store.dispatch('address/list') | |
120 | + uni.showToast({ | |
121 | + title: '删除成功', | |
122 | + duration: 1000, | |
123 | + }) | |
124 | + }) | |
125 | + } else { | |
126 | + uni.showToast({ | |
127 | + title: '请保留至少一条地址信息', | |
128 | + duration: 1000, | |
129 | + }) | |
130 | + } | |
131 | + } | |
132 | + }, | |
133 | + }) | |
134 | + }, | |
135 | + }, | |
106 | 136 | } |
107 | 137 | </script> |
108 | 138 | |
... | ... | @@ -126,7 +156,7 @@ export default { |
126 | 156 | width: 100%; |
127 | 157 | align-items: center; |
128 | 158 | padding-left: 126rpx; |
129 | - box-sizing: border-box; | |
159 | + box-sizing: border-box; | |
130 | 160 | .name { |
131 | 161 | display: flex; |
132 | 162 | justify-content: space-between; | ... | ... |
src/pages/confirmOrder/confirmOrder.vue
... | ... | @@ -21,7 +21,7 @@ |
21 | 21 | <view |
22 | 22 | v-else |
23 | 23 | @tap="toaddAddress" |
24 | - class="list order-user" | |
24 | + :class="addressInfo !== false ? 'list order-user' : 'list order-user user_address'" | |
25 | 25 | > |
26 | 26 | <view |
27 | 27 | class="order-user-head" |
... | ... | @@ -40,16 +40,20 @@ |
40 | 40 | </view> |
41 | 41 | <view |
42 | 42 | class="order-user-body" |
43 | - v-if="addressInfo != false" | |
43 | + v-if="addressInfo !== false" | |
44 | 44 | > |
45 | 45 | <image src="../../static/myorder-paying-location.png"></image> |
46 | 46 | <text class="address">{{addressInfo.address}}\n{{addressInfo.add_detail}}</text> |
47 | 47 | </view> |
48 | 48 | <view |
49 | - class="order-user-body" | |
49 | + class="order_user_body_add" | |
50 | 50 | v-if="addressInfo == false" |
51 | 51 | > |
52 | - <text class="address">点击添加地址</text> | |
52 | + <image | |
53 | + src="../../static/add_address.png" | |
54 | + mode="aspectFill" | |
55 | + ></image> | |
56 | + <text class="address_add">点击添加地址</text> | |
53 | 57 | </view> |
54 | 58 | <image |
55 | 59 | class="arrow" |
... | ... | @@ -70,7 +74,7 @@ |
70 | 74 | |
71 | 75 | <view |
72 | 76 | class="infoBox" |
73 | - v-if="isCart == 'true'" | |
77 | + v-if="isCart === 'true'" | |
74 | 78 | v-for="(item, index) in checkedCartLst" |
75 | 79 | :key="index" |
76 | 80 | > |
... | ... | @@ -125,7 +129,7 @@ |
125 | 129 | |
126 | 130 | <view |
127 | 131 | class="infoBox" |
128 | - v-if="isCart !== 'true'" | |
132 | + v-else | |
129 | 133 | > |
130 | 134 | <view class="infoTop"> |
131 | 135 | <image |
... | ... | @@ -293,7 +297,7 @@ export default { |
293 | 297 | } |
294 | 298 | }, |
295 | 299 | onLoad({ pid, addressId, isCart, count, name }) { |
296 | - if (isCart == 'false') { | |
300 | + if (isCart === 'false') { | |
297 | 301 | this.pid = pid |
298 | 302 | // store.dispatch('read/fetch', { |
299 | 303 | // pid, |
... | ... | @@ -390,8 +394,9 @@ export default { |
390 | 394 | // 下单 |
391 | 395 | orderBuild() { |
392 | 396 | if (!this.addressInfo) { |
393 | - uni.showLoading({ | |
397 | + uni.showToast({ | |
394 | 398 | title: '请先添加地址', |
399 | + icon: 'none', | |
395 | 400 | }) |
396 | 401 | return |
397 | 402 | } |
... | ... | @@ -843,6 +848,7 @@ export default { |
843 | 848 | letter-spacing: -0.26px; |
844 | 849 | } |
845 | 850 | } |
851 | + | |
846 | 852 | .arrow { |
847 | 853 | width: 12px; |
848 | 854 | height: 12px; |
... | ... | @@ -851,6 +857,32 @@ export default { |
851 | 857 | bottom: 104rpx; |
852 | 858 | } |
853 | 859 | } |
860 | + | |
861 | +.user_address { | |
862 | + height: 62px; | |
863 | + .order_user_body_add { | |
864 | + display: flex; | |
865 | + align-items: center; | |
866 | + image { | |
867 | + background: #f2f2f2; | |
868 | + border-radius: 2px; | |
869 | + border-radius: 2px; | |
870 | + width: 30px; | |
871 | + height: 28px; | |
872 | + margin: 0 20px; | |
873 | + } | |
874 | + .address_add { | |
875 | + font-family: PingFangSC-Regular; | |
876 | + font-size: 14px; | |
877 | + color: #333333; | |
878 | + letter-spacing: -0.26px; | |
879 | + line-height: 62px; | |
880 | + } | |
881 | + } | |
882 | + .arrow { | |
883 | + bottom: 46rpx; | |
884 | + } | |
885 | +} | |
854 | 886 | .last_zhanwei { |
855 | 887 | background: #f2f2f2; |
856 | 888 | height: 60px; | ... | ... |
src/pages/myOrder/myOrder.vue
... | ... | @@ -21,13 +21,14 @@ |
21 | 21 | </view> |
22 | 22 | <view class="orderList"> |
23 | 23 | <view |
24 | - v-for="(order) in orderList" | |
24 | + v-for="(order, index) in orderList" | |
25 | 25 | :key="order.pay_id" |
26 | 26 | > |
27 | 27 | <OrderCard |
28 | + :key="index" | |
28 | 29 | :order="order" |
29 | 30 | :current="current" |
30 | - v-if="order.order_info !== null" | |
31 | + v-if="order.order_info !== null && order.order_info.keyname" | |
31 | 32 | ></OrderCard> |
32 | 33 | </view> |
33 | 34 | </view> |
... | ... | @@ -60,7 +61,7 @@ export default { |
60 | 61 | |
61 | 62 | onShow() { |
62 | 63 | store.dispatch('myOrder/getList', { |
63 | - way: '', | |
64 | + way: '', | |
64 | 65 | }) |
65 | 66 | }, |
66 | 67 | onLoad: function(option) { | ... | ... |
src/pages/myOrderPaying/myOrderPaying.vue
... | ... | @@ -248,29 +248,38 @@ export default { |
248 | 248 | this.cancleOrder() |
249 | 249 | }, |
250 | 250 | cancleOrder() { |
251 | - console.log('dddd', this.skuList) | |
252 | - // const uid = this.uid | |
253 | - // const openid = this.openid | |
254 | - // const keyname = this.orderInfo.order_info.keyname | |
255 | - // // console.log('keyname',this.orderInfo.keyname) | |
256 | - // uni.showModal({ | |
257 | - // title: '提示', | |
258 | - // content: '现在取消,订单不可恢复哦,确认取消吗?', | |
259 | - // success: function(res) { | |
260 | - // if (res.confirm) { | |
261 | - // store.dispatch('cancelOrder/cancel', { | |
262 | - // keyname: keyname, | |
263 | - // uid: uid, | |
264 | - // openid: openid, | |
265 | - // }) | |
266 | - // uni.navigateBack({ | |
267 | - // delta: 1, | |
268 | - // }) | |
269 | - // } else if (res.cancel) { | |
270 | - // console.log('用户点击取消') | |
271 | - // } | |
272 | - // }, | |
273 | - // }) | |
251 | + const uid = this.uid | |
252 | + const openid = this.openid | |
253 | + const keyname = this.orderInfo.order_info.keyname | |
254 | + const that = this | |
255 | + // console.log('keyname',this.orderInfo.keyname) | |
256 | + uni.showModal({ | |
257 | + title: '提示', | |
258 | + content: '现在取消,订单不可恢复哦,确认取消吗?', | |
259 | + success: function(res) { | |
260 | + if (res.confirm) { | |
261 | + store.dispatch('cancelOrder/cancel', { | |
262 | + keyname: keyname, | |
263 | + uid: uid, | |
264 | + openid: openid, | |
265 | + }).then(() => { | |
266 | + if (that.isPay === '1') { | |
267 | + console.log('lalallala-1') | |
268 | + uni.switchTab({ | |
269 | + url: '/pages/index/index', | |
270 | + }) | |
271 | + } else { | |
272 | + console.log('lalallala-2') | |
273 | + uni.navigateBack({ | |
274 | + delta: 1, | |
275 | + }) | |
276 | + } | |
277 | + }) | |
278 | + } else if (res.cancel) { | |
279 | + console.log('用户点击取消', that.isPay) | |
280 | + } | |
281 | + }, | |
282 | + }) | |
274 | 283 | }, |
275 | 284 | paylog() { |
276 | 285 | console.log('pay', this.orderInfo) | ... | ... |
src/static/add_address.png
1.74 KB
src/store/modules/address.js
1 | 1 | import urlAlias from '../url' |
2 | 2 | import request from '../request' |
3 | 3 | |
4 | -const { editAddress, addressList, getAddress, getDefaultAddress } = urlAlias | |
4 | +const { editAddress, addressList, getAddress, getDefaultAddress, delAddress } = urlAlias | |
5 | 5 | |
6 | 6 | const state = { list: [], detail: {}, defaultInfo: {} } |
7 | 7 | |
... | ... | @@ -87,6 +87,21 @@ const actions = { |
87 | 87 | }, |
88 | 88 | })) |
89 | 89 | }, |
90 | + delete(_, param) { | |
91 | + return new Promise((resolve) => request({ | |
92 | + url: delAddress, | |
93 | + data: param, | |
94 | + success: (res) => { | |
95 | + resolve() | |
96 | + }, | |
97 | + fail: () => { | |
98 | + uni.showModal({ | |
99 | + content: '删除地址失败', | |
100 | + showCancel: false, | |
101 | + }) | |
102 | + }, | |
103 | + })) | |
104 | + }, | |
90 | 105 | } |
91 | 106 | |
92 | 107 | export default { | ... | ... |
src/store/url.js
... | ... | @@ -42,6 +42,7 @@ const urlAlias = { |
42 | 42 | addressList: '/app/address/get_address_list', // 获取用户地址列表 |
43 | 43 | getAddress: '/app/address/get_address_by_id', // 获取用户某一地址信息 |
44 | 44 | getDefaultAddress: '/app/address/get_default_address', // 获取用户默认地址信息 |
45 | + delAddress: '/app/address/del_address', // 删除用户地址 | |
45 | 46 | |
46 | 47 | // 用户数据 |
47 | 48 | mylovelist: '/app/user/mylovelist', // 关心的人的数据 | ... | ... |