From 928ab131a8a97b2c4b2c9df4b6e200ff9de271b8 Mon Sep 17 00:00:00 2001 From: educoder_weapp Date: Sun, 10 Nov 2019 13:44:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=8F=91=E7=8E=B0=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2UI=EF=BC=8C=E6=94=B9=E8=BF=9B=E9=87=8D=E7=BD=AE?= =?UTF-8?q?=E5=AF=86=E7=A0=81=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.json | 10 ++- app.wxss | 4 +- data/client.js | 23 +++++- data/eduapi.js | 25 +++++- .../tabbar-icon/tabbar_findmore_default.png | Bin 0 -> 1932 bytes .../tabbar-icon/tabbar_findmore_pressed.png | Bin 0 -> 1485 bytes pages/exercises/exercises.wxss | 4 +- pages/findmore/findmore.js | 76 ++++++++++++++++++ pages/findmore/findmore.json | 3 + pages/findmore/findmore.wxml | 47 +++++++++++ pages/findmore/findmore.wxss | 65 +++++++++++++++ pages/login/login.js | 6 ++ pages/login/login.wxml | 2 +- pages/reset_password/reset_password.js | 43 +++++++++- pages/reset_password/reset_password.wxml | 1 + utils/pathutils.js | 3 + 16 files changed, 300 insertions(+), 12 deletions(-) create mode 100644 images/tabbar-icon/tabbar_findmore_default.png create mode 100644 images/tabbar-icon/tabbar_findmore_pressed.png create mode 100644 pages/findmore/findmore.js create mode 100644 pages/findmore/findmore.json create mode 100644 pages/findmore/findmore.wxml create mode 100644 pages/findmore/findmore.wxss create mode 100644 utils/pathutils.js diff --git a/app.json b/app.json index a707efa..9e518da 100644 --- a/app.json +++ b/app.json @@ -1,5 +1,6 @@ { "pages": [ + "pages/findmore/findmore", "pages/my_courses/my_courses", "pages/course_setting/course_setting", "pages/exercises/exercises", @@ -14,10 +15,11 @@ "pages/files/files", "pages/mark_detail/mark_detail", "pages/reset_password/reset_password" + ], "window": { "backgroundTextStyle": "dark", - "navigationBarTitleText": "EduCoder", + "navigationBarTitleText": "积分教室", "navigationBarTextStyle": "black", "backgroundColor": "#f2f2f2", "navigationBarBackgroundColor": "#fbfbfb" @@ -31,6 +33,12 @@ "iconPath": "images/tabbar-icon/tabbar_study_default.png", "selectedIconPath": "images/tabbar-icon/tabbar_study_pressed.png" }, + { + "pagePath": "pages/findmore/findmore", + "text": "发现", + "iconPath": "images/tabbar-icon/tabbar_findmore_default.png", + "selectedIconPath": "images/tabbar-icon/tabbar_findmore_pressed.png" + }, { "pagePath": "pages/courses/courses", "text": "课程列表", diff --git a/app.wxss b/app.wxss index d3e6aa2..bfd62ec 100644 --- a/app.wxss +++ b/app.wxss @@ -25,9 +25,9 @@ page { .error .warning { display: block; - margin: 8px 0; + margin: 7px 0; color: #888; - font-size: 14px; + font-size: 12px; } .error{ color:red; diff --git a/data/client.js b/data/client.js index 24b4093..7124c71 100644 --- a/data/client.js +++ b/data/client.js @@ -1,4 +1,4 @@ -import {Account, Course, Exercise, ExerciseQuestion} from "./eduapi" +import {Account, Course, Exercise, ExerciseQuestion, Ui} from "./eduapi" import {Session} from "./requests"; import {Cookie} from "./cookie"; @@ -484,4 +484,25 @@ export class Client{ }) }); } + + get_home_page({success, fail, complete}={}){ + return new Promise((resolve, reject) => { + Ui.get_home_page({ + session: this.session, + complete: complete, + success: res=>{ + if(typeof success == "function"){ + success(res); + }; + resolve(res); + }, + fail: error=>{ + if(typeof success == "function"){ + fail(error); + } + reject(error); + } + }) + }) + } } \ No newline at end of file diff --git a/data/eduapi.js b/data/eduapi.js index 92971ea..a2bfa5a 100644 --- a/data/eduapi.js +++ b/data/eduapi.js @@ -90,8 +90,8 @@ export class Account{ complete: complete }) } - static get_user_courses({session,user,page=1, per_page=16, success, fail, complete}){ - let data = {page: page, per_page: per_page}; + static get_user_courses({session,user,category="",status="",sort_by="",sort_direction="",page=1, per_page=16, success, fail, complete}){ + let data = {page: page, per_page: per_page, category:category, status: status, sort_by: sort_by, sort_direction: sort_direction}; return session.request({ url: api_base_url + "/users/"+user +"/courses.json", method: "GET", @@ -365,7 +365,26 @@ export class ExerciseQuestion { } export class Ui{ - + static get_home_page({session, success, fail, complete}){ + return session.request({ + session: this.session, + url: api_base_url + "/home/index.json", + method: "GET", + success: res=> { + if ("status" in res.data) { + if (res.data.status < 0){ + fail(new Error(res.data.message)); + return; + } + } + if (typeof success == "function") { + success(res); + } + }, + fail:fail, + complete: complete + }) + } } diff --git a/images/tabbar-icon/tabbar_findmore_default.png b/images/tabbar-icon/tabbar_findmore_default.png new file mode 100644 index 0000000000000000000000000000000000000000..afc04e69b6c3db498325676427c6241c06964e3c GIT binary patch literal 1932 zcmV;72Xpv|P)$_u75|;P&Gw53uj$)+XREJ9O`}mtkct&4P;1+WZGurD`oRPw5HJuwpax77qXGPv z7>ODhrI9Zh1&yI9R;&1jQu@cDLTpGS`h=Zx-)s6*{LpQ8=a{qJd6~|e-I>{T8@b8k zz1_Lz-1EEl-1Bz{XKA$C?aM{vY7tolAp7VFFQyL>y+}kq?Q}Z7KO0NanJ{U$+gp+( z*$m)X05dgt%>wwoG3FPYPG@&b+QsR$0ZdO%zrq-EJrP|G;No!?&e0tfk)27B?3|yU z|4$vBl>tmoPrD%a4FFzWu*mZOegfbx0A@vG_T169>rrM0O#B%0DK|KfQW8B zTY~2W3qT&oeg8>j{^BqYLjgGF^pZZ9BfOTGe^6yt$DQMx`+!=f9Q_T3&-pCtgCb8iK(KRc0`OYce@0jth+ z&Pi_WrObTbG?mVNP*d4xG!*3<((jEit2>>}z#N|I(QdbAk|gE_e-5k|g=>L*0xcJKZD zI(HF(bM6mmY%|H-SAmx;TXun_5?i3C)^IH}HSZlWt(W8^t z{Z!zvdv6Z{yPTj4yq^=x9bZ;ETca5VCN|P0s zh;*k_=-1@=iHPO}djY89+QrP<%hrsd=pGTdQ|F1u4)6WV0|3rBO*qsp=-Qggx24-st=;uV_2^Bg?lD%_tb9=3|FA&ix70P>mU)h>roz$6in0XahYc~;5 zs(Z7{y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 --- a/pages/exercises/exercises.wxss +++ b/pages/exercises/exercises.wxss @@ -44,12 +44,12 @@ text.start-answer{ } .exercise{ background: white; - padding: 17rpx 14rpx; + padding: 15rpx 15rpx; margin: 14rpx 0rpx; border-radius: 12rpx; } .exercise-info{ - margin-top: 4rpx; + margin-top: 2rpx; align-items: center; } .exercise-tip{ diff --git a/pages/findmore/findmore.js b/pages/findmore/findmore.js new file mode 100644 index 0000000..7b33557 --- /dev/null +++ b/pages/findmore/findmore.js @@ -0,0 +1,76 @@ +const app = getApp(); + + +Page({ + + /** + * 页面的初始数据 + */ + data: { + base_url: "https://www.educoder.net", + page_info: {}, + page_status: 0 + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + app.client.get_home_page() + .then(res=>{ + console.info(res); + this.setData({page_info: res.data, page_status: 1}); + }).catch(error=>{ + this.setData({page_status: 2}); + }) + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + } +}) \ No newline at end of file diff --git a/pages/findmore/findmore.json b/pages/findmore/findmore.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/pages/findmore/findmore.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/findmore/findmore.wxml b/pages/findmore/findmore.wxml new file mode 100644 index 0000000..22563ad --- /dev/null +++ b/pages/findmore/findmore.wxml @@ -0,0 +1,47 @@ + + + + + + + + + + + 实训课程 + TRAINING COURSE + + + + + + + + + + {{subject.name}} + + + + + + + + 实训课程 + DEVELOPMENT COMMUNITY + + + + + + + + + + {{practice.name}} + + + + + + \ No newline at end of file diff --git a/pages/findmore/findmore.wxss b/pages/findmore/findmore.wxss new file mode 100644 index 0000000..6c0199a --- /dev/null +++ b/pages/findmore/findmore.wxss @@ -0,0 +1,65 @@ +view.swiper-images{ + margin: 0 -12px; +} +swiper.swiper-images{ + height: 220rpx; +} + +image.swiper-image{ + width: 100%; +} + +.title{ + margin-top: 2px; + text-align: center; +} + +.title .hint{ + font-size: 8px; + margin: 5px 0; +} + +.subjects{ + margin: 0 -8px; +} + +.grid-view{ + display: -webkit-flex; + display: flex; + align-items: center; + justify-content: space-between; + flex-wrap: wrap; + width: 100%; +} + +.grid-item{ + flex: 0 0 auto; + width: 50%; +} + +.item{ + overflow: hidden; + border-radius: 12rpx; + box-shadow: 1px 1px 8px #909090; + margin: 12rpx 10rpx 16rpx 10rpx; +} +.item:hover{ + box-shadow: 2px 2px 14px #707070; + margin: 8rpx 10rpx 20rpx 10rpx; +} +.item image{ + width: 100%; +} +.item .detail{ + padding: 2rpx 16rpx 14rpx 16rpx; +} + +text.name{ + display: block; + overflow: hidden; + font-size: 10px; + text-overflow: ellipsis; + white-space: nowrap; +} + +/**动画*/ diff --git a/pages/login/login.js b/pages/login/login.js index 99c1dfc..73ea655 100644 --- a/pages/login/login.js +++ b/pages/login/login.js @@ -68,6 +68,12 @@ Page({ }else{ this.load_input(); } + if(options.password){ + this.setData({password: options.password}); + } + if(options.autologin==1){ + this.login(); + } }, /** diff --git a/pages/login/login.wxml b/pages/login/login.wxml index ca7c852..9599937 100644 --- a/pages/login/login.wxml +++ b/pages/login/login.wxml @@ -27,5 +27,5 @@ 注册 - 忘记密码 + 忘记密码 diff --git a/pages/reset_password/reset_password.js b/pages/reset_password/reset_password.js index ad3a5af..a01fb73 100644 --- a/pages/reset_password/reset_password.js +++ b/pages/reset_password/reset_password.js @@ -6,9 +6,36 @@ Page({ * 页面的初始数据 */ data: { + autologin: true, login: "", countDownNum: 0 }, + save_input: function () { + wx.setStorage({ + key: 'login', + data: this.data.login, + }) + }, + login: function ({login, password}) { + app.client.login({ + login: login, password: password, autologin: 1, + success: res => { + this.save_input(); + wx.navigateBack({ + delta: 1 + }); + app.logining = false; + console.log("login_successful!!!!"); + }, + fail(error) { + console.error(error); + wx.showToast({ + title: error.toString(), + icon: "none" + }) + } + }) + }, reset_password: function ({ detail: { value } }) { console.log("reset_password"); console.info(value); @@ -17,8 +44,14 @@ Page({ wx.showToast({ title: "重置成功", }); + let url = '/pages/login/login?login=' + this.data.login; + if (this.data.autologin) { + this.login({login: value.login, password: value.new_password}); + return; + //url = url + "&password=" + value.new_password + "&autologin=" + "1"; + } wx.redirectTo({ - url: '/pages/login/login?login='+this.data.login, + url: url, }); }).catch(error => { console.error(error); @@ -28,6 +61,10 @@ Page({ }) }); }, + updateAutologin: function(event){ + console.info(event); + this.setData({autologin: !this.data.autologin}) + }, updateLogin: function ({ detail: { value } }) { this.setData({ login: value }); }, @@ -65,7 +102,9 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + if(options.login){ + this.setData({login: options.login}); + } }, /** diff --git a/pages/reset_password/reset_password.wxml b/pages/reset_password/reset_password.wxml index 1f3d7aa..b36e570 100644 --- a/pages/reset_password/reset_password.wxml +++ b/pages/reset_password/reset_password.wxml @@ -33,6 +33,7 @@ + 重置后自动登陆 diff --git a/utils/pathutils.js b/utils/pathutils.js new file mode 100644 index 0000000..0993d0d --- /dev/null +++ b/utils/pathutils.js @@ -0,0 +1,3 @@ +/** + * analyse url path to get info in order to navigate to the right page + */ \ No newline at end of file