用户封禁、后台筛选排序
This commit is contained in:
1 parent
6b263af74f
commit
c45025fc86
14 files changed
+293
-30
No files matched your search
+12
-2
@@ -14,6 +14,13 @@ const store = require('./store');
|
||||
/** 进行中的会话恢复,避免并发 401 触发多次恢复流程 */
|
||||
let recovering = null;
|
||||
|
||||
/**
|
||||
* 服务端错误码:账号被封禁。
|
||||
* 要和「登录过期」分开:页面据此走自己的提示分支,而不是把人赶去登录。
|
||||
* 具体提示什么文字由后台配置决定,这里只管把错误码原样带出去。
|
||||
*/
|
||||
const ACCOUNT_DISABLED = 2003;
|
||||
|
||||
function staticUrl(path) {
|
||||
if (!path) return '';
|
||||
if (/^https?:\/\//i.test(path)) return path;
|
||||
@@ -74,7 +81,10 @@ function request(options) {
|
||||
if (needLogin && options.auth !== false && options.retried !== true) {
|
||||
return recoverSession()
|
||||
.then(() => request(Object.assign({}, options, { retried: true })))
|
||||
.catch(() => {
|
||||
.catch((err) => {
|
||||
// 账号异常:把原因原样抛给页面,并且不清本地用户——
|
||||
// 清掉的话知识页会把它当成未登录,只剩一片空白,看不出发生了什么
|
||||
if (err && err.code === ACCOUNT_DISABLED) throw err;
|
||||
store.reset();
|
||||
throw { code: 2000, message: '登录已过期,请重新进入小程序' };
|
||||
});
|
||||
@@ -236,4 +246,4 @@ function requestVirtualPayment(payData) {
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = Object.assign(api, { requestVirtualPayment, devicePlatform: platform });
|
||||
module.exports = Object.assign(api, { requestVirtualPayment, devicePlatform: platform, ACCOUNT_DISABLED });
|
||||
Reference in new issue
Block a user