|
@@ -1,6 +1,5 @@
|
|
|
<script>
|
|
|
import { isWechat, wxConfigH5, weixinLogin, getQueryString } from '@/utils/utils';
|
|
|
- import { wxUserInfo } from '@/api/userInfo';
|
|
|
|
|
|
export default {
|
|
|
async onLaunch(options) {
|
|
@@ -20,26 +19,11 @@
|
|
|
// #endif
|
|
|
// 获取页面设置配置
|
|
|
if(process.env.NODE_ENV === 'production') {
|
|
|
- const token = uni.getStorageSync('accessToken');
|
|
|
- const wxUser = uni.getStorageSync('wxUser');
|
|
|
const code = getQueryString('code');
|
|
|
- if (!wxUser && !code) {
|
|
|
+ const storageCode = uni.getStorageInfoSync('code');
|
|
|
+ if((code && !storageCode) || (storageCode && code != storageCode)) {
|
|
|
+ uni.setStorageSync('code', code)
|
|
|
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('获取用户失败');
|
|
|
- })
|
|
|
}
|
|
|
}
|
|
|
}
|