用户封禁、后台筛选排序
This commit is contained in:
1 parent
6b263af74f
commit
c45025fc86
14 files changed
+293
-30
No files matched your search
@@ -11,6 +11,10 @@ Page({
|
||||
hasCourse: false,
|
||||
ownedCourses: [],
|
||||
tipsHtml: '',
|
||||
/** 账号被封禁:不显示已购权益,改为显示提示。文字全部来自后台配置 */
|
||||
blocked: false,
|
||||
blockedTitle: '',
|
||||
blockedDesc: '',
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
@@ -31,9 +35,23 @@ Page({
|
||||
.getEntitlements()
|
||||
.then((list) => {
|
||||
store.setEntitlements(list);
|
||||
this.setData({ ownedCourses: list || [], hasCourse: (list || []).length > 0 });
|
||||
this.setData({ ownedCourses: list || [], hasCourse: (list || []).length > 0, blocked: false });
|
||||
})
|
||||
.catch((err) => console.warn('[kecheng] 已购课程加载失败', err));
|
||||
.catch((err) => {
|
||||
if (err && err.code === api.ACCOUNT_DISABLED) {
|
||||
// 服务端不返回权益了,本地缓存也一并清掉,免得露出上一次的课程
|
||||
store.setEntitlements([]);
|
||||
this.setData({
|
||||
ownedCourses: [],
|
||||
hasCourse: false,
|
||||
blocked: true,
|
||||
blockedTitle: store.cfg('account.blocked_title'),
|
||||
blockedDesc: store.cfg('account.blocked_desc'),
|
||||
});
|
||||
return;
|
||||
}
|
||||
console.warn('[kecheng] 已购课程加载失败', err);
|
||||
});
|
||||
},
|
||||
|
||||
loadTips() {
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
<scroll-view class="container" scroll-y enable-flex type="custom">
|
||||
<block wx:if="{{!hasCourse}}">
|
||||
<block wx:if="{{blocked}}">
|
||||
<view class="blocked-tip">
|
||||
<text wx:if="{{blockedTitle}}" class="blocked-title">{{blockedTitle}}</text>
|
||||
<text wx:if="{{blockedDesc}}" class="blocked-desc">{{blockedDesc}}</text>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<block wx:elif="{{!hasCourse}}">
|
||||
<view style="width: 100%;height: 400rpx;">
|
||||
<image style="margin-top: 30rpx; margin-left: 20rpx; height: 350rpx; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5); width: 710rpx; border-radius: 20rpx; background-color: rgb(0, 255, 255);"
|
||||
src="{{staticBase}}/Images/Banner/BGbanner.png" mode="aspectFill" />
|
||||
@@ -7,7 +14,7 @@
|
||||
<Parser html="{{tipsHtml}}" />
|
||||
</block>
|
||||
|
||||
<block wx:if="{{hasCourse}}">
|
||||
<block wx:elif="{{hasCourse}}">
|
||||
<view wx:for="{{ownedCourses}}" wx:for-item="item" wx:for-index="index" wx:key="courseId"
|
||||
class="kecheng" bind:tap="toMyCourse" data-code="{{item.code}}">
|
||||
<view class="kecheng_video_up">
|
||||
|
||||
@@ -46,4 +46,29 @@
|
||||
font-size: 25rpx;
|
||||
margin-top: 15rpx;
|
||||
margin-left: 15rpx;
|
||||
}
|
||||
}
|
||||
|
||||
/* 账号异常提示的容器:整页替换成这一块,文字由后台配置下发 */
|
||||
.blocked-tip {
|
||||
box-sizing: border-box;
|
||||
width: 710rpx;
|
||||
margin-top: 120rpx;
|
||||
padding: 60rpx 40rpx;
|
||||
border: 1rpx solid #ffd9d9;
|
||||
border-radius: 20rpx;
|
||||
background-color: #fff7f7;
|
||||
}
|
||||
.blocked-title {
|
||||
display: block;
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
color: #e60012;
|
||||
}
|
||||
.blocked-desc {
|
||||
display: block;
|
||||
margin-top: 20rpx;
|
||||
font-size: 26rpx;
|
||||
text-align: center;
|
||||
color: #888;
|
||||
}
|
||||
+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