msb_beta
ch 3 years ago
parent 8769ead395
commit 106da4ad72

@ -2,7 +2,7 @@
* @Author: ch * @Author: ch
* @Date: 2022-04-28 16:30:54 * @Date: 2022-04-28 16:30:54
* @LastEditors: ch * @LastEditors: ch
* @LastEditTime: 2022-04-28 17:00:54 * @LastEditTime: 2022-04-28 18:11:12
* @Description: file content * @Description: file content
*/ */
@ -24,8 +24,15 @@ export const ApiGetOpenId = ({code}) =>
ToAsyncAwait(MsbRequest.get(`${BASE_URL}/wx/mp/getOpenId/${APPID}`, {code})); ToAsyncAwait(MsbRequest.get(`${BASE_URL}/wx/mp/getOpenId/${APPID}`, {code}));
/** /**
* 获取支付参数 * 微信h5支付获取支付URL
* @param {*} data * @param {*} data
*/ */
export const ApiPostWxPay = (data) => export const ApiPostWxH5Pay = (data) =>
ToAsyncAwait(MsbRequestTk.post(`${BASE_URL}/pay/wxPay/h5`, 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 * @Author: ch
* @Date: 2022-03-22 18:28:52 * @Date: 2022-03-22 18:28:52
* @LastEditors: ch * @LastEditors: ch
* @LastEditTime: 2022-04-28 16:45:47 * @LastEditTime: 2022-04-28 18:05:32
* @Description: file content * @Description: file content
*/ */
import Vue from 'vue' import Vue from 'vue'
@ -44,6 +44,9 @@ export default new Vuex.Store({
}, },
SET_SESSION_MSG_COUNT (state, data){ SET_SESSION_MSG_COUNT (state, data){
state.sessionMsgCount = data; state.sessionMsgCount = data;
},
SET_OPEN_ID (state, data){
state.openId = data;
} }
}, },
actions : { actions : {

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

Loading…
Cancel
Save