|
|
|
@ -140,9 +140,12 @@ |
|
|
|
|
<view v-for="(a,index) in paymentMethods" @click="chosePayType(a,index)" |
|
|
|
|
class="pay-item dis-flex flex-x-between"> |
|
|
|
|
<view class="item-left dis-flex flex-y-center"> |
|
|
|
|
<view class="item-left_icon" :class="[a.method]"> |
|
|
|
|
<view v-if="a.method!=='huifu'" class="item-left_icon" :class="[a.method]"> |
|
|
|
|
<text class="iconfont" :class="[PayMethodIconEnum[a.method]]"></text> |
|
|
|
|
</view> |
|
|
|
|
<view v-else class="huifu-box"> |
|
|
|
|
<image :src="`${$picUrl}/static/yinlian.png`" mode="heightFix" class="huifu"></image> |
|
|
|
|
</view> |
|
|
|
|
<view class="item-left_text"> |
|
|
|
|
<text>{{ PayMethodEnum[a.method].name }}</text> |
|
|
|
|
</view> |
|
|
|
@ -180,6 +183,7 @@ |
|
|
|
|
<script> |
|
|
|
|
// import img from "@/static/member/top.png"; |
|
|
|
|
import * as member from '@/api/member/index.js'; |
|
|
|
|
import * as CashierApi from '@/api/cashier'; |
|
|
|
|
import { |
|
|
|
|
Wechat |
|
|
|
|
} from '@/core/payment' |
|
|
|
@ -228,10 +232,47 @@ |
|
|
|
|
this.getMemberInfo() |
|
|
|
|
}, |
|
|
|
|
onLoad(options) { |
|
|
|
|
console.log(options); |
|
|
|
|
this.user = uni.getStorageSync('userInfo') |
|
|
|
|
this.type = options.type |
|
|
|
|
uni.$on('appShow', this.solveShowMsg); |
|
|
|
|
}, |
|
|
|
|
onUnload() { |
|
|
|
|
uni.$off('appShow', this.solveShowMsg); |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
solveShowMsg(info) { |
|
|
|
|
console.log(info); |
|
|
|
|
if (this.miniPayRequest && Object.keys(this.miniPayRequest).length > 0 && info.appId === this.miniPayRequest.miniuser) { |
|
|
|
|
this.onTradeQuery(this.miniPayRequest.out_trade_no, this.payType); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
// 已完成支付按钮事件: 请求后端查单 |
|
|
|
|
onTradeQuery(outTradeNo, method) { |
|
|
|
|
const app = this |
|
|
|
|
// 交易查询 |
|
|
|
|
// 查询第三方支付订单是否付款成功 |
|
|
|
|
CashierApi.tradeQuery({ |
|
|
|
|
outTradeNo, |
|
|
|
|
method, |
|
|
|
|
client: app.platform |
|
|
|
|
}) |
|
|
|
|
.then(result => { |
|
|
|
|
if (result.data.isPay) { |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: result.message || "支付成功", |
|
|
|
|
icon: 'success' |
|
|
|
|
}) |
|
|
|
|
app.getMemberInfo(); |
|
|
|
|
} else { |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: result.message || "支付失败", |
|
|
|
|
icon: 'none' |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
.finally(() => app.showConfirmModal = false) |
|
|
|
|
}, |
|
|
|
|
getMemberInfo() { |
|
|
|
|
const that = this |
|
|
|
|
let params = { |
|
|
|
@ -245,6 +286,7 @@ |
|
|
|
|
that.packageList = res.data.list.list; |
|
|
|
|
that.paymentMethods = res.data.list.paymentMethods; |
|
|
|
|
that.choseItem = that.packageList[0] |
|
|
|
|
that.setDefaultPayType(); |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
.finally(() => that.isLoading = false) |
|
|
|
@ -256,6 +298,7 @@ |
|
|
|
|
that.packageList = res.data.list.list; |
|
|
|
|
that.paymentMethods = res.data.list.paymentMethods; |
|
|
|
|
that.choseItem = that.packageList[0] |
|
|
|
|
that.setDefaultPayType(); |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
.finally(() => that.isLoading = false) |
|
|
|
@ -265,19 +308,27 @@ |
|
|
|
|
chosePackage(item, index) { |
|
|
|
|
this.isChose = index; |
|
|
|
|
this.choseItem = item; |
|
|
|
|
|
|
|
|
|
if (this.payType === 'huifu') { |
|
|
|
|
this.huifuPay(); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
goBuyInfo() { |
|
|
|
|
uni.navigateTo({ |
|
|
|
|
url: '/pages/memberInfo/index?userInfo=' + JSON.stringify(this.userInfo) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
// 设置默认的支付方式 |
|
|
|
|
setDefaultPayType() { |
|
|
|
|
const app = this |
|
|
|
|
const defaultIndex = app.paymentMethods.findIndex(item => item.is_default == true) |
|
|
|
|
defaultIndex > -1 && app.chosePayType(app.paymentMethods[defaultIndex], defaultIndex); |
|
|
|
|
}, |
|
|
|
|
chosePayType(item, index) { |
|
|
|
|
// 选择支付方式 |
|
|
|
|
if (this.paymentMethods[index].method == 'huifu') { |
|
|
|
|
this.$toast('抱歉,此支付方式暂未完善') |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
// if (this.paymentMethods[index].method == 'huifu') { |
|
|
|
|
// this.$toast('抱歉,此支付方式暂未完善') |
|
|
|
|
// return |
|
|
|
|
// } |
|
|
|
|
this.tabIndex = index |
|
|
|
|
this.paymentMethods[index].is_default = true; |
|
|
|
|
this.payType = item.method; |
|
|
|
@ -286,6 +337,9 @@ |
|
|
|
|
// this.paymentMethods[i].is_default = false |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
if (this.payType === 'huifu') { |
|
|
|
|
this.huifuPay(); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
gotoPay() { |
|
|
|
|
// 去支付 |
|
|
|
@ -293,8 +347,38 @@ |
|
|
|
|
this.weChatPay() |
|
|
|
|
} else if (this.payType == 'balance') { |
|
|
|
|
this.balancePay() |
|
|
|
|
} else if (this.payType == 'huifu') { |
|
|
|
|
if (!this.miniPayRequest || Object.keys(this.miniPayRequest).length === 0) { |
|
|
|
|
this.$toast(`暂无${this.PayMethodEnum[this.payType].name}支付信息`); |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
let appPayRequest = ''; |
|
|
|
|
appPayRequest = encodeURIComponent(JSON.stringify({ |
|
|
|
|
sign: this.miniPayRequest.sign, |
|
|
|
|
prepayid: this.miniPayRequest.prepayid, |
|
|
|
|
})); |
|
|
|
|
uni.openEmbeddedMiniProgram({ |
|
|
|
|
appId: this.miniPayRequest.miniuser, |
|
|
|
|
path: `${this.miniPayRequest.minipath}?appPayRequest=${appPayRequest}` |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
huifuPay() { |
|
|
|
|
const that = this |
|
|
|
|
let params = { |
|
|
|
|
identity_id: that.choseItem.identity_id, |
|
|
|
|
method: 'huifu', |
|
|
|
|
client: 'MP-WEIXIN' |
|
|
|
|
} |
|
|
|
|
member.submit(params) |
|
|
|
|
.then(result => { |
|
|
|
|
console.log(result); |
|
|
|
|
const { miniPayRequest, out_trade_no } = result.data.payment; |
|
|
|
|
that.miniPayRequest = miniPayRequest; |
|
|
|
|
that.miniPayRequest.out_trade_no = out_trade_no; |
|
|
|
|
}) |
|
|
|
|
.finally(() => that.isLoading = false) |
|
|
|
|
}, |
|
|
|
|
weChatPay() { |
|
|
|
|
// 微信支付 |
|
|
|
|
const that = this |
|
|
|
@ -694,12 +778,12 @@ |
|
|
|
|
.payment-method { |
|
|
|
|
width: 100%; |
|
|
|
|
margin: 20rpx 0 50rpx 0; |
|
|
|
|
padding: 0 40rpx; |
|
|
|
|
padding: 0 40rpx 0 20rpx; |
|
|
|
|
background-color: #ffffff; |
|
|
|
|
border-radius: 20rpx; |
|
|
|
|
|
|
|
|
|
.title { |
|
|
|
|
padding: 30rpx 0; |
|
|
|
|
padding: 30rpx 0 30rpx 20rpx; |
|
|
|
|
font-size: 30rpx; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -713,8 +797,9 @@ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
.item-left_icon { |
|
|
|
|
margin-right: 20rpx; |
|
|
|
|
font-size: 44rpx; |
|
|
|
|
width: 100rpx; |
|
|
|
|
text-align: center; |
|
|
|
|
font-size: 60rpx; |
|
|
|
|
|
|
|
|
|
&.wechat { |
|
|
|
|
color: #00c800; |
|
|
|
@ -732,6 +817,14 @@ |
|
|
|
|
color: #009fe8; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.huifu-box { |
|
|
|
|
width: 100rpx; |
|
|
|
|
display: flex; |
|
|
|
|
justify-content: center; |
|
|
|
|
.huifu { |
|
|
|
|
height: 44rpx; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
.item-left_text { |
|
|
|
|
font-size: 28rpx; |
|
|
|
|