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 0000000..afc04e6 Binary files /dev/null and b/images/tabbar-icon/tabbar_findmore_default.png differ diff --git a/images/tabbar-icon/tabbar_findmore_pressed.png b/images/tabbar-icon/tabbar_findmore_pressed.png new file mode 100644 index 0000000..7807bb8 Binary files /dev/null and b/images/tabbar-icon/tabbar_findmore_pressed.png differ diff --git a/pages/exercises/exercises.wxss b/pages/exercises/exercises.wxss index d930af1..3837931 100644 --- 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