diff --git a/cloudfunctions/cloudapi/config.json b/cloudfunctions/cloudapi/config.json index 5ecc33e..310b4f8 100644 --- a/cloudfunctions/cloudapi/config.json +++ b/cloudfunctions/cloudapi/config.json @@ -1,6 +1,7 @@ { "permissions": { "openapi": [ + "subscribeMessage.send" ] } } \ No newline at end of file diff --git a/cloudfunctions/cloudapi/index.js b/cloudfunctions/cloudapi/index.js index cb2864b..8749672 100644 --- a/cloudfunctions/cloudapi/index.js +++ b/cloudfunctions/cloudapi/index.js @@ -87,17 +87,30 @@ const sceneDescMap = { 1150: "扫一扫商品条码结果页打开小程序", 1153: '“识物”结果页打开小程序' } +function getFormatTime(date){ + date = date || new Date(); + let hour = date.getHours(); + let minu = date.getMinutes(); + let sec = date.getSeconds(); + if (hour < 10) hour = "0" + hour; + if (minu < 10) minu = "0" + minu; + if (sec < 10) sec = "0" + sec; + return hour + ":" + minu + ":" + sec; +} + cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }); +const db = cloud.database(); +const pageHistoryCollection = db.collection("pageHistory"); exports.main = async (event, context) => { let {name, data} = event; console.log(event); const wxContext = cloud.getWXContext(); - let db = cloud.database(); + switch (name) { case 'getOpenData': { return cloud.getOpenData(data); @@ -112,16 +125,49 @@ exports.main = async (event, context) => { } case "reportPageHistory":{ console.log("reportPageHistory"); - return db.collection("pageHistory").add({ + var now = new Date(); + let res = await pageHistoryCollection.add({ data:{ ...data, isCrawl: data.scene==1129, sceneDesc: sceneDescMap[data.scene], - time: new Date(), + time: now, timestamp: Date.now(), 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.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":{ + return pageHistoryCollection.where(data).remove(); } default: { return diff --git a/miniprogram/admin/pages/page_history/page_history.js b/miniprogram/admin/pages/page_history/page_history.js new file mode 100644 index 0000000..1bcad23 --- /dev/null +++ b/miniprogram/admin/pages/page_history/page_history.js @@ -0,0 +1,107 @@ +import {checkAuth} from "../../utils"; +import {getFormatDatetime} from "../../../js/utils" +const app = getApp(); +const db = wx.cloud.database(); +const pageHistoryCollection = db.collection("pageHistory"); + + +Page({ + + data: { + data:[] + }, + subscribe(){ + wx.requestSubscribeMessage({ + tmplIds: ["atZ4ZFfGIPxTiFGTCtkwvnfqjBA-fM7o1p5OiJQA_0Y"], + fail:console.error + }) + }, + onLoad: function (options) { + this.options = {page:1, limit:20}; + if(checkAuth()){ + this.refresh({refresh:1}); + pageHistoryCollection.count() + .then(res=>{ + console.log(res); + this.setData({total: res.total}); + }) + }else{ + wx.showModal({ + title:"提示", + content:"您没有权限访问", + success: res=>{ + wx.navigateBack({ + delta: 1 + }); + } + }) + } + }, + + async refresh({refresh=0}={}){ + if(!checkAuth()) + return; + if(refresh){ + this.options.page = 1; + }else{ + this.options.page ++ + } + let {page,limit} = this.options; + let skip = (page-1)*limit; + console.log(skip, limit); + let res = await pageHistoryCollection.orderBy("time", "desc").skip(skip).limit(limit).get(); + let data = res.data.map(i=>{ + i.time_show = getFormatDatetime(i.time); + i.options_show = JSON.stringify(i.options); + i.page_show = i.page.match(/\/([^\/]*$)/)[1]; + return i; + }); + console.log(data); + if(!refresh){ + data = this.data.data.concat(data) + } + this.setData({data}); + }, + deleteMine(){ + app.cloudapi("clearPageHistory")({ + openid: app.globalData.openid + }).then(res=>{ + console.log(res); + wx.showToast({ + title: res.errMsg, + }) + this.refresh({refresh:1}); + }).catch(e=>{ + wx.showToast({ + title: e.errMsg,icon:"none" + }) + }) + }, + onReady: function () { + + }, + + onShow: function () { + + }, + + onHide: function () { + + }, + + onUnload: function () { + + }, + + onPullDownRefresh: function () { + this.refresh({refresh:1}); + }, + + onReachBottom: function () { + this.refresh({refresh:0}); + }, + + onShareAppMessage: function () { + + } +}) \ No newline at end of file diff --git a/miniprogram/admin/pages/page_history/page_history.json b/miniprogram/admin/pages/page_history/page_history.json new file mode 100644 index 0000000..09f295e --- /dev/null +++ b/miniprogram/admin/pages/page_history/page_history.json @@ -0,0 +1,6 @@ +{ + "usingComponents": {}, + "enablePullDownRefresh": true, + "onReachBottomDistance": 260, + "navigationBarTitleText": "访问记录" +} \ No newline at end of file diff --git a/miniprogram/admin/pages/page_history/page_history.wxml b/miniprogram/admin/pages/page_history/page_history.wxml new file mode 100644 index 0000000..9ae9cb6 --- /dev/null +++ b/miniprogram/admin/pages/page_history/page_history.wxml @@ -0,0 +1,21 @@ + + + + {{item.time_show}} {{item.isCrawl?'爬虫访问':""}} + + + {{item.page_show}} + {{item.options_show}} + + + {{item.scene}} {{item.sceneDesc}} + + + {{item.openid}} + + + + + + + \ No newline at end of file diff --git a/miniprogram/admin/pages/page_history/page_history.wxss b/miniprogram/admin/pages/page_history/page_history.wxss new file mode 100644 index 0000000..6bd3f66 --- /dev/null +++ b/miniprogram/admin/pages/page_history/page_history.wxss @@ -0,0 +1,31 @@ +page{ + height: 100%; +} +.list{ + min-height: 100vh; +} +.history{ + background: white; + padding: 12px; + margin: 10px; + border-radius: 8px; +} +.history.crawl{ + border: 2px green solid; +} +.header, +.detail{ + color: dimgray; + font-size: 12px; +} +.footer{ + display: flex; +} +.footer>button{ + flex: 1; + border-radius: 0; +} +.sticky{ + bottom: 0; + position: sticky; +} \ No newline at end of file diff --git a/miniprogram/admin/utils.js b/miniprogram/admin/utils.js new file mode 100644 index 0000000..61c609d --- /dev/null +++ b/miniprogram/admin/utils.js @@ -0,0 +1,3 @@ +export function checkAuth(){ + return getApp().globalData.openid == "oqugK431bepFwW6TGrHpQTerPkI0" +} \ No newline at end of file diff --git a/miniprogram/app.json b/miniprogram/app.json index 6dd818e..3c1b0e9 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -7,7 +7,7 @@ "backgroundColor": "#f5f5f5" }, "usingComponents": { - "iconfont":"/components/iconfont/iconfont", + "iconfont": "/components/iconfont/iconfont", "require-login": "/components/require-login/require-login" }, "pages": [ @@ -17,6 +17,12 @@ "pages/tidings/tidings" ], "subpackages": [ + { + "root": "admin", + "pages": [ + "pages/page_history/page_history" + ] + }, { "root": "markdown", "pages": [ @@ -129,8 +135,8 @@ ] }, "account/pages/account/account": { - "network":"all", - "packages":[ + "network": "all", + "packages": [ "markdown" ] } diff --git a/miniprogram/markdown/path/path/path.wxml b/miniprogram/markdown/path/path/path.wxml index f0bfb75..e064485 100644 --- a/miniprogram/markdown/path/path/path.wxml +++ b/miniprogram/markdown/path/path/path.wxml @@ -81,6 +81,6 @@ - + \ No newline at end of file diff --git a/miniprogram/markdown/path/path/path.wxss b/miniprogram/markdown/path/path/path.wxss index 7cdbddb..fd6e005 100644 --- a/miniprogram/markdown/path/path/path.wxss +++ b/miniprogram/markdown/path/path/path.wxss @@ -98,10 +98,6 @@ display: flex; background: white; } -.operations>.collect{ - background: white!important; - flex: 1; -} .operations>button{ flex: 1; border-radius: 0; diff --git a/miniprogram/markdown/shixun/shixun/shixun.wxml b/miniprogram/markdown/shixun/shixun/shixun.wxml index 5fc0681..fcbf7ca 100644 --- a/miniprogram/markdown/shixun/shixun/shixun.wxml +++ b/miniprogram/markdown/shixun/shixun/shixun.wxml @@ -44,8 +44,8 @@ - + - + \ No newline at end of file diff --git a/miniprogram/markdown/shixun/shixun/shixun.wxss b/miniprogram/markdown/shixun/shixun/shixun.wxss index 10e5a22..490ccfb 100644 --- a/miniprogram/markdown/shixun/shixun/shixun.wxss +++ b/miniprogram/markdown/shixun/shixun/shixun.wxss @@ -80,9 +80,6 @@ white-space: nowrap; border-radius: 0; } -button.collect, button.send{ - background: white!important; -} /* tmp solution*/ .weui-half-screen-dialog__hd__side .weui-icon-btn.weui-icon-btn_more{ display: none; diff --git a/miniprogram/markdown/task/task/task.js b/miniprogram/markdown/task/task/task.js index 365c1dd..b3cc541 100644 --- a/miniprogram/markdown/task/task/task.js +++ b/miniprogram/markdown/task/task/task.js @@ -190,7 +190,6 @@ Page({ }, 1000); }, onSwiperChange(e){ - ; let {detail:{current,source}} = e; if(source=="touch"){ this.setData({current}); @@ -215,7 +214,6 @@ Page({ }, async pullContent(){ - ; let {path} = this.data.challenge; path = this.processPath(path); let {identifier} = this.data; @@ -233,17 +231,14 @@ Page({ } }else this.setData({content}); - ; }, onEditorReady({pullContent=0}={}) { - const that = this wx.createSelectorQuery().select('#code-editor').context(function (res) { that.editor = res.context if(pullContent&&that.editor) that.pullContent(); //that.editor.insertText({text:that.content}); - ; }).exec(); }, diff --git a/miniprogram/markdown/task/task/task.wxml b/miniprogram/markdown/task/task/task.wxml index 91e8757..d379297 100644 --- a/miniprogram/markdown/task/task/task.wxml +++ b/miniprogram/markdown/task/task/task.wxml @@ -39,9 +39,9 @@ bindinput="onTextAreaInput"> - + - + diff --git a/miniprogram/pages/findmore/shixuns/shixuns.wxss b/miniprogram/pages/findmore/shixuns/shixuns.wxss index ac499ce..ef98a04 100644 --- a/miniprogram/pages/findmore/shixuns/shixuns.wxss +++ b/miniprogram/pages/findmore/shixuns/shixuns.wxss @@ -4,6 +4,7 @@ .sticky-top{ top: 0; position: sticky; + z-index: 1000; } .header{ background: white; diff --git a/miniprogram/pages/home/home.js b/miniprogram/pages/home/home.js index 62c45a8..1fbd54a 100644 --- a/miniprogram/pages/home/home.js +++ b/miniprogram/pages/home/home.js @@ -22,15 +22,19 @@ Page({ let { envVersion, env } = global.config; if (envVersion && envVersion != "release") { wx.showActionSheet({ - itemList: [env != "release" ? "切换为发布环境" : "切换为开发环境"], + itemList: [env != "release" ? "切换为发布环境" : "切换为开发环境", "查看页面访问记录"], success: res => { - global.config.switchEnv(env != "release" ? "release" : "trial"); - wx.showToast({ - title: '切换成功' - }); - this.logout({ showToast: 0 }); - let { version, eduImgDir } = global.config; - this.setData({ version, eduImgDir }); + if(res.tapIndex==0){ + global.config.switchEnv(env != "release" ? "release" : "trial"); + wx.showToast({ + title: '切换成功' + }); + this.logout({ showToast: 0 }); + let { version, eduImgDir } = global.config; + this.setData({ version, eduImgDir }); + }else if(res.tapIndex==1){ + app.navigateTo({url:"{page_history}"}) + } } }) return; diff --git a/miniprogram/pages/main/main.js b/miniprogram/pages/main/main.js index e39a78b..2b86a6b 100644 --- a/miniprogram/pages/main/main.js +++ b/miniprogram/pages/main/main.js @@ -50,6 +50,7 @@ Page({ onShareAppMessage(){ let {list, current} = this.data; return app.shareApp({ + imageUrl: global.config.attachDir + "944406", path: "/"+this.route+"?type="+list[current].type }) } diff --git a/miniprogram/pages/main/my_course/course-item/course-item.js b/miniprogram/pages/main/my_course/course-item/course-item.js index e781aa5..e704442 100644 --- a/miniprogram/pages/main/my_course/course-item/course-item.js +++ b/miniprogram/pages/main/my_course/course-item/course-item.js @@ -99,8 +99,10 @@ Component({ }, exit_course(){ wx.showModal({ - title: '提示', + title: '警告', content: '退出后您将不再是本课题的成员,\n作品将全部被删除,\n确定要退出该课堂吗?', + confirmColor:"#fa5151", + confirmText:"退出", success:res=>{ if(res.confirm){ app.api("courses.exit_course")({course_id:this.data.data.id}) @@ -173,6 +175,7 @@ Component({ title: '警告', content: '课堂删除后所有数据将被删除并且【无法恢复】,\n是否确定删除?', confirmColor:"#fa5151", + confirmText:"删除", success: res=>{ if(!res.confirm) return; diff --git a/miniprogram/pages/main/my_course/course-item/course-item.wxss b/miniprogram/pages/main/my_course/course-item/course-item.wxss index c2cb787..3b389d7 100644 --- a/miniprogram/pages/main/my_course/course-item/course-item.wxss +++ b/miniprogram/pages/main/my_course/course-item/course-item.wxss @@ -43,7 +43,7 @@ background: orange; top: -6px; left: -16px; - border-bottom: #f0f0f0 3px solid; + border-bottom: #f0f0f0 2px solid; } .body{ display: flex; diff --git a/miniprogram/setting/pages/image_crop/image_crop.wxml b/miniprogram/setting/pages/image_crop/image_crop.wxml index 0f407f7..4453912 100644 --- a/miniprogram/setting/pages/image_crop/image_crop.wxml +++ b/miniprogram/setting/pages/image_crop/image_crop.wxml @@ -5,13 +5,13 @@