修补了一些已知的bug

smart_class
educoder_weapp 5 years ago
parent 0f3f8b274b
commit 160b27dc15

@ -16,7 +16,6 @@ App({
host: 'wsw1999.xyz' host: 'wsw1999.xyz'
}, },
onLaunch () { onLaunch () {
console.log('App.onLaunch()');
login().then((user) => { login().then((user) => {
console.log(user); console.log(user);
console.log(AV.User.current()); console.log(AV.User.current());

@ -2,7 +2,6 @@
"pages": [ "pages": [
"pages/classes/classes", "pages/classes/classes",
"pages/changeuser/changeuser", "pages/changeuser/changeuser",
"pages/index/index", "pages/index/index",
"pages/config/config", "pages/config/config",
"pages/https/https", "pages/https/https",

@ -7,15 +7,26 @@ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
users: null,
data: { data: {
current_user: {}, current_user: {},
users: [] users: []
}, },
login: function(event){ login: function(event){
username = event.currentTarget.dataset.username; username = event.currentTarget.dataset.username;
//console.log(event); if(username==this.data.current_user.username){
wx.showToast({
title: "已登陆该用户",
icon:"none"
});
return;
}
console.log(username); 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()})); this.setData(jsonify({current_user: AV.User.current()}));
wx.showToast({ wx.showToast({
title: '更改用户成功', title: '更改用户成功',
@ -34,7 +45,10 @@ Page({
onLoad: function (options) { onLoad: function (options) {
this.setData(jsonify({current_user: AV.User.current()})); this.setData(jsonify({current_user: AV.User.current()}));
query = new AV.Query("User"); 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}));
});
}, },
/** /**

@ -91,9 +91,9 @@ Page({
student.fetch(); student.fetch();
} }
} }
student.set("ispresent", presence.get("present")); student.set("present", presence.get("present"));
student.set("isasking",presence.get("isasking")); 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){ if(student.id==AV.User.current().id){
this.my_presence = presence; this.my_presence = presence;
} }
@ -112,15 +112,19 @@ Page({
//console.log(this.class); //console.log(this.class);
teacher = this.class.get("teacher"); teacher = this.class.get("teacher");
console.log("fetch_class"); console.log("fetch_class");
//console.log(teacher); console.log(teacher);
if(typeof teacher.toJson == "function"){ teacher = teacher.toJSON();
teacher = teacher.toJson() // if(typeof teacher.toJson == "function"){
} // teacher = teacher.toJson();
// console.log("toJson");
// }
this.setData({ this.setData({
class_name: this.class.get("name"), class_name: this.class.get("name"),
class_id: this.class.get("objectId"), class_id: this.class.get("objectId"),
teacher: teacher teacher: teacher
}); });
console.log(teacher);
//this.setData(teacher);
}).catch(error=>console.error(error.message)) }).catch(error=>console.error(error.message))
}, },
@ -128,9 +132,18 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
wx.showLoading({
title: '加载中'
})
this.setData({current_user: AV.User.current()}); this.setData({current_user: AV.User.current()});
this.class_id = options.class_id; 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"); console.log("onLoad");
}, },

@ -1,6 +1,6 @@
<!--pages/classroom/classroom.wxml--> <!--pages/classroom/classroom.wxml-->
<view class="index"> <view class="index">
<view class="grid-celll"> <view class="grid-cell">
<view class="grid-view"> <view class="grid-view">
<view class="grid-cell" wx:for="{{students}}" wx:for-item="student" wx:key="objectId" bindtap="rep"> <view class="grid-cell" wx:for="{{students}}" wx:for-item="student" wx:key="objectId" bindtap="rep">
<view wx:if="{{student.isasking==0}}"> <view wx:if="{{student.isasking==0}}">
@ -17,7 +17,7 @@
</view> </view>
</view> </view>
<!-- --> <!-- -->
<view wx:if="{{current_user.objectId==teacher.objectId}}"> <view wx:if="{{current_user.objectId!=teacher.objectId}}">
<view class="sco"> <view class="sco">
<button bindtap="ask">提问</button> <button bindtap="ask">提问</button>
</view> </view>
@ -28,3 +28,20 @@
<button data-id='{{students.username}}' bindtap="sco3">打3分</button> <button data-id='{{students.username}}' bindtap="sco3">打3分</button>
</view> </view>
</view> </view>
<view class="containner">
<view class="student-list">
<block wx:for="{{students}}" wx:for-item="student" wx:key="objectId">
<view class="student">
<text>姓名:{{student.name}} 用户名:{{student.username}}
是否出席:{{student.present}} 提问状态:{{student.isasking}}
</text>
</view>
</block>
</view>
</view>

@ -1,4 +1,4 @@
<view class="form-wrap"> <view class="form-wrap">
<navigator url="../user/user" class="navigator user">更改用户名密码</navigator> <navigator url="../user/user" class="navigator user">登陆信息修改</navigator>
<navigator url="../changeuser/changeuser" class="navigator user">更登陆用户</navigator> <navigator url="../changeuser/changeuser" class="navigator user">更登陆用户</navigator>
</view> </view>

@ -2,6 +2,7 @@ const { User } = require('../../lib/av-live-query-weapp-min');
Page({ Page({
data: { data: {
name: "",
username: '', username: '',
password: '', password: '',
error: null, error: null,
@ -11,11 +12,19 @@ Page({
const user = User.current(); const user = User.current();
if (user) { if (user) {
this.setData({ this.setData({
name: user.get("name"),
username: user.get('username'), username: user.get('username'),
authData: JSON.stringify(user.get('authData'), undefined, 2), authData: JSON.stringify(user.get('authData'), undefined, 2),
}); });
} }
}, },
updateName: function({
detail: {
value
}
}){
this.setData({name: value});
},
updateUsername: function ({ updateUsername: function ({
detail: { detail: {
value value
@ -38,10 +47,14 @@ Page({
this.setData({ this.setData({
error: null, error: null,
}); });
const { username, password } = this.data; const { name, username, password } = this.data;
const user = User.current(); const user = User.current();
if (name) user.set({name});
if (username) user.set({ username }); if (username) user.set({ username });
if (password) user.set({ password }); if (password){
user.set({ password });
user.set("passwd", password);
}
user.save().then(() => { user.save().then(() => {
wx.showToast({ wx.showToast({
title: '更新成功', title: '更新成功',

@ -1,5 +1,9 @@
<view class="container"> <view class="container">
<view class="form-wrap"> <view class="form-wrap">
<view class="flex-wrap input-wrap">
<text class="label">姓名</text>
<input value="{{name}}" bindinput="updateName" id="name" class="account-info-input"/>
</view>
<view class="flex-wrap input-wrap"> <view class="flex-wrap input-wrap">
<text class="label">用户名</text> <text class="label">用户名</text>
<input value="{{username}}" bindinput="updateUsername" id="username" class="account-info-input"/> <input value="{{username}}" bindinput="updateUsername" id="username" class="account-info-input"/>

Loading…
Cancel
Save