6f893b30 by 华明祺

登录调整

1 parent c0aee960
......@@ -13,7 +13,6 @@ export default {
firstload = true
this.globalData.baseUrl_api = config.baseUrl_api;
let userName = uni.getStorageSync('userName')
if (userName) {
this.globalData.isLogin = true;
......
......@@ -90,15 +90,21 @@ function loginByPhone(phonenumber, code) {
// 获取用户详细信息
function getInfo() {
let app
return request({
url: `${config.baseUrl_api}/getInfoForPc`,
method: 'get'
}).then(res => {
const app = getApp()
app = getApp()
const user = res.data.user
uni.setStorageSync('userName', user.userName)
uni.setStorageSync('perId', aes.encrypt(user.userId))
app.globalData.userInfo = user
}).catch(() => {
app = getApp()
uni.removeStorageSync('token')
uni.removeStorageSync('userName')
app.globalData.isLogin = false
})
}
......
// import config from '@/config.js'
import {
h5LoginAuto
} from './login'
import _ from 'lodash'
const excludeUrls = ['pages/index/login', 'pages/index/register']
const excludeUrls = ['getMemberCountInfo', 'getInfoForPc']
// 获取Token
function getToken() {
......@@ -65,10 +63,9 @@ const request = function(req) {
switch (res.statusCode) {
case 200:
const data = res.data || {}
if (!data || data.code === 0 || data.code === 200 || data.pageData?.code ===
200) {
if (!data || data.code === 0 || data.code === 200 || data.pageData?.code === 200) {
resolve(data)
} else if (req.url.indexOf('getMemberCountInfo') > -1) {
} else if (_.some(excludeUrls, (url) => req.url.indexOf(url) > -1)) {
resolve(data)
} else {
if (data.msg) {
......@@ -80,26 +77,27 @@ const request = function(req) {
}
// 登录超时
if (data.code === 60002 || data.code === 60001) {
uni.redirectTo({
url: '/pages/index/login'
})
} else if (data.code === 401) {
h5LoginAuto()
.then(() => {
uni.hideLoading()
uni.redirectTo({
url: getCurrentPages()[getCurrentPages()
.length - 1].$page.fullPath
})
})
.catch(() => {
uni.showToast({
title: '服务异常,请稍后重试',
icon: 'none'
})
})
}
// if (data.code === 60002 || data.code === 60001) {
// uni.redirectTo({
// url: '/pages/index/login'
// })
// } else if (data.code === 401) {
// h5LoginAuto()
// .then(() => {
// uni.hideLoading()
// uni.redirectTo({
// url: getCurrentPages()[getCurrentPages()
// .length - 1].$page.fullPath
// })
// })
// .catch(() => {
// debugger
// uni.showToast({
// title: '服务异常,请稍后重试',
// icon: 'none'
// })
// })
// }
reject(res)
}
......
<template>
<view>
<web-view src="http://192.168.1.194:5173">
<web-view src="http://192.168.1.98:5173">
</web-view>
</view>
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!