登录模块调整,兼容H5平台

This commit is contained in:
唐明明
2022-01-11 11:35:38 +08:00
parent 69328de055
commit a27ffc0a7f
6 changed files with 139 additions and 20 deletions

View File

@@ -1,26 +1,91 @@
<template>
<view>
<oct-pay
price="100.00"
payNo="2021321649127837218918231"
:price="price"
:payNo="payNo"
color="#34CE98"
price-color="#e6576b"
:payPlatform="['alipay', 'wxpay']"
:payPlatform="platform"
@onPay="pay"
/>
</view>
</template>
<script>
import { wxPAY, alPAY } from '@/apis/interfaces/pay'
export default {
data() {
return {
payNo : "",
price : "",
platform: ['wxpay', 'alipay']
}
},
mounted() {
this.payNo = this.$Route.query.orderNo
this.price = Number(this.$Route.query.price).toFixed(2)
},
methods: {
pay(e){
console.log("支付平台" + e.platform)
uni.getProvider({
service: 'payment',
success: res => {
if(res.provider.findIndex(val => val === e.platform) < 0){
switch (e.platform){
case 'wxpay':
uni.showToast({
title: '支付失败,您暂未安装微信',
icon : 'none'
})
break;
case 'alipay':
uni.showToast({
title: '支付失败,您暂未安装支付宝',
icon : 'none'
})
break;
}
return
}
if(e.platform === 'wxpay') this.getWXPAY(e.platform)
if(e.platform === 'alipay') this.getALPAY(e.platform)
}
})
},
getALPAY(payType){
alPAY(this.payNo).then(res => {
this.callPay(res, payType)
})
},
getWXPAY(payType){
wxPAY(this.payNo).then(res => {
let config = JSON.parse(res)
this.callPay(config, payType)
})
},
callPay(orderInfo, payType){
uni.requestPayment({
provider: payType,
orderInfo,
success: payRes => {
console.log(payRes)
},
fail: payErr => {
console.log(payErr)
if(payErr.errCode == '-100'){
uni.showToast({
title: '支付被取消',
icon : 'none'
})
}else{
uni.showToast({
title: payErr.errMsg,
icon : 'none'
})
}
}
})
}
}
}

View File

@@ -75,7 +75,6 @@
if(JSON.stringify(this.$store.getters.getAddress) !== '{}') this.address = this.$store.getters.getAddress
},
mounted() {
console.log(this.$Route.query)
this.getBuy()
},
methods:{
@@ -107,10 +106,13 @@
address_id : this.address.address_id,
remark : this.remark || ''
}).then(res => {
console.log(res)
this.$store.commit('setAddress', {})
this.$Router.replace({
name: 'Pay'
name: 'Pay',
params: {
orderNo: res.order_no,
price : res.total
}
})
})
}

View File

@@ -62,7 +62,6 @@
methods:{
getGoods(){
goods(this.$Route.query.id).then(res => {
console.log(res)
this.goods = res
})
},