From 80b7d665e4a8fa0e5fa28cd003833d453cba09af Mon Sep 17 00:00:00 2001 From: educoder_weapp Date: Sat, 18 Jul 2020 09:05:09 +0800 Subject: [PATCH] =?UTF-8?q?F=20=E8=AF=BE=E5=A0=82=E9=82=80=E8=AF=B7?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=A0=81=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=A4=B1=E8=B4=A5=20=20=20F=20=E6=AF=8F=E6=97=A5?= =?UTF-8?q?=E7=AD=BE=E5=88=B0=E5=AE=8C=E5=90=8E=E6=8C=89=E9=92=AE=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E5=8F=98=E7=81=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog.md | 4 + cloudfunctions/cloudapi/index.js | 32 +----- cloudfunctions/trigger/index.js | 99 +++++++------------ .../competition-item/competition-item.wxml | 3 +- .../components/home-notice/home-notice.js | 23 +++++ .../components/home-notice/home-notice.json | 4 + .../components/home-notice/home-notice.wxml | 2 + .../components/home-notice/home-notice.wxss | 1 + miniprogram/config.js | 4 +- .../pages/course_invite/course_invite.js | 14 ++- miniprogram/markdown/path/path/path.js | 10 +- miniprogram/markdown/shixun/shixun/shixun.js | 10 +- .../mooc_case_item/mooc_case_item.wxml | 3 +- miniprogram/pages/home/home.js | 18 +++- miniprogram/pages/home/home.wxml | 13 +-- miniprogram/pages/home/home.wxss | 7 +- miniprogram/sitemap.json | 16 +++ project.config.json | 2 +- 18 files changed, 140 insertions(+), 125 deletions(-) create mode 100644 miniprogram/components/home-notice/home-notice.js create mode 100644 miniprogram/components/home-notice/home-notice.json create mode 100644 miniprogram/components/home-notice/home-notice.wxml create mode 100644 miniprogram/components/home-notice/home-notice.wxss diff --git a/changelog.md b/changelog.md index bf224eb..b504cba 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,7 @@ +## v0.19.2 + * F 课堂邀请页面小程序码获取失败 + * F 每日签到完后按钮没有变灰 + ## v0.19.1 * U 个人中心界面优化 * U 主题色加深 diff --git a/cloudfunctions/cloudapi/index.js b/cloudfunctions/cloudapi/index.js index fda2747..626e3c6 100644 --- a/cloudfunctions/cloudapi/index.js +++ b/cloudfunctions/cloudapi/index.js @@ -137,37 +137,11 @@ exports.main = async (event, context) => { sceneDesc: sceneDescMap[data.scene], time: now, timestamp: Date.now(), - openid: wxContext.OPENID + openid: wxContext.OPENID, + _openid: wxContext.OPENID } }); - try{ - console.log(sceneDescMap[data.scene].slice(0,31),now.toLocaleTimeString()); - let result = await cloud.openapi.subscribeMessage.send({ - touser: 'oqugK431bepFwW6TGrHpQTerPkI0', - page: 'admin/pages/page_history/page_history', - lang: 'zh_CN', - templateId: 'atZ4ZFfGIPxTiFGTCtkwvnfqjBA-fM7o1p5OiJQA_0Y', - miniprogramState: 'trial', - data: { - character_string1:{ - value:"pageHistory" //服务器 - }, - character_string2:{ - value: (data.route||data.page).match(/\/([^\/]*$)/)[1] //数据类型 - }, - thing4:{ - value:sceneDescMap[data.scene].slice(0,20) //添加内容 - }, - date3:{ - value:getFormatTime(now) - } - } - }) - console.log(result); - }catch(e){ - console.error(e); - } - + return res; } case "clearPageHistory":{ diff --git a/cloudfunctions/trigger/index.js b/cloudfunctions/trigger/index.js index 75789bf..9cc0929 100644 --- a/cloudfunctions/trigger/index.js +++ b/cloudfunctions/trigger/index.js @@ -19,7 +19,9 @@ const collectionNameMap = { const PagePathMap = { shixun:"markdown/shixun/shixun/shixun", - path:"markdown/path/path/path" + path:"markdown/path/path/path", + mooc_case:"markdown/mooc_case/mooc_case/mooc_case", + competition:"markdown/competition/competition/competition" } @@ -40,75 +42,48 @@ exports.main = async (event, context) => { } } -async function submitPages({Time}){ - console.log("start submitPages"); +async function submitPage({route, timeStart, timeEnd}){ const db = cloud.database(); const _ = db.command; const pageHistoryCollection = db.collection(collectionNameMap.pageHistory); - let shixunPath = PagePathMap.shixun; - let pathPath = PagePathMap.path; - let timeEnd = new Date(Time); - let timeStart = new Date(timeEnd.getTime() - config.submitPagesGapDay*milliSecondsPerDay); - - let shixunResult = await pageHistoryCollection.where({ - page: shixunPath, + let data = await pageHistoryCollection.aggregate() + .match({ + page: route, status: 200, isCrawl: false, time: _.lt(timeEnd).and(_.gte(timeStart)) - }).get(); + }) + .group({ + _id:"$options" + }) + .end(); + + if(data.list.length==0) + return "empty history: " + route; + let pages = data.list.map(i=>{ + let query = Object.keys(i._id).map(k=>`${k}=${i._id[k]}`).join("&"); + return { + path: route, + query + } + }) + let res = await cloud.openapi.search.submitPages({pages}); + console.log("submit pages success", route, pages.length, res, pages); + return "submit success: " + route + " " + pages.length; +} - let pathResult = await pageHistoryCollection.where({ - page: pathPath, - status: 200, - isCrawl: false, - time:_.lt(timeEnd).and(_.gte(timeStart)) - }).get(); - - let shixunQueries = shixunResult.data.reduce(function(arr, v){ - var query = Object.keys(v.options).map(k=>`${k}=${v.options[k]}`).join("&"); - if(arr.indexOf(query)==-1) - arr.push(query); - return arr - },[]); - - let pathQueries = pathResult.data.reduce(function(arr, v){ - var query = Object.keys(v.options).map(k=>`${k}=${v.options[k]}`).join("&"); - if(arr.indexOf(query)==-1) - arr.push(query); - return arr - },[]); - - console.info("shixunQueries", shixunQueries.length, shixunQueries); - console.info("pathQueries", pathQueries.length, pathQueries); - - if(shixunQueries.length>0){ - var pages = shixunQueries.map(i=>{ - return { - path: shixunPath, - query: i - } - }); - var res = await cloud.openapi.search.submitPages({pages}); - console.log("submit shixun pages",pages.length, res); - console.info("arguments", pages); - }else{ - console.warn("no shixun history"); - } - if(pathQueries.length>0){ - var pages = pathQueries.map(i=>{ - return { - path: pathPath, - query: i - } - }); - var res = await cloud.openapi.search.submitPages({pages}); - console.log("submit path pages success", pages.length, res); - console.info("arguments", pages); - }else{ - console.warn("no path history"); - } - return {code:0, message:"success"}; +async function submitPages({Time}){ + let timeEnd = new Date(Time); + let timeStart = new Date(timeEnd.getTime() - config.submitPagesGapDay*milliSecondsPerDay); + // pages to be submitted + let routes = [ + "shixun", "path", "mooc_case", "competition" + ] + let promises = routes.map(i=>{ + return submitPage({route: PagePathMap[i], timeStart, timeEnd}) + }) + return Promise.all(promises) } async function clearPageHistory({Time}){ diff --git a/miniprogram/competition/pages/competitions/competition-item/competition-item.wxml b/miniprogram/competition/pages/competitions/competition-item/competition-item.wxml index 0ad2351..ec98c97 100644 --- a/miniprogram/competition/pages/competitions/competition-item/competition-item.wxml +++ b/miniprogram/competition/pages/competitions/competition-item/competition-item.wxml @@ -1,4 +1,5 @@ - + diff --git a/miniprogram/components/home-notice/home-notice.js b/miniprogram/components/home-notice/home-notice.js new file mode 100644 index 0000000..8977e2c --- /dev/null +++ b/miniprogram/components/home-notice/home-notice.js @@ -0,0 +1,23 @@ +// components/home-notice/home-notice.js +Component({ + /** + * 组件的属性列表 + */ + properties: { + + }, + + /** + * 组件的初始数据 + */ + data: { + + }, + + /** + * 组件的方法列表 + */ + methods: { + + } +}) diff --git a/miniprogram/components/home-notice/home-notice.json b/miniprogram/components/home-notice/home-notice.json new file mode 100644 index 0000000..e8cfaaf --- /dev/null +++ b/miniprogram/components/home-notice/home-notice.json @@ -0,0 +1,4 @@ +{ + "component": true, + "usingComponents": {} +} \ No newline at end of file diff --git a/miniprogram/components/home-notice/home-notice.wxml b/miniprogram/components/home-notice/home-notice.wxml new file mode 100644 index 0000000..e6b5929 --- /dev/null +++ b/miniprogram/components/home-notice/home-notice.wxml @@ -0,0 +1,2 @@ + +components/home-notice/home-notice.wxml diff --git a/miniprogram/components/home-notice/home-notice.wxss b/miniprogram/components/home-notice/home-notice.wxss new file mode 100644 index 0000000..d6c8691 --- /dev/null +++ b/miniprogram/components/home-notice/home-notice.wxss @@ -0,0 +1 @@ +/* components/home-notice/home-notice.wxss */ \ No newline at end of file diff --git a/miniprogram/config.js b/miniprogram/config.js index 3a3f4d7..3e390ae 100644 --- a/miniprogram/config.js +++ b/miniprogram/config.js @@ -1,6 +1,6 @@ const cloudDir = "cloud://educoder.6564-educoder-1300855313/"; -let _version = "0.19.1"; +let _version = "0.19.2"; let { miniProgram:{ envVersion="release", version=_version}={}} = wx.getAccountInfoSync(); version = version||_version; @@ -19,7 +19,7 @@ export function switchEnv(env) { } else if (env == "trial") { eduUrl = trialUrl; - config.version = "体验版 " + version; + config.version = version+" 体验版"; } else { eduUrl = releaseUrl; diff --git a/miniprogram/course/pages/course_invite/course_invite.js b/miniprogram/course/pages/course_invite/course_invite.js index e902207..95ca8ab 100644 --- a/miniprogram/course/pages/course_invite/course_invite.js +++ b/miniprogram/course/pages/course_invite/course_invite.js @@ -17,6 +17,7 @@ Page({ eduImgDir:global.config.eduImgDir }, onImgLoad(e){ + console.log("imageload", e); this.setData({code_loaded:1}); }, onImgError(e){ @@ -24,8 +25,14 @@ Page({ let scene = this.getScene(); wx.cloud.callFunction({ name: "openapi", data: { name:"wxacode.getUnlimited", data:{page, scene}}}) .then(res=>{ - this.setData({invite_code_url:""}); - this.setData({invite_code_url: res.result.fileID||res.result}) + let t = new Date().getTime(); + wx.cloud.getTempFileURL({ + fileList:[res.result.fileID], + success:res=>{ + console.log(res) + this.setData({invite_code_url: res.fileList[0].tempFileURL+"?t="+t}) + } + }) }); }, login:function(){ @@ -119,6 +126,9 @@ Page({ if(this.data.status==-1) this.pull_course() }, + onReady(){ + app.reportPageHistory(); + }, onShareAppMessage(){ let {course} = this.data; return app.shareApp({ diff --git a/miniprogram/markdown/path/path/path.js b/miniprogram/markdown/path/path/path.js index 3b3c46c..bcaf580 100644 --- a/miniprogram/markdown/path/path/path.js +++ b/miniprogram/markdown/path/path/path.js @@ -79,15 +79,7 @@ Page({ wx.setNavigationBarTitle({ title:"实践课程-"+res[0].name }) - app.cloudapi("reportPageHistory")({ - page: this.route, - options: this.options, - status: 200, - scene: app.globalData.scene - }).catch(e=>{ - global.realTimeLog.error("report history error", e); - wx.reportMonitor('2', 1); - }) + app.reportPageHistory() return res; }).catch(e=>{ if(e.code==403) diff --git a/miniprogram/markdown/shixun/shixun/shixun.js b/miniprogram/markdown/shixun/shixun/shixun.js index 5ac9694..0856326 100644 --- a/miniprogram/markdown/shixun/shixun/shixun.js +++ b/miniprogram/markdown/shixun/shixun/shixun.js @@ -98,15 +98,7 @@ Page({ let current = cateTypes[cate_type]; this.setData({identifier, current}); this.pullShixun().then(res=>{ - app.cloudapi("reportPageHistory")({ - page: this.route, - options: this.options, - status: 200, - scene: app.globalData.scene - }).catch(e=>{ - global.realTimeLog.error("report history error", e); - wx.reportMonitor('2', 1); - }) + app.reportPageHistory(); }).catch(e=>{ app.showError(e); wx.hideShareMenu(); diff --git a/miniprogram/mooc_case/pages/mooc_cases/mooc_case_item/mooc_case_item.wxml b/miniprogram/mooc_case/pages/mooc_cases/mooc_case_item/mooc_case_item.wxml index ef03856..56e579e 100644 --- a/miniprogram/mooc_case/pages/mooc_cases/mooc_case_item/mooc_case_item.wxml +++ b/miniprogram/mooc_case/pages/mooc_cases/mooc_case_item/mooc_case_item.wxml @@ -1,4 +1,5 @@ - + {{data.title}}{{item.name}} diff --git a/miniprogram/pages/home/home.js b/miniprogram/pages/home/home.js index d3e2ee8..818af76 100644 --- a/miniprogram/pages/home/home.js +++ b/miniprogram/pages/home/home.js @@ -180,7 +180,7 @@ Page({ data: this.data.auto_attendance, }); }, - updateGold({gold, duration}){ + updateGold({gold, duration=2500}){ let {grade} = this.data.user; if(grade >= gold) return console.log(new Date().getTime()) @@ -199,12 +199,28 @@ Page({ attendance({ show = 1 }={}) { if(!app.checkLogin({content:"您需要登陆后才能签到获取金币"})) return; + if(this.data.user.attendance_signed){ + if(show) + wx.showToast({ + title: '您已经签到过了',icon:"none" + }); + return; + } app.api("users.attendance")() .then(res => { res.message = "签到成功"; if (show) app.showMsg(res); let {grade} = res; + var db = wx.cloud.database(); + db.collection("res").add({ + data:{ + ...res, + name: "users.attendance", + createAt: db.serverDate() + } + }) + this.setData({"user.attendance_signed": true}); this.updateGold({gold: grade}) }).catch(e=>{ if(show) diff --git a/miniprogram/pages/home/home.wxml b/miniprogram/pages/home/home.wxml index 272d3c0..3a6d7ab 100644 --- a/miniprogram/pages/home/home.wxml +++ b/miniprogram/pages/home/home.wxml @@ -29,10 +29,10 @@ - 金币 - + 金币 + {{user.grade||0}} - + @@ -136,8 +136,9 @@ 小程序客服 - + 设置 + v{{version}}