groupFlow.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. // subPackagesB/pages/groupFlow/groupFlow.js
  2. import {
  3. get
  4. } from "../../../utils/http"
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. groupGoodsDetail: '', //拼团商品ID
  11. store_id: "", //店铺ID
  12. page: 1,
  13. limit: 3,
  14. total: '',
  15. checkGrouping: '', //是否有拼团资格,0不能参团,1可以参团
  16. groupStatus: '', //拼团状态
  17. self: false, // 是否是拼团记录跳转
  18. group_id: "", //拼团活动ID
  19. total: '',
  20. swiperPage: 1, //swiper可以滑动的页数
  21. groupingList: '', //拼团中列表
  22. source:'', //产品类型(0美妆 1次卡)
  23. },
  24. /**
  25. * 生命周期函数--监听页面加载
  26. */
  27. onLoad(options) {
  28. // 判断是否是拼团记录跳转
  29. let self = false
  30. if (options.self) {
  31. self = true
  32. }
  33. this.setData({
  34. store_id: wx.getStorageSync('store_id'), //店铺ID
  35. groupStatus: options.groupStatus, //拼团状态
  36. self, //是否是拼团记录跳转
  37. group_id: options.group_id, //拼团活动ID
  38. })
  39. // 检查是否有拼团资格
  40. this.getCheckGrouping()
  41. // 获取拼团商品详情
  42. this.getGroupGoodsDetail()
  43. },
  44. /**
  45. * 生命周期函数--监听页面初次渲染完成
  46. */
  47. onReady() {
  48. },
  49. /**
  50. * 生命周期函数--监听页面显示
  51. */
  52. onShow() {
  53. },
  54. /**
  55. * 生命周期函数--监听页面隐藏
  56. */
  57. onHide() {
  58. },
  59. /**
  60. * 生命周期函数--监听页面卸载
  61. */
  62. onUnload() {
  63. },
  64. /**
  65. * 页面相关事件处理函数--监听用户下拉动作
  66. */
  67. onPullDownRefresh() {
  68. },
  69. /**
  70. * 页面上拉触底事件的处理函数
  71. */
  72. onReachBottom() {
  73. },
  74. /**
  75. * 用户点击右上角分享
  76. */
  77. onShareAppMessage() {
  78. },
  79. // 获取拼团商品详情
  80. getGroupGoodsDetail() {
  81. get('v2/api/grouping/info', {
  82. id: this.data.group_id,
  83. store_id: this.data.store_id || wx.getStorageSync('store_id')
  84. }, (res) => {
  85. if (res.code == 200) {
  86. this.setData({
  87. groupGoodsDetail: res.data,
  88. source: res.data.goods_type == 1 ? 'goods' : 'secondaryCard'
  89. })
  90. this.getGroupingList()
  91. }
  92. })
  93. },
  94. // 获取拼团中列表
  95. getGroupingList(_page) {
  96. get('v2/api/grouping/grouping', {
  97. id: this.data.groupGoodsDetail.id,
  98. store_id: this.data.store_id || wx.getStorageSync('store_id'),
  99. page: _page || this.data.page,
  100. limit: this.data.limit
  101. }, (res) => {
  102. if (res.code == 200) {
  103. this.setData({
  104. groupingList: res.data.list,
  105. total: res.data.total
  106. })
  107. if (res.data.total > 3) {
  108. let swiperPage = Math.ceil(res.data.total / 3)
  109. this.setData({
  110. swiperPage
  111. })
  112. }
  113. }
  114. })
  115. },
  116. // 检查是否有拼团资格
  117. getCheckGrouping() {
  118. get('v2/api/grouping/check', {}, (res) => {
  119. this.setData({
  120. // 结果,0不能参团,1可以参团
  121. checkGrouping: res.data.status
  122. })
  123. })
  124. },
  125. // 切换swiper
  126. swiperChange(e) {
  127. let index = e.detail.current
  128. this.getGroupingList(index + 1)
  129. },
  130. // 去拼单
  131. goGrouping(e) {
  132. let grouping_id = e.currentTarget.dataset.grouping_id
  133. // if (this.data.checkGrouping == 0) {
  134. // wx.showToast({
  135. // title: '您不满足拼单条件,新用户才可以参与拼单',
  136. // icon: 'none',
  137. // })
  138. // return
  139. // }
  140. wx.navigateTo({
  141. url: `/subPackagesB/pages/GroupConfirm/GroupConfirm?store_id=${this.data.store_id}&&productId=${this.data.groupGoodsDetail.goods_id}&&source=${this.data.source}&&groupPrice=${this.data.groupGoodsDetail.price}&&isGrouping=true&&original_price=${this.data.groupGoodsDetail.original_price}&&groupID=${this.data.groupGoodsDetail.id}&&isSuccess=true&&grouping_id=${grouping_id}`,
  142. })
  143. },
  144. // 单独购买
  145. toGoodsOrderConfrim() {
  146. wx.navigateTo({
  147. url: `/subPackagesB/pages/GroupConfirm/GroupConfirm?store_id=${this.data.store_id}&&productId=${this.data.groupGoodsDetail.goods_id}&&source=${this.data.source}&&groupPrice=${this.data.groupGoodsDetail.original_price}&&isGrouping=false`,
  148. })
  149. },
  150. // 发起拼团
  151. toGroupOrderConfrim() {
  152. wx.navigateTo({
  153. url: `/subPackagesB/pages/GroupConfirm/GroupConfirm?store_id=${this.data.store_id}&&productId=${this.data.groupGoodsDetail.goods_id}&&source=${this.data.source}&&groupPrice=${this.data.groupGoodsDetail.price}&&isGrouping=true&&original_price=${this.data.groupGoodsDetail.original_price}&&groupID=${this.data.groupGoodsDetail.id}`,
  154. })
  155. }
  156. })