diff --git a/changelog.md b/changelog.md index c751121..a5d922b 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,11 @@ +## v0.16.5 + * A 头像安全检查 + * U 信息安全检查速度 + +## v0.16.4 + * A 试卷答题时网络不好情况处理 + * A 课堂界面兼容iphone X + ## v0.16.3 * U 优化项目结构,主包压缩一半 diff --git a/cloudfunctions/cloudapi/config.json b/cloudfunctions/cloudapi/config.json new file mode 100644 index 0000000..5ecc33e --- /dev/null +++ b/cloudfunctions/cloudapi/config.json @@ -0,0 +1,6 @@ +{ + "permissions": { + "openapi": [ + ] + } +} \ No newline at end of file diff --git a/cloudfunctions/cloudapi/index.js b/cloudfunctions/cloudapi/index.js new file mode 100644 index 0000000..128b7ca --- /dev/null +++ b/cloudfunctions/cloudapi/index.js @@ -0,0 +1,18 @@ +const cloud = require('wx-server-sdk') + +cloud.init() + + +exports.main = async (event, context) => { + let {name, data} = event; + const wxContext = cloud.getWXContext() + switch (name) { + case 'getOpenData': { + return cloud.getOpenData(data); + } + default: { + return + } + } + +} \ No newline at end of file diff --git a/cloudfunctions/cloudapi/package.json b/cloudfunctions/cloudapi/package.json new file mode 100644 index 0000000..b72753e --- /dev/null +++ b/cloudfunctions/cloudapi/package.json @@ -0,0 +1,14 @@ +{ + "name": "cloudapi", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "dependencies": { + "wx-server-sdk": "~2.0.2" + } +} \ No newline at end of file diff --git a/cloudfunctions/login/index.js b/cloudfunctions/login/index.js index 1b3f973..6278729 100644 --- a/cloudfunctions/login/index.js +++ b/cloudfunctions/login/index.js @@ -14,8 +14,6 @@ exports.main = (event, context) => { const wxContext = cloud.getWXContext() return { - event, - context, openid: wxContext.OPENID, appid: wxContext.APPID, unionid: wxContext.UNIONID, diff --git a/cloudfunctions/openapi/config.json b/cloudfunctions/openapi/config.json index 4678407..2e99058 100644 --- a/cloudfunctions/openapi/config.json +++ b/cloudfunctions/openapi/config.json @@ -4,7 +4,9 @@ "wxacode.get", "wxacode.getUnlimited", "security.msgSecCheck", - "security.imgSecCheck" + "security.imgSecCheck", + "search.siteSearch", + "search.submitPages" ] } } \ No newline at end of file diff --git a/cloudfunctions/openapi/index.js b/cloudfunctions/openapi/index.js index dbe6265..5d7d1d6 100644 --- a/cloudfunctions/openapi/index.js +++ b/cloudfunctions/openapi/index.js @@ -49,7 +49,10 @@ exports.main = async (event, context) => { } } case 'getOpenData': { - return getOpenData(event) + return cloud.getOpenData(data); + } + case "search.siteSearch":{ + return cloud.openapi.search.siteSearch(data); } default: { return @@ -87,8 +90,3 @@ async function getWXACode(data) { }); } -async function getOpenData(event) { - return cloud.getOpenData({ - list: event.openData.list, - }) -} diff --git a/miniprogram/account/pages/profile/add-department/add-department.js b/miniprogram/account/pages/profile/add-department/add-department.js index 876e748..69c1ced 100644 --- a/miniprogram/account/pages/profile/add-department/add-department.js +++ b/miniprogram/account/pages/profile/add-department/add-department.js @@ -1,6 +1,7 @@ const app = getApp(); import {throttle} from "../../../../js/utils"; const risk_message = "检测到内容含有敏感词汇"; + function msgSecCheck({name="", remarks=""}){ let content = name+","+ remarks; console.log("msgsecCheck", content); @@ -11,7 +12,7 @@ function msgSecCheck({name="", remarks=""}){ this.tmp_promise.then(res=>{ if(res.errCode==87014){ wx.showToast({ - title: risk_message,icon:"none",duration:4000 + title: risk_message,icon:"none",duration:2600 }) } }) diff --git a/miniprogram/account/pages/profile/profile.js b/miniprogram/account/pages/profile/profile.js index 29a8916..c740882 100644 --- a/miniprogram/account/pages/profile/profile.js +++ b/miniprogram/account/pages/profile/profile.js @@ -13,7 +13,7 @@ function msgSecCheck({name, nickname}){ this.tmp_promise.then(res=>{ if(res.errCode==87014){ wx.showToast({ - title: risk_message,icon:"none",duration:4000 + title: risk_message,icon:"none",duration:2600 }) } }) @@ -52,6 +52,9 @@ Page({ this.setData({name: value}); this.throttledMsgSecCheck(this.data); }, + onGetUserInfo(e){ + console.log(e); + }, setInfo(res){ let locations = Object.keys(locationData); let location_index = locations.indexOf(res.location); @@ -230,9 +233,13 @@ Page({ }, saveInfo(value){ + wx.showLoading({ + title: '提交中' + }); value.gender = parseInt(value.gender); this.msgSecCheck(value).then(res=>{ if(res.errCode==87014){ + wx.hideLoading(); wx.showModal({ content: risk_message,showCancel:false }) @@ -241,6 +248,7 @@ Page({ .then(res => { app.syncUser({refresh:1}); res.message = "更新成功"; + wx.hideLoading(); app.showMsg(res); setTimeout(() => { wx.navigateBack({ @@ -248,10 +256,12 @@ Page({ }) }, 420); }).catch(e => { + wx.hideLoading(); this.showError(e); }) } }).catch(e=>{ + wx.hideLoading(); wx.showToast({ title: '出错了\n>︿<',icon:"none" }); @@ -260,7 +270,6 @@ Page({ }, onTap(e){ - ; let { target: { id } } = e; if (id) { if ((id == 'name' || id == "gender") && this.data.authen) diff --git a/miniprogram/account/pages/profile/profile.wxml b/miniprogram/account/pages/profile/profile.wxml index 2927c1a..a6ec4d7 100644 --- a/miniprogram/account/pages/profile/profile.wxml +++ b/miniprogram/account/pages/profile/profile.wxml @@ -67,4 +67,5 @@ *我们确保您所提供的信息均处于严格保密状态,不会泄露 + \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index cf2bd5b..6b21abd 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -9,18 +9,31 @@ wx.cloud.init({ App({ globalData: { versionCode: config.versionCode, - debug: config.debug + debug: config.debug, + openid:wx.getStorageSync('openid') }, client, openapi(name){ - return ({success, fail, complete, ...data})=>{ + return ({success, fail, complete, ...data}={})=>{ return this.callOpenapi({name, data, success,fail, complete}); } }, + cloudapi(name){ + return ({success, fail, complete, ...data})=>{ + return this.callCloudfunction({ + name:"cloudapi", data:{name, data}, success, fail, complete + }); + } + }, callOpenapi({name, data, success, fail, complete}){ - return this.callCloudapi({name:"openapi", data:{name, data}, success, fail, complete}); + return this.callCloudfunction({name:"openapi", data:{name, data}, success, fail, complete}); }, - callCloudapi({name, data, success, fail, complete}){ + cloudfunction(name){ + return ({success, fail, complete, ...data}={})=>{ + return this.callCloudfunction({name, data, success, fail, complete}); + } + }, + callCloudfunction({name, data, success, fail, complete}){ return new Promise((resolve, reject)=>{ return wx.cloud.callFunction({name, data, success:res=>{ @@ -42,15 +55,15 @@ App({ syncUser(options) { return client.syncUser(options) }, updateUserInfo(info){return client.updateUserInfo(info)}, onLaunch: function (options) { - if(options.scene==1129){ + if(options.scene==1129||options["user-agent"]=="mpcrawler"){ this.api("accounts.login")(global.accountManager.testAccount) .then(res=>{ let account = { ...res, ...global.accountManager.testAccount}; global.accountManager.setCurrentAccount(account); }); wx.reportMonitor('1', 1); - global.realTimeLog.info("爬虫访问"); - global.realTimeLog.setFilterMsg("wxcrawl"); + global.realTimeLog.info("爬虫访问", options); + global.realTimeLog.setFilterMsg("mpcrawl"); } if (options.referrerInfo && options.referrerInfo.appId) { var db = wx.cloud.database(); @@ -83,6 +96,16 @@ App({ }) } }).catch(e=>{}); + if(!this.globalData.openid){ + this.cloudfunction("login")() + .then(res=>{ + this.globalData.openid = res.openid; + wx.setStorage({ + data: res.openid, + key: 'openid', + }) + }) + } }, onShow() { @@ -155,4 +178,5 @@ function toAbsPath(current, path) { } return path; } -*/ \ No newline at end of file +*/ + diff --git a/miniprogram/components/modal/join-course/join-course.js b/miniprogram/components/modal/join-course/join-course.js index c6f35ad..3de95f0 100644 --- a/miniprogram/components/modal/join-course/join-course.js +++ b/miniprogram/components/modal/join-course/join-course.js @@ -106,10 +106,8 @@ Component({ }, update_identities: function ({ detail: { value } }) { var data = {assistant_professor:"", professor:"",student:""} - ; for(var identity of value) data[identity] = 1 - ; this.setData(data) }, join_course () { @@ -130,8 +128,10 @@ Component({ this.triggerEvent("success"); this.onCancel(); }) - .catch(app.showError) - + .catch(e=>{ + e.message =e.message||'未知错误'; + app.showError(e); + }) } } }) diff --git a/miniprogram/components/require-login/require-login.js b/miniprogram/components/require-login/require-login.js index b3ea51c..bf79128 100644 --- a/miniprogram/components/require-login/require-login.js +++ b/miniprogram/components/require-login/require-login.js @@ -16,7 +16,7 @@ Component({ } }, attached(){ - this.refresh().finally(()=>{ + this.refresh().then(()=>{ this.loaded = true; }) }, diff --git a/miniprogram/config.js b/miniprogram/config.js index d145ca8..b0dec21 100644 --- a/miniprogram/config.js +++ b/miniprogram/config.js @@ -5,11 +5,9 @@ const developUrl = "https://test-newweb.educoder.net"; const trialUrl = "https://pre-newweb.educoder.net"; const releaseUrl = "https://www.educoder.net"; -let _version = "0.16.4"; +let _version = "0.16.5"; var eduUrl = releaseUrl; /** - * A 试卷答题时网络不好情况处理 - * A 课堂界面兼容iphone X */ export function switchEnv(env) { diff --git a/miniprogram/course/modules/students/students.js b/miniprogram/course/modules/students/students.js index 4a74594..9020ee0 100644 --- a/miniprogram/course/modules/students/students.js +++ b/miniprogram/course/modules/students/students.js @@ -26,10 +26,8 @@ Component({ methods: { onChoose(e){ - ; }, onChange(e){ - ; let {detail:{value}} = e; this.sort_type = value?'id':''; this.refresh(); @@ -39,7 +37,6 @@ Component({ let {sort_type=''} = this; if(sort_type!='id') app.api("weapps.courses.students")({course_id, limit:1000}).then(res=>{ - ; var {students,students_count} = res; this.setData({students,students_count}); if(!this.imageMap) @@ -53,17 +50,19 @@ Component({ else app.api("courses.students")({course_id, limit:10000}) .then(res=>{ - ; var students; if(this.imageMap) students = res.students.map(i=>{ i.image_url = this.imageMap.get(i.user_id); return i; }) - students = [{letter:"#", items:res.students}]; + if(res.students.length>0) + students = [{letter:"#", items:res.students}]; + else + students = []; var {students_count} = res; this.setData({ students, students_count}); - }) + }); let ext = {course_id, course_identity}; this.setData({ext}); } diff --git a/miniprogram/course/modules/students/students.wxml b/miniprogram/course/modules/students/students.wxml index 37ada63..b280b61 100644 --- a/miniprogram/course/modules/students/students.wxml +++ b/miniprogram/course/modules/students/students.wxml @@ -7,7 +7,7 @@ 按学号排序 - + diff --git a/miniprogram/course/modules/teachers/teachers.wxml b/miniprogram/course/modules/teachers/teachers.wxml index c5e5c14..141c3d4 100644 --- a/miniprogram/course/modules/teachers/teachers.wxml +++ b/miniprogram/course/modules/teachers/teachers.wxml @@ -4,8 +4,8 @@ 教师人数: {{teacher_list_size}} - - + + 待审批({{apply_size}}) diff --git a/miniprogram/markdown/account/pro_authentication/pro_authentication.wxss b/miniprogram/markdown/account/pro_authentication/pro_authentication.wxss index afbfc5c..22bfbf6 100644 --- a/miniprogram/markdown/account/pro_authentication/pro_authentication.wxss +++ b/miniprogram/markdown/account/pro_authentication/pro_authentication.wxss @@ -37,6 +37,7 @@ display: flex; justify-content: center; align-items: center; + line-height: 22px; } .tips{ display: flex; diff --git a/miniprogram/pages/home/home.js b/miniprogram/pages/home/home.js index 84fd354..62c45a8 100644 --- a/miniprogram/pages/home/home.js +++ b/miniprogram/pages/home/home.js @@ -176,10 +176,14 @@ Page({ attendance({ show = 1 }) { app.api("users.attendance")() .then(res => { - this.refresh(); res.message = "签到成功"; if (show) app.showMsg(res); + }).catch(e=>{ + if(show) + app.showError(e); + }).finally(()=>{ + this.refresh(); }) }, enterUserinfo(){ diff --git a/miniprogram/pages/main/main.json b/miniprogram/pages/main/main.json index 5ad1890..1964778 100644 --- a/miniprogram/pages/main/main.json +++ b/miniprogram/pages/main/main.json @@ -4,7 +4,7 @@ "add-tips": "/components/add-tips/add-tips", "my-course":"./my_course/my_course", "my-shixun":"./my_shixun/my_shixun", - "my-path":"../my_path/my_path" + "my-path":"./my_path/my_path" }, "navigationBarTextStyle": "white", "navigationBarTitleText": "我的", diff --git a/miniprogram/pages/main/my_course/my_course.js b/miniprogram/pages/main/my_course/my_course.js index c6ccaa6..6638751 100644 --- a/miniprogram/pages/main/my_course/my_course.js +++ b/miniprogram/pages/main/my_course/my_course.js @@ -64,7 +64,7 @@ Component({ addCourse() { if(app.user().user_id==2) return wx.showToast({ - title: '请先登录' + title: '请先登录',icon:"none" }); return this.setData({ showModal: 1 }); /* diff --git a/miniprogram/pages/search/search.wxml b/miniprogram/pages/search/search.wxml index 4a9c3fb..f9aa06d 100644 --- a/miniprogram/pages/search/search.wxml +++ b/miniprogram/pages/search/search.wxml @@ -14,7 +14,7 @@ - + \ No newline at end of file diff --git a/miniprogram/setting/pages/image_crop/image_crop.js b/miniprogram/setting/pages/image_crop/image_crop.js index 00de37e..a3e3edc 100644 --- a/miniprogram/setting/pages/image_crop/image_crop.js +++ b/miniprogram/setting/pages/image_crop/image_crop.js @@ -8,21 +8,34 @@ Page({ }, touchStart(e) { - if(!this.mycropper) - return wx.showToast({ - title: '请先选取图片',icon:"none" - }) + this.mycropper.touchStart(e) }, - touchMove(e) { this.mycropper.touchMove(e) }, touchEnd(e) { this.mycropper.touchEnd(e) }, + onGetUserInfo(e){ + console.log(e); + let {detail:{userInfo}} = e; + if(userInfo.avatarUrl){ + let path = userInfo.avatarUrl; + this.mycropper.pushOrign(path); + }else{ + wx.showToast({ + title: '微信头像获取失败',icon:"none" + }) + } + }, async _checkImg({path}){ - let cloudPath = "images/avatars/"+ path.replace(/[\/\\:]/g, "_"); + let match = path.match(/(\.[^\.]*?)$/) + if(match) + var ext = match[0]; + else + var ext = ".jpg"; + let cloudPath = "images/temp/"+ app.globalData.openid + "-" + Date.now() + ext; let res = await wx.cloud.uploadFile({ cloudPath, filePath: path @@ -33,7 +46,6 @@ Page({ checkImg({path}){ if(this.promise&&path==this.tmp_path) return this.promise; - let buffer = wx.getFileSystemManager().readFileSync(path); this.promise = this._checkImg({path}); this.tmp_path = path; this.promise.then(res=>{ @@ -47,35 +59,49 @@ Page({ return this.promise; }, onConfirm(){ + this.setData({submitting:1}); if(!this.mycropper||!this.mycropper.src) return wx.showToast({ title: '请先选取图片',icon:"none" }) - let {src} = this.mycropper; + let {croperTarget} = this.mycropper; wx.showLoading({ title: '检查图片中...', }) - this.checkImg({path: src}).then(res=>{ + this.checkImg({path: croperTarget}).then(res=>{ if(res.errCode==0) this.startUpload(); else if(res.errCode==87014){ wx.hideLoading(); wx.showModal({ content:rich_message,showCancel: false - }) + }); + this.setData({submitting:0}); }else{ wx.showToast({ - title: '发生了未知错误',icon:"none" + title: '发生了未知错误,请重试',icon:"none" }); + this.promise = null; + let {croperTarget} = this.mycropper; + this.checkImg({path:croperTarget}); + this.setData({submitting:0}); + wx.reportMonitor('2', 1); - global.realTimeLog.error("未知错误 checkImg1"); + global.realTimeLog.error("未知错误 checkImg1", res); global.realTimeLog.setFilterMsg("unexpected"); } }).catch(e=>{ wx.hideLoading(); - app.showError(e); + wx.showToast({ + title: '请求超时,请重试',icon:"none" + }); + this.promise = null; + let {croperTarget} = this.mycropper; + this.checkImg({path:croperTarget}); + this.setData({submitting:0}); + wx.reportMonitor('2', 1); - global.realTimeLog.error("未知错误 checkImg2"); + global.realTimeLog.error("未知错误 checkImg2", e); global.realTimeLog.setFilterMsg("unexpected"); }) }, @@ -93,10 +119,11 @@ Page({ }); }, startUpload() { + this.setData({submitting:1}); this.mycropper.getCropperImage((avatar) => { if (avatar) { wx.showLoading({ - title: '上传中', + title: '上传头像中', }); this.uploadAvartar(avatar) .then(res => { @@ -104,6 +131,7 @@ Page({ wx.showToast({ title: '更改成功', }); + this.setData({submitting:0}); setTimeout(()=>{ wx.navigateBack({ delta: 1 @@ -115,12 +143,14 @@ Page({ icon: "none" }); wx.hideLoading(); + this.setData({submitting:0}); }); } else { wx.showToast({ title: '图片截取失败', icon: "none" }); + this.setData({submitting:0}); } }) }, @@ -165,11 +195,11 @@ Page({ this.mycropper = new WeCropper(cropperOpt); this.mycropper .on('beforeImageLoad', (ctx) => { - wx.showLoading({title: '上传中'}) + wx.showLoading({title: '图片加载中'}) }) .on('imageLoad', (ctx) => { - let {src} = this.mycropper; - this.checkImg({path:src}); + let {croperTarget} = this.mycropper; + this.checkImg({path:croperTarget}); wx.hideLoading(); }) .updateCanvas(); diff --git a/miniprogram/setting/pages/image_crop/image_crop.wxml b/miniprogram/setting/pages/image_crop/image_crop.wxml index fb9b803..0f407f7 100644 --- a/miniprogram/setting/pages/image_crop/image_crop.wxml +++ b/miniprogram/setting/pages/image_crop/image_crop.wxml @@ -8,8 +8,11 @@ - + \ No newline at end of file diff --git a/miniprogram/setting/pages/image_crop/image_crop.wxss b/miniprogram/setting/pages/image_crop/image_crop.wxss index add5a41..148fa65 100644 --- a/miniprogram/setting/pages/image_crop/image_crop.wxss +++ b/miniprogram/setting/pages/image_crop/image_crop.wxss @@ -25,5 +25,9 @@ height: 100% .operations>button{ flex: auto; border-radius: 0; + white-space: nowrap; + display: flex; + justify-content: center; + align-items: center; } diff --git a/miniprogram/sitemap.json b/miniprogram/sitemap.json index 88ef00b..a6f5f2c 100644 --- a/miniprogram/sitemap.json +++ b/miniprogram/sitemap.json @@ -3,7 +3,7 @@ "rules": [ { "action":"allow", - "page":"path/pages/path/path", + "page":"markdown/path/path/path", "params":[ "subject_id" ], @@ -11,7 +11,7 @@ }, { "action": "allow", - "page": "shixun/pages/shixun/shixun", + "page": "markdown/shixun/shixun/shixun", "params": [ "identifier" ], @@ -23,12 +23,20 @@ }, { "action":"disallow", - "page":"task/pages/task/task" + "page":"markdown/task/task/task" + }, + { + "action":"disallow", + "page":"account/pages/accounts/accounts" }, { "action":"disallow", "page":"course/pages/course/course" }, + { + "action":"disallow", + "page":"pages/my_courses/my_courses" + }, { "action": "allow", "page": "*" diff --git a/project.config.json b/project.config.json index bac6ebe..6620a45 100644 --- a/project.config.json +++ b/project.config.json @@ -6,7 +6,7 @@ "ignore": [] }, "setting": { - "urlCheck": true, + "urlCheck": false, "es6": true, "enhance": true, "postcss": true,