|
@@ -1,6 +1,5 @@
|
|
<script>
|
|
<script>
|
|
import { isWechat, wxConfigH5, weixinLogin, getQueryString } from '@/utils/utils';
|
|
import { isWechat, wxConfigH5, weixinLogin, getQueryString } from '@/utils/utils';
|
|
- import { wxUserInfo } from '@/api/userInfo';
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
async onLaunch(options) {
|
|
async onLaunch(options) {
|
|
@@ -12,40 +11,19 @@
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
async initData() {
|
|
async initData() {
|
|
- this.$mStore.dispatch('getCompetitionId')
|
|
|
|
// #ifdef H5
|
|
// #ifdef H5
|
|
if (isWechat()) {
|
|
if (isWechat()) {
|
|
const url = window.location.href.split('#')[0];
|
|
const url = window.location.href.split('#')[0];
|
|
await wxConfigH5(url);
|
|
await wxConfigH5(url);
|
|
}
|
|
}
|
|
// #endif
|
|
// #endif
|
|
- const token = uni.getStorageSync('accessToken');
|
|
|
|
// 获取页面设置配置
|
|
// 获取页面设置配置
|
|
if(process.env.NODE_ENV === 'production') {
|
|
if(process.env.NODE_ENV === 'production') {
|
|
- const token = uni.getStorageSync('accessToken');
|
|
|
|
- const wxUser = uni.getStorageSync('wxUser');
|
|
|
|
const code = getQueryString('code');
|
|
const code = getQueryString('code');
|
|
- if (!wxUser && !code) {
|
|
|
|
|
|
+ const storageCode = uni.getStorageInfoSync('code');
|
|
|
|
+ if((code && !storageCode) || (storageCode && code != storageCode)) {
|
|
|
|
+ uni.setStorageSync('code', code)
|
|
weixinLogin();
|
|
weixinLogin();
|
|
- } else if (!wxUser && code) {
|
|
|
|
- this.$http.get(wxUserInfo, {
|
|
|
|
- 'code': code
|
|
|
|
- })
|
|
|
|
- .then((res) => {
|
|
|
|
- this.$mStore.commit('wxUser', res.data);
|
|
|
|
- if (!this.$mStore.getters.hasLogin) {
|
|
|
|
- this.$mRouter.push({
|
|
|
|
- route: '/pages/login/index'
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- .catch(() => {
|
|
|
|
- this.$mHelper.toast('获取用户失败');
|
|
|
|
- })
|
|
|
|
- } else if (wxUser && !code) {
|
|
|
|
-
|
|
|
|
- } else if (wxUser && code) {
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|