Browse Source

对接微信支付

master
unknown 7 months ago
parent
commit
a8cb9e4023
  1. 6
      config/api.js
  2. 12
      manifest.json
  3. 62
      pages/indexEntry/enroll/payment/payh5.vue
  4. 67
      pages/indexEntry/enroll/payment/payment.vue

6
config/api.js

@ -222,6 +222,12 @@ export const periodConfirm = (data) => http.post('app/student-process/periodConf
export const pre_create = (data) => http.post('pay/ysb/pre_create', data) export const pre_create = (data) => http.post('pay/ysb/pre_create', data)
// 创建支付应用信息加密 // 创建支付应用信息加密
export const param_sign = (data) => http.post('pay/ysb/param_sign', data) export const param_sign = (data) => http.post('pay/ysb/param_sign', data)
// 支付订单详情接口
export const course_info = (data) => http.post('pay/ysb/course_info', data)
// 查询支付状态
export const order_info = (data) => http.post('pay/ysb/order_info', data)

12
manifest.json

@ -2,8 +2,8 @@
"name" : "洛阳学车", "name" : "洛阳学车",
"appid" : "__UNI__3347C6E", "appid" : "__UNI__3347C6E",
"description" : "", "description" : "",
"versionName" : "1.1.8",
"versionCode" : 118,
"versionName" : "1.1.9",
"versionCode" : 119,
"transformPx" : false, "transformPx" : false,
/* 5+App */ /* 5+App */
"app-plus" : { "app-plus" : {
@ -82,8 +82,8 @@
"sdkConfigs" : { "sdkConfigs" : {
"share" : { "share" : {
"weixin" : { "weixin" : {
"appid" : "wx9e7d9eea420f6541",
"UniversalLinks" : "https://static-mp-87b9fa27-0273-48d3-a586-bd058cd2ce3d.next.bspapp.com/uni-universallinks/__UNI__3347C6E/"
"appid" : "wxdfeef42d2a053912",
"UniversalLinks" : "https://payconfig.jaxc.cn/"
} }
}, },
"ad" : {}, "ad" : {},
@ -108,8 +108,8 @@
"payment" : { "payment" : {
"weixin" : { "weixin" : {
"__platform__" : [ "ios", "android" ], "__platform__" : [ "ios", "android" ],
"appid" : "wx9e7d9eea420f6541",
"UniversalLinks" : "https://static-mp-87b9fa27-0273-48d3-a586-bd058cd2ce3d.next.bspapp.com/uni-universallinks/__UNI__3347C6E/"
"appid" : "wxdfeef42d2a053912",
"UniversalLinks" : "https://payconfig.jaxc.cn/"
} }
} }
} }

62
pages/indexEntry/enroll/payment/payh5.vue

@ -6,11 +6,32 @@
</template> </template>
<script> <script>
let polling = null
let timerNum = 0
import { order_info } from '@/config/api.js'
export default { export default {
onLoad() {
data() {
return {
iswxPay: false
}
},
onLoad(options) {
this.outTradeNo = options.outTradeNo
this.initWx() this.initWx()
this.order_infoFn()
},
onShow() {
if(this.iswxPay) {
timerNum = 0
this.pollFn()
}
},
onHide() {
clearInterval(polling)
polling = null
}, },
methods: { methods: {
// h5
postMessage(res) { postMessage(res) {
console.log('监听到了') console.log('监听到了')
let item = res.detail.data[0] let item = res.detail.data[0]
@ -19,15 +40,51 @@
console.log(item) console.log(item)
if(item.action=='lyxc-wxPay') { if(item.action=='lyxc-wxPay') {
this.$u.toast('用户点击了微信支付') this.$u.toast('用户点击了微信支付')
this.iswxPay = true
this.wxPay(item) this.wxPay(item)
}else if(item.action=='lyxc-paySuccess') { }else if(item.action=='lyxc-paySuccess') {
this.$u.toast('支付完成,app跳转页面吧')
this.$u.toast('支付成功')
this.iswxPay = false
setTimeout(()=>{
uni.switchTab({
url: '/pages/tabbar/learnCar/index'
})
},1500)
}
},
//
pollFn() {
polling = setInterval(async ()=>{
timerNum ++
if(timerNum>10) {
clearInterval(polling)
polling = null
}
await this.order_infoFn()
},1000)
},
//
async order_infoFn() {
const {data: res} = await order_info({outTradeNo:this.outTradeNo})
if(res.status==10) {
this.$u.toast('支付成功')
clearInterval(polling)
polling = null
setTimeout(()=>{
uni.switchTab({
url: '/pages/tabbar/learnCar/index'
})
},1500)
} }
console.log('订单状态')
console.log(res)
}, },
// "action": "lyxc-wxPay", // "action": "lyxc-wxPay",
// "miniProgramType": 2, // "miniProgramType": 2,
// "miniAppId": "gh_89b377cbc340", // "miniAppId": "gh_89b377cbc340",
// "path": "/pages/wxPayOnly/wxPayOnly?channelNo=QD202404083509&orderNo=20240423170705024771&inpartNo=820198016000045&merchantName=&amount=1&redMsg=&payType=04" // "path": "/pages/wxPayOnly/wxPayOnly?channelNo=QD202404083509&orderNo=20240423170705024771&inpartNo=820198016000045&merchantName=&amount=1&redMsg=&payType=04"
//
wxPay(item) { wxPay(item) {
console.log(item) console.log(item)
// #ifdef APP-PLUS // #ifdef APP-PLUS
@ -38,6 +95,7 @@
}) : plus.nativeUI.alert('当前环境不支持微信操作!'); }) : plus.nativeUI.alert('当前环境不支持微信操作!');
// #endif // #endif
}, },
//
initWx() { initWx() {
// #ifdef APP-PLUS // #ifdef APP-PLUS
plus.share.getServices((s) => { plus.share.getServices((s) => {

67
pages/indexEntry/enroll/payment/payment.vue

@ -18,30 +18,7 @@
<view class="val">{{info.a}}</view> <view class="val">{{info.a}}</view>
</view> --> </view> -->
</view> </view>
<view class="card">
<view class="pay">
<!-- <view class="h2">选择支付方式</view> -->
<!-- <view class="row border">
<view class="wxIcon">
<image src="@/static/images/carIcon/xfbIcon.png" mode=""></image>
</view>
<view class="text">支付宝</view>
<view class="icon">
<!-- <image src="@/static/images/index/noSelect.png" mode=""></image> -->
<!-- <image src="@/static/images/carIcon/isSelect.png" mode=""></image>
</view> -->
</view>
<!-- <view class="row">
<view class="wxIcon">
<image src="@/static/images/carIcon/wxIcon.png" mode=""></image>
</view>
<view class="text">微信</view>
<view class="icon">
<image src="@/static/images/index/noSelect.png" mode=""></image>
<image src="@/static/images/carIcon/isSelect.png" mode=""></image>
</view>
</view> -->
</view>
</view> </view>
<view class="footerBtn pad"> <view class="footerBtn pad">
<view class="btnBg" @click="getStudentByPayment()">确认支付</view> <view class="btnBg" @click="getStudentByPayment()">确认支付</view>
@ -54,7 +31,7 @@
<script> <script>
import { import {
getStudentByPayment, pre_create, param_sign
getStudentByPayment, pre_create, param_sign,course_info
} from '@/config/api.js' } from '@/config/api.js'
export default { export default {
data() { data() {
@ -72,14 +49,14 @@
this.trainingApplyId = options.trainingApplyId this.trainingApplyId = options.trainingApplyId
} }
// this.getYSBLink() // this.getYSBLink()
this.getStudentByPayment()
this.course_infoFn()
this.initWx() this.initWx()
}, },
onPullDownRefresh() { onPullDownRefresh() {
// this.getStudentByPayment() // this.getStudentByPayment()
}, },
methods: { methods: {
//
initWx() { initWx() {
// #ifdef APP-PLUS // #ifdef APP-PLUS
plus.share.getServices((s) => { plus.share.getServices((s) => {
@ -96,7 +73,13 @@
}); });
// #endif // #endif
}, },
//
async course_infoFn() {
const {data: res} = await course_info({trainingApplyId: this.trainingApplyId})
this.amount = res.amount
this.schoolName = res.schoolName
},
// 1
async getStudentByPayment(type) { async getStudentByPayment(type) {
console.log('来到了这没有') console.log('来到了这没有')
const { const {
@ -104,13 +87,11 @@
} = await pre_create({ } = await pre_create({
trainingApplyId: this.trainingApplyId trainingApplyId: this.trainingApplyId
}) })
this.amount = res.amount
this.schoolName = res.schoolName
console.log('创建的订单信息') console.log('创建的订单信息')
console.log(res) console.log(res)
this.param_sign(res.orderNo) this.param_sign(res.orderNo)
}, },
//
// 2
async param_sign(outOrderNo) { async param_sign(outOrderNo) {
let obj = { let obj = {
outOrderNo, outOrderNo,
@ -118,13 +99,13 @@
} }
console.log(JSON.stringify(obj)) console.log(JSON.stringify(obj))
const {data: res} = await param_sign({jsonParam:JSON.stringify(obj)}) const {data: res} = await param_sign({jsonParam:JSON.stringify(obj)})
this.encodeData = res.encodeData
console.log('加密后的数据') console.log('加密后的数据')
console.log(res.encodeData) console.log(res.encodeData)
this.getYSBLink()
this.getYSBLink(res.encodeData, outOrderNo)
}, },
async getYSBLink() {
if(!this.encodeData) return this.$u.toast('没有获取到支付信息')
// 3h5
async getYSBLink(encodeData, outTradeNo) {
if(!encodeData) return this.$u.toast('没有获取到支付信息')
const channelNo = 'QD202404083509'; const channelNo = 'QD202404083509';
//commonh5platformpay_miniPro //commonh5platformpay_miniPro
const platform = 'common'; const platform = 'common';
@ -134,13 +115,12 @@
const preUrl = 'https://u8wbs.zyebank.cn/cem_ysb_u8/index.html' const preUrl = 'https://u8wbs.zyebank.cn/cem_ysb_u8/index.html'
// //
// const preUrl = 'https://zmcht.zybank.com.cn/cem_ysb/index.html'; // const preUrl = 'https://zmcht.zybank.com.cn/cem_ysb/index.html';
// let obj = {"outOrderNo":orderNo || "2024041211570300000308","timestamp":"1632815312300"}
const distinctId = this.userId
const payLink = `${preUrl}?encodeData=${this.encodeData}#/checkStandPre?platform=${platform}&channelNo=${channelNo}&checkStand_v3=true&distinctId=${distinctId}`;
console.log('payLink')
const distinctId = this.userId //
const payLink = `${preUrl}?encodeData=${encodeData}#/checkStandPre?platform=${platform}&channelNo=${channelNo}&checkStand_v3=true&distinctId=${distinctId}`;
console.log('第三方收银台')
console.log(payLink) console.log(payLink)
this.$store.commit('updateWebVeiwUrl', payLink) this.$store.commit('updateWebVeiwUrl', payLink)
this.$goPage('/pages/indexEntry/enroll/payment/payh5')
this.$goPage('/pages/indexEntry/enroll/payment/payh5?outTradeNo='+ outTradeNo)
}, },
@ -150,10 +130,13 @@
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.pageBg {
overflow: hidden;
}
.card { .card {
width: 100%; width: 100%;
margin-bottom: 20rpx;
padding: 0 20rpx;
margin: 50rpx 0;
padding: 40rpx 20rpx;
.orderInfo { .orderInfo {
text-align: center; text-align: center;

Loading…
Cancel
Save