|
|
@@ -30,11 +30,16 @@
|
|
|
|
|
|
<script>
|
|
|
import {
|
|
|
- orderPay
|
|
|
+ orderPay,
|
|
|
+ orderCheck
|
|
|
} from '@/api/order.js';
|
|
|
import colors from '@/mixins/color.js';
|
|
|
export default {
|
|
|
props: {
|
|
|
+ id: {
|
|
|
+ type: Number,
|
|
|
+ default: 0
|
|
|
+ },
|
|
|
payMode: {
|
|
|
type: Array,
|
|
|
default: function() {
|
|
|
@@ -58,7 +63,7 @@
|
|
|
default: false
|
|
|
}
|
|
|
},
|
|
|
- mixins:[colors],
|
|
|
+ mixins: [colors],
|
|
|
data() {
|
|
|
return {
|
|
|
formContent: '',
|
|
|
@@ -88,7 +93,7 @@
|
|
|
methods: {
|
|
|
payType(number, paytype, index) {
|
|
|
this.active = index;
|
|
|
- console.log(this.active,'this.active');
|
|
|
+ console.log(this.active, 'this.active');
|
|
|
this.paytype = paytype;
|
|
|
this.number = number;
|
|
|
this.$emit('changePayType', paytype)
|
|
|
@@ -98,7 +103,7 @@
|
|
|
action: 'payClose'
|
|
|
});
|
|
|
},
|
|
|
- goPay: function(number, paytype) {
|
|
|
+ goPay: async function(number, paytype) {
|
|
|
if (this.isCall) {
|
|
|
return this.$emit('onChangeFun', {
|
|
|
action: 'payCheck',
|
|
|
@@ -109,33 +114,90 @@
|
|
|
if (!that.order_id) return that.$util.Tips({
|
|
|
title: '请选择要支付的订单'
|
|
|
});
|
|
|
+ if (that.id > 0) {
|
|
|
+ try {
|
|
|
+ const {
|
|
|
+ data
|
|
|
+ } = await orderCheck(that.id)
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error)
|
|
|
+ }
|
|
|
+ const tip = `此次复投起提示需要支付至少${parseFloat(that.totalPrice*0.1*data.reorder_count)}的现金,否则出局时消费分比例加10%`;
|
|
|
+ if (paytype == 'yue') {
|
|
|
+ uni.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content:tip,
|
|
|
+ cancelText: '取消支付',
|
|
|
+ confirmText: '继续支付',
|
|
|
+ success: res => {
|
|
|
+ if(res.confirm){
|
|
|
+ this.payMoney(number, paytype)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (paytype != 'yue') {
|
|
|
+ if (data.reorder_count > 1) {
|
|
|
+ uni.showModal({
|
|
|
+ title: '提示',
|
|
|
+ editable:true,
|
|
|
+ placeholderText:tip,
|
|
|
+ cancelText: '取消支付',
|
|
|
+ success: res => {
|
|
|
+ if(res.confirm){
|
|
|
+ if(!isNaN(res.content)){
|
|
|
+ this.payMoney(number, paytype,res.content)
|
|
|
+ }else{
|
|
|
+ uni.showToast({
|
|
|
+ title: '请输入数字',
|
|
|
+ icon:'error'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail: () => {},
|
|
|
+ complete: () => {}
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ this.payMoney(number, paytype)
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ //支付方法
|
|
|
+ async payMoney(number, paytype,yue_pay=0) {
|
|
|
+ let that = this;
|
|
|
if (paytype == 'yue' && parseFloat(number) < parseFloat(that.totalPrice)) return that.$util.Tips({
|
|
|
title: '余额不足!'
|
|
|
});
|
|
|
uni.showLoading({
|
|
|
title: '支付中'
|
|
|
});
|
|
|
- let upData={
|
|
|
- uni: that.order_id,
|
|
|
- paytype: paytype,
|
|
|
- // #ifdef MP
|
|
|
- 'from': 'routine',
|
|
|
- // #endif
|
|
|
- // #ifdef H5
|
|
|
- 'from': this.$wechat.isWeixin() ? 'weixin' : 'weixinh5',
|
|
|
- // #endif
|
|
|
- // #ifdef H5
|
|
|
- quitUrl: location.port ? location.protocol + '//' + location.hostname + ':' + location
|
|
|
- .port +
|
|
|
- '/pages/goods/order_details/index?order_id=' + this.order_id : location.protocol +
|
|
|
- '//' + location.hostname +
|
|
|
- '/pages/goods/order_details/index?order_id=' + this.order_id
|
|
|
- // #endif
|
|
|
- // #ifdef APP-PLUS
|
|
|
- quitUrl: '/pages/goods/order_details/index?order_id=' + this.order_id
|
|
|
- // #endif
|
|
|
+ let upData = {
|
|
|
+ yue_pay,
|
|
|
+ uni: that.order_id,
|
|
|
+ paytype: paytype,
|
|
|
+ // #ifdef MP
|
|
|
+ 'from': 'routine',
|
|
|
+ // #endif
|
|
|
+ // #ifdef H5
|
|
|
+ 'from': this.$wechat.isWeixin() ? 'weixin' : 'weixinh5',
|
|
|
+ // #endif
|
|
|
+ // #ifdef H5
|
|
|
+ quitUrl: location.port ? location.protocol + '//' + location.hostname + ':' + location
|
|
|
+ .port +
|
|
|
+ '/pages/goods/order_details/index?order_id=' + this.order_id : location.protocol +
|
|
|
+ '//' + location.hostname +
|
|
|
+ '/pages/goods/order_details/index?order_id=' + this.order_id
|
|
|
+ // #endif
|
|
|
+ // #ifdef APP-PLUS
|
|
|
+ quitUrl: '/pages/goods/order_details/index?order_id=' + this.order_id
|
|
|
+ // #endif
|
|
|
}
|
|
|
- orderPay(upData).then(res => {
|
|
|
+ try {
|
|
|
+ const res = await orderPay(upData)
|
|
|
+
|
|
|
let jsConfig = res.data.result.jsConfig;
|
|
|
// console.log(res,upData,'神英优选')
|
|
|
switch (paytype) {
|
|
|
@@ -145,11 +207,11 @@
|
|
|
});
|
|
|
|
|
|
// #ifdef MP
|
|
|
- let mp_pay_name=''
|
|
|
- if(uni.requestOrderPayment){
|
|
|
- mp_pay_name='requestOrderPayment'
|
|
|
- }else{
|
|
|
- mp_pay_name='requestPayment'
|
|
|
+ let mp_pay_name = ''
|
|
|
+ if (uni.requestOrderPayment) {
|
|
|
+ mp_pay_name = 'requestOrderPayment'
|
|
|
+ } else {
|
|
|
+ mp_pay_name = 'requestPayment'
|
|
|
}
|
|
|
uni[mp_pay_name]({
|
|
|
timeStamp: jsConfig.timestamp,
|
|
|
@@ -219,7 +281,7 @@
|
|
|
.catch(function(res) {
|
|
|
if (res.errMsg == 'chooseWXPay:cancel') return that.$util.Tips({
|
|
|
title: '取消支付'
|
|
|
- },() => {
|
|
|
+ }, () => {
|
|
|
that.$emit('onChangeFun', {
|
|
|
action: 'pay_fail'
|
|
|
});
|
|
|
@@ -339,7 +401,7 @@
|
|
|
// #endif
|
|
|
break;
|
|
|
}
|
|
|
- }).catch(err => {
|
|
|
+ } catch (err) {
|
|
|
uni.hideLoading();
|
|
|
return that.$util.Tips({
|
|
|
title: err
|
|
|
@@ -348,16 +410,18 @@
|
|
|
action: 'pay_fail'
|
|
|
});
|
|
|
});
|
|
|
- })
|
|
|
+ //TODO handle the exception
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
- .bgcolor{
|
|
|
+ .bgcolor {
|
|
|
background-color: var(--view-theme)
|
|
|
}
|
|
|
+
|
|
|
.payment {
|
|
|
position: fixed;
|
|
|
bottom: 0;
|
|
|
@@ -470,4 +534,4 @@
|
|
|
font-size: 40rpx;
|
|
|
color: #ccc;
|
|
|
}
|
|
|
-</style>
|
|
|
+</style>
|