diff --git a/app.js b/app.js index d325da7..8fe40c3 100644 --- a/app.js +++ b/app.js @@ -16,7 +16,6 @@ App({ host: 'wsw1999.xyz' }, onLaunch () { - console.log('App.onLaunch()'); login().then((user) => { console.log(user); console.log(AV.User.current()); diff --git a/app.json b/app.json index c887095..6f2a219 100644 --- a/app.json +++ b/app.json @@ -2,7 +2,6 @@ "pages": [ "pages/classes/classes", "pages/changeuser/changeuser", - "pages/index/index", "pages/config/config", "pages/https/https", diff --git a/pages/changeuser/changeuser.js b/pages/changeuser/changeuser.js index b0e0998..0325ad7 100644 --- a/pages/changeuser/changeuser.js +++ b/pages/changeuser/changeuser.js @@ -7,15 +7,26 @@ Page({ /** * 页面的初始数据 */ + users: null, data: { current_user: {}, users: [] }, login: function(event){ username = event.currentTarget.dataset.username; - //console.log(event); + if(username==this.data.current_user.username){ + wx.showToast({ + title: "已登陆该用户", + icon:"none" + }); + return; + } console.log(username); - AV.User.logIn(username, "123456").then((user)=>{ + user = this.users.filter(user=>user.get("username")==username)[0]; + passwd = user.get("passwd")?user.get("passwd"):"123456"; + console.log(user.get("passwd")); + console.log("passwd"); + AV.User.logIn(username, passwd).then((user)=>{ this.setData(jsonify({current_user: AV.User.current()})); wx.showToast({ title: '更改用户成功', @@ -34,7 +45,10 @@ Page({ onLoad: function (options) { this.setData(jsonify({current_user: AV.User.current()})); query = new AV.Query("User"); - return query.find().then((users)=>{this.setData(jsonify({users}))}); + return query.find().then((users)=>{ + this.users = users; + this.setData(jsonify({users})); + }); }, /** diff --git a/pages/classroom/classroom.js b/pages/classroom/classroom.js index 0e1a0bb..5e62951 100644 --- a/pages/classroom/classroom.js +++ b/pages/classroom/classroom.js @@ -91,9 +91,9 @@ Page({ student.fetch(); } } - student.set("ispresent", presence.get("present")); + student.set("present", presence.get("present")); student.set("isasking",presence.get("isasking")); - student.set("mark", presence.get("mark")) + student.set("mark", presence.get("mark")); if(student.id==AV.User.current().id){ this.my_presence = presence; } @@ -112,15 +112,19 @@ Page({ //console.log(this.class); teacher = this.class.get("teacher"); console.log("fetch_class"); - //console.log(teacher); - if(typeof teacher.toJson == "function"){ - teacher = teacher.toJson() - } + console.log(teacher); + teacher = teacher.toJSON(); + // if(typeof teacher.toJson == "function"){ + // teacher = teacher.toJson(); + // console.log("toJson"); + // } this.setData({ class_name: this.class.get("name"), class_id: this.class.get("objectId"), teacher: teacher }); + console.log(teacher); + //this.setData(teacher); }).catch(error=>console.error(error.message)) }, @@ -128,9 +132,18 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad: function (options) { + wx.showLoading({ + title: '加载中' + }) this.setData({current_user: AV.User.current()}); this.class_id = options.class_id; - this.fetch_class.bind(this)(this.class_id).then(this.pull_presence.bind(this)).then((presences)=>{this.origin_presences=presences, this.my_presence.enter()}); + this.fetch_class.bind(this)(this.class_id) + .then(()=>{ + this.pull_presence.bind(this)(); + wx.hideLoading(); + console.log(this.data); + }) + .then(this.my_presence.enter); console.log("onLoad"); }, diff --git a/pages/classroom/classroom.wxml b/pages/classroom/classroom.wxml index 64e8bbe..7d592b0 100644 --- a/pages/classroom/classroom.wxml +++ b/pages/classroom/classroom.wxml @@ -1,6 +1,6 @@ - + @@ -17,7 +17,7 @@ - + @@ -28,3 +28,20 @@ + + + + + + + + + + + 姓名:{{student.name}} 用户名:{{student.username}} + 是否出席:{{student.present}} 提问状态:{{student.isasking}} + + + + + diff --git a/pages/setting/setting.wxml b/pages/setting/setting.wxml index 635d729..ea2bee9 100644 --- a/pages/setting/setting.wxml +++ b/pages/setting/setting.wxml @@ -1,4 +1,4 @@ - 更改用户名密码 - 更改登陆用户 + 登陆信息修改 + 更换登陆用户 \ No newline at end of file diff --git a/pages/user/user.js b/pages/user/user.js index a20b059..c15d380 100644 --- a/pages/user/user.js +++ b/pages/user/user.js @@ -2,6 +2,7 @@ const { User } = require('../../lib/av-live-query-weapp-min'); Page({ data: { + name: "", username: '', password: '', error: null, @@ -11,11 +12,19 @@ Page({ const user = User.current(); if (user) { this.setData({ + name: user.get("name"), username: user.get('username'), authData: JSON.stringify(user.get('authData'), undefined, 2), }); } }, + updateName: function({ + detail: { + value + } + }){ + this.setData({name: value}); + }, updateUsername: function ({ detail: { value @@ -38,10 +47,14 @@ Page({ this.setData({ error: null, }); - const { username, password } = this.data; + const { name, username, password } = this.data; const user = User.current(); + if (name) user.set({name}); if (username) user.set({ username }); - if (password) user.set({ password }); + if (password){ + user.set({ password }); + user.set("passwd", password); + } user.save().then(() => { wx.showToast({ title: '更新成功', diff --git a/pages/user/user.wxml b/pages/user/user.wxml index df6fc39..e2d6617 100644 --- a/pages/user/user.wxml +++ b/pages/user/user.wxml @@ -1,5 +1,9 @@ + + 姓名 + + 用户名 diff --git a/utils.js b/utils.js deleted file mode 100644 index e69de29..0000000