msb_prod
ch 3 years ago
parent 3636fc2958
commit b2bdc38c30

@ -2,12 +2,12 @@
* @Author: ch * @Author: ch
* @Date: 2022-07-08 11:46:30 * @Date: 2022-07-08 11:46:30
* @LastEditors: ch * @LastEditors: ch
* @LastEditTime: 2022-07-12 10:47:34 * @LastEditTime: 2022-07-12 10:55:29
* @Description: file content * @Description: file content
*/ */
import {FormatSearchJson} from '@/common/utils'; import { FormatSearchJson } from '@/common/utils';
import {ApiGetOpenId, ApiGetAuthUrl} from '@/common/api/auth'; import { ApiGetOpenId, ApiGetAuthUrl } from '@/common/api/auth';
import { ApiGetOrderInfo } from '@/common/api/pay'; import { ApiGetOrderInfo } from '@/common/api/pay';
import Vue from 'vue'; import Vue from 'vue';
import App from './App'; import App from './App';
@ -18,59 +18,44 @@ const ua = navigator ? navigator.userAgent.toLowerCase() : '';
if (ua.includes('micromessenger')) { if (ua.includes('micromessenger')) {
const openId = localStorage.getItem('openId'); const openId = localStorage.getItem('openId');
if(!openId){ if (!openId) {
let query = FormatSearchJson(window.location.search); let query = FormatSearchJson(window.location.search);
if(query.code){
ApiGetOrderInfo({ payOrderNo: query.payOrderNo }).then(({ result }) => {
const appid = result.prepayWxApp.prepayAppId;
if (query.code) {
ApiGetOpenId({ ApiGetOpenId({
code : query.code code: query.code,
}).then(({error, result}) => { appid
if(error){ }).then(({ error, result }) => {
if (error) {
// uni.$u.toast(error.message); // uni.$u.toast(error.message);
return false; return false;
} }
store.commit('SET_OPEN_ID', result.openId); store.commit('SET_OPEN_ID', result.openId);
}) })
} else { } else {
ApiGetOrderInfo({ payOrderNo: query.payOrderNo }).then(({result}) => {
ApiGetAuthUrl({ ApiGetAuthUrl({
appid: result.prepayWxApp.prepayAppId, appid,
redirectUrl : window.location.href, redirectUrl: window.location.href,
scope : 'snsapi_base' scope: 'snsapi_base'
}).then(({result, error}) => { }).then(({ result, error }) => {
if(error){ if (error) {
// uni.$u.toast(error.message); // uni.$u.toast(error.message);
uni.showToast({ uni.showToast({
title: error.message, title: error.message,
icon: 'none', icon: 'none',
duration : 2000 duration: 2000
}) })
return false; return false;
} }
window.location.replace(result); window.location.replace(result);
}); });
})
// ApiGetOpenId({ payOrderNo: query.payOrderNo }).then(res => {
// ApiGetAuthUrl({
// redirectUrl : window.location.href,
// scope : 'snsapi_base'
// }).then(({result, error}) => {
// if(error){
// // uni.$u.toast(error.message);
// uni.showToast({
// title: error.message,
// icon: 'none',
// duration : 2000
// })
// return false;
// }
// window.location.replace(result);
// })
// });
} }
})
} }
} }

Loading…
Cancel
Save