全新UI视觉体验,移动端API优化降低重复调用,提高并发6倍,修复N多Bug

This commit is contained in:
337031187
2021-06-11 17:41:16 +08:00
parent 37995ed9e6
commit 34bf68c7ed
582 changed files with 35633 additions and 28276 deletions

View File

@@ -1,11 +1,12 @@
import store from "../store";
import Cache from '../utils/cache';
// #ifdef H5 || APP-PLUS
import { Debounce } from '@/utils/validate.js'
// #ifdef H5
import { isWeixin } from "../utils";
import auth from './wechat';
// #endif
import { LOGIN_STATUS, USER_INFO, EXPIRES_TIME, STATE_R_KEY} from './../config/cache';
import { LOGIN_STATUS, USER_INFO, EXPIRES_TIME, STATE_R_KEY, BACK_URL} from './../config/cache';
function prePage(){
let pages = getCurrentPages();
@@ -13,28 +14,55 @@ function prePage(){
return prePage.route;
}
export function toLogin(push, pathLogin) {
export const toLogin = Debounce(_toLogin,800)
export function _toLogin(push, pathLogin) {
store.commit("LOGOUT");
let path = prePage();
let login_back_url = Cache.get(BACK_URL);
// #ifdef H5
path = location.href;
// path = location.href;
path = location.pathname + location.search;
// #endif
if(!pathLogin)
if(!pathLogin){
pathLogin = '/page/users/login/index'
Cache.set('login_back_url',path);
// #ifdef H5 || APP-PLUS
Cache.set('login_back_url',path);
}
// #ifdef H5
if (isWeixin()) {
auth.oAuth();
let urlData = location.pathname + location.search
if (urlData.indexOf('?') !== -1) {
urlData += '&go_longin=1';
} else {
urlData += '?go_longin=1';
}
if (!Cache.has('snsapiKey')) {
auth.oAuth('snsapi_base', urlData);
} else {
if (['/pages/user/index'].indexOf(login_back_url) == -1) {
uni.navigateTo({
url: '/pages/users/wechat_login/index'
})
}
}
} else {
if (path !== pathLogin) {
push ? uni.navigateTo({
url:'/pages/users/login/index'
}) : uni.reLaunch({
url: '/pages/users/login/index'
});
if (['/pages/user/index'].indexOf(login_back_url) == -1) {
uni.navigateTo({
url: '/pages/users/login/index'
})
}
}
// #endif
if (['pages/user/index','/pages/user/index'].indexOf(login_back_url) == -1) {
// #ifdef MP
uni.navigateTo({
url: '/pages/users/wechat_login/index'
})
// #endif
}
}
@@ -58,4 +86,4 @@ export function checkLogin()
return true;
}
}
}