调试第三方支付

h5
wangdong 6 months ago
parent 6138dfab5e
commit 4d77e53fc1
  1. 13
      pages/checkout/cashier/index.vue
  2. 120
      pages/gamll/index.vue
  3. 125
      pages/member/index.vue
  4. 113
      pages/member/index1.vue
  5. 92
      pages/wallet/recharge/index.vue

@ -140,7 +140,9 @@
//
this.getCashierInfo();
uni.$on('appShow', this.solveShowMsg);
uni.onAppShow()
},
onUnload() {
uni.$off('appShow', this.solveShowMsg);
},
methods: {
@ -245,6 +247,7 @@
if (app.disabled) return
app.disabled = true
if (app.curPaymentItem.method === 'huifu') {
app.disabled = false
if (!app.miniPayRequest || Object.keys(app.miniPayRequest).length === 0) {
app.$toast(`暂无${app.PayMethodEnum[app.curPaymentItem.method].name}支付信息`);
return
@ -256,13 +259,7 @@
}));
uni.openEmbeddedMiniProgram({
appId: app.miniPayRequest.miniuser,
path: `${app.miniPayRequest.minipath}?appPayRequest=${appPayRequest}`,
success(res) {
console.log('success', res)
},
fail(e) {
console.log('fail', e);
}
path: `${app.miniPayRequest.minipath}?appPayRequest=${appPayRequest}`
});
} else {
// API

@ -147,9 +147,12 @@
<view v-for="(a,index) in paymentMethods" @click="tabItem1(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>
@ -181,6 +184,7 @@
</template>
<script>
import * as api from '@/api/tutorial'
import * as CashierApi from '@/api/cashier';
import {
Wechat
} from '@/core/payment'
@ -244,6 +248,11 @@
console.log(this.retail)
this.getRetailList()
this.getDescribe()
uni.$on('appShow', this.solveShowMsg);
console.log(route);
},
onUnload() {
uni.$off('appShow', this.solveShowMsg);
},
onShow() {
@ -256,12 +265,52 @@
this.show = true
}
},
tabItem1(i) {
if (this.paymentMethods[i].method == 'huifu') {
this.$toast('抱歉,此支付方式暂未完善')
return
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.paymentMethods[this.payIndex].method);
}
},
// :
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'
})
setTimeout(() => {
uni.switchTab({
url: "/pages/user/index"
})
}, 1000)
} else {
uni.showToast({
title: result.message || "支付失败",
icon: 'none'
})
}
})
.finally(() => app.showConfirmModal = false)
},
tabItem1(i) {
// if (this.paymentMethods[i].method == 'huifu') {
// this.$toast('')
// return
// }
this.payIndex = i
if (this.paymentMethods[i].method == "huifu") {
this.huifuPay();
}
},
onChage(index) {
this.radius = index == 0 ? '28rpx 0 0 0' : '0 28rpx 0 0';
@ -274,7 +323,10 @@
this.getRetailList()
},
onChagePrice(index) {
this.priceIndex = index
this.priceIndex = index;
if (this.paymentMethods[this.payIndex].method == "huifu") {
this.huifuPay();
}
},
getBan() {
let that = this
@ -289,6 +341,29 @@
}
});
},
//
setDefaultPayType() {
const app = this
const defaultIndex = app.paymentMethods.findIndex(item => item.is_default == true)
defaultIndex > -1 && app.tabItem1(defaultIndex);
},
huifuPay() {
const that = this
let params = {
retail_price_id: that.tabType[that.banIndex].retail_price_id,
year: that.tabFavour[that.priceIndex].year,
method: 'huifu',
client: 'MP-WEIXIN'
}
api.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)
},
//
async toWechatPay() {
const that = this;
@ -378,6 +453,21 @@
}
} else if (that.paymentMethods[that.payIndex].method == "wechat") {
that.toWechatPay();
} else if (that.paymentMethods[that.payIndex].method == "huifu") {
that.isClick = true;
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}`
});
}
},
//
@ -575,6 +665,7 @@
that.tabType = data.list.list
that.paymentMethods = data.list.paymentMethods
that.getBan()
this.setDefaultPayType();
} else {
that.$toast(message)
}
@ -1105,12 +1196,12 @@
.payment-method {
width: 100%;
margin: 20rpx 0 180rpx 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;
}
@ -1124,8 +1215,9 @@
}
.item-left_icon {
margin-right: 20rpx;
font-size: 44rpx;
width: 100rpx;
text-align: center;
font-size: 60rpx;
&.wechat {
color: #00c800;
@ -1143,6 +1235,14 @@
color: #009fe8;
}
}
.huifu-box {
width: 100rpx;
display: flex;
justify-content: center;
.huifu {
height: 44rpx;
}
}
.item-left_text {
font-size: 28rpx;

@ -106,9 +106,12 @@
<view v-for="(a,index) in paymentMethods" @click="tabItem1(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>
@ -138,6 +141,7 @@
Wechat
} from '@/core/payment'
import * as member from '@/api/member/index.js';
import * as CashierApi from '@/api/cashier';
import {
PayMethodEnum
} from '@/common/enum/payment'
@ -177,16 +181,60 @@
onLoad(options) {
this.type = options.type
this.getMemberInfo()
uni.$on('appShow', this.solveShowMsg);
},
onUnload() {
uni.$off('appShow', this.solveShowMsg);
},
methods: {
tabItem1(i) {
if (this.paymentMethods[i].method == 'huifu') {
this.$toast('抱歉,此支付方式暂未完善')
return
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.paymentMethods[this.tabIndex].method);
}
},
// :
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'
})
setTimeout(() => {
uni.redirectTo({
url: "/pages/news/caigou/notice1"
})
}, 1000)
} else {
uni.showToast({
title: result.message || "支付失败",
icon: 'none'
})
}
})
.finally(() => app.showConfirmModal = false)
},
tabItem1(i) {
// if (this.paymentMethods[i].method == 'huifu') {
// this.$toast('')
// return
// }
this.tabIndex = i
if (this.paymentMethods[this.tabIndex].method == "huifu") {
this.huifuPay();
}
},
async getMemberInfo() {
async getMemberInfo(type) {
const {
status,
data,
@ -197,6 +245,16 @@
client: 'MP-WEIXIN'
}));
if (status == 200) {
if (type === 'toast') {
if (((this.type == 'fx'&& this.personal.user_type == 30) || (this.type == 'hy' && this.personal.user_type == 20)) && this.personal.fx_effective_time !== data.list.personal.fx_effective_time) {
} else {
uni.showToast({
title: "支付失败",
icon: 'none'
})
}
}
let list = data.list.list;
if (list && list.length > 0) {
list.sort((a, b) => {
@ -206,8 +264,31 @@
this.info = list && list.length > 0 ? list[0] : [];
this.paymentMethods = data.list.paymentMethods
this.personal = data.list.personal
this.setDefaultPayType();
}
},
//
setDefaultPayType() {
const app = this
const defaultIndex = app.paymentMethods.findIndex(item => item.is_default == true)
defaultIndex > -1 && app.tabItem1(defaultIndex);
},
huifuPay() {
const that = this
let params = {
identity_id: this.info.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)
},
//
async toWechatPay() {
const that = this;
@ -294,6 +375,21 @@
}
} else if (this.paymentMethods[this.tabIndex].method == "wechat") {
this.toWechatPay();
} else if (this.paymentMethods[this.tabIndex].method == "huifu") {
this.isClick = true;
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}`
});
}
},
@ -481,12 +577,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;
}
@ -500,8 +596,9 @@
}
.item-left_icon {
margin-right: 20rpx;
font-size: 44rpx;
width: 100rpx;
text-align: center;
font-size: 60rpx;
&.wechat {
color: #00c800;
@ -519,6 +616,14 @@
color: #009fe8;
}
}
.huifu-box {
width: 100rpx;
display: flex;
justify-content: center;
.huifu {
height: 44rpx;
}
}
.item-left_text {
font-size: 28rpx;

@ -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;

@ -38,9 +38,12 @@
<view v-for="(item, index) in methods" :key="index" class="pay-item dis-flex flex-x-between"
@click="handleSelectPayType(index)">
<view class="item-left dis-flex flex-y-center">
<view class="item-left_icon" :class="[item.method]">
<view v-if="item.method!=='huifu'" class="item-left_icon" :class="[item.method]">
<text class="iconfont" :class="[PayMethodIconEnum[item.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[item.method].name }}</text>
</view>
@ -140,14 +143,26 @@
onLoad(options) {
//
this.getPageData()
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.curPaymentItem.method);
}
},
//
onSelectPlan(planId) {
this.selectedPlanId = planId
this.inputValue = ''
if (this.curPaymentItem.method === 'huifu') {
this.createOrder();
}
},
//
@ -159,6 +174,9 @@
//
handleSelectPayType(index) {
this.curPaymentItem = this.methods[index]
if (this.curPaymentItem.method === 'huifu' && (this.selectedPlanId > 0 || this.inputValue)) {
this.createOrder();
}
},
//
@ -221,19 +239,51 @@
//
if (app.disabled) return
app.disabled = true
//
RechargeApi.submit({
planId: app.selectedPlanId,
customMoney: app.inputValue ? app.inputValue : '',
method: app.curPaymentItem.method,
client: app.platform,
extra: app.getExtraAsUnify(app.curPaymentItem.method)
})
.then(result => app.onSubmitCallback(result))
.finally(err => {
setTimeout(() => app.disabled = false, 10)
})
if (app.curPaymentItem.method === 'huifu') {
app.disabled = false
if (!this.selectedPlanId && !this.inputValue) {
app.$toast('请选择充值套餐或输入充值金额');
return;
}
if (!app.miniPayRequest || Object.keys(app.miniPayRequest).length === 0) {
app.$toast(`暂无${app.PayMethodEnum[app.curPaymentItem.method].name}支付信息`);
return
}
let appPayRequest = '';
appPayRequest = encodeURIComponent(JSON.stringify({
sign: app.miniPayRequest.sign,
prepayid: app.miniPayRequest.prepayid,
}));
uni.openEmbeddedMiniProgram({
appId: app.miniPayRequest.miniuser,
path: `${app.miniPayRequest.minipath}?appPayRequest=${appPayRequest}`
});
} else {
// API
this.createOrder();
}
},
createOrder() {
const app = this;
RechargeApi.submit({
planId: app.selectedPlanId,
customMoney: app.inputValue ? app.inputValue : '',
method: app.curPaymentItem.method,
client: app.platform,
extra: app.getExtraAsUnify(app.curPaymentItem.method)
})
.then(result => {
console.log(result);
if (app.curPaymentItem.method === 'huifu') {
const { miniPayRequest, out_trade_no } = result.data.payment;
app.miniPayRequest = miniPayRequest;
app.miniPayRequest.out_trade_no = out_trade_no;
} else {
app.onSubmitCallback(result)
}
})
.finally(err => setTimeout(() => app.disabled = false, 10))
},
//
getExtraAsUnify(method) {
@ -466,8 +516,9 @@
font-size: 26rpx;
.item-left_icon {
margin-right: 20rpx;
font-size: 44rpx;
width: 100rpx;
text-align: center;
font-size: 60rpx;
&.wechat {
color: #00c800;
@ -478,6 +529,15 @@
}
}
.huifu-box {
width: 100rpx;
display: flex;
justify-content: center;
.huifu {
height: 44rpx;
}
}
.item-left_text {
font-size: 30rpx;

Loading…
Cancel
Save