|
@@ -5,12 +5,41 @@ Page({
|
|
*/
|
|
*/
|
|
data: {
|
|
data: {
|
|
frameStyle: { useTop: true, name: '羽校信息', leftArrow: true, useBar: false },
|
|
frameStyle: { useTop: true, name: '羽校信息', leftArrow: true, useBar: false },
|
|
|
|
+ user: {},
|
|
|
|
+ // 查询
|
|
|
|
+ search: {},
|
|
|
|
+ list: [],
|
|
|
|
+ total: 0,
|
|
|
|
+ skip: 0,
|
|
|
|
+ limit: 6,
|
|
|
|
+ page: 0,
|
|
},
|
|
},
|
|
// 跳转菜单
|
|
// 跳转菜单
|
|
back(e) {
|
|
back(e) {
|
|
wx.navigateBack({ delta: 1 })
|
|
wx.navigateBack({ delta: 1 })
|
|
},
|
|
},
|
|
-
|
|
|
|
|
|
+ // 查询
|
|
|
|
+ toInput(e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ let value = e.detail.value;
|
|
|
|
+ if (value) that.setData({ 'search.name': value })
|
|
|
|
+ else that.setData({ search: {} })
|
|
|
|
+ that.clearPage(); that.watchLogin();
|
|
|
|
+ },
|
|
|
|
+ // 清空列表
|
|
|
|
+ clearPage() {
|
|
|
|
+ const that = this;
|
|
|
|
+ that.setData({ list: [], skip: 0, limit: 6, page: 0 })
|
|
|
|
+ },
|
|
|
|
+ // 详细信息
|
|
|
|
+ toView: function (e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ const { item } = e.currentTarget.dataset;
|
|
|
|
+ that.clearPage()
|
|
|
|
+ wx.navigateTo({
|
|
|
|
+ url: `/pagesSchool/school/info?id=${item.school_id}`,
|
|
|
|
+ })
|
|
|
|
+ },
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
*/
|
|
@@ -27,9 +56,49 @@ Page({
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
*/
|
|
- onShow: function () {
|
|
|
|
|
|
+ onShow: async function () {
|
|
const that = this;
|
|
const that = this;
|
|
-
|
|
|
|
|
|
+ // 监听用户是否登录
|
|
|
|
+ await that.watchLogin();
|
|
|
|
+ },
|
|
|
|
+ watchLogin: async function () {
|
|
|
|
+ const that = this;
|
|
|
|
+ wx.getStorage({
|
|
|
|
+ key: 'user',
|
|
|
|
+ success: async res => {
|
|
|
|
+ that.setData({ user: res.data });
|
|
|
|
+ that.search()
|
|
|
|
+ },
|
|
|
|
+ fail: async res => {
|
|
|
|
+ wx.redirectTo({ url: '/pages/index/index' })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ async search() {
|
|
|
|
+ const that = this;
|
|
|
|
+ let user = that.data.user;
|
|
|
|
+ let info = { skip: that.data.skip, limit: that.data.limit, student_id: user.info.id };
|
|
|
|
+ let arr = await app.$get(`/rss`, { ...info });
|
|
|
|
+ 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' }) }
|
|
|
|
+ },
|
|
|
|
+ // 分页
|
|
|
|
+ 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.search();
|
|
|
|
+ wx.hideLoading()
|
|
|
|
+ } else { wx.showToast({ title: '没有更多数据了', icon: 'none', duration: 2000 }) }
|
|
},
|
|
},
|
|
|
|
|
|
|
|
|