msb_beta
ch 3 years ago
parent 8769ead395
commit 106da4ad72

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-04-28 16:30:54
* @LastEditors: ch
* @LastEditTime: 2022-04-28 17:00:54
* @LastEditTime: 2022-04-28 18:11:12
* @Description: file content
*/
@ -24,8 +24,15 @@ export const ApiGetOpenId = ({code}) =>
ToAsyncAwait(MsbRequest.get(`${BASE_URL}/wx/mp/getOpenId/${APPID}`, {code}));
/**
* 获取支付参数
* 微信h5支付获取支付URL
* @param {*} data
*/
export const ApiPostWxPay = (data) =>
ToAsyncAwait(MsbRequestTk.post(`${BASE_URL}/pay/wxPay/h5`, data));
export const ApiPostWxH5Pay = (data) =>
ToAsyncAwait(MsbRequestTk.post(`${BASE_URL}/pay/wxPay/h5`, data));
/**
* 微信JSAPI支付获取支付参数
* @param {*} data
*/
export const ApiPostWxJsApiPay = (data) =>
ToAsyncAwait(MsbRequestTk.post(`${BASE_URL}/pay/wxPay/jsapi`, data));

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-03-22 18:28:52
* @LastEditors: ch
* @LastEditTime: 2022-04-28 16:45:47
* @LastEditTime: 2022-04-28 18:05:32
* @Description: file content
*/
import Vue from 'vue'
@ -44,6 +44,9 @@ export default new Vuex.Store({
},
SET_SESSION_MSG_COUNT (state, data){
state.sessionMsgCount = data;
},
SET_OPEN_ID (state, data){
state.openId = data;
}
},
actions : {

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-03-20 14:14:53
* @LastEditors: ch
* @LastEditTime: 2022-04-28 17:15:11
* @LastEditTime: 2022-04-28 18:18:30
* @Description: file content
-->
<template>
@ -81,7 +81,7 @@
<script>
import UiCell from '@/components/UiCell';
import {ApiPostSubmitOrder, ApiGetBeforeOrder, ApiGetBeforeCartOrder} from '@/common/api/order';
import { ApiPostWxPay } from '@/common/api/wx';
import { ApiPostWxH5Pay, ApiPostWxJsApiPay } from '@/common/api/wx';
import UiButton from '@/components/UiButton.vue';
import UiWhiteBox from '../../components/UiWhiteBox.vue';
export default {
@ -181,14 +181,24 @@ export default {
}
},
async wxpay(orderId){
const ua = navigator.userAgent.toLowerCase();
if(ua.includes('micromessenger')) {
const openId = this.$store.state.openId;
if(openId) {
// JSAPI
const {error, result} = await ApiPostWxJsApiPay({orderId,openId});
if(error){
uni.$u.toast(error.message);
return false;
}
WeixinJSBridge.invoke('getBrandWCPayRequest', result.dataInfo, res => {
if(res.err_msg === 'get_brand_wcpay_request:cancel'){
this.$$Router.replace(`/payResult?orderId=${orderId}`);
}else{
this.$$Router.replace(`/orderDetail?id=${orderId}`);
}
})
}else{
// h5
const {error, result} = await ApiPostWxPay({orderId});
const {error, result} = await ApiPostWxH5Pay({orderId});
if(error){
uni.$u.toast(error.message);
return false;

Loading…
Cancel
Save