完成发现页面UI,改进重置密码操作

smart_class
educoder_weapp 5 years ago
parent 48a110907e
commit 928ab131a8

@ -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": "课程列表",

@ -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;

@ -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);
}
})
})
}
}

@ -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
})
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

@ -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{

@ -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 () {
}
})

@ -0,0 +1,3 @@
{
"usingComponents": {}
}

@ -0,0 +1,47 @@
<view class="container">
<view class="swiper-images">
<swiper class="swiper-images" indicator-dots="1" autoplay="1">
<swiper-item class="swiper-image" wx:for="{{page_info.images_url}}" wx:for-item="image">
<image class="swiper-image" mode="widthFix" src="{{base_url+image.image_url}}"></image>
</swiper-item>
</swiper>
</view>
<view class="subjects">
<view class="title">
<text>实训课程</text>
<text class="hint">TRAINING COURSE</text>
</view>
<view class="loading">
<!---->
</view>
<view class="grid-view">
<view class="grid-item" wx:for="{{page_info.subjects}}" wx:for-item="subject">
<view class="item">
<image src="{{base_url+'/'+subject.image_url}}" mode="widthFix"></image>
<view class="detail">
<text class="name">{{subject.name}}</text>
</view>
</view>
</view>
</view>
</view>
<view class="pratices">
<view class="title">
<text>实训课程</text>
<text class="hint">DEVELOPMENT COMMUNITY</text>
</view>
<view class="loading" wx:if="{{page_status==0}}">
<!---->
</view>
<view class="grid-view">
<view class="grid-item" wx:for="{{page_info.shixuns}}" wx:for-item="practice">
<view class="item">
<image src="{{base_url+'/'+practice.pic}}" mode="widthFix"></image>
<view class="detail">
<text class="name">{{practice.name}}</text>
</view>
</view>
</view>
</view>
</view>
</view>

@ -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;
}
/**动画*/

@ -68,6 +68,12 @@ Page({
}else{
this.load_input();
}
if(options.password){
this.setData({password: options.password});
}
if(options.autologin==1){
this.login();
}
},
/**

@ -27,5 +27,5 @@
<button class="login-submit" type="primary" bindtap="login" bindlongpress="login_test">登陆</button>
</view>
<navigator class="tappable register" url="../register/register" open-type="redirect">注册</navigator>
<navigator class="tappable reset_password" url="../reset_password/reset_password" open-type="redirect">忘记密码</navigator>
<navigator class="tappable reset_password" url="../reset_password/reset_password?login={{login}}" open-type="redirect">忘记密码</navigator>
</view>

@ -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});
}
},
/**

@ -33,6 +33,7 @@
</input>
<button class="code" bindtap="send_code" disabled="{{countDownNum}}">{{countDownNum?countDownNum+'秒后重试':'获取验证码'}}</button>
</view>
<checkbox checked="{{autologin}}" bindtap="updateAutologin">重置后自动登陆</checkbox>
<button class="submit" type="primary" form-type="submit">重置密码</button>
</form>
<navigator class="tappable login" url="../login/login" open-type="redirect">返回登陆</navigator>

@ -0,0 +1,3 @@
/**
* analyse url path to get info in order to navigate to the right page
*/
Loading…
Cancel
Save