|
@@ -1,66 +1,129 @@
|
|
|
-// pagesSchool/common/lessonstudent.js
|
|
|
+const app = getApp();
|
|
|
Page({
|
|
|
-
|
|
|
/**
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
-
|
|
|
+ frameStyle: { useTop: true, name: '学员信息', leftArrow: true, useBar: false },
|
|
|
+ id: '',
|
|
|
+ // 查询
|
|
|
+ search: {},
|
|
|
+ list: [],
|
|
|
+ total: 0,
|
|
|
+ skip: 0,
|
|
|
+ limit: 6,
|
|
|
+ page: 0,
|
|
|
+ },
|
|
|
+ // 跳转菜单
|
|
|
+ back(e) {
|
|
|
+ wx.navigateBack({ delta: 1 })
|
|
|
+ },
|
|
|
+ // 查询
|
|
|
+ toInput(e) {
|
|
|
+ const that = this;
|
|
|
+ let value = e.detail.value;
|
|
|
+ if (value) that.setData({ 'search.student_id_name': value })
|
|
|
+ else that.setData({ search: {} })
|
|
|
+ that.clearPage(); that.watchLogin();
|
|
|
+ },
|
|
|
+ // 清空列表
|
|
|
+ clearPage() {
|
|
|
+ const that = this;
|
|
|
+ that.setData({ list: [], skip: 0, limit: 6, page: 0 })
|
|
|
+ },
|
|
|
+ // 签到
|
|
|
+ toSign(e) {
|
|
|
+ const that = this;
|
|
|
+ let { item } = e.currentTarget.dataset;
|
|
|
+ console.log(item);
|
|
|
},
|
|
|
-
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
- onLoad(options) {
|
|
|
-
|
|
|
+ onLoad: async function (options) {
|
|
|
+ const that = this;
|
|
|
+ await that.setData({ id: options.id || '' })
|
|
|
+ // 监听用户是否登录
|
|
|
+ await that.watchLogin();
|
|
|
+ },
|
|
|
+ watchLogin: async function () {
|
|
|
+ const that = this;
|
|
|
+ wx.getStorage({
|
|
|
+ key: 'user',
|
|
|
+ success: async res => {
|
|
|
+ let info = { skip: that.data.skip, limit: that.data.limit, lesson_id: that.data.id };
|
|
|
+ const arr = await app.$get(`/lessonStudent`, { ...info, ...that.data.search });
|
|
|
+ if (arr.errcode == '0') {
|
|
|
+ let list = [...that.data.list, ...arr.data];
|
|
|
+ that.setData({ list });
|
|
|
+ that.setData({ total: arr.total })
|
|
|
+ }
|
|
|
+ else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }); }
|
|
|
+ },
|
|
|
+ fail: async res => {
|
|
|
+ wx.redirectTo({ url: '/pages/index/index' })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 分页
|
|
|
+ toPage: function () {
|
|
|
+ const that = this;
|
|
|
+ let list = that.data.list;
|
|
|
+ let limit = that.data.limit;
|
|
|
+ if (that.data.total > list.length) {
|
|
|
+ wx.showLoading({ title: '加载中', mask: true })
|
|
|
+ let page = that.data.page + 1;
|
|
|
+ that.setData({ page: page })
|
|
|
+ let skip = page * limit;
|
|
|
+ that.setData({ skip: skip })
|
|
|
+ that.watchLogin();
|
|
|
+ wx.hideLoading()
|
|
|
+ } else { wx.showToast({ title: '没有更多数据了', icon: 'none', duration: 2000 }) }
|
|
|
},
|
|
|
-
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|
|
|
- onReady() {
|
|
|
+ onReady: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
- onShow() {
|
|
|
-
|
|
|
- },
|
|
|
+ onShow: async function () { },
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
*/
|
|
|
- onHide() {
|
|
|
+ onHide: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
*/
|
|
|
- onUnload() {
|
|
|
+ onUnload: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
*/
|
|
|
- onPullDownRefresh() {
|
|
|
+ onPullDownRefresh: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
*/
|
|
|
- onReachBottom() {
|
|
|
+ onReachBottom: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 用户点击右上角分享
|
|
|
*/
|
|
|
- onShareAppMessage() {
|
|
|
+ onShareAppMessage: function () {
|
|
|
|
|
|
}
|
|
|
})
|