index.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. import { match_status } from '../../utils/dict';
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. frameStyle: { useTop: true, name: '赛事信息', leftArrow: false, useBar: false },
  9. fileUrl: app.globalData.fileUrl,
  10. id: '',
  11. info: {},
  12. // 选项卡
  13. tabs: {
  14. active: 'a',
  15. list: [
  16. { title: '规程', name: 'a' },
  17. { title: '选手', name: 'b' },
  18. { title: '秩序册', name: 'c' },
  19. { title: '赛况', name: 'd' },
  20. { title: '成绩册', name: 'e' },
  21. ],
  22. },
  23. // 场地选项卡
  24. fieldtabs: {
  25. active: '0',
  26. list: [],
  27. },
  28. // 选手
  29. bActive: '0',
  30. groupList: [],
  31. //比赛进程安排
  32. racelist: [
  33. {
  34. match_time: '2022-07-03 16:18',
  35. ground_name: '大馆场地1',
  36. player_one: '刘泽皓轩(琦迹羽球)',
  37. person: [{ name: '张益涵' }, { name: '朱宇航' }, { name: '李帅' }],
  38. player_two: '王子铭(龙伟羽校)',
  39. score_one: '6',
  40. score_two: '21',
  41. match_name: '青少组小学男单 半决赛 [青少组MS113]'
  42. },
  43. {
  44. match_time: '2022-07-03 16:18',
  45. ground_name: '大馆场地1',
  46. player_one: '刘泽皓轩(琦迹羽球)',
  47. player_two: '王子铭(龙伟羽校)',
  48. person: [{ name: '张益涵' }, { name: '朱宇航' }, { name: '李帅' }],
  49. score_one: '6',
  50. score_two: '21',
  51. match_name: '青少组小学男单 半决赛 [青少组MS113]'
  52. },
  53. {
  54. match_time: '2022-07-03 16:18',
  55. ground_name: '大馆场地1',
  56. player_one: '刘泽皓轩(琦迹羽球)',
  57. person: [{ name: '张益涵' }, { name: '朱宇航' }, { name: '李帅' }],
  58. player_two: '王子铭(龙伟羽校)',
  59. score_one: '6',
  60. score_two: '21',
  61. match_name: '青少组小学男单 半决赛 [青少组MS113]'
  62. },
  63. {
  64. match_time: '2022-07-03 16:18',
  65. ground_name: '大馆场地1',
  66. player_one: '刘泽皓轩(琦迹羽球)',
  67. player_two: '王子铭(龙伟羽校)',
  68. person: [{ name: '张益涵' }, { name: '朱宇航' }, { name: '李帅' }],
  69. score_one: '6',
  70. score_two: '21',
  71. match_name: '青少组小学男单 半决赛 [青少组MS113]'
  72. }, {
  73. match_time: '2022-07-03 16:18',
  74. ground_name: '大馆场地1',
  75. player_one: '刘泽皓轩(琦迹羽球)',
  76. person: [{ name: '张益涵' }, { name: '朱宇航' }, { name: '李帅' }],
  77. player_two: '王子铭(龙伟羽校)',
  78. score_one: '6',
  79. score_two: '21',
  80. match_name: '青少组小学男单 半决赛 [青少组MS113]'
  81. },
  82. {
  83. match_time: '2022-07-03 16:18',
  84. ground_name: '大馆场地1',
  85. player_one: '刘泽皓轩(琦迹羽球)',
  86. player_two: '王子铭(龙伟羽校)',
  87. person: [{ name: '张益涵' }, { name: '朱宇航' }, { name: '李帅' }],
  88. score_one: '6',
  89. score_two: '21',
  90. match_name: '青少组小学男单 半决赛 [青少组MS113]'
  91. }, {
  92. match_time: '2022-07-03 16:18',
  93. ground_name: '大馆场地1',
  94. player_one: '刘泽皓轩(琦迹羽球)',
  95. person: [{ name: '张益涵' }, { name: '朱宇航' }, { name: '李帅' }],
  96. player_two: '王子铭(龙伟羽校)',
  97. score_one: '6',
  98. score_two: '21',
  99. match_name: '青少组小学男单 半决赛 [青少组MS113]'
  100. },
  101. {
  102. match_time: '2022-07-03 16:18',
  103. ground_name: '大馆场地1',
  104. player_one: '刘泽皓轩(琦迹羽球)',
  105. player_two: '王子铭(龙伟羽校)',
  106. person: [{ name: '张益涵' }, { name: '朱宇航' }, { name: '李帅' }],
  107. score_one: '6',
  108. score_two: '21',
  109. match_name: '青少组小学男单 半决赛 [青少组MS113]'
  110. }
  111. ],
  112. btnList: [],
  113. btnActive: ['1'],
  114. active: '',
  115. },
  116. // 选项卡
  117. tabsChange: function (e) {
  118. const that = this;
  119. const { name } = e.detail;
  120. that.setData({ 'tabs.active': name });
  121. },
  122. // 场地选项卡
  123. fieldtabsChange: async function (e) {
  124. const that = this;
  125. const { name } = e.detail;
  126. that.setData({ 'fieldtabs.active': name });
  127. let group = that.data.fieldtabs.list.find((i) => i.name == name);
  128. if (group) {
  129. that.setData({ active: group.name });
  130. // const arr = await app.$get(`/newCourt/api/race`, { ground_id: group._id });
  131. // if (arr.errcode == '0') {
  132. // that.setData({ racelist: arr.data })
  133. // }
  134. }
  135. },
  136. toCommon: function (e) {
  137. const { route } = e.currentTarget.dataset;
  138. if (route) { wx.navigateTo({ url: `/pages/${route}` }) };
  139. },
  140. // 选择手风琴
  141. bChange: function (e) {
  142. const that = this;
  143. that.setData({ btnActive: e.detail })
  144. },
  145. // 更多
  146. toCommon: function (e) {
  147. const { route } = e.currentTarget.dataset;
  148. wx.redirectTo({ url: `/pages/${route}/index` })
  149. },
  150. // 报名
  151. toSign: function (e) {
  152. const { item } = e.currentTarget.dataset;
  153. wx.navigateTo({ url: `/pages/matchInfo/sign?id=${item._id}` })
  154. },
  155. // 选择手风琴
  156. bChange: function (e) {
  157. const that = this;
  158. that.setData({ bActive: e.detail })
  159. },
  160. /**
  161. * 生命周期函数--监听页面加载
  162. */
  163. onLoad: function (options) {
  164. const that = this;
  165. that.setData({ id: options.id || '62e388d4fd61d871861b80af' });
  166. // 监听用户是否登录
  167. that.watchLogin();
  168. },
  169. watchLogin: async function () {
  170. const that = this;
  171. if (that.data.id) {
  172. let arr;
  173. arr = await app.$get(`/newCourt/api/match/${that.data.id}`);
  174. if (arr.errcode == '0') {
  175. arr.data.statusZh = that.getStatusZh(arr.data.status);
  176. that.setData({ info: arr.data })
  177. const ground = await app.$get(`/newCourt/api/ground`);
  178. if (ground.errcode == '0') {
  179. let groundList = []
  180. ground.data.unshift({ _id: '', title: '全部场地', name: '0' });
  181. for (const [index, val] of ground.data.entries()) {
  182. groundList.push({ _id: val._id, title: val.title || val.name, name: index })
  183. }
  184. that.setData({ 'fieldtabs.list': groundList })
  185. const matchProject = await app.$get(`/newCourt/api/matchProject`);
  186. if (matchProject.errcode == '0') {
  187. that.setData({ btnList: matchProject.data })
  188. }
  189. }
  190. } else { wx.showToast({ title: `${res.errMsg}`, icon: 'fail', duration: 2000 }); }
  191. arr = await app.$get(`/newCourt/api/view/groupProjectUser?match_id=${that.data.id}`);
  192. if (arr.errcode == '0') { that.setData({ groupList: arr.data }) }
  193. }
  194. },
  195. getStatusZh(status) {
  196. let word = "未知"
  197. let data = match_status.find((i) => i.label == status);
  198. if (data) word = data.value;
  199. return word;
  200. },
  201. /**
  202. * 生命周期函数--监听页面初次渲染完成
  203. */
  204. onReady: function () {
  205. },
  206. /**
  207. * 生命周期函数--监听页面显示
  208. */
  209. onShow: function () {
  210. },
  211. /**
  212. * 生命周期函数--监听页面隐藏
  213. */
  214. onHide: function () {
  215. },
  216. /**
  217. * 生命周期函数--监听页面卸载
  218. */
  219. onUnload: function () {
  220. },
  221. /**
  222. * 页面相关事件处理函数--监听用户下拉动作
  223. */
  224. onPullDownRefresh: function () {
  225. },
  226. /**
  227. * 页面上拉触底事件的处理函数
  228. */
  229. onReachBottom: function () {
  230. },
  231. /**
  232. * 用户点击右上角分享
  233. */
  234. onShareAppMessage: function () {
  235. }
  236. })