index.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. const app = getApp()
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. frameStyle: { useTop: true, name: '组队信息', leftArrow: true, useBar: false },
  8. list: [],
  9. // 弹框
  10. dialog: { title: '详细信息', show: false, type: '1' },
  11. info: {}
  12. },
  13. // 跳转菜单
  14. back(e) {
  15. wx.navigateBack({ delta: 1 })
  16. },
  17. // 详细信息
  18. toView: async function (e) {
  19. const that = this;
  20. const { item } = e.currentTarget.dataset;
  21. // 赛事信息
  22. const match = await app.$get(`/newCourt/api/match/${item.match_id}`);
  23. if (match.errcode = '0') { item.match_name = match.data.name; item.grouping = match.data.grouping; };
  24. // 赛事组别
  25. let group = match.data.grouping.find((i) => i._id == item.grouping_id);
  26. if (group) { item.grouping_name = group.name; }
  27. // 赛事项目
  28. const project = await app.$get(`/newCourt/api/matchProject/${item.project_id}`)
  29. if (project.errcode = '0') { item.project_name = project.data.name };
  30. that.setData({ info: item })
  31. that.setData({ dialog: { title: '详细信息', show: true, type: '1' } })
  32. },
  33. // 关闭弹框
  34. toClose: function () {
  35. const that = this;
  36. that.setData({ dialog: { title: '详细信息', show: false, type: '1' } })
  37. },
  38. /**
  39. * 生命周期函数--监听页面加载
  40. */
  41. onLoad: function (options) {
  42. const that = this;
  43. // 监听用户是否登录
  44. that.watchLogin();
  45. },
  46. watchLogin: function () {
  47. const that = this;
  48. let searchInfo = that.data.searchInfo;
  49. wx.getStorage({
  50. key: 'user',
  51. success: async (res) => {
  52. let info = { skip: 0, limit: 1000 };
  53. if (searchInfo && searchInfo.name) info.teammate_name = searchInfo.name;
  54. const arr = await app.$get(`/newCourt/api/teamApply`, { openid: res.data.openid, ...info });
  55. if (arr.errcode == '0') {
  56. that.setData({ list: arr.data })
  57. } else { wx.showToast({ title: `${res.errMsg}`, icon: 'fail', duration: 2000 }); }
  58. },
  59. fail: async (res) => {
  60. wx.redirectTo({ url: '/pages/index/index' });
  61. },
  62. });
  63. },
  64. /**
  65. * 生命周期函数--监听页面初次渲染完成
  66. */
  67. onReady: function () {
  68. },
  69. /**
  70. * 生命周期函数--监听页面显示
  71. */
  72. onShow: function () {
  73. },
  74. /**
  75. * 生命周期函数--监听页面隐藏
  76. */
  77. onHide: function () {
  78. },
  79. /**
  80. * 生命周期函数--监听页面卸载
  81. */
  82. onUnload: function () {
  83. },
  84. /**
  85. * 页面相关事件处理函数--监听用户下拉动作
  86. */
  87. onPullDownRefresh: function () {
  88. },
  89. /**
  90. * 页面上拉触底事件的处理函数
  91. */
  92. onReachBottom: function () {
  93. },
  94. /**
  95. * 用户点击右上角分享
  96. */
  97. onShareAppMessage: function () {
  98. }
  99. })