Showing
7 changed files
with
73 additions
and
26 deletions
@@ -65,21 +65,15 @@ export default { | @@ -65,21 +65,15 @@ export default { | ||
65 | }, | 65 | }, |
66 | data() { | 66 | data() { |
67 | return { | 67 | return { |
68 | - data: {} | 68 | + data: { |
69 | + pay_list: [{ | ||
70 | + payment_id: 1, | ||
71 | + pay_name: '支付宝' | ||
72 | + }] | ||
73 | + } | ||
69 | }; | 74 | }; |
70 | }, | 75 | }, |
71 | async mounted() { | 76 | async mounted() { |
72 | - if (!this.orderCode) { | ||
73 | - return; | ||
74 | - } | ||
75 | - | ||
76 | - const payListResult = await this.fetchPayList({ | ||
77 | - order_code: this.orderCode | ||
78 | - }); | ||
79 | - | ||
80 | - if (payListResult.code === 200) { | ||
81 | - this.data = payListResult.data; | ||
82 | - } | ||
83 | }, | 77 | }, |
84 | methods: { | 78 | methods: { |
85 | ...mapOrderAction(['fetchPayList']), | 79 | ...mapOrderAction(['fetchPayList']), |
@@ -84,7 +84,7 @@ export default { | @@ -84,7 +84,7 @@ export default { | ||
84 | }, | 84 | }, |
85 | }, | 85 | }, |
86 | methods: { | 86 | methods: { |
87 | - ...mapOrderAction(['fetchOrderAddress', 'fetchUserStatus', 'fetchPayList', 'fetchPayment', 'computeOrder']), | 87 | + ...mapOrderAction(['fetchOrderAddress', 'fetchUserStatus', 'fetchPayList', 'fetchPayment', 'computeOrder', 'buyPayAction']), |
88 | ...mapOrderMutations([Types.CHANGE_SELECT_COUPON_LIST, Types.CHANGE_SELECT_PROMOTION]), | 88 | ...mapOrderMutations([Types.CHANGE_SELECT_COUPON_LIST, Types.CHANGE_SELECT_PROMOTION]), |
89 | replaceBr(str) { | 89 | replaceBr(str) { |
90 | return str ? str.replace(/\n/g, '<br />') : ''; | 90 | return str ? str.replace(/\n/g, '<br />') : ''; |
@@ -150,17 +150,57 @@ export default { | @@ -150,17 +150,57 @@ export default { | ||
150 | }); | 150 | }); |
151 | }, | 151 | }, |
152 | async onPayAction() { | 152 | async onPayAction() { |
153 | + const vm = this; | ||
154 | + | ||
153 | await this.compute(); | 155 | await this.compute(); |
156 | + | ||
157 | + const { data: { orderCode, message } } = await this.buyPayAction({ | ||
158 | + skup: this.productDetail.skup, | ||
159 | + addressId: this.address.address_id, | ||
160 | + couponCode: get(this.orderDetail, 'recommendedCouponInfo.coupon_code', ''), | ||
161 | + promotionId: get(this.orderDetail, 'promotionTips.promotionIds', '') | ||
162 | + }); | ||
163 | + | ||
164 | + if (!orderCode) { | ||
165 | + this.$createToast({ | ||
166 | + time: 1500, | ||
167 | + txt: message, | ||
168 | + type: 'txt' | ||
169 | + }).show(); | ||
170 | + return; | ||
171 | + } | ||
172 | + | ||
154 | this.$createOrderPayType({ | 173 | this.$createOrderPayType({ |
174 | + orderCode, | ||
155 | price: this.orderDetail.amount, | 175 | price: this.orderDetail.amount, |
156 | - desc: '金额' | 176 | + desc: '金额', |
177 | + onCloseAction() { | ||
178 | + vm.onClose(orderCode); | ||
179 | + }, | ||
180 | + onPayAction() { | ||
181 | + vm.onPay(); | ||
182 | + } | ||
157 | }).show(); | 183 | }).show(); |
184 | + }, | ||
185 | + onPay() { | ||
186 | + console.log('ok'); | ||
187 | + }, | ||
188 | + onClose(orderCode) { | ||
189 | + this.$router.push({ | ||
190 | + name: 'orderDetail', | ||
191 | + params: { | ||
192 | + owner: UserType.buy, | ||
193 | + code: orderCode | ||
194 | + } | ||
195 | + }); | ||
158 | } | 196 | } |
159 | } | 197 | } |
160 | }; | 198 | }; |
161 | </script> | 199 | </script> |
162 | 200 | ||
163 | <style lang="scss" scoped> | 201 | <style lang="scss" scoped> |
202 | +@import '~statics/scss/variable.scss'; | ||
203 | + | ||
164 | .footer { | 204 | .footer { |
165 | position: absolute; | 205 | position: absolute; |
166 | bottom: 0; | 206 | bottom: 0; |
@@ -130,12 +130,7 @@ export default { | @@ -130,12 +130,7 @@ export default { | ||
130 | 130 | ||
131 | const { orderCode } = orderResult.data; | 131 | const { orderCode } = orderResult.data; |
132 | 132 | ||
133 | - const payListResult = await this.fetchPayList({ | ||
134 | - order_code: orderCode | ||
135 | - }); | ||
136 | - | ||
137 | this.orderPay = this.$createOrderPayType({ | 133 | this.orderPay = this.$createOrderPayType({ |
138 | - data: payListResult.data, | ||
139 | price: this.fee.earnestMoneyStr, | 134 | price: this.fee.earnestMoneyStr, |
140 | desc: '保证金', | 135 | desc: '保证金', |
141 | orderCode, | 136 | orderCode, |
1 | +$xianyu-theme-red: #d0021b; |
@@ -181,6 +181,18 @@ export default function() { | @@ -181,6 +181,18 @@ export default function() { | ||
181 | commit(Types.UPDATE_ORDER, orderInfo.data); | 181 | commit(Types.UPDATE_ORDER, orderInfo.data); |
182 | 182 | ||
183 | return orderInfo; | 183 | return orderInfo; |
184 | + }, | ||
185 | + | ||
186 | + async buyPayAction(ctx, { skup, couponCode, addressId, promotionId }) { | ||
187 | + const order = await this.$api.post('/api/order/submit', { | ||
188 | + skup, | ||
189 | + addressId, | ||
190 | + coupon_code: couponCode, | ||
191 | + promotionId, | ||
192 | + depositRequirement: 'N' | ||
193 | + }); | ||
194 | + | ||
195 | + return order; | ||
184 | } | 196 | } |
185 | }, | 197 | }, |
186 | getters: {}, | 198 | getters: {}, |
@@ -280,9 +280,7 @@ module.exports = { | @@ -280,9 +280,7 @@ module.exports = { | ||
280 | auth: true, | 280 | auth: true, |
281 | path: 'shopping', | 281 | path: 'shopping', |
282 | api: 'ufo.order.compute', | 282 | api: 'ufo.order.compute', |
283 | - params: { | ||
284 | - skup: { type: Number, require: true }, | ||
285 | - }, | 283 | + params: {}, |
286 | }, | 284 | }, |
287 | 285 | ||
288 | // 买家预定单订单价格 | 286 | // 买家预定单订单价格 |
@@ -291,9 +289,7 @@ module.exports = { | @@ -291,9 +289,7 @@ module.exports = { | ||
291 | auth: true, | 289 | auth: true, |
292 | path: 'shopping', | 290 | path: 'shopping', |
293 | api: 'ufo.order.payment', | 291 | api: 'ufo.order.payment', |
294 | - params: { | ||
295 | - skup: { type: Number, require: true }, | ||
296 | - }, | 292 | + params: {}, |
297 | }, | 293 | }, |
298 | 294 | ||
299 | // 买家获得优惠券 | 295 | // 买家获得优惠券 |
@@ -307,6 +303,15 @@ module.exports = { | @@ -307,6 +303,15 @@ module.exports = { | ||
307 | }, | 303 | }, |
308 | }, | 304 | }, |
309 | 305 | ||
306 | + // 买家下单 | ||
307 | + '/api/order/submit': { | ||
308 | + ufo: true, | ||
309 | + auth: true, | ||
310 | + path: 'shopping', | ||
311 | + api: 'ufo.order.submit', | ||
312 | + params: {} | ||
313 | + }, | ||
314 | + | ||
310 | // 订单物流信息 | 315 | // 订单物流信息 |
311 | '/api/order/express': { | 316 | '/api/order/express': { |
312 | ufo: true, | 317 | ufo: true, |
-
Please register or login to post a comment