增加注册、找回密码功能,完成创建课堂的界面UI

smart_class
educoder_weapp 5 years ago
parent 8695a98f7c
commit 48a110907e

5
.gitignore vendored

@ -9,11 +9,12 @@ $RECYCLE.BIN/
.Spotlight-V100
.TemporaryItems
.Trashes
project.config.json
app.js
lib_refer
towxml
project.config.json
.idea
api_docs
# Node.js
node_modules/

@ -1,3 +1,10 @@
# 简介
educoder微信小程序帮助使用[educoder平台](https://www.educoder.net)的应用方便在手机上使用。利用educoder网站的API搭建
## 小程序码
![小程序码](./images/weapp_code.png)
# 功能介绍
## 教室

@ -1,7 +1,7 @@
{
"pages": [
"pages/my_courses/my_courses",
"pages/course_setting/course_setting",
"pages/exercises/exercises",
"pages/courses/courses",
"pages/exercise/exercise",
@ -10,15 +10,14 @@
"pages/about/about",
"pages/login/login",
"pages/test/test",
"pages/course_detail/course_detail",
"pages/course/course",
"pages/files/files",
"pages/course_setting/course_setting",
"pages/mark_detail/mark_detail"
"pages/mark_detail/mark_detail",
"pages/reset_password/reset_password"
],
"window": {
"backgroundTextStyle": "dark",
"navigationBarTitleText": "积分教室",
"navigationBarTitleText": "EduCoder",
"navigationBarTextStyle": "black",
"backgroundColor": "#f2f2f2",
"navigationBarBackgroundColor": "#fbfbfb"

@ -7,9 +7,14 @@ page {
flex-direction: row;
}
.form-wrap {
border-top: 1px solid #eee;
border-top: 1px solid #bbb;
margin: 12px 0;
}
.tappable{
color: #1aad19;
padding: 0 12px;
}
.tappable:hover {
opacity: .6;
}

@ -136,6 +136,30 @@ export class Client{
});
});
}
reset_password({login, code, new_password, new_password_confirmation, success, fail, complete}){
return new Promise((resolve, reject) => {
Account.reset_password({
session: this.session,
login: login,
code: code,
new_password: new_password,
new_password_confirmation: new_password_confirmation,
complete: complete,
success: res=>{
if(typeof success == "function"){
success(res);
}
resolve(res);
},
fail: error=>{
if(typeof fail == "function"){
fail(error);
}
reject(error);
}
})
})
}
get_user_info({success, fail, complete}={}){
return new Promise((resolve, reject) => {
Account.get_user_info({session: this.session, complete: complete,
@ -160,10 +184,46 @@ export class Client{
});
}
get_verification_code_for_register({login, success, fail, complete}){
return Account.get_verification_code({session: this.session, login: login, type: 1,
fail: fail, complete: complete, success: success});
return new Promise((resolve, reject) => {
Account.get_verification_code({
session: this.session, login: login, type: 1,
complete: complete,
success: res => {
if (typeof success == "function") {
success(res);
}
resolve(res);
},
fail: error => {
if (typeof fail == "function") {
fail(error);
}
reject(error);
}
});
})
}
get_verification_code_for_reset_password({login, success, fail, complete}){
return new Promise((resolve, reject) => {
Account.get_verification_code({
session: this.session, login: login, type: 2,
complete: complete,
success: res => {
if (typeof success == "function") {
success(res);
}
resolve(res);
},
fail: error => {
if (typeof fail == "function") {
fail(error);
}
reject(error);
}
});
})
}
get_verification_code_for_reset_password({}){}
search_courses({limit=20, page=1, order="all", search="", success, fail, complete}={}){
return new Promise((resolve, reject) => {
@ -228,6 +288,27 @@ export class Client{
});
});
}
create_course({data, success, fail, complete}){
return new Promise((resolve,reject)=>{
Course.create({
session: this.session,
data: data,
complete: complete,
success: res => {
if (typeof success == "function") {
success(res);
}
resolve(res);
},
fail: error => {
if (typeof fail == "function") {
fail(error);
}
reject(error);
}
})
});
}
join_course({invite_code, professor=null,assistant_professor=null,student=null, success, fail, complete}){
return new Promise((resolve, reject)=>{
Course.join({session: this.session, invite_code: invite_code, professor: professor, assistant_professor: assistant_professor, student: student, complete: complete,

@ -3,70 +3,68 @@ const api_base_url = "https://www.educoder.net/api";
* https://www.educoder.net的api接口通过其实现用户与后端进行交互
*/
export class Account{
static login({session, login, password, autologin, success, fail, complete}) {
console.log("login");
let data = {login: login, password: password, autologin: autologin};
session.request({
url: api_base_url + "/accounts/login.json",
method: "POST",
data: data,
header: {"content-type": "application/json"},
success: (res)=>{
if("status" in res.data && res.data.status<0){
fail(new Error(res.data.message));
return;
}
console.log("type of success:"+ typeof success);
if(typeof success == "function") {
success(res);
}
},
fail: fail,
complete: complete
});
}
static get_user_info({session, success, fail, complete}){
let data = {school: 1}
session.request({
url: api_base_url + "/users/get_user_info.json",
method: "GET",
data: data,
success: success,
fail: fail,
complete: complete
})
}
static get_verification_code({session, login, type, success, fail, complete}){
let data = {login: login, type: type};
//@notice type: 验证码用途 type=1=> 注册 type=2 => 重置密码
session.request({
url: api_base_url + "/accounts/get_verification_code.json",
method: "GET",
data: data,
success: success,
fail: fail,
complete: complete
})
}
static register({session, login, password, code, success, fail, complete}){
let data = {login: login, password: password, code: code};
session.request({
url: api_base_url + "/accounts/register.json",
method: "POST",
data:data,
success(res) {
if("status" in res.data && res.data.status<0){
fail(new Error(res.data.message));
return;
}
success(res);
},
fail: fail,
complete: complete
})
}
static attendance({session, success, fail, complete}){
session.request({
static register({session, login, password, code, success, fail, complete}){
let data = {login: login, password: password, code: code};
session.request({
url: api_base_url + "/accounts/register.json",
method: "POST",
data:data,
success(res) {
if("status" in res.data && res.data.status<0){
fail(new Error(res.data.message));
return;
}
success(res);
},
fail: fail,
complete: complete
})
}
static login({session, login, password, autologin, success, fail, complete}) {
console.log("login");
let data = {login: login, password: password, autologin: autologin};
session.request({
url: api_base_url + "/accounts/login.json",
method: "POST",
data: data,
header: {"content-type": "application/json"},
success: (res)=>{
if("status" in res.data && res.data.status<0){
fail(new Error(res.data.message));
return;
}
console.log("type of success:"+ typeof success);
if(typeof success == "function") {
success(res);
}
},
fail: fail,
complete: complete
});
}
static logout({session, success, fail, complete}){
session.request({
url: api_base_url + "/accounts/logout.json",
method: "GET",
success: success,
fail: fail,
complete: complete
})
}
static get_verification_code({session, login, type, success, fail, complete}){
let data = {login: login, type: type};
//@notice type: 验证码用途 type=1=> 注册 type=2 => 重置密码
session.request({
url: api_base_url + "/accounts/get_verification_code.json",
method: "GET",
data: data,
success: success,
fail: fail,
complete: complete
})
}
static attendance({session, success, fail, complete}){
session.request({
url: api_base_url + "/users/attendance.json",
success(res) {
if("status" in res.data && res.data.status<0){
@ -81,156 +79,177 @@ export class Account{
complete: complete
})
}
static logout({session, success, fail, complete}){
session.request({
url: api_base_url + "/accounts/logout.json",
method: "GET",
success: success,
fail: fail,
complete: complete
})
}
static get_user_courses({session,user,page=1, per_page=16, success, fail, complete}){
let data = {page: page, per_page: per_page};
return session.request({
url: api_base_url + "/users/"+user +"/courses.json",
method: "GET",
data: data,
success: success,
fail: fail,
complete: complete
})
}
static get_user_info({session, success, fail, complete}){
let data = {school: 1}
session.request({
url: api_base_url + "/users/get_user_info.json",
method: "GET",
data: data,
success: success,
fail: fail,
complete: complete
})
}
static get_user_courses({session,user,page=1, per_page=16, success, fail, complete}){
let data = {page: page, per_page: per_page};
return session.request({
url: api_base_url + "/users/"+user +"/courses.json",
method: "GET",
data: data,
success: success,
fail: fail,
complete: complete
})
}
static reset_password({session, login, code, new_password, new_password_confirmation, success, fail, complete}){
let data ={
login: login,
code: code,
new_password: new_password,
new_password_confirmation: new_password_confirmation
};
return session.request({
url: api_base_url + "/accounts/reset_password.json",
method: "POST",
data: data,
success(res) {
if("status" in res.data && res.data.status<0){
fail(new Error(res.data.message));
return;
}
success(res);
},
fail: fail,
complete: complete
})
}
static set_password({}){
}
}
export class Course{
static create({session, data, success, fail, complete}){
static create({session, data, success, fail, complete}){
return session.request({
url: api_base_url + "/courses.json",
method: "POST",
data: data,
success: res => {
if ("status" in res.data && res.data.status < 0) {
fail(new Error(res.data.message));
return;
}
if (typeof success == "function") {
success(res);
}
},
fail: fail,
complete: complete
})
}
static setting({session, course_id, data, success, fail, complete}){
return session.request({
}
static search({session, limit=20, page=1, order="all", search="", success, fail, complete}){
let data = {limit: limit, page: page, order: order, search: search};
return session.request({
url: api_base_url + "/courses.json",
method: "GET",
})
}
static search({session, limit=20, page=1, order="all", search="", success, fail, complete}){
let data = {limit: limit, page: page, order: order, search: search};
return session.request({
url: api_base_url + "/courses.json",
method: "GET",
data: data,
success: success,
fail: fail,
complete: complete
})
}
static join({session, invite_code, professor=null,assistant_professor=null,student=null, success, fail, complete}){
let data = {
invite_code: invite_code,
professor: professor,
assistant_professor: assistant_professor,
student: student
};
return session.request({
url: api_base_url + "/courses/apply_to_join_course.json",
method:"POST",
data: data,
success: success,
fail: fail,
complete: complete
})
}
static join({session, invite_code, professor=null,assistant_professor=null,student=null, success, fail, complete}){
let data = {
invite_code: invite_code,
professor: professor,
assistant_professor: assistant_professor,
student: student
};
return session.request({
url: api_base_url + "/courses/apply_to_join_course.json",
method:"POST",
data: data,
success: res=>{
if("status" in res.data && res.data.status<0){
fail(new Error(res.data.message));
return;
success: res=>{
if("status" in res.data && res.data.status<0){
fail(new Error(res.data.message));
return;
}
if(typeof success == "function"){
success(res);
}
if(typeof success == "function"){
success(res);
},
fail: fail,
complete: complete
})
}
static get_user_info({session, course_id, success, fail, complete}){
let data = {course_id: course_id, school: 1}
return session.request({
url: api_base_url + "/users/get_user_info.json",
method: "GET",
data: data,
success: success,
fail: fail,
complete: complete
})
}
static get_files({session, course_id, page_size=15, page=1,search="",sort=0, sort_type="created_on", success, fail, complete}){
let data = {course_id: course_id, page_size: page_size, page: page, search: search, sort: sort, sort_type: sort_type};
return session.request({
url: api_base_url + "/files.json",
method: "GET",
data: data,
success: success,
fail: fail,
complete: complete
})
}
static get_students({session, course_id, order=1,sort="asc",page=1, limit=20, course_group_id="", success, fail, complete}){
let data = {
order: order,
sort: sort,
page: page,
limit: limit,
course_group_id: course_group_id
};
return session.request({
url: api_base_url + "/courses/" + course_id + "/students.json",
method: "GET",
data: data,
success(res){
if("status" in res.data && "message" in res.data){
fail(new Error(res.data.message));
return;
}
success(res);
},
fail: fail,
complete: complete
})
}
static get_user_info({session, course_id, success, fail, complete}){
let data = {course_id: course_id, school: 1}
return session.request({
url: api_base_url + "/users/get_user_info.json",
method: "GET",
data: data,
success: success,
fail: fail,
complete: complete
})
}
static get_files({session, course_id, page_size=15, page=1,search="",sort=0, sort_type="created_on", success, fail, complete}){
let data = {course_id: course_id, page_size: page_size, page: page, search: search, sort: sort, sort_type: sort_type};
return session.request({
url: api_base_url + "/files.json",
method: "GET",
data: data,
success: success,
fail: fail,
complete: complete
})
}
static get_students({session, course_id, order=1,sort="asc",page=1, limit=20, course_group_id="", success, fail, complete}){
let data = {
order: order,
sort: sort,
page: page,
limit: limit,
course_group_id: course_group_id
};
return session.request({
url: api_base_url + "/courses/" + course_id + "/students.json",
method: "GET",
data: data,
success(res){
if("status" in res.data && "message" in res.data){
fail(new Error(res.data.message));
return;
}
success(res);
},
fail: fail,
complete: complete
})
}
static get_course_info({session, course_id, success, fail, complete}){
session.request({
url: api_base_url + "/courses/"+course_id+"/top_banner.json",
method : "GET",
success: success,
fail: fail,
complete: complete
})
}
fail: fail,
complete: complete
})
}
static get_course_info({session, course_id, success, fail, complete}){
session.request({
url: api_base_url + "/courses/"+course_id+"/top_banner.json",
method : "GET",
success: success,
fail: fail,
complete: complete
})
}
}
export class Exercise{
static search({session,course_id, page=1, limit=15, success, fail, complete}){
let data = {page:page, limit:limit};
static search({session,course_id, page=1, limit=15, success, fail, complete}){
let data = {page:page, limit:limit};
return session.request({
url: api_base_url + "/courses/"+course_id+"/exercises.json",
method: "GET",
data: data,
success(res) {
if ("status" in res.data ) {
if (res.data.status < 0){
fail(new Error(res.data.message));
return;
}
switch(res.data.status){
case 409:
fail(new Error(res.data.message));
return;
}
}
if (typeof success == "function") {
success(res);
}
},
fail:fail,
complete: complete
})
}
static start_answer({session, exercise_id, login, success, fail, complete}){
let data = {login: login};
return session.request({
url: api_base_url + "/exercises/" + exercise_id + "/start_answer.json",
method: "GET",
data: data,
url: api_base_url + "/courses/"+course_id+"/exercises.json",
method: "GET",
data: data,
success(res) {
if ("status" in res.data ) {
if (res.data.status < 0){
@ -247,11 +266,37 @@ export class Exercise{
success(res);
}
},
fail: fail,
complete: complete
})
}
static save({session, exercise_id, success, fail, complete}){
fail:fail,
complete: complete
})
}
static start_answer({session, exercise_id, login, success, fail, complete}){
let data = {login: login};
return session.request({
url: api_base_url + "/exercises/" + exercise_id + "/start_answer.json",
method: "GET",
data: data,
success(res) {
if ("status" in res.data ) {
if (res.data.status < 0){
fail(new Error(res.data.message));
return;
}
switch(res.data.status){
case 409:
fail(new Error(res.data.message));
return;
}
}
if (typeof success == "function") {
success(res);
}
},
fail: fail,
complete: complete
})
}
static save({session, exercise_id, success, fail, complete}){
return session.request({
url: api_base_url + "/exercises/"+exercise_id+"/begin_commit.json",
method: "GET",
@ -262,7 +307,7 @@ export class Exercise{
}
static commit({session, exercise_id, commit_method=1, success, fail, complete}){
let data = {commit_method: commit_method};
return session.request({
return session.request({
url: api_base_url+ "/exercises/"+exercise_id+"/commit_exercise.json",
method: "POST",
data: data,
@ -274,49 +319,49 @@ export class Exercise{
}
export class ExerciseQuestion {
static answer({session, question_id, exercise_choice_id, answer_text, success, fail, complete}){
let data = {};
if(exercise_choice_id){data["exercise_choice_id"] = exercise_choice_id;}
if(answer_text){data["answer_text"] = answer_text}
return session.request({
url: api_base_url + "/exercise_questions/" + question_id +"/exercise_answers.json",
method: "POST",
data: data,
success: res=>{
if("status" in res.data){
if(res.data.status<0){
fail(new Error(res.data.message));
return;
}
/*switch (res.data.status) {
case -1:
fail(new Error("???"));
return;
}*/
}
if(typeof success == "function") {
success(res);
}
},
fail: error=>{
// console.error("wx.request error:");
// console.log(error);
// console.log(error.toString());
// console.log(error.message);
// console.log(error.errMsg);
let e = error;
if(!("message" in error)){
if("errMsg" in error){
e = new Error(error.errMsg);
}
}
if(typeof fail == "function") {
fail(e);
}
},
complete: complete
})
}
static answer({session, question_id, exercise_choice_id, answer_text, success, fail, complete}){
let data = {};
if(exercise_choice_id){data["exercise_choice_id"] = exercise_choice_id;}
if(answer_text){data["answer_text"] = answer_text}
return session.request({
url: api_base_url + "/exercise_questions/" + question_id +"/exercise_answers.json",
method: "POST",
data: data,
success: res=>{
if("status" in res.data){
if(res.data.status<0){
fail(new Error(res.data.message));
return;
}
/*switch (res.data.status) {
case -1:
fail(new Error("???"));
return;
}*/
}
if(typeof success == "function") {
success(res);
}
},
fail: error=>{
// console.error("wx.request error:");
// console.log(error);
// console.log(error.toString());
// console.log(error.message);
// console.log(error.errMsg);
let e = error;
if(!("message" in error)){
if("errMsg" in error){
e = new Error(error.errMsg);
}
}
if(typeof fail == "function") {
fail(e);
}
},
complete: complete
})
}
}
export class Ui{

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

@ -12,7 +12,7 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({"course.id": options.id})
this.setData({"course.id": options.course_id})
if(options.course_name && options.course_name!="undefined"){
wx.setNavigationBarTitle({
title: options.course_name

@ -1,5 +1,7 @@
<view class="nav-list">
<view class="container">
<view class="nav-list">
<navigator url="../classroom/classroom?id={{course.id}}" class="nav">进入教室</navigator>
<navigator url="../exercises/exercises?id={{course.id}}" class="nav">试卷</navigator>
<navigator url="../files/files?id={{course.id}}" class="nav">资源</navigator>
</view>
</view>
</view>

@ -1,18 +1,70 @@
// pages/course_setting/course_setting.js
import { getNowFormatDate } from "../../utils/dateutils";
const app = getApp();
Page({
/**
* 页面的初始数据
*/
initial_form_data: {
//course_module_types
shixun_homework: true,
common_homework: true,
group_homework: true,
exercise: true,
attachment: true,
course_group: true,
//course_module_types
end_date: "",
school: ""
},
data: {
current_date: getNowFormatDate(),
form_data: {}
},
reset: function () {
this.setData({ form_data: this.initial_form_data });
},
create_course: function ({ detail: { value } }) {
console.info(value);
if (this.intent == "create") {
app.client.create_course({
data: value,
success: res => {
console.info("create course")
console.info(res);
wx.navigateTo({
url:"/pages/course/course?course_id="+res.course_id
})
wx.showToast({
title: "创建成功",
duration: 5000
});
},
fail: error => {
wx.showToast({
title: error.toString(),
icon: "none"
})
}
})
}
},
updateCourseListName({ detail: { value } }) {
this.setData({ "form_data.name": value });
},
updateEndDate({ detail: { value } }) {
console.log(value);
this.setData({ "form_data.end_date": value });
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.intent = options.intent;
if (this.intent == "create") this.reset();
console.log(options);
console.log(this.intent);
},

@ -1,23 +1,11 @@
<view class="container">
<!--"course_list_name":"数据结构",
"name":"数据结构",
"class_period":"30",
"credit":3,
"end_date":"2020-10-31",
"is_public":0,
"course_module_types":[
"shixun_homework",
"common_homework",
"group_homework",
"exercise",
"attachment",
"course_group"],
"school":"国防科技大学"-->
<form class="course-setting">
<form class="course-setting" bindsubmit="create_course">
<view class="form-item form-wrap">
<text class="hint form-item">课程名称</text>
<input class="form-item"
placeholder="示例:大学数学"
bindinput="updateCourseListName"
value="{{form_data.course_list_name}}"
name="course_list_name"
></input>
</view>
@ -25,13 +13,15 @@
<text class="hint form-item">课堂名称</text>
<input class="form-item"
placeholder="示例大学数学2019春季A1班"
name="class_period">
</input>
value="{{form_data.name}}"
name="name">
</input>
</view>
<view class="form-item form-wrap">
<text class="hint form-item">总学时</text>
<input class="form-item"
name="class_period"
value="{{form_data.class_period}}"
type="number">
</input>
</view>
@ -39,47 +29,53 @@
<text class="hint form-item">学分</text>
<input class="form-item"
name="credit"
value="{{form_data.credit}}"
type="digit">
</input>
</view>
<view class="form-item form-wrap">
<text class="hint form-item">结束时间</text>
<picker class="form-item"
name="end_date"
mode="date"
bindchange="updateEndDate"
value="{{form_data.end_date}}"
start="{{current_date}}">{{form_data.end_date||"请选择结束时间"}}
</picker>
</view>
<view class="form-item form-wrap">
<text class="hint form-item">课堂模块</text>
<checkbox-group name="course_module_types" class="form-item">
<checkbox value="announcement" checked="{{form_data.announcement}}">公告栏</checkbox>
<checkbox value="shixun_homework" checked="{{form_data.shixun_homework}}">实训作业</checkbox>
<checkbox value="common_homework" checked="{{form_data.common_homework}}">普通作业</checkbox>
<checkbox value="group_homework" checked="{{form_data.group_homework}}">分组作业</checkbox>
<checkbox value="graduation" checked="{{form_data.graduation}}">毕业设计</checkbox>
<checkbox value="exercise" checked="{{form_data.exercise}}">试卷</checkbox>
<checkbox value="pool" checked="{{form_data.pool}}">问卷</checkbox>
<checkbox value="attachment" checked="{{form_data.attachment}}">资源</checkbox>
<checkbox value="board" checked="{{form_data.board}}">讨论</checkbox>
<checkbox value="course_group" checked="{{form_data.course_group}}">分班</checkbox>
<checkbox value="statistics" checked="{{form_data.statistics}}">统计</checkbox>
</checkbox-group>
</view>
<view class="form-item form-wrap">
<text class="hint form-item">加入课堂条件</text>
<checkbox name="authentication">已实名认证</checkbox>
<checkbox name="professional_certification">已职业认证</checkbox>
</view>
<view class="form-item form-wrap">
<text class="hint form-item">公开设置</text>
<checkbox name="is_public">公开课堂</checkbox>
</view>
<view class="form-item form-wrap">
<text class="hint form-item">课堂所属单位</text>
<input class="form-item"
name="school"
bindinput="updateSchool"
value="{{form_data.school}}">
</input>
</view>
<button class="submit" form-type="submit">提交</button>
</form>
</view>
<!--
课程名称
正确示例:数据结构
错误示例数据结构2019春
课堂名称
0/60
正确示例数据结构2019春季班级
错误示例2019春季班级数据结构
总学时
0/5
学分
0/5
结束时间
课堂模块
公告栏
实训作业
普通作业
分组作业
毕业设计
试卷
问卷
资源
讨论
分班
统计
加入课堂条件
已实名认证
已职业认证 (勾选,则通过邀请码加入课堂的用户,需要完成相关认证才能加入课堂)
公开设置
公开课堂
(选中后本课堂对所有用户可见,否则仅本课堂成员可见)
课堂所属单位
-->
</view>

@ -1 +1,10 @@
/* pages/course_setting/course_setting.wxss */
input.form-item{
border: 1rpx solid gray;
border-radius: 8rpx;
padding: 12rpx 18rpx;
}
.form-wrap{
margin: 24rpx -12rpx;
padding: 2rpx 10rpx;
}

@ -3,9 +3,9 @@
<block wx:for="{{exercise_questions}}" wx:for-item="question" wx:key="question_id">
<view class="question">
<text class="hint">第{{question.q_position}}题</text>
<rich-text class="question-title" nodes="{{question.question_title}}" sapce="nbsp"></rich-text>
<rich-text class="question-title" nodes="{{question.question_title}}" space="nbsp"></rich-text>
<view wx:if="{{question.question_type==0 || question.question_type==2}}">
<radio-group class="choices" bindchange="answer_choice_question" data-question_id="{{question.question_id}}">
<radio-group class="choices" bindchange="answer_choice_question" data-question_id="{{question.question_id}}">
<radio disabled="{{exercise.user_exercise_status==1 || exercise.user_exercise_status==4}}" class="choice" wx:for="{{question.question_choices}}" wx:for-item="choice" wx:key="choice_id" checked="{{choice.user_answer_boolean}}" value="{{choice.choice_id}}">
<text class="choice-text">{{choice.choice_text}}</text>
<text wx:if="{{choice.standard_boolean}}" class="error standard-choice">正确答案</text>

@ -28,7 +28,7 @@
}
.question-title{
display: block;
display: inline-block;
margin: 5rpx 0rpx 12rpx 0rpx;
}
@ -40,7 +40,8 @@
margin-bottom: 12rpx;
}
.choice-text{
margin-left: 10rpx;
display: inline-block;
width: 600rpx;
}
.main-input{
@ -68,4 +69,4 @@ input.null-input{
standard-null-input{
align-items: center;
}
}

@ -9,7 +9,11 @@ Page({
data: {
error: "",
login: "",
password: ""
password: "",
password_focus: false
},
password_focus: function(){
this.setData({password_focus: true});
},
save_input:function(){
wx.setStorage({
@ -59,7 +63,11 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.load_input();
if(options.login){
this.setData({login: options.login})
}else{
this.load_input();
}
},
/**

@ -1,4 +1,4 @@
{
"navigationBarTitleText": "登陆educoder",
"navigationBarTitleText": "登陆",
"usingComponents": {}
}

@ -4,25 +4,28 @@
</view>
<view class="form-wrap">
<view class="input-wrap">
<input class="login-input"
<input focus class="login-input"
bindinput="update_login"
value="{{login}}"
confirm-type="next"
bindconfirm="password_focus"
confirm-hold="{{true}}"
placeholder="用户名、邮箱、手机号">
</input>
</view>
<text class="error" wx:if="{{!error}}">{{error}}</text>
<view class="input-wrap">
<input password
<input focus="{{password_focus}}" password
class="login-input"
placeholder="密码"
confirm-type="done"
value="{{password}}"
bindinput="update_password"
bindconfirm="login">
</input>
</view>
<button class="login-submit" type="primary" bindtap="login" bindlongpress="login_test">登陆</button>
</view>
<button class="login-submit" type="primary" bindtap="login" bindlongpress="login_test">
登陆
</button>
<button hidden="{{true}}" class="login-submit" type="primary" bindtap="login_test">登陆测试账号</button>
<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>
</view>

@ -31,4 +31,12 @@
}
textarea {
width: 100%;
}
.register{
position: fixed;
right: 36rpx;
}
.reset_password{
position: fixed;
left: 36rpx;
}

@ -51,7 +51,7 @@ Page({
title: res.data.message
})
wx.navigateTo({
url: "../course_detail/course_detail?course_id=" + res.data.course_id
url: "../course/course?course_id=" + res.data.course_id
});
this.cancel_join_course_modal();
})
@ -69,7 +69,7 @@ Page({
console.log(event);
let {id, course_name} = event.currentTarget.dataset;
wx.navigateTo({
url: "../course_detail/course_detail?id="+id+"&course_name="+course_name,
url: "../course/course?course_id="+id+"&course_name="+course_name,
})
},

@ -1,13 +1,64 @@
// pages/register/register.js
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
login:"",
countDownNum: 0
},
register: function({detail:{value}}){
console.log("register");
console.info(value);
app.client.register(value).then(res=>{
wx.showToast({
title: res.message,
});
wx.navigateBack({
delta: 1
})
}).catch(error=>{
wx.showToast({
title: error.toString(),
icon: "none"
})
});
},
updateLogin: function({detail:{value}}) {
this.setData({login: value});
},
send_code: function(){
if (!this.data.login) return;
this.countDown();
app.client.get_verification_code_for_register({
login: this.data.login,
success:res=>{
wx.showToast({
title: "发送成功"
})
}
}).catch(console.error);
},
countDown: function () {
let that = this;
let countDownNum = 30;
that.setData({
countDownNum: countDownNum
});
that.setData({
timer: setInterval(function () {
countDownNum--;
that.setData({
countDownNum: countDownNum
})
if (countDownNum == 0) {
clearInterval(that.data.timer);
}
}, 1000)
})
},
/**
* 生命周期函数--监听页面加载
*/

@ -1,3 +1,4 @@
{
"usingComponents": {}
"usingComponents": {},
"navigationBarTitleText": "注册"
}

@ -1 +1,32 @@
<view class="container">
<view class="logo-view">
<image class="logo" src="../../images/educoder.png" mode="aspectFit"></image>
</view>
<form class="form-wrap" bindsubmit="register">
<view class="input-wrap">
<input focus class="form-input"
name="login"
bindinput="updateLogin"
value="{{login}}"
placeholder="邮箱或手机号">
</input>
</view>
<view class="input-wrap code">
<input class="code form-input"
name="code"
placeholder="验证码"
confirm-hold="{{true}}">
</input>
<button class="code" bindtap="send_code" disabled="{{countDownNum}}">{{countDownNum?countDownNum+'秒后重试':'获取验证码'}}</button>
</view>
<view class="input-wrap">
<input password
name="password"
class="form-input"
placeholder="输入8-16位密码">
</input>
</view>
<button class="submit" type="primary" form-type="submit">注册</button>
</form>
<navigator class="tappable login" url="../login/login" open-type="redirect">返回登陆</navigator>
</view>

@ -1 +1,46 @@
/* pages/register/register.wxss */
.logo-view{
display: flex;
flex-direction: column;
}
.logo{
align-self: center;
width: 160rpx;
height: 160rpx;
margin-top: 40rpx;
}
.input-wrap {
background: #fff;
border-bottom: 1px solid #eee;
margin: 0 -12px;
padding: 0 12px;
height: 46px;
line-height: 46px;
}
.label {
color: #999;
width: 4.5em;
}
.form-input {
font-size: 18px;
line-height: 100%;
height: 100%;
width: 100%;
}
input.code{
width: 60%;
}
view.code{
display: flex;
flex-direction: row;
}
button.code{
display: block;
}
.submit{
margin: 24rpx 36rpx;
}
.login{
position: fixed;
right: 36rpx;
}

@ -0,0 +1,119 @@
// pages/register/register.js
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
login: "",
countDownNum: 0
},
reset_password: function ({ detail: { value } }) {
console.log("reset_password");
console.info(value);
app.client.reset_password(value).then(res => {
console.info(res);
wx.showToast({
title: "重置成功",
});
wx.redirectTo({
url: '/pages/login/login?login='+this.data.login,
});
}).catch(error => {
console.error(error);
wx.showToast({
title: error.toString(),
icon: "none"
})
});
},
updateLogin: function ({ detail: { value } }) {
this.setData({ login: value });
},
send_code: function () {
if(!this.data.login)return;
this.countDown();
app.client.get_verification_code_for_reset_password({
login: this.data.login,
success: res => {
wx.showToast({
title: "发送成功"
})
}
}).catch(console.error);
},
countDown: function () {
let that = this;
let countDownNum = 30;
that.setData({
countDownNum: countDownNum
});
that.setData({
timer: setInterval(function () {
countDownNum--;
that.setData({
countDownNum: countDownNum
})
if (countDownNum == 0) {
clearInterval(that.data.timer);
}
}, 1000)
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})

@ -0,0 +1,4 @@
{
"usingComponents": {},
"navigationBarTitleText": "找回密码"
}

@ -0,0 +1,39 @@
<view class="container">
<view class="logo-view">
<image class="logo" src="../../images/educoder.png" mode="aspectFit"></image>
</view>
<form class="form-wrap" bindsubmit="reset_password">
<view class="input-wrap">
<input focus class="form-input"
name="login"
bindinput="updateLogin"
value="{{login}}"
placeholder="邮箱或手机号">
</input>
</view>
<view class="input-wrap">
<input password
name="new_password"
class="form-input"
placeholder="输入8-16位新密码">
</input>
</view>
<view class="input-wrap">
<input password
name="new_password_confirmation"
class="form-input"
placeholder="再次输入新密码">
</input>
</view>
<view class="input-wrap code">
<input class="code form-input"
name="code"
placeholder="验证码"
confirm-hold="{{true}}">
</input>
<button class="code" bindtap="send_code" disabled="{{countDownNum}}">{{countDownNum?countDownNum+'秒后重试':'获取验证码'}}</button>
</view>
<button class="submit" type="primary" form-type="submit">重置密码</button>
</form>
<navigator class="tappable login" url="../login/login" open-type="redirect">返回登陆</navigator>
</view>

@ -0,0 +1,46 @@
.logo-view{
display: flex;
flex-direction: column;
}
.logo{
align-self: center;
width: 160rpx;
height: 160rpx;
margin-top: 40rpx;
}
.input-wrap {
background: #fff;
border-bottom: 1px solid #eee;
margin: 0 -12px;
padding: 0 12px;
height: 46px;
line-height: 46px;
}
.label {
color: #999;
width: 4.5em;
}
.form-input {
font-size: 18px;
line-height: 100%;
height: 100%;
width: 100%;
}
input.code{
width: 60%;
}
view.code{
display: flex;
flex-direction: row;
}
button.code{
display: block;
}
.submit{
margin: 24rpx 36rpx;
}
.login{
position: fixed;
right: 36rpx;
}

@ -52,7 +52,7 @@ Page({
title: res.data.message
})
wx.navigateTo({
url: "../course_detail/course_detail?course_id="+res.data.course_id
url: "../course/course?course_id="+res.data.course_id
});
this.cancel_join_course_modal();
})

@ -0,0 +1,15 @@
export function getNowFormatDate() {
var date = new Date();
var seperator1 = "-";
var year = date.getFullYear();
var month = date.getMonth() + 1;
var strDate = date.getDate();
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = "0" + strDate;
}
var currentdate = year + seperator1 + month + seperator1 + strDate;
return currentdate;
}
Loading…
Cancel
Save