list.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. const app = getApp();
  2. import { pay_status } from "../../../utils/dict";
  3. Page({
  4. data: {
  5. frameStyle: { useTop: true, name: '赛事报名', leftArrow: true, useBar: false },
  6. list: [],
  7. total: 0,
  8. page: 0,
  9. skip: 0,
  10. limit: 10,
  11. },
  12. // 返回
  13. back: function () { wx.navigateBack({ delta: 1 }) },
  14. // 详细信息
  15. toCommon: function (e) {
  16. const that = this;
  17. const { item, route } = e.currentTarget.dataset;
  18. that.setData({ skip: 0, page: 0, list: [] });
  19. wx.navigateTo({ url: `/pagesMatch/${route}?id=${item && item._id ? item._id : ''}` })
  20. },
  21. // 申请退赛
  22. toOut: function (e) {
  23. const that = this;
  24. const { item } = e.currentTarget.dataset;
  25. wx.showModal({
  26. title: '提示',
  27. content: `是否确定退赛,如需退款请联系赛事负责人,联系电话:${item.match_id_contact}`,
  28. async success(res) {
  29. if (res.confirm) {
  30. const arr = await app.$post(`/matchSign/${item._id}`, { pay_status: '-2' }, 'race');
  31. if (arr.errcode == '0') {
  32. wx.showToast({ title: `退赛申请成功`, icon: 'success', duration: 2000 });
  33. that.setData({ skip: 0, page: 0, list: [] })
  34. that.watchLogin();
  35. } else wx.showToast({ title: `${toRefund.errmsg}`, icon: 'none', duration: 2000 })
  36. } else if (res.cancel) { }
  37. }
  38. });
  39. },
  40. // 分页
  41. toPage: function () {
  42. const that = this;
  43. let list = that.data.list;
  44. let limit = that.data.limit;
  45. if (that.data.total > list.length) {
  46. wx.showLoading({ title: '加载中', mask: true })
  47. let page = that.data.page + 1;
  48. that.setData({ page: page })
  49. let skip = page * limit;
  50. that.setData({ skip: skip })
  51. that.watchLogin();
  52. wx.hideLoading()
  53. } else { wx.showToast({ title: '没有更多数据了', icon: 'none', duration: 2000 }) }
  54. },
  55. /**
  56. * 生命周期函数--监听页面加载
  57. */
  58. onLoad: function (options) { },
  59. /**
  60. * 生命周期函数--监听页面初次渲染完成
  61. */
  62. onReady: function () { },
  63. /**
  64. * 生命周期函数--监听页面显示
  65. */
  66. onShow: function () {
  67. const that = this;
  68. // 监听用户是否登录
  69. that.watchLogin();
  70. },
  71. // 监听用户是否登录
  72. watchLogin: async function () {
  73. const that = this;
  74. wx.getStorage({
  75. key: 'raceuser',
  76. success: async res => {
  77. let info = { skip: that.data.skip, limit: that.data.limit, user_id: res.data._id };
  78. let arr = await app.$get(`/matchSign`, { ...info }, 'race');
  79. if (arr.errcode == '0') {
  80. let list = [...that.data.list, ...arr.data]
  81. for (const val of list) { val.zhpay_status = that.searchStatus(val.pay_status) }
  82. that.setData({ list })
  83. that.setData({ total: arr.total })
  84. } else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }) }
  85. },
  86. fail: async res => {
  87. wx.redirectTo({ url: '/pages/index/index' })
  88. }
  89. })
  90. },
  91. // 查询状态
  92. searchStatus: function (e) {
  93. let data = pay_status.find(i => i.value == e);
  94. if (data) return data.label;
  95. else return '暂无';
  96. },
  97. /**
  98. * 页面上拉触底事件的处理函数
  99. */
  100. /**
  101. * 生命周期函数--监听页面隐藏
  102. */
  103. onHide: function () {
  104. const that = this;
  105. that.setData({ skip: 0, page: 0, list: [] })
  106. },
  107. /**
  108. * 生命周期函数--监听页面卸载
  109. */
  110. onUnload: function () {
  111. },
  112. /**
  113. * 页面相关事件处理函数--监听用户下拉动作
  114. */
  115. onPullDownRefresh: function () {
  116. },
  117. /**
  118. * 用户点击右上角分享
  119. */
  120. onShareAppMessage: function () {
  121. }
  122. })