|
@@ -6,12 +6,11 @@ Page({
|
|
|
*/
|
|
|
data: {
|
|
|
frameStyle: { useTop: true, name: '学员信息', leftArrow: true, useBar: false },
|
|
|
- list: [
|
|
|
- { _id: '1', icon: [{ url: '/image/beijing.jpeg' }], name: "测试姓名", card: '220581200003302462', phone: '12345678901', age: '18', gender: '0' },
|
|
|
- { _id: '2', icon: [{ url: '/image/beijing.jpeg' }], name: "测试姓名", card: '220581200003302462', phone: '12345678901', age: '18', gender: '1' },
|
|
|
- { _id: '1', icon: [{ url: '/image/beijing.jpeg' }], name: "测试姓名", card: '220581200003302462', phone: '12345678901', age: '18', gender: '0' },
|
|
|
- { _id: '2', icon: [{ url: '/image/beijing.jpeg' }], name: "测试姓名", card: '220581200003302462', phone: '12345678901', age: '18', gender: '1' }
|
|
|
- ],
|
|
|
+ list: [],
|
|
|
+ total: 0,
|
|
|
+ page: 0,
|
|
|
+ skip: 0,
|
|
|
+ limit: 5,
|
|
|
},
|
|
|
// 返回
|
|
|
back: function () {
|
|
@@ -19,6 +18,8 @@ Page({
|
|
|
},
|
|
|
//添加或修改
|
|
|
toCommon: function (e) {
|
|
|
+ const that = this;
|
|
|
+ that.setData({ skip: 0, page: 0, list: [] })
|
|
|
const { route, id } = e.currentTarget.dataset;
|
|
|
if (id) wx.navigateTo({ url: `/pages/sstudent/${route}?id=${id}` })
|
|
|
else wx.navigateTo({ url: `/pages/sstudent/${route}` })
|
|
@@ -32,9 +33,10 @@ Page({
|
|
|
content: '是否确认删除该条数据?',
|
|
|
async success(res) {
|
|
|
if (res.confirm) {
|
|
|
- const arr = await app.$delete(`/newCourt/api/student/${id}`);
|
|
|
+ const arr = await app.$delete(`/student/${id}`);
|
|
|
if (arr.errcode == '0') {
|
|
|
wx.showToast({ title: `删除信息成功`, icon: 'success', duration: 2000 })
|
|
|
+ that.setData({ skip: 0, page: 0, list: [] })
|
|
|
that.watchLogin()
|
|
|
} else {
|
|
|
wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
|
|
@@ -43,19 +45,41 @@ Page({
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+ // 分页
|
|
|
+ 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 }) }
|
|
|
+ },
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
- const that = this;
|
|
|
- that.watchLogin();
|
|
|
+
|
|
|
},
|
|
|
// 监听用户是否登录
|
|
|
watchLogin: async function () {
|
|
|
const that = this;
|
|
|
wx.getStorage({
|
|
|
key: 'user',
|
|
|
- success: async res => { },
|
|
|
+ success: async res => {
|
|
|
+ let info = { skip: that.data.skip, limit: that.data.limit };
|
|
|
+ let arr;
|
|
|
+ arr = await app.$get(`/student`, { ...info });
|
|
|
+ if (arr.errcode == '0') {
|
|
|
+ that.setData({ list: [...that.data.list, ...arr.data] })
|
|
|
+ that.setData({ total: arr.total })
|
|
|
+ } else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }) }
|
|
|
+ },
|
|
|
fail: async res => {
|
|
|
wx.redirectTo({ url: '/pages/index/index' })
|
|
|
}
|
|
@@ -73,7 +97,8 @@ Page({
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
onShow: function () {
|
|
|
-
|
|
|
+ const that = this;
|
|
|
+ that.watchLogin();
|
|
|
},
|
|
|
|
|
|
/**
|