完善支付选项

This commit is contained in:
@fawn-nine
2023-05-31 16:25:16 +08:00
parent c37c93a293
commit 27f08527e8
8 changed files with 412 additions and 66 deletions

View File

@@ -67,8 +67,8 @@
<text>{{farePrice}}</text>
</view>
</view>
<view class="zhif_fangsh">
<!-- 安卓支付列表 -->
<view class="zhif_fangsh" v-if="isAndorid">
<view class="zhif_radio">
<u-radio-group v-model="payType">
<view style="width: 100%;">
@@ -84,7 +84,24 @@
</u-radio-group>
</view>
</view>
<!-- ios支付列表 -->
<view class="zhif_fangsh" v-else>
<view class="zhif_radio">
<u-radio-group v-model="payType">
<view style="width: 100%;">
<view v-for="(item, index) in paylistIos" class="zhif_xuanx">
<image :src="item.img"></image>
{{item.title}}
<span v-if="item.id == 4" style="color: #bbb; margin-left: 10px;">{{userMes.peanutCoin}}疯币可用</span>
<span @click.stop="buPoint" style="color: #bf0c0c; margin-left: 10px;" v-if="item.id == 4" class="chongBtn">去充值</span>
<u-radio :key="index" activeColor="#fe6e09" :name='item.id'
style="float: right;margin-top: 5rpx;" ></u-radio>
</view>
</view>
</u-radio-group>
</view>
</view>
<view class="footer" >
<view class="commodityPrice" v-if="payType != 4">
<span style="color: #666;margin-right: 10rpx; font-size: 15px;">实付款: </span>
@@ -183,7 +200,7 @@
import $http from '@/config/requestConfig.js';
import {
setPay,
setPayAssign
setPayAssign,setWXPay
} from '@/config/utils';
import {
mapState
@@ -191,6 +208,8 @@
export default {
data() {
return {
isAndorid:true, // 操作系统
typeId: 0,
shangIDNum: 0,
cartIDNum: [],
@@ -234,6 +253,27 @@
// img: '../../static/icon/pay_2.png'
// }
],
paylistIos: [{
title: '支付宝',
id: 2,
img: '../../static/icon/pay_1.png'
},
// {
// title: '微信',
// id: 1,
// img: '../../static/icon/pay_2.png'
// },
{
title: '疯币购买',
id: 4,
img: '../../static/icon/oder_chong.png'
},
// {
// title: 'ios内购',
// id: 3,
// img: '../../static/icon/pay_2.png'
// }
],
}
},
onLoad(e) {
@@ -254,12 +294,24 @@
} else if (this.typeId == 0) {
this.getShangList(this.shangIDNum);
}
this.getData()
this.getData()
this.getOS()
},
computed: {
...mapState(['userInfo']),
},
methods: {
// 获得操作系统
getOS(){
let oprateOs = ''
oprateOs = uni.getSystemInfoSync().platform
console.log(oprateOs)
if(oprateOs == 'android'){
this.isAndorid = true
}else{
this.isAndorid = false
}
},
// 充值疯币
buPoint() {
uni.navigateTo({
@@ -306,7 +358,7 @@
if(this.realPrice > this.userMes.peanutCoin){
uni.showToast({
title:'疯币不足,请充值',
icon: 'error',
icon: 'none',
duration: 2000
})
return
@@ -548,7 +600,7 @@
image: '../../static/icon/ic_close.png'
});
} else {
if(this.payType != 4){
if(this.payType == 2){
// 常规支付
uni.showToast({
title: "正在支付",
@@ -584,7 +636,41 @@
}, 1000)
}
})
}else{
}else if(this.payType == 1){
// 微信支付
let data1 = {
orderSn:res.orderSn,
buyOrderId: null,
totalAmount: res.money
}
setWXPay(data1,res => {
if (res.success) {
uni.showToast({
title: "支付成功"
});
setTimeout(() => {
uni.navigateTo({
url: './orderList'
});
}, 1000)
} else {
console.log(res)
if(res.data.errMsg.indexOf('User canceled') != -1){
uni.showToast({
title: "用户取消支付",
icon: "none",
image: '../../static/icon/ic_close.png'
});
}else{
uni.showToast({
title: "支付失败",
icon: "none",
image: '../../static/icon/ic_close.png'
});
}
}
})
}else if(this.payType == 4){
// 疯币支付
uni.showToast({
title: "购买成功",
@@ -767,7 +853,7 @@
padding: 30rpx 40rpx 0 40rpx;
background-color: #fff;
border-bottom: 1px solid #eee;
padding-bottom:90rpx;
.zhif_radio {
.zhif_xuanx {