Authored by TaoHuang

add pay

... ... @@ -56,6 +56,12 @@ export default {
desc: {
type: String,
default: ''
},
extra: {
type: Object,
default() {
return {};
}
}
},
components: {
... ... @@ -76,7 +82,7 @@ export default {
async mounted() {
},
methods: {
...mapOrderAction(['fetchPayList']),
...mapOrderAction(['payAction']),
show() {
this.$refs.actionSheet.show();
},
... ... @@ -90,6 +96,32 @@ export default {
pay() {
this.$emit('confirmAction');
const toast = this.$createToast({
txt: '正在调起支付宝'
}).show();
this.payAction({
orderCode: this.orderCode
}).then((result) => {
toast.hide();
this.onSuccess(result);
}).catch((result) => {
toast.hide();
this.onError(result);
})
},
onError(result) {
this.$emit('on-pay-error');
this.$createToast({
txt: result.message,
time: 1500,
type: 'txt'
}).show();
},
onSuccess() {
this.hide();
this.$emit('on-pay-success');
this.$router.push({
name: 'OrderPay',
query: {
... ...
... ... @@ -154,37 +154,31 @@ export default {
await this.compute();
const { data: { orderCode, message } } = await this.buyPayAction({
const result = await this.buyPayAction({
skup: this.productDetail.skup,
addressId: this.address.address_id,
couponCode: get(this.orderDetail, 'recommendedCouponInfo.coupon_code', ''),
promotionId: get(this.orderDetail, 'promotionTips.promotionIds', '')
});
if (!orderCode) {
if (!result?.data?.orderCode) {
this.$createToast({
time: 1500,
txt: message,
txt: result?.message,
type: 'txt'
}).show();
return;
}
this.$createOrderPayType({
orderCode,
orderCode: result.data.orderCode,
price: this.orderDetail.amount,
desc: '金额',
onCloseAction() {
vm.onClose(orderCode);
vm.onClose(result.data.orderCode);
},
onPayAction() {
vm.onPay();
}
}).show();
},
onPay() {
console.log('ok');
},
onClose(orderCode) {
this.$router.push({
name: 'orderDetail',
... ... @@ -199,8 +193,6 @@ export default {
</script>
<style lang="scss" scoped>
@import '~statics/scss/variable.scss';
.footer {
position: absolute;
bottom: 0;
... ...
... ... @@ -128,33 +128,24 @@ export default {
return;
}
const { orderCode } = orderResult.data;
this.orderPay = this.$createOrderPayType({
price: this.fee.earnestMoneyStr,
desc: '保证金',
orderCode,
orderCode: orderResult.data.orderCode,
onCloseAction() {
vm.onClose();
vm.$router.push({
name: 'orderDetail',
params: {
owner: UserType.sell,
code: orderCode
}
});
},
onPayAction() {
vm.onPay();
vm.onClose(orderResult.data.orderCode);
}
}).show();
},
onClose() {
console.log('close');
onClose(orderCode) {
this.$router.push({
name: 'orderDetail',
params: {
owner: UserType.sell,
code: orderCode
}
});
},
onPay() {
console.log('pay');
}
}
};
</script>
... ...
... ... @@ -193,6 +193,19 @@ export default function() {
});
return order;
},
async payAction(ctx, { orderCode }) {
const payResult = await this.$api.post('/api/order/pay', {
orderCode,
payment: 2
});
if (payResult.code !== 200) {
return Promise.reject(payResult);
}
return payResult;
}
},
getters: {},
... ...
... ... @@ -322,6 +322,14 @@ module.exports = {
params: {}
},
// 支付下单
'/api/order/pay': {
ufo: true,
auth: true,
api: 'ufo.order.pay',
params: {}
},
// 订单物流信息
'/api/order/express': {
ufo: true,
... ...