list.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. const app = getApp()
  2. import { race_status } from "../../utils/dict";
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. frameStyle: { useTop: true, name: '淘汰赛管理', leftArrow: true, useBar: false },
  9. list: [{ match_time: '2022-08-06-08:00', match_name: '辽源市第一届青少年羽毛球公开赛暨“小虎杯”羽毛球争霸赛', grouping_name: '小组赛', project_name: '小组赛', ground_name: '场地一', status: 1, score_one: 16, player_one_name: '张三', player_two_name: '李四', is_change: 0 },
  10. { match_time: '2022-08-06-08:00', match_name: '辽源市第一届青少年羽毛球公开赛暨“小虎杯”羽毛球争霸赛', grouping_name: '小组赛', project_name: '小组赛', ground_name: '场地一', status: 1, score_one: 16, player_one_name: '张三三-张三三', player_two_name: '李四四-李四四', is_change: 0 },
  11. ],
  12. total: 0,
  13. page: 0,
  14. skip: 0,
  15. limit: 5,
  16. dialog: { title: '详细信息', show: false, type: '1' },
  17. form: {},
  18. statusList: race_status,
  19. },
  20. // 跳转菜单
  21. back(e) {
  22. wx.navigateBack({ delta: 1 })
  23. },
  24. // 查看
  25. toView: async function (e) {
  26. const that = this;
  27. const { item } = e.currentTarget.dataset;
  28. // const arr = await app.$get(`/newCourt/api/eliminateRace/${item._id}`);
  29. // if (arr.errcode == '0') {
  30. // if (arr.data.winner) {
  31. // const user = await app.$get(`/newCourt/api/user/${arr.data.winner}`);
  32. // if (user.errcode == '0' && user.data) { arr.data.winner_name = user.data.name; }
  33. // else {
  34. // const team = await app.$get(`/newCourt/api/teamApply/${arr.data.winner}`);
  35. // if (team.errcode == '0' && team.data) { arr.data.winner_name = team.data.applyuser_name + '-' + team.data.teammate_name; }
  36. // }
  37. // }
  38. // that.setData({ form: arr.data });
  39. that.setData({ form: item })
  40. that.setData({ dialog: { title: '详细信息', show: true, type: '1' } })
  41. // }
  42. },
  43. // 更换场地
  44. toChange: async function (e) {
  45. const that = this;
  46. const { item } = e.currentTarget.dataset;
  47. wx.showModal({
  48. title: '提示',
  49. content: '您是否确定要更换场地吗?',
  50. async success(res) {
  51. if (res.confirm) {
  52. // const arr = await app.$post(`/newCourt/api/eliminateRace/${item._id}`, { is_change: '1' });
  53. // if (arr.errcode == '0') {
  54. // wx.showToast({ title: `更换场地完成`, icon: 'error', duration: 2000 })
  55. // that.watchLogin()
  56. // } else {
  57. // wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
  58. // }
  59. }
  60. }
  61. })
  62. },
  63. // 赛事管理
  64. toScore: async function (e) {
  65. const that = this;
  66. const { item } = e.currentTarget.dataset;
  67. // const arr = await app.$get(`/newCourt/api/eliminateRace/${item._id}`);
  68. // if (arr.errcode == '0') { that.setData({ form: arr.data }) }
  69. that.setData({ form: item })
  70. that.setData({ dialog: { title: '赛事管理', show: true, type: '2' } });
  71. },
  72. // 选择比赛状态
  73. statusChange: function (e) {
  74. const that = this;
  75. let data = that.data.statusList[e.detail.value];
  76. if (data) { that.setData({ 'form.status': data.value }) }
  77. },
  78. // 提交保存
  79. onSubmit: async function (e) {
  80. const that = this;
  81. const params = e.detail.value;
  82. // const arr = await app.$post(`/newCourt/api/eliminateRace/${params._id}`, params);
  83. // if (arr.errcode == '0') {
  84. // wx.showToast({ title: `信息维护成功`, icon: 'error', duration: 2000 })
  85. // that.toClose()
  86. // } else {
  87. // wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
  88. // }
  89. },
  90. // 关闭弹框
  91. toClose: function () {
  92. const that = this;
  93. that.setData({ dialog: { title: '详细信息', show: false, type: '1' } })
  94. },
  95. // 分页
  96. toPage: function () {
  97. const that = this;
  98. let list = that.data.list;
  99. let limit = that.data.limit;
  100. if (that.data.total > list.length) {
  101. wx.showLoading({ title: '加载中', mask: true })
  102. let page = that.data.page + 1;
  103. that.setData({ page: page })
  104. let skip = page * limit;
  105. that.setData({ skip: skip })
  106. that.watchLogin();
  107. wx.hideLoading()
  108. } else { wx.showToast({ title: '没有更多数据了', icon: 'none', duration: 2000 }) }
  109. },
  110. /**
  111. * 生命周期函数--监听页面加载
  112. */
  113. onLoad: function (options) {
  114. const that = this;
  115. },
  116. /**
  117. * 生命周期函数--监听页面初次渲染完成
  118. */
  119. onReady: function () {
  120. },
  121. /**
  122. * 生命周期函数--监听页面显示
  123. */
  124. onShow: function () {
  125. const that = this;
  126. that.watchLogin()
  127. },
  128. watchLogin: function () {
  129. const that = this;
  130. let searchInfo = that.data.searchInfo;
  131. wx.getStorage({
  132. key: 'user',
  133. success: async (res) => {
  134. let info = { skip: that.data.skip, limit: that.data.limit, referee_id: res.data.openid, status: '2' };
  135. // if (searchInfo && searchInfo.name) info.name = searchInfo.name;
  136. // const arr = await app.$get(`/newCourt/api/eliminateRace`, { ...info });
  137. // if (arr.errcode == '0') {
  138. // that.setData({ list: [...that.data.list, ...arr.data] });
  139. // that.setData({ total: arr.total })
  140. // } else { wx.showToast({ title: `${res.errMsg}`, icon: 'fail', duration: 2000 }); }
  141. },
  142. fail: async (res) => {
  143. wx.redirectTo({ url: '/pages/index/index' });
  144. },
  145. });
  146. },
  147. /**
  148. * 生命周期函数--监听页面隐藏
  149. */
  150. onHide: function () {
  151. },
  152. /**
  153. * 生命周期函数--监听页面卸载
  154. */
  155. onUnload: function () {
  156. },
  157. /**
  158. * 页面相关事件处理函数--监听用户下拉动作
  159. */
  160. onPullDownRefresh: function () {
  161. },
  162. /**
  163. * 页面上拉触底事件的处理函数
  164. */
  165. onReachBottom: function () {
  166. },
  167. /**
  168. * 用户点击右上角分享
  169. */
  170. onShareAppMessage: function () {
  171. }
  172. })