msb_prod
ch 3 years ago
parent 3636fc2958
commit b2bdc38c30

@ -2,83 +2,68 @@
* @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';
import '@/common/utils/uniUtilsIndex' import '@/common/utils/uniUtilsIndex'
// 微信打开需要授权 // 微信打开需要授权
const ua = navigator ? navigator.userAgent.toLowerCase() : ''; 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){
ApiGetOpenId({ ApiGetOrderInfo({ payOrderNo: query.payOrderNo }).then(({ result }) => {
code : query.code const appid = result.prepayWxApp.prepayAppId;
}).then(({error, result}) => { if (query.code) {
if(error){ ApiGetOpenId({
// uni.$u.toast(error.message); code: query.code,
return false; appid
} }).then(({ error, result }) => {
store.commit('SET_OPEN_ID', result.openId); if (error) {
}) // uni.$u.toast(error.message);
} else { return false;
ApiGetOrderInfo({ payOrderNo: query.payOrderNo }).then(({result}) => { }
store.commit('SET_OPEN_ID', result.openId);
})
} else {
ApiGetAuthUrl({
appid,
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);
});
}
})
}
ApiGetAuthUrl({
appid: result.prepayWxApp.prepayAppId,
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);
});
})
// 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);
// })
// });
}
}
} }
Vue.config.productionTip = false Vue.config.productionTip = false
App.mpType = 'app' App.mpType = 'app'
const app = new Vue({ const app = new Vue({
...App ...App
}) })
app.$mount() app.$mount()

Loading…
Cancel
Save