groupRecord.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. // subPackagesB/pages/groupRecord/groupRecord.js
  2. import {
  3. get,
  4. post
  5. } from '../../../utils/http.js'
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. current: 0, //切换拼团状态下标
  12. type: 0, //拼团记录类型 0拼团中,1拼团成功,2拼团失败
  13. groupRecordList: [], //拼团记录列表
  14. total:'',
  15. limit:10,
  16. page:1,
  17. },
  18. /**
  19. * 生命周期函数--监听页面加载
  20. */
  21. onLoad(options) {
  22. // 禁用分享
  23. wx.hideShareMenu()
  24. // 获取拼团记录列表
  25. this.getGroupRecordList()
  26. // 禁用分享
  27. wx.hideShareMenu()
  28. },
  29. /**
  30. * 生命周期函数--监听页面初次渲染完成
  31. */
  32. onReady() {
  33. },
  34. /**
  35. * 生命周期函数--监听页面显示
  36. */
  37. onShow() {
  38. },
  39. /**
  40. * 生命周期函数--监听页面隐藏
  41. */
  42. onHide() {
  43. },
  44. /**
  45. * 生命周期函数--监听页面卸载
  46. */
  47. onUnload() {
  48. },
  49. /**
  50. * 页面相关事件处理函数--监听用户下拉动作
  51. */
  52. onPullDownRefresh() {
  53. },
  54. /**
  55. * 页面上拉触底事件的处理函数
  56. */
  57. onReachBottom() {
  58. if(this.data.groupRecordList.length<this.data.total){
  59. this.getGroupRecordList(++this.data.page)
  60. }
  61. },
  62. /**
  63. * 用户点击右上角分享
  64. */
  65. onShareAppMessage() {
  66. },
  67. // 切换tab栏状态
  68. changeTabs(e) {
  69. let index = e.currentTarget.dataset.index
  70. this.setData({
  71. current: index,
  72. type:index
  73. })
  74. this.getGroupRecordList(1)
  75. },
  76. // 拼团记录列表
  77. getGroupRecordList(_page) {
  78. let { groupRecordList, page,type } = this.data;
  79. get('v2/api/grouping/log', {
  80. type: type,
  81. limit:10,
  82. page:_page||page
  83. }, (res) => {
  84. if (res.code == 200) {
  85. if (_page == 1 || page == 1) {
  86. groupRecordList = []
  87. this.data.page = 1
  88. }
  89. groupRecordList.push(...res.data.list)
  90. this.setData({
  91. groupRecordList,
  92. total:res.data.total
  93. })
  94. }
  95. })
  96. },
  97. // 跳转到不同拼团状态页面
  98. goGroupType(e){
  99. // 状态,0拼团中,1拼团成功,-1已取消(拼团失败),-2已结束(拼团失败)
  100. let type = e.currentTarget.dataset.type
  101. let id = e.currentTarget.dataset.id //用户拼团id
  102. let group_id = e.currentTarget.dataset.group_id
  103. if(type==0){
  104. wx.navigateTo({
  105. url: `/subPackagesB/pages/groupOrder/groupOrder?userGroupId=${id}&&groupStatus=${type}&&group_id=${group_id}`,
  106. })
  107. }else if(type==1){
  108. wx.navigateTo({
  109. url: `/subPackagesB/pages/groupOrder/groupOrder?userGroupId=${id}&&groupStatus=${type}`,
  110. })
  111. }else if(type==-1){
  112. wx.navigateTo({
  113. url: `/subPackagesB/pages/groupFlow/groupFlow?groupStatus=${type}&&self=true&&group_id=${group_id}`,
  114. })
  115. }else if(type==-2){
  116. wx.navigateTo({
  117. url: `/subPackagesB/pages/groupFlow/groupFlow?groupStatus=${type}&&self=true&&group_id=${group_id}`,
  118. })
  119. }
  120. },
  121. // 取消拼团
  122. cancelGroup(e){
  123. let id = e.currentTarget.dataset.id //用户拼团ID
  124. post('v2/api/grouping/cancel',{
  125. id:id
  126. },(res)=>{
  127. wx.showToast({
  128. title: '取消成功',
  129. })
  130. // 获取刷新拼团记录列表
  131. this.getGroupRecordList(1)
  132. })
  133. },
  134. })