123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- // subPackagesB/pages/groupFlow/groupFlow.js
- import {
- get
- } from "../../../utils/http"
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- groupGoodsDetail: '', //拼团商品ID
- store_id: "", //店铺ID
- page: 1,
- limit: 3,
- total: '',
- checkGrouping: '', //是否有拼团资格,0不能参团,1可以参团
- groupStatus: '', //拼团状态
- self: false, // 是否是拼团记录跳转
- group_id: "", //拼团活动ID
- total: '',
- swiperPage: 1, //swiper可以滑动的页数
- groupingList: '', //拼团中列表
- source:'', //产品类型(0美妆 1次卡)
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- // 判断是否是拼团记录跳转
- let self = false
- if (options.self) {
- self = true
- }
- this.setData({
- store_id: wx.getStorageSync('store_id'), //店铺ID
- groupStatus: options.groupStatus, //拼团状态
- self, //是否是拼团记录跳转
- group_id: options.group_id, //拼团活动ID
- })
- // 检查是否有拼团资格
- this.getCheckGrouping()
- // 获取拼团商品详情
- this.getGroupGoodsDetail()
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- },
- // 获取拼团商品详情
- getGroupGoodsDetail() {
- get('v2/api/grouping/info', {
- id: this.data.group_id,
- store_id: this.data.store_id || wx.getStorageSync('store_id')
- }, (res) => {
- if (res.code == 200) {
- this.setData({
- groupGoodsDetail: res.data,
- source: res.data.goods_type == 1 ? 'goods' : 'secondaryCard'
- })
- this.getGroupingList()
- }
- })
- },
- // 获取拼团中列表
- getGroupingList(_page) {
- get('v2/api/grouping/grouping', {
- id: this.data.groupGoodsDetail.id,
- store_id: this.data.store_id || wx.getStorageSync('store_id'),
- page: _page || this.data.page,
- limit: this.data.limit
- }, (res) => {
- if (res.code == 200) {
- this.setData({
- groupingList: res.data.list,
- total: res.data.total
- })
- if (res.data.total > 3) {
- let swiperPage = Math.ceil(res.data.total / 3)
- this.setData({
- swiperPage
- })
- }
- }
- })
- },
- // 检查是否有拼团资格
- getCheckGrouping() {
- get('v2/api/grouping/check', {}, (res) => {
- this.setData({
- // 结果,0不能参团,1可以参团
- checkGrouping: res.data.status
- })
- })
- },
- // 切换swiper
- swiperChange(e) {
- let index = e.detail.current
- this.getGroupingList(index + 1)
- },
- // 去拼单
- goGrouping(e) {
- let grouping_id = e.currentTarget.dataset.grouping_id
- // if (this.data.checkGrouping == 0) {
- // wx.showToast({
- // title: '您不满足拼单条件,新用户才可以参与拼单',
- // icon: 'none',
- // })
- // return
- // }
- wx.navigateTo({
- 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}`,
- })
- },
- // 单独购买
- toGoodsOrderConfrim() {
- wx.navigateTo({
- 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`,
- })
- },
- // 发起拼团
- toGroupOrderConfrim() {
- wx.navigateTo({
- 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}`,
- })
- }
- })
|