F 用户信息未完善时加入课堂bug

master
educoder_weapp 5 years ago
parent 0320a78d18
commit 946a2e57a7

@ -1,3 +1,6 @@
## v0.16.7
* F 用户信息未完善时加入课堂bug
## v0.16.6
* A 支持选用微信头像
* F 兼容Promise.finally

@ -1,10 +1,101 @@
const cloud = require('wx-server-sdk')
const sceneDescMap = {
[void 0]: "未知",
1000: "其他",
1001: "发现栏小程序主入口「最近使用」列表基础库2.2.4版本起包含「我的小程序」列表)",
1005: "微信首页顶部搜索框的搜索结果页",
1006: "发现栏小程序主入口搜索框的搜索结果页",
1007: "单人聊天会话中的小程序消息卡片",
1008: "群聊会话中的小程序消息卡片",
1011: "扫描二维码",
1012: "长按图片识别二维码",
1013: "扫描手机相册中选取的二维码",
1014: "小程序模板消息",
1017: "前往小程序体验版的入口页",
1019: "微信钱包微信客户端7.0.0版本改为支付入口)",
1020: "公众号profile 页相关小程序列表(已废弃)",
1022: "聊天顶部置顶小程序入口微信客户端6.6.1版本起废弃)",
1023: "安卓系统桌面图标",
1024: "小程序profile页",
1025: "扫描一维码",
1026: "发现栏小程序主入口,「附近的小程序」列表",
1027: "微信首页顶部搜索框搜索结果页「使用过的小程序」列表",
1028: "我的卡包",
1029: "小程序中的卡券详情页",
1030: "自动化测试下打开小程序",
1031: "长按图片识别一维码",
1032: "扫描手机相册中选取的一维码",
1034: "微信支付完成页",
1035: "公众号自定义菜单",
1036: "App分享消息卡片",
1037: "小程序打开小程序",
1038: "从另一个小程序返回",
1039: "摇电视",
1042: "添加好友搜索框的搜索结果页",
1043: "公众号模板消息",
1044: "带shareTicket的小程序消息卡片",
1045: "朋友圈广告",
1046: "朋友圈广告详情页",
1047: "扫描小程序码",
1048: "长按图片识别小程序码",
1049: "扫描手机相册中选取的小程序码",
1052: "卡券的适用门店列表",
1053: "搜一搜的结果页",
1054: "顶部搜索框小程序快捷入口微信客户端版本6.7.4起废弃)",
1056: "聊天顶部音乐播放器右上角菜单",
1057: "钱包中的银行卡详情页",
1058: "公众号文章",
1059: "体验版小程序绑定邀请页",
1064: "微信首页连Wi-Fi状态栏",
1067: "公众号文章广告",
1068: "附近小程序列表广告(已废弃)",
1069: "移动应用",
1071: "钱包中的银行卡列表页",
1072: "二维码收款页面",
1073: "客服消息列表下发的小程序消息卡片",
1074: "公众号会话下发的小程序消息卡片",
1077: "摇周边",
1078: "微信连Wi-Fi成功提示页",
1079: "微信游戏中心",
1081: "客服消息下发的文字链",
1082: "公众号会话下发的文字链",
1084: "朋友圈广告原生页",
1088: "会话中系统消息,打开小程序",
1089: "微信聊天主界面下拉「最近使用」栏基础库2.2.4版本起包含「我的小程序」栏)",
1090: "长按小程序右上角菜单唤出最近使用历史",
1091: "公众号文章商品卡片",
1092: "城市服务入口",
1095: "小程序广告组件",
1096: "聊天记录,打开小程序",
1097: "微信支付签约原生页,打开小程序",
1099: "页面内嵌插件",
1102: "公众号profile 页服务预览",
1103: "发现栏小程序主入口「我的小程序」列表基础库2.2.4版本起废弃)",
1104: "微信聊天主界面下拉「我的小程序」栏基础库2.2.4版本起废弃)",
1106: "聊天主界面下拉,从顶部搜索结果页,打开小程序",
1107: "订阅消息,打开小程序",
1113: "安卓手机负一屏,打开小程序(三星)",
1114: "安卓手机侧边栏,打开小程序(三星)",
1124: "扫“一物一码”打开小程序",
1125: "长按图片识别“一物一码”",
1126: "扫描手机相册中选取的“一物一码”",
1129: "微信爬虫访问",
1131: "浮窗打开小程序",
1135: "小程序资料页打开小程序",
1146: "地理位置信息打开出行类小程序",
1148: "卡包-交通卡,打开小程序",
1150: "扫一扫商品条码结果页打开小程序",
1153: '“识物”结果页打开小程序'
}
cloud.init()
cloud.init({
env: cloud.DYNAMIC_CURRENT_ENV
});
exports.main = async (event, context) => {
let {name, data} = event;
console.log(event);
const wxContext = cloud.getWXContext();
let db = cloud.database();
switch (name) {
@ -20,9 +111,12 @@ exports.main = async (event, context) => {
}
}
case "reportPageHistory":{
db.collection("pageHistory").add({
console.log("reportPageHistory");
return db.collection("pageHistory").add({
data:{
...data,
isCrawl: data.scene==1129,
sceneDesc: sceneDescMap[data.scene],
time: new Date(),
timestamp: Date.now(),
openid: wxContext.OPENID

@ -7,7 +7,7 @@ cloud.init({
})
exports.main = (event, context) => {
exports.main = async (event, context) => {

@ -10,6 +10,11 @@
"name": "submitPages",
"type": "timer",
"config": "0 0 2 * * * *"
},
{
"name": "clearPageHistory",
"type":"timer",
"config":"0 0 3 1 * * *"
}
]
}

@ -1,17 +1,36 @@
const cloud = require('wx-server-sdk');
cloud.init({
env: cloud.DYNAMIC_CURRENT_ENV
})
const cloud = require('wx-server-sdk')
const config = {
submitPagesGapDay: 1,
clearPageHistoryGapDay: 30
};
cloud.init()
const milliSecondsPerDay = 24*60*60*1000;
const collectionNameMap = {
pageHistory: "pageHistory"
}
const PagePathMap = {
shixun:"markdown/shixun/shixun/shixun",
path:"markdown/path/path/path"
}
exports.main = async (event, context) => {
const wxContext = cloud.getWXContext()
const wxContext = cloud.getWXContext();
console.log(event);
let {TriggerName, Time} = event;
switch(TriggerName){
case "submitPages":{
return submitPages({Time});
}
case "clearPageHistory":{
return clearPageHistory({Time});
}
}
}
@ -19,22 +38,24 @@ async function submitPages({Time}){
console.log("start submitPages");
const db = cloud.database();
const _ = db.command;
const pageHistoryCollection = db.collection("pageHistory");
const pageHistoryCollection = db.collection(collectionNameMap.pageHistory);
let shixunPath = "markdown/shixun/shixun/shixun";
let pathPath = "markdown/path/path/path";
let shixunPath = PagePathMap.shixun;
let pathPath = PagePathMap.path;
let timeEnd = new Date(Time);
let timeStart = new Date(timeEnd.getTime()-24*60*60*1000);
let timeStart = new Date(timeEnd.getTime() - config.submitPagesGapDay*milliSecondsPerDay);
let shixunResult = await pageHistoryCollection.where({
page: shixunPath,
status: 200,
isCrawl: false,
time: _.lt(timeEnd).and(_.gte(timeStart))
}).get();
let pathResult = await pageHistoryCollection.where({
page: pathPath,
status:200,
status: 200,
isCrawl: false,
time:_.lt(timeEnd).and(_.gte(timeStart))
}).get();
@ -81,4 +102,23 @@ async function submitPages({Time}){
}else{
console.warn("no path history");
}
return {code:0, message:"success"};
}
async function clearPageHistory({Time}){
console.log("clearPageHistory", Time);
let now = new Date(Time);
let timeEnd = new Date(now.getTime() - config.clearPageHistoryGapDay*milliSecondsPerDay);
const db = cloud.database();
const _ = cloud.command;
const pageHistoryCollection = db.collection(collectionNameMap.pageHistory);
let res = await pageHistoryCollection.where({
time: _lt(timeEnd)
}).remove();
console.log("remove page History result: ", res);
return {code: 0, message:"success", data:res};
}

@ -155,7 +155,7 @@ Page({
this.refresh();
},
onShow: function () {
if(this.secondShow){
if(this.secondShow){ //更新头像
app.api("users.accounts")()
.then(res=>{
let {avatar_url} = res;
@ -246,7 +246,7 @@ Page({
}else{
app.api("users.accounts", { method: "PUT" })(value)
.then(res => {
app.syncUser({refresh:1});
app.syncUser({refresh:1});//更新用户信息
res.message = "更新成功";
wx.hideLoading();
app.showMsg(res);

@ -66,7 +66,7 @@ App({
let account = { ...res, ...global.accountManager.testAccount};
global.accountManager.setCurrentAccount(account);
});
/* 访
/* 访
wx.reportMonitor('1', 1);
global.realTimeLog.info("爬虫访问", options);
global.realTimeLog.setFilterMsg("mpcrawl");
@ -93,6 +93,8 @@ App({
}
})
}
/**
* 系统升级提醒
this.api("users.system_update")().then(res => {
if (res.system_update) {
let { subject = "升级服务通知", system_score} = res;
@ -112,7 +114,7 @@ App({
})
}
}).catch(e=>{});
*/
},
onShow() {

@ -2,22 +2,10 @@ const app = getApp();
Component({
properties: {
hidden:{
show:{
type:Boolean,
value: true,
observer:function(hidden){
if(!hidden){
wx.getClipboardData({
success:res=>{
if(!res.data||res.data==this.clipboardData) return;
this.clipboardData = res.data;
var match = res.data.match(/(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Z]{5,6}/);
if(match)
this.setData({invite_code: match[0]});
}
})
}
}
value: false,
observer: "onShowChange"
},
show_code:{
type:Number,
@ -36,23 +24,75 @@ Component({
data: {
identities:[],
hidden:true,
showDialog: false,
buttons:[
{text:"取消"},
{text:"提交"}
]
},
methods: {
onShowChange(value){
if(value){
if(!this.checkLogin()||!this.checkProfile()){
value = false;
this.setData({show: false});
}
wx.getClipboardData({
success:res=>{
if(!res.data||res.data==this.clipboardData) return;
this.clipboardData = res.data;
var match = res.data.match(/(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Z]{5,6}/);
if(match)
this.setData({invite_code: match[0]});
}
})
this.setData({showDialog: value});
}else{
this.setData({showDialog: value});
}
},
checkLogin(){
if(app.user().user_id==2){
wx.showModal({
title:"提示",
content:"您需要登录后才能加入课堂",
confirmText:"现在登录",
success: res=>{
if(res.confirm)
app.navigateTo({url:"{account}"});
}
})
return false;
}
return true;
},
checkProfile(){
if(app.user().profile_completed)
return true;
else{
wx.showModal({
title:"提示",
content:"您需要完善您的个人资料,才能加入课堂",
confirmText:"立即完善",
success:res=>{
if(res.confirm){
app.navigateTo({
url:"{profile}"
});
}
}
})
return false;
}
},
scan(){
wx.scanCode({
success:res=>{
;
var fail = false;
if(res.scanType=="QR_CODE")
this.setData({invite_code: res.result});
else if(res.scanType=="WX_CODE"&&res.path){
var match = res.path.match(/course_invite\?(.*)$/)
;
if(match){
var options = {}
match[1].split("&").map(i=>{
@ -60,7 +100,6 @@ Component({
var k = i.slice(0, index);
var v = i.slice(index + 1);
options[k]=v})
;
if(options.scene){
var scene = {};
for (var i of decodeURIComponent(options.scene).split("&")) {
@ -69,12 +108,10 @@ Component({
var v = i.slice(index+1);
scene[k] = v;
}
;
if(scene.course_id){
var {course_id} = scene;
app.api("weapps.courses.basic_info")({ course_id })
.then(({ course:{invite_code=""}}) => {
;
this.setData({invite_code});
}).catch(app.showError);
}else
@ -93,7 +130,7 @@ Component({
})
},
onCancel() {
this.setData({ hidden: true,invite_code:'', professor:"", student:"", assistant_professor:"" });
this.setData({ show: false, invite_code:'', professor:"", student:"", assistant_professor:"" });
},
onTapButton({detail:{index}}){
if(index==0)
@ -129,8 +166,14 @@ Component({
this.onCancel();
})
.catch(e=>{
e.message =e.message||'未知错误';
app.showError(e);
if(e.code==402){ //一般是信息没完善
if(this.checkProfile()){ //信息已完善还是出错
wx.showToast({ title: '发生未知错误',icon:"none"})
global.realTimeLog.error("join course", e);
}
}
else
app.showError(e);
})
}
}

@ -1,5 +1,5 @@
<mp-dialog show="{{!hidden}}" title="加入课堂" bindclose="onCancel" bindbuttontap="onTapButton" buttons="{{buttons}}">
<block wx:if="{{!hidden}}">
<mp-dialog show="{{showDialog}}" title="加入课堂" bindclose="onCancel" bindbuttontap="onTapButton" buttons="{{buttons}}">
<block wx:if="{{show}}">
<view class="input-wrap {{show_code?'':'hidden'}}">
<input class="code-input" cursor-spacing="130" type='text' bindinput="update_invite_code" value="{{invite_code}}" placeholder="邀请码" auto-focus="1" />
<image class="scan" src="./scan.png" mode="aspectFit" catchtap="scan" />

@ -1,6 +1,6 @@
const cloudDir = "cloud://educoder.6564-educoder-1300855313/";
let _version = "0.16.6";
let _version = "0.16.7";
/**
*/
let { miniProgram:{ envVersion="release", version=_version}={}} = wx.getAccountInfoSync();

@ -62,7 +62,7 @@
<mp-tabbar ext-class="tabbar" bindchange="onModuleChange" current="{{current}}" list="{{list}}" />
</view>
<error-page status="{{status}}" config="{{scenes}}" bindrefresh="onTapError" />
<join-course hidden="{{!show_join_course}}" bindsuccess="refresh" auto_navigate="0" />
<join-course show="{{show_join_course}}" bindsuccess="refresh" auto_navigate="0" />
<mp-halfScreenDialog show="{{showModules}}">
<text slot="title">课堂模块</text>
<view slot="desc" class="modules">

@ -19,4 +19,4 @@
<button wx:if="{{user.user_id!=2}}" class="join-button" bindtap="joinCourse">加入课堂</button>
<button wx:else class="join-button" bindtap="login">点击登录</button>
</view>
<join-course hidden="{{!show_join_modal}}" show_code="0" invite_code="{{course.invite_code}}" opentype="redirectTo"></join-course>
<join-course show="{{show_join_modal}}" show_code="0" invite_code="{{course.invite_code}}" opentype="redirectTo"></join-course>

@ -25,6 +25,7 @@ Page({
this.setData({ form_data: this.initial_form_data });
},
create_course: function ({ detail: { value } }) {
console.log("create_course");
if (this.intent == "create") {
app.callApi({
name:"courses",
@ -61,6 +62,8 @@ Page({
},
focusSchool: function({detail:{value}}){
if(!value)
return
if(this.data.bindSource.length==0){
app.api("schools.school_list")({ search: value })
.then(res => {

@ -83,8 +83,10 @@ Page({
page: this.route,
options: this.options,
status: 200,
scene: app.globalData.scene,
isCrawl: app.globalData.isCrawl
scene: app.globalData.scene
}).catch(e=>{
global.realTimeLog.error("report history error", e);
wx.reportMonitor('2', 1);
})
return res;
}).catch(e=>{
@ -99,7 +101,7 @@ Page({
onShareAppMessage: function () {
let {subject} = this.data;
return app.shareApp({
title: "[实践课程]"+subject.name,
title: "「实践课程」"+subject.name,
imageUrl: global.config.eduUrl + "/" + subject.cover
})
}

@ -45,7 +45,7 @@
<view class="shixuns-list">
<navigator class="shixun {{shixun.allow_visit?'':'forbidden'}}" hover-class="{{shixun.allow_visit?'navigator-hover':'none'}}"
wx:for="{{stage.shixuns_list}}" wx:for-item="shixun" wx:key="identifier"
url="{{shixun.allow_visit?('/shixun/pages/shixun/shixun?identifier='+shixun.identifier):''}}"
url="{{shixun.allow_visit?('/markdown/shixun/shixun/shixun?identifier='+shixun.identifier):''}}"
data-allow_visit="{{shixun.allow_visit}}" bindtap="onEnterShixun">
<icon wx:if="{{shixun.complete_status}}" type="success" class="shixun-icon" size="18" color="#00b0f0"/>
<mp-icon wx:else extClass="shixun-icon" icon="play2" size="18" color="#dedede" type="field"/>

@ -90,25 +90,27 @@ Page({
let {identifier,cate_type} = options;
let current = cateTypes[cate_type];
this.setData({identifier, current});
this.pullChallenges().catch(e=>{
});
this.pullShixun().then(res=>{
app.cloudapi("reportPageHistory")({
page: this.route,
options: this.options,
status: 200,
scene: app.globalData.scene,
isCrawl: app.globalData.isCrawl
scene: app.globalData.scene
}).catch(e=>{
global.realTimeLog.error("report history error", e);
wx.reportMonitor('2', 1);
})
}).catch(e=>{
app.showError(e);
});
this.pullChallenges().catch(e=>{
});
},
onShareAppMessage: function () {
return app.shareApp({
title:"[实训项目]"+this.data.shixun.name,
title:"「实训项目」"+this.data.shixun.name,
imageUrl: global.config.eduImgDir+"avatars/Shixun/"+this.data.shixun.id
})
}

@ -139,7 +139,7 @@ Component({
}
},
fail:e=>{
fail && fail({message:"删除失败"});
success && success();
complete&&complete();
}
})
@ -148,12 +148,10 @@ Component({
wx.showLoading({
title: '删除中'
})
;
let {id:course_id} = this.data.data;
app.callApi({name:"courses",data:{course_id}, config:{method:"DELETE"},
success:res=>{
;
res.message = "删除成功";
app.showMsg(res);
this.triggerRefresh();
@ -172,8 +170,9 @@ Component({
},
delete_course(){
wx.showModal({
title: '确认删除课堂吗',
title: '警告',
content: '课堂删除后所有数据将被删除并且【无法恢复】,\n是否确定删除',
confirmColor:"#fa5151",
success: res=>{
if(!res.confirm)
return;
@ -183,9 +182,8 @@ Component({
},
fail:(e={})=>{
wx.showToast({
title: e.message||'验证失败',
icon:"none",
duration:800
title: e.message||'身份验证失败',
icon:"none"
})
}
});

@ -62,10 +62,6 @@ Component({
this.pullCourses({ refresh: 1 });
},
addCourse() {
if(app.user().user_id==2)
return wx.showToast({
title: '请先登录',icon:"none"
});
return this.setData({ showModal: 1 });
/*
if (app.user().user_identity == "学生") {

@ -18,5 +18,5 @@
<mp-icon icon="add" type="field" color="#0080f0" size="32"/>
</view>
<join-course-modal hidden="{{!showModal}}"/>
<join-course-modal show="{{showModal}}"/>
</view>

@ -220,6 +220,13 @@
"pathName": "setting/pages/image_crop/image_crop",
"query": "",
"scene": null
},
{
"id": -1,
"name": "course/pages/course_invite/course_invite",
"pathName": "course/pages/course_invite/course_invite",
"query": "course_id=7582",
"scene": null
}
]
}

Loading…
Cancel
Save