🐞 fix(重定向登录): 修复重定向登录时请求mall路径的问题

This commit is contained in:
xuan 2022-11-22 15:16:39 +08:00
parent 625616cc0e
commit 7b79db34fc
2 changed files with 15 additions and 9 deletions

View File

@ -183,13 +183,19 @@ export const useRequest = (
// removeSessionKey()
removeUserInfo()
// 跳转回登录页面
login().catch((err)=>{
if (err){
Taro.reLaunch({
url: '/pages/login/index',
})
}
Taro.reLaunch({
url: '/pages/login/index',
})
// 这一步是微信授权登录的步骤如果执行通过了就不需要重定向到login页面了
// 但是因为现在还没有规划微信授权登录这一步所以注释掉直接重定向到login页面
// 2022-11-22
// login().catch((err)=>{
// if (err){
// Taro.reLaunch({
// url: '/pages/login/index',
// })
// }
// })
} else {
Taro.showToast({
title: `错误:${showStatus(statusCode)}`,

View File

@ -1,9 +1,8 @@
import { BASE_URL, WX_APPID } from '@/common/constant'
import Taro, { useRouter } from '@tarojs/taro'
import { useRef, useState } from 'react'
import { useRef } from 'react'
import qs from 'qs'
import useUserInfo from './useUserInfo'
import useLogin from './useLogin'
//开这个hook 主要是为了让useHttp 能够调用
@ -23,10 +22,11 @@ export default () => {
//微信登录请求v2
const fetchDataLogin = async (login_code) => {
const q = {
url: BASE_URL + '/v1/mall/login',
url: BASE_URL + '/v2/mp/login',
header: {
Platform: 3,
Appid: WX_APPID,
// Authorization: token || stateRef.current.token,
},
method: 'post',
data: { js_code: login_code },