1、购买选择规格属性点不了
2、购物车列表点击管理 点击收藏功能去掉 3、下单点击积分抵扣没反应 4、待收货 列表查看物流点击没反应,详情查看物流可以点 5、添加地址选择地区无效 6、个人中心我的余额点进去点击账单记录一直正在加载中,点击下全部就出来了,应该你没带默认参数 8、订单点击评价没反应 9、小程序订单核销没上 你那边先根据路径判断隐藏下 10、我的推广,里面样式有问题,点击海报里面空白 11、分类点击 会分类Tab页分类一级比一级低 12、拼团详情客服功能隐藏去掉,其他地方有客服功能的都去掉
This commit is contained in:
@ -218,7 +218,7 @@ export const login = (option) => {
|
||||
console.log('登录成功4')
|
||||
store.commit("LOGIN", data.token, dayjs(data.expires_time));
|
||||
console.log('登录成功5')
|
||||
|
||||
console.log(store)
|
||||
handleGetUserInfo()
|
||||
|
||||
}).catch(error => {
|
||||
@ -259,6 +259,7 @@ export const login = (option) => {
|
||||
}
|
||||
|
||||
export const handleGetUserInfo = () => {
|
||||
console.log('登录后请求用户信息')
|
||||
getUser().then(res => {
|
||||
console.log(res.data, '登录后的样式')
|
||||
store.dispatch('setUserInfo', res.data)
|
||||
@ -341,9 +342,25 @@ export function parseRoute($mp) {
|
||||
}
|
||||
}
|
||||
|
||||
export function auth() {
|
||||
/**
|
||||
* 如何判断权限?
|
||||
* 用户如果登录了系统,会留下两个东西,一个是token,一个是userInfo
|
||||
* token存在会过期的问题,如果长时间没有打开小程序,会导致登录失效,出现打开一个页面瞬间跳转到授权页面的问题
|
||||
* 解决办法,保存token的时候加上过期时间,每次请求都取一下缓存里的token
|
||||
* userInfo只是用来限时用户信息,作用并不是很大
|
||||
* ps:只需要判断 token 是否存在即可
|
||||
*/
|
||||
console.log(cookie.get('login_status'), 'token')
|
||||
if (cookie.get('login_status')) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
export const handleLoginStatus = (location, complete, fail, success) => {
|
||||
console.log(location, '开始健全')
|
||||
console.log(location, '开始检验权限')
|
||||
// 不登录可访问的页面
|
||||
let page = [{
|
||||
path: '/pages/Loading/index',
|
||||
@ -374,8 +391,7 @@ export const handleLoginStatus = (location, complete, fail, success) => {
|
||||
path = location.path
|
||||
}
|
||||
|
||||
console.log(store.getters.userInfo, '用户信息')
|
||||
if (!store.getters.token) {
|
||||
if (!auth()) {
|
||||
page.map((item) => {
|
||||
console.log(item.path == path)
|
||||
if (item.path == path) {
|
||||
|
@ -2,6 +2,7 @@ import Fly from "flyio/dist/npm/wx";
|
||||
import $store from "../store";
|
||||
import toLogin from "@/libs/login";
|
||||
import { VUE_APP_API_URL } from "@/config";
|
||||
import cookie from "@/utils/store/cookie";
|
||||
|
||||
|
||||
const fly = new Fly()
|
||||
@ -28,28 +29,38 @@ fly.interceptors.response.use(
|
||||
const defaultOpt = { login: true };
|
||||
|
||||
function baseRequest(options) {
|
||||
const token = $store.state.token;
|
||||
const headers = options.headers || {};
|
||||
if (options.login) {
|
||||
headers["Authorization"] = "Bearer " + token;
|
||||
|
||||
// 从缓存中获取 token 防止 token 失效后还会继续请求的情况
|
||||
const token = cookie.get('login_status');
|
||||
|
||||
// 合并传参过来的 headers
|
||||
// 如果接口需要登录,携带 token 去请求
|
||||
options.headers = {
|
||||
...options.headers,
|
||||
Authorization: options.login ? "Bearer " + token : null
|
||||
}
|
||||
|
||||
options.headers = headers;
|
||||
if (options.login && !token) {
|
||||
// 如果需要登录才可访问的接口没有拿到 token 视为登录失效
|
||||
if (options.login === true && !token) {
|
||||
// 跳转到登录或授权页面
|
||||
toLogin();
|
||||
// 提示错误信息
|
||||
return Promise.reject({ msg: "未登录", toLogin: true });
|
||||
}
|
||||
|
||||
// 结构请求需要的参数
|
||||
const { url, params, data, login, ...option } = options
|
||||
|
||||
// 发起请求
|
||||
return fly.request(url, params || data, {
|
||||
...option
|
||||
}).then(res => {
|
||||
console.log(res)
|
||||
// console.log(url,params,data, ...option)
|
||||
}).then(res => {
|
||||
console.log(res)
|
||||
// console.log(url,params,data, ...option)
|
||||
const data = res.data || {};
|
||||
if (res.status !== 200)
|
||||
if (res.status !== 200) {
|
||||
return Promise.reject({ msg: "请求失败", res, data });
|
||||
|
||||
}
|
||||
if ([410000, 410001, 410002].indexOf(data.status) !== -1) {
|
||||
toLogin();
|
||||
return Promise.reject({ msg: res.data.msg, res, data, toLogin: true });
|
||||
|
Reference in New Issue
Block a user