123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- const app = getApp()
- Page({
- data: {
- team_id: '',
- id: '',
- // 用户信息
- user: {},
- list: [],
- total: 0,
- page: 0,
- skip: 0,
- limit: 10,
- statusList: []
- },
- // 上传比分
- async toUpload(e) {
- const that = this;
- let item = e.currentTarget.dataset.item
- wx.navigateTo({ url: '/pagesMy/score/index?id=' + item._id + '&team_id=' + that.data.team_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: 10 })
- that.setData({ total: 0 })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- async onLoad(options) {
- const that = this;
- that.setData({ id: options.id, team_id: options.team_id });
- },
- /**
- * 生命周期函数--监听页面显示
- */
- 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: 'course_status', is_use: '0' })
- if (res.errcode == '0') that.setData({ statusList: res.data })
- // 查分数
- res = await app.$api('course/ranking', 'GET', { match_id: that.data.id })
- },
- // 查询通知
- async search() {
- const that = this;
- let info = { skip: that.data.skip, limit: that.data.limit };
- info.match_id = that.data.id
- let res;
- if (that.data.team_id) {
- info.team_id = that.data.team_id
- res = await app.$api('course/only', 'GET', { ...info })
- } else res = await app.$api('course', 'GET', { ...info })
- 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() {
- }
- })
|