From 74bd7c5c9ed1bd8cdad662e43be665b9db3814fd Mon Sep 17 00:00:00 2001 From: educoder_weapp Date: Sun, 12 Jul 2020 13:46:18 +0800 Subject: [PATCH] =?UTF-8?q?A=20=E5=A2=9E=E5=8A=A0=E5=9C=A8=E7=BA=BF?= =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E6=A8=A1=E5=9D=97=E3=80=81=E7=9C=81=E6=B5=81?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog.md | 12 ++ cloudfunctions/cloudapi/index.js | 2 +- cloudfunctions/trigger/config.json | 4 + cloudfunctions/trigger/index.js | 18 +++ miniprogram/app.js | 43 +++++- miniprogram/app.json | 15 ++- miniprogram/competition/apiConfig.js | 15 --- .../pages/competition/competition.wxml | 2 - .../pages/competition/competition.wxss | 1 - .../competition-item/competition-item.js | 27 ++++ .../competition-item/competition-item.json} | 1 + .../competition-item/competition-item.wxml | 9 ++ .../competition-item/competition-item.wxss | 30 +++++ .../competitions.js} | 23 +++- .../pages/competitions/competitions.json | 6 + .../pages/competitions/competitions.wxml | 5 + .../pages/competitions/competitions.wxss | 6 + miniprogram/components/iconfont/iconfont.wxss | 16 ++- miniprogram/config.js | 17 ++- miniprogram/course/pages/course/course.json | 3 +- miniprogram/js/api.js | 3 +- miniprogram/js/apiConfig.js | 7 + miniprogram/js/utils.js | 44 +++++- .../competition/competition/competition.js | 127 ++++++++++++++++++ .../competition/competition/competition.json | 7 + .../competition/competition/competition.wxml | 16 +++ .../competition/competition/competition.wxss | 15 +++ miniprogram/pages/home/home.wxml | 14 +- miniprogram/setting/pages/setting/setting.js | 31 ++--- .../setting/pages/setting/setting.wxml | 6 +- project.config.json | 7 + 31 files changed, 457 insertions(+), 75 deletions(-) delete mode 100644 miniprogram/competition/apiConfig.js delete mode 100644 miniprogram/competition/pages/competition/competition.wxml delete mode 100644 miniprogram/competition/pages/competition/competition.wxss create mode 100644 miniprogram/competition/pages/competitions/competition-item/competition-item.js rename miniprogram/competition/pages/{competition/competition.json => competitions/competition-item/competition-item.json} (54%) create mode 100644 miniprogram/competition/pages/competitions/competition-item/competition-item.wxml create mode 100644 miniprogram/competition/pages/competitions/competition-item/competition-item.wxss rename miniprogram/competition/pages/{competition/competition.js => competitions/competitions.js} (66%) create mode 100644 miniprogram/competition/pages/competitions/competitions.json create mode 100644 miniprogram/competition/pages/competitions/competitions.wxml create mode 100644 miniprogram/competition/pages/competitions/competitions.wxss create mode 100644 miniprogram/markdown/competition/competition/competition.js create mode 100644 miniprogram/markdown/competition/competition/competition.json create mode 100644 miniprogram/markdown/competition/competition/competition.wxml create mode 100644 miniprogram/markdown/competition/competition/competition.wxss diff --git a/changelog.md b/changelog.md index 6722a66..1dd61c2 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,15 @@ +## v0.18.0 + * A 添加在线竞赛模块 + * A 添加省流模式 + * A 增加设置界面 + * U 完善markdown网址解析功能 + + +## v0.17.1 + * A 增加分享朋友圈 + * A 添加收藏时的封面图 + * A 配置代码懒注入 + ## v0.17.0 * A 增加开源版本库查看 diff --git a/cloudfunctions/cloudapi/index.js b/cloudfunctions/cloudapi/index.js index 36ea4b7..fda2747 100644 --- a/cloudfunctions/cloudapi/index.js +++ b/cloudfunctions/cloudapi/index.js @@ -153,7 +153,7 @@ exports.main = async (event, context) => { value:"pageHistory" //服务器 }, character_string2:{ - value: data.page.match(/\/([^\/]*$)/)[1] //数据类型 + value: (data.route||data.page).match(/\/([^\/]*$)/)[1] //数据类型 }, thing4:{ value:sceneDescMap[data.scene].slice(0,20) //添加内容 diff --git a/cloudfunctions/trigger/config.json b/cloudfunctions/trigger/config.json index 127b1bd..b7aa720 100644 --- a/cloudfunctions/trigger/config.json +++ b/cloudfunctions/trigger/config.json @@ -15,6 +15,10 @@ "name": "clearPageHistory", "type":"timer", "config":"0 0 3 1 * * *" + },{ + "name":"attendance", + "type":"timer", + "config":"0 0 4 * * * *" } ] } \ No newline at end of file diff --git a/cloudfunctions/trigger/index.js b/cloudfunctions/trigger/index.js index 38e1d50..75789bf 100644 --- a/cloudfunctions/trigger/index.js +++ b/cloudfunctions/trigger/index.js @@ -1,4 +1,7 @@ const cloud = require('wx-server-sdk'); +//const got = require("got"); +//const rp = require("request-promise") + cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) @@ -31,6 +34,9 @@ exports.main = async (event, context) => { case "clearPageHistory":{ return clearPageHistory({Time}); } + case "attandance":{ + return attandance({Time}); + } } } @@ -121,4 +127,16 @@ async function clearPageHistory({Time}){ console.log("remove page History result: ", res); return {code: 0, message:"success", data:res}; +} + +async function attandance({Time}){ + /**let postResponse = await got(url, { + method: 'GET', //post请求 + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + + }) + })**/ } \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index 1916f95..95c2078 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -50,6 +50,34 @@ App({ }); }); }, + reportPageHistory:function({page, route, scene, status, options}){ + let data = {} + page = page||getCurrentPages()[getCurrentPages().length-1]; + if(page){ + Object.assign(data, + { + route: page.route, + page: page.route, //@desprate + scene: this.globalData.scene, + status: 200, + options: page.options + }) + } + if(route){ + data.page = data.route = route; + } + if(scene) + data.scene = scene; + if(status) + data.status = status; + if(options) + data.options = options; + + this.cloudapi("reportPageHistory")(data).catch(e=>{ + global.realTimeLog.error("report history error", e); + wx.reportMonitor('2', 1); + }) + }, realTimeLog:global.realTimeLog, api(name, config) { return client.api(name, config) }, callApi(options) { return client.callApi(options) }, @@ -115,7 +143,11 @@ App({ } }).catch(e=>{}); */ - + if(global.config.saveFlow){ + wx.showToast({ + title: '省流模式已开启,默认不加载图片',icon:"none",duration:2600 + }) + } }, onShow() { if (client.user_id && client.user_id != 2) @@ -179,6 +211,7 @@ App({ addToFavorites({title, query, imageUrl}={}){ let db = wx.cloud.database(); let data = { + type:"addToFavorites", title, imageUrl, query, @@ -187,7 +220,7 @@ App({ time: db.serverDate() } db.collection("shareInfo").add({ - type:"addToFavorites", + data }); return { @@ -197,6 +230,7 @@ App({ shareTimeline({title, query, imageUrl}={}){ let db = wx.cloud.database(); let data = { + type:"shareTimeline", title, imageUrl, query, @@ -205,7 +239,6 @@ App({ time: db.serverDate() } db.collection("shareInfo").add({ - type:"shareTimeline", data }); return { @@ -229,6 +262,7 @@ App({ path = "/" + route + (query ? ('?' + query) : ''); } let data = { + type:"shareAppMessage", title, imageUrl, path, @@ -238,7 +272,7 @@ App({ } console.log("upload", data); db.collection("shareInfo").add({ - type:"shareAppMessage", + data }); } @@ -278,4 +312,3 @@ function toAbsPath(current, path) { return path; } */ - diff --git a/miniprogram/app.json b/miniprogram/app.json index f72ec8d..83e1560 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -8,16 +8,22 @@ }, "usingComponents": { "iconfont": "/components/iconfont/iconfont", - "require-login": "/components/require-login/require-login" + "require-login": "/components/require-login/require-login", + "mp-icon": "/weui-miniprogram/icon/icon" }, "pages": [ "pages/main/main", "pages/findmore/findmore", "pages/home/home", - "pages/tidings/tidings", - "competition/pages/competition/competition" + "pages/tidings/tidings" ], "subpackages": [ + { + "root":"competition", + "pages":[ + "pages/competitions/competitions" + ] + }, { "root": "project", "pages": [ @@ -38,6 +44,7 @@ "account/about/about", "account/agreement/agreement", "account/pro_authentication/pro_authentication", + "competition/competition/competition", "exercise/exercise/exercise", "path/path/path", "path/path_send/path_send", @@ -186,5 +193,5 @@ "themeLocation": "theme.json", "lazyCodeLoading": "requiredComponents", "style": "v2", - "debug":true + "debug": true } \ No newline at end of file diff --git a/miniprogram/competition/apiConfig.js b/miniprogram/competition/apiConfig.js deleted file mode 100644 index d6e3e5f..0000000 --- a/miniprogram/competition/apiConfig.js +++ /dev/null @@ -1,15 +0,0 @@ -import apiConfig from "../js/apiConfig" - -Object.assign(apiConfig, -{ -competitions:{ - common_header:{url:"{identifier}/*"}, - competition_staff:{url:"{identifier}/*"}, - competition_modules:{url:"{identifier}/*/{module_id}"}, -} - -}) - - - -export default apiConfig; \ No newline at end of file diff --git a/miniprogram/competition/pages/competition/competition.wxml b/miniprogram/competition/pages/competition/competition.wxml deleted file mode 100644 index 3200328..0000000 --- a/miniprogram/competition/pages/competition/competition.wxml +++ /dev/null @@ -1,2 +0,0 @@ - -miniprogram/competition/pages/competition/competition.wxml diff --git a/miniprogram/competition/pages/competition/competition.wxss b/miniprogram/competition/pages/competition/competition.wxss deleted file mode 100644 index a91573b..0000000 --- a/miniprogram/competition/pages/competition/competition.wxss +++ /dev/null @@ -1 +0,0 @@ -/* miniprogram/competition/pages/competition/competition.wxss */ \ No newline at end of file diff --git a/miniprogram/competition/pages/competitions/competition-item/competition-item.js b/miniprogram/competition/pages/competitions/competition-item/competition-item.js new file mode 100644 index 0000000..8af025e --- /dev/null +++ b/miniprogram/competition/pages/competitions/competition-item/competition-item.js @@ -0,0 +1,27 @@ +const app = getApp(); + +Component({ + /** + * 组件的属性列表 + */ + properties: { + data:Object + }, + + /** + * 组件的初始数据 + */ + data: { + eduUrl: global.config.eduUrl + }, + + methods: { + previewImage(){ + let url = this.data.eduUrl +"/"+this.data.data.image; + wx.previewImage({ + urls: [url], + }) + } + + } +}) diff --git a/miniprogram/competition/pages/competition/competition.json b/miniprogram/competition/pages/competitions/competition-item/competition-item.json similarity index 54% rename from miniprogram/competition/pages/competition/competition.json rename to miniprogram/competition/pages/competitions/competition-item/competition-item.json index 8835af0..e8cfaaf 100644 --- a/miniprogram/competition/pages/competition/competition.json +++ b/miniprogram/competition/pages/competitions/competition-item/competition-item.json @@ -1,3 +1,4 @@ { + "component": true, "usingComponents": {} } \ No newline at end of file diff --git a/miniprogram/competition/pages/competitions/competition-item/competition-item.wxml b/miniprogram/competition/pages/competitions/competition-item/competition-item.wxml new file mode 100644 index 0000000..0ad2351 --- /dev/null +++ b/miniprogram/competition/pages/competitions/competition-item/competition-item.wxml @@ -0,0 +1,9 @@ + + + + + + {{data.name}} + 竞赛时间:{{data.start_time}}~{{data.end_time}} + + \ No newline at end of file diff --git a/miniprogram/competition/pages/competitions/competition-item/competition-item.wxss b/miniprogram/competition/pages/competitions/competition-item/competition-item.wxss new file mode 100644 index 0000000..c42d022 --- /dev/null +++ b/miniprogram/competition/pages/competitions/competition-item/competition-item.wxss @@ -0,0 +1,30 @@ +.item-container{ + padding: 10px 12px; + display: flex; + background: white; + align-items: center; +} + +.item-detail{ + display: flex; + flex-direction: column; + font-size: 15pxs; + margin-left: 12px; +} + +.tip{ + font-size: 12px; + color: grey; +} +.image-wrp{ + flex: none; + width: 200rpx; + height: 110rpx; + overflow:hidden; + border-radius: 4px; +} +.item-image{ + height: 100%; + width: 128.2%; + background: lightblue; +} \ No newline at end of file diff --git a/miniprogram/competition/pages/competition/competition.js b/miniprogram/competition/pages/competitions/competitions.js similarity index 66% rename from miniprogram/competition/pages/competition/competition.js rename to miniprogram/competition/pages/competitions/competitions.js index 19daef0..6d7b858 100644 --- a/miniprogram/competition/pages/competition/competition.js +++ b/miniprogram/competition/pages/competitions/competitions.js @@ -1,13 +1,20 @@ -import apiConfig from "../../apiConfig" - +const app = getApp(); Page({ data: { }, + /** + * 生命周期函数--监听页面加载 + */ onLoad: function (options) { - + app.reportPageHistory({page: this}) + app.api("competitions")() + .then(res=>{ + this.setData(res); + }) + .catch(app.showError) }, /** @@ -52,10 +59,12 @@ Page({ }, - onShareTimeline:function(){ - - }, + /** + * 用户点击右上角分享 + */ onShareAppMessage: function () { - + return app.shareApp({ + title:"EduCoder在线竞赛" + }) } }) \ No newline at end of file diff --git a/miniprogram/competition/pages/competitions/competitions.json b/miniprogram/competition/pages/competitions/competitions.json new file mode 100644 index 0000000..85c6743 --- /dev/null +++ b/miniprogram/competition/pages/competitions/competitions.json @@ -0,0 +1,6 @@ +{ + "usingComponents": { + "competition-item":"./competition-item/competition-item" + }, + "navigationBarTitleText": "在线竞赛" +} \ No newline at end of file diff --git a/miniprogram/competition/pages/competitions/competitions.wxml b/miniprogram/competition/pages/competitions/competitions.wxml new file mode 100644 index 0000000..9b67529 --- /dev/null +++ b/miniprogram/competition/pages/competitions/competitions.wxml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/miniprogram/competition/pages/competitions/competitions.wxss b/miniprogram/competition/pages/competitions/competitions.wxss new file mode 100644 index 0000000..6035a1c --- /dev/null +++ b/miniprogram/competition/pages/competitions/competitions.wxss @@ -0,0 +1,6 @@ +.item-list{ + background: #f0f0f0; +} +.item-wrp{ + margin-top: 5px; +} \ No newline at end of file diff --git a/miniprogram/components/iconfont/iconfont.wxss b/miniprogram/components/iconfont/iconfont.wxss index 7ddf04e..c40c4a5 100644 --- a/miniprogram/components/iconfont/iconfont.wxss +++ b/miniprogram/components/iconfont/iconfont.wxss @@ -1,11 +1,11 @@ @font-face { font-family: 'iconfont'; /* project id 1656783 */ - src: url('//at.alicdn.com/t/font_1656783_pkasgj0rzun.eot'); - src: url('//at.alicdn.com/t/font_1656783_pkasgj0rzun.eot?#iefix') format('embedded-opentype'), - url('//at.alicdn.com/t/font_1656783_pkasgj0rzun.woff2') format('woff2'), - url('//at.alicdn.com/t/font_1656783_pkasgj0rzun.woff') format('woff'), - url('//at.alicdn.com/t/font_1656783_pkasgj0rzun.ttf') format('truetype'), - url('//at.alicdn.com/t/font_1656783_pkasgj0rzun.svg#iconfont') format('svg'); + src: url('//at.alicdn.com/t/font_1656783_5uvt676wssl.eot'); + src: url('//at.alicdn.com/t/font_1656783_5uvt676wssl.eot?#iefix') format('embedded-opentype'), + url('//at.alicdn.com/t/font_1656783_5uvt676wssl.woff2') format('woff2'), + url('//at.alicdn.com/t/font_1656783_5uvt676wssl.woff') format('woff'), + url('//at.alicdn.com/t/font_1656783_5uvt676wssl.ttf') format('truetype'), + url('//at.alicdn.com/t/font_1656783_5uvt676wssl.svg#iconfont') format('svg'); } .iconfont { display: inline-block; @@ -139,4 +139,6 @@ .icon-filter:before { content: "\e6c7"; } - +.icon-jingsai:before{ + content:"\e702"; +} diff --git a/miniprogram/config.js b/miniprogram/config.js index 0ff35f4..9cc709f 100644 --- a/miniprogram/config.js +++ b/miniprogram/config.js @@ -1,6 +1,6 @@ const cloudDir = "cloud://educoder.6564-educoder-1300855313/"; -let _version = "0.17.0"; +let _version = "0.18.0"; let { miniProgram:{ envVersion="release", version=_version}={}} = wx.getAccountInfoSync(); version = version||_version; @@ -32,13 +32,24 @@ export function switchEnv(env) { const config = global.config = { version, envVersion, + saveFlow: wx.getStorageSync('saveFlow'), env:envVersion, get apiRoot(){return eduUrl + "/api/"}, get attachDir(){return eduUrl + "/api/attachments/"}, cloudDir, - get eduUrl(){return eduUrl}, + get eduUrl(){ + if(!config.saveFlow) + return eduUrl + else + return "" + }, imgDir: cloudDir + "images/", - get eduImgDir(){ return eduUrl + "/images/"}, + get eduImgDir(){ + if(!config.saveFlow) + return eduUrl + "/images/" + else + return "" + }, switchEnv, pages:[ "exercise/pages/exercise_setting/exercise_setting", diff --git a/miniprogram/course/pages/course/course.json b/miniprogram/course/pages/course/course.json index f8cbebd..af14704 100644 --- a/miniprogram/course/pages/course/course.json +++ b/miniprogram/course/pages/course/course.json @@ -12,8 +12,7 @@ "join-course":"/components/modal/join-course/join-course", "error-page":"/components/error-page/error-page", "mp-tabbar": "weui-miniprogram/tabbar/tabbar", - "mp-halfScreenDialog": "weui-miniprogram/half-screen-dialog/half-screen-dialog", - "mp-icon": "/weui-miniprogram/icon/icon" + "mp-halfScreenDialog": "weui-miniprogram/half-screen-dialog/half-screen-dialog" }, "navigationStyle": "custom", "navigationBarTextStyle": "white", diff --git a/miniprogram/js/api.js b/miniprogram/js/api.js index 22ad932..993f98d 100644 --- a/miniprogram/js/api.js +++ b/miniprogram/js/api.js @@ -30,6 +30,7 @@ export class Session{ url, header: {...header, "Cookie": this.cookies}, success: (res) => { + console.debug("request success", res); if (res.cookies && res.cookies.length>0) this.setCookies(res.cookies); else if (res.header["Set-Cookie"]) @@ -122,7 +123,7 @@ export function triggerApi({session, name, data:_data = {}, success, fail, compl if(url){ if(url._) url = url[method||"GET"]||url._; - url = name.replace(/\.?[^\.]+$|\./g, "/") + url.replace(/\{(.*?)\}/, function (match, k) { + url = name.replace(/\.?[^\.]+$|\./g, "/") + url.replace(/\{(.*?)\}/g, function (match, k) { return _data[k]; }).replace(/\*/g,key); }else diff --git a/miniprogram/js/apiConfig.js b/miniprogram/js/apiConfig.js index 142c6bc..a6e2f16 100644 --- a/miniprogram/js/apiConfig.js +++ b/miniprogram/js/apiConfig.js @@ -20,6 +20,13 @@ attachments:{url:{_:1,DELETE:'*/{attachment_id}',uploadFile:"*"},query,form:{_:1 collections:{config, query, form:{container_id: null, container_type: null}, cancel:{query, config:{method:"DELETE", form:{container_id: null, container_type: null}}}, }, + +competitions:{ form:{page:1, per_page:15, category:void 0}, data:{category:"nearly_published, progressing, ended"}, + common_header:{url:"{identifier}/*"}, + competition_staff:{url:"{identifier}/*"}, + competition_modules:{url:"{identifier}/*/{module_id}"}, +}, + courses:{ url:{_:"*", DELETE:"*/{course_id}",PUT:"*/{course_id}"},query, form:{_:1,GET:{search:"",limit:20, page:1, order:"all"}, POST:{course_list_name:null,name:null,school: null,end_date: null,class_period:null,credit:null,course_module_types:["shixun_homework","common_homework","group_homework","exercise","attachment","course_group"],authentication:null,professional_certification:null},PUT:{course_list_name:null,name:null,school: null,end_date: null,class_period:null,credit:null,course_module_types:["shixun_homework","common_homework","group_homework","exercise","attachment","course_group"],authentication:null,professional_certification:null}}, act_score:{url:"{course_id}/*", query}, all_course_groups:{url:"{course_id}/*", query}, diff --git a/miniprogram/js/utils.js b/miniprogram/js/utils.js index 228a692..24ac835 100644 --- a/miniprogram/js/utils.js +++ b/miniprogram/js/utils.js @@ -230,7 +230,7 @@ export function parseUrl({url}){ return ''; const route = match[1]; // 路径 // case 1: - match = route.match(/shixuns\/(.*)\/challenges\/(.*)/); + match = route.match(/shixuns\/([^\/]*)/); if(match){ var identifier = match[1] return `{shixun}?identifier=${identifier}&cate_type=task` @@ -239,13 +239,47 @@ export function parseUrl({url}){ } export function navigateToUrl({url,open_type='navigateTo'}){ - url = parseUrl({url}); + console.log("parse url ...",url); + let path = parseUrl({url}); const app = getApp(); - if(url){ - app.navigateTo({url}); + if(path){ + app.navigateTo({url:path}); return true; - }else + }else{ + var match = url.match(/api\/attachments\/([0-9]*)/); + console.log(url,match) + if(match){ + wx.showLoading({ + title: '加载中' + }); + wx.downloadFile({ + url: 'https://www.educoder.net/api/attachments/'+match[1], + success: res=>{ + wx.openDocument({ + filePath: res.tempFilePath, + showMenu: true, + complete: res=>{ + wx.hideLoading() + }, + fail:e=>{ + wx.showToast({ + title:"暂不支持预览",icon:"none" + }) + } + }) + }, + fail:e=>{ + wx.hideLoading(); + wx.showToast({ + title: '下载失败',icon:"none" + }) + } + }) + return true + } return false; + } + } export function throttle(func, wait, options) { diff --git a/miniprogram/markdown/competition/competition/competition.js b/miniprogram/markdown/competition/competition/competition.js new file mode 100644 index 0000000..49bbd45 --- /dev/null +++ b/miniprogram/markdown/competition/competition/competition.js @@ -0,0 +1,127 @@ + +const app = getApp(); + +Page({ + + data: { + + }, + + onLoad: function (options) { + app.reportPageHistory({page:this}); + this.pullData(); + }, + async pullData(){ + let header = await app.api("competitions.common_header")({identifier: this.options.identifier}).catch(app.showError); + header.modules = [] + for(var m of header.competition_modules){ + if(m.module_type=='enroll') + continue; + m.text = m.name; + header.modules.push(m); + } + this.setData(header); + try{ + wx.showLoading({title: '加载中'}); + let module = await app.api("competitions.competition_modules")({ + identifier: this.options.identifier, + module_id: header.modules[0].id}); + this.setData({module}); + }catch(e){ + app.showError(e); + } + wx.hideLoading() + }, + onNavChange(e){ + console.log(e); + let {detail:{value:{id}}} = e; + wx.showNavigationBarLoading(); + app.api("competitions.competition_modules")( + { + identifier: this.options.identifier, + module_id: id + }) + .then(res=>{ + this.setData({module:res}); + }).finally(()=>{ + wx.hideNavigationBarLoading({}); + }); + + }, + onTapAttachment(e){ + console.log(e); + let {currentTarget:{dataset:{url}}} = e; + console.log(url); + url = "https://www.educoder.net"+url; + wx.downloadFile({ + url, + success: res=>{ + wx.openDocument({ + filePath: res.tempFilePath, + showMenu: true + }) + } + }) + }, + + + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + onAddToFavorites:function(){ + let {name, sub_title, avatar_url} = this.data + return app.addToFavorites({ + title: "「在线竞赛」"+name+(sub_title?("--"+sub_title):""), + imageUrl:global.config.eduUrl+"/"+avatar_url + }) + }, + onShareTimeline:function(){ + let {name, sub_title, avatar_url} = this.data + return app.shareTimeline({ + title: "「在线竞赛」"+name+(sub_title?("--"+sub_title):""), + imageUrl:global.config.eduUrl+"/"+avatar_url + }) + }, + onShareAppMessage: function () { + let {name, sub_title, avatar_url} = this.data + return app.shareApp({ + title: "「在线竞赛」"+name+(sub_title?("--"+sub_title):""), + imageUrl:global.config.eduUrl+"/"+avatar_url + }) + } +}) \ No newline at end of file diff --git a/miniprogram/markdown/competition/competition/competition.json b/miniprogram/markdown/competition/competition/competition.json new file mode 100644 index 0000000..fe4358e --- /dev/null +++ b/miniprogram/markdown/competition/competition/competition.json @@ -0,0 +1,7 @@ +{ + "usingComponents": { + "nav-bar":"/components/nav-bar/nav-bar", + "rich-md":"../../components/rich-md/rich-md" + }, + "navigationBarTitleText": "在线竞赛" +} \ No newline at end of file diff --git a/miniprogram/markdown/competition/competition/competition.wxml b/miniprogram/markdown/competition/competition/competition.wxml new file mode 100644 index 0000000..88d64f7 --- /dev/null +++ b/miniprogram/markdown/competition/competition/competition.wxml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + {{item.title}} + + + \ No newline at end of file diff --git a/miniprogram/markdown/competition/competition/competition.wxss b/miniprogram/markdown/competition/competition/competition.wxss new file mode 100644 index 0000000..e5173a5 --- /dev/null +++ b/miniprogram/markdown/competition/competition/competition.wxss @@ -0,0 +1,15 @@ +.sticky-top{ + position: sticky; + top: 0; + background: white; + padding-bottom: 3px; +} + +.attachments{ + text-decoration: underline; + font-size: 15px; + color: #003190; +} +.attachment-item{ + padding: 8px; +} \ No newline at end of file diff --git a/miniprogram/pages/home/home.wxml b/miniprogram/pages/home/home.wxml index f9e8c7b..76586d4 100644 --- a/miniprogram/pages/home/home.wxml +++ b/miniprogram/pages/home/home.wxml @@ -32,12 +32,16 @@ - + EduCoder云网 推荐使用 + + 在线竞赛 + + 修改密码 @@ -53,21 +57,21 @@ - + 设置 - + 切换账号 {{currentLogin}} diff --git a/miniprogram/setting/pages/setting/setting.js b/miniprogram/setting/pages/setting/setting.js index c62fd5e..d598b76 100644 --- a/miniprogram/setting/pages/setting/setting.js +++ b/miniprogram/setting/pages/setting/setting.js @@ -5,12 +5,24 @@ Page({ * 页面的初始数据 */ data: { - + saveFlow: global.config.saveFlow }, - /** - * 生命周期函数--监听页面加载 - */ + onChangeSaveFlow:function(e){ + console.log(e); + let {detail:{value}} = e; + global.config.saveFlow = value; + wx.setStorageSync("saveFlow", value); + wx.showToast({ + title: '重启小程序后生效',icon:"none" + }) + this.setData({requireRelaunch: true}); + }, + reLaunch(){ + wx.reLaunch({ + url: "/"+__wxConfig.pages[0], + }) + }, onLoad: function (options) { }, @@ -49,18 +61,7 @@ Page({ onPullDownRefresh: function () { }, - - /** - * 页面上拉触底事件的处理函数 - */ onReachBottom: function () { - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - } }) \ No newline at end of file diff --git a/miniprogram/setting/pages/setting/setting.wxml b/miniprogram/setting/pages/setting/setting.wxml index 05ef064..b5d30aa 100644 --- a/miniprogram/setting/pages/setting/setting.wxml +++ b/miniprogram/setting/pages/setting/setting.wxml @@ -1,2 +1,4 @@ - -miniprogram/setting/pages/setting/setting.wxml + + 省流模式(内测功能) + + \ No newline at end of file diff --git a/project.config.json b/project.config.json index 450f5db..f4c940a 100644 --- a/project.config.json +++ b/project.config.json @@ -262,6 +262,13 @@ "pathName": "markdown/admin/git_repo/git_repo", "query": "", "scene": null + }, + { + "id": -1, + "name": "competitions", + "pathName": "competition/pages/competitions/competitions", + "query": "course_id=7845&module_type=students", + "scene": null } ] }