123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- const app = getApp()
- Page({
- data: {
- // 用户信息
- user: {},
- searchInfo: {},
- list: [],
- total: 0,
- page: 0,
- skip: 0,
- limit: 5,
- statusList: []
- },
- // 查询
- async toSearch(e) {
- const that = this;
- if (e.detail.value) that.setData({ 'searchInfo.name': e.detail.value })
- else that.setData({ searchInfo: {} })
- that.clearPage();
- that.search()
- },
- // 添加团队
- toAdd() {
- wx.navigateTo({ url: `/pagesMy/teamCreate/index` })
- },
- // 查看
- toView(e) {
- const that = this;
- if (that.data.user.name) {
- let item = e.currentTarget.dataset.item
- wx.navigateTo({ url: '/pagesTeam/apply/index?id=' + item._id })
- } else {
- wx.showToast({ title: `请维护基础信息`, icon: 'none' });
- }
- },
- // 审核
- toExam(e) {
- let item = e.currentTarget.dataset.item
- wx.navigateTo({ url: '/pagesMy/apply/index?id=' + item._id })
- },
- // 修改
- toEdit(e) {
- let item = e.currentTarget.dataset.item
- wx.navigateTo({ url: '/pagesMy/teamCreate/index?id=' + item._id })
- },
- // 分页-触底
- toLower() {
- 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 })
- let skip = page * limit
- that.setData({ skip })
- that.search()
- wx.hideLoading()
- } else {
- wx.showToast({ title: `到底了没数据了`, icon: 'none' });
- }
- },
- // 分页-滚动
- toScroll() {
- // console.log('滚动');
- },
- // 字典
- getDict(value, model) {
- const that = this;
- if (model == 'status') {
- if (value) {
- let data = that.data.statusList.find(i => i.value == value)
- if (data) return data.label
- else return '暂无'
- }
- }
- },
- // 清空列表
- clearPage() {
- const that = this;
- that.setData({ list: [] })
- that.setData({ skip: 0 })
- that.setData({ limit: 5 })
- that.setData({ total: 0 })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- async onLoad(options) {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- async onShow() {
- const that = this;
- wx.showLoading({ title: '加载中', mask: true })
- await that.searchUser()
- await that.searchOther()
- await that.clearPage()
- await that.search()
- wx.hideLoading()
- },
- async searchUser() {
- const that = this;
- wx.getStorage({
- key: 'user',
- async success(res) {
- that.setData({ user: res.data })
- },
- fail(err) {
- // console.log(err);
- }
- })
- },
- // 查询其他信息
- async searchOther() {
- const that = this;
- let res;
- res = await app.$api('dictData', 'GET', { type: 'status', is_use: '0' })
- if (res.errcode == '0') that.setData({ statusList: res.data })
- },
- // 查询通知
- async search() {
- const that = this;
- let info = { skip: that.data.skip, limit: that.data.limit };
- if (that.data.user.type == '1') info.administrator = that.data.user._id
- else info.user = that.data.user._id
- let res = await app.$api('team', 'GET', { ...info, ...that.data.searchInfo })
- if (res.errcode == '0') {
- let list = [...that.data.list, ...res.data]
- for (const val of list) {
- val.status_name = that.getDict(val.status, 'status')
- }
- that.setData({ list })
- that.setData({ total: res.total })
- }
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|