groupRecord.js 3.2 KB

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