123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 |
- import {
- get
- } from "../../../utils/http"
- // subPackagesB/pages/groupDetail/groupDetail.js
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- id: '', //拼团id
- grouping_id: '', //拼团记录ID
- store_id: '', //店铺id
- groupDetail: '', //拼团详情列表
- source: '', //拼团类型 (拼团类型,1美妆产品,2次卡)
- page: 1,
- limit: 3,
- total: '',
- pageA:1, //查看更多的数据
- limitA:10, //查看更多的数据
- checkGrouping: '', //是否有拼团资格,0不能参团,1可以参团
- groupingList: '', //拼团中列表
- groupingListAll:'', //拼团中前10条用来查看更多展示
- swiperPage: 1, //swiper可以滑动的页数
- autoplay:true, //swiper自动滚动
- isShare: false, //是否是分享点进来的
- storeName: '', //店铺名字
- groupStatus:'' , //订单状态 状态:0拼团中,1拼团成功,-1已取消(拼团失败),-2已结束(拼团失败)
- isGroupPop:false, //控制产看更多拼团中列表弹出框
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- console.log(options);
- let isShare = false
- if (options.isShare) {
- isShare = true
- }
- // 获取拼团id
- this.setData({
- store_id: wx.getStorageSync('store_id'),
- id: options.id,
- isShare,
- grouping_id: options.grouping_id,
- })
- // 检查是否有拼团资格
- this.getCheckGrouping()
- // 获取店铺信息
- this.getStoreInfo()
- // 获取拼团详情
- this.getGroupDetail()
- // 查看拼团记录详情改记录的状态
- if(this.data.isShare){
- this.getGroupOrderDetail()
- }
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- this.setData({
- autoplay:true
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- // 关闭自动滚动
- this.setData({
- autoplay:false
- })
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- return{
- path:`/subPackagesB/pages/groupDetail/groupDetail?grouping_id=${this.data.grouping_id}&id=${this.data.id}`
- }
- },
- // 获取拼团详情
- getGroupDetail() {
- get('v2/api/grouping/info', {
- id: this.data.id,
- store_id: this.data.store_id || wx.getStorageSync('store_id')
- }, (res) => {
- if (res.code == 200) {
- this.setData({
- groupDetail: res.data,
- // 拼团类型,1美妆产品,2次卡
- source: res.data.goods_type == 1 ? 'goods' : 'secondaryCard'
- })
- }
- // 获取拼团中列表
- if (!this.data.isShare) {
- this.getGroupingList()
-
- }
- })
- },
- // 获取拼团中列表
- getGroupingList(_page) {
- get('v2/api/grouping/grouping', {
- id: this.data.groupDetail.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
- })
- }
- }
- })
- },
- // 查看更多拼团中列表
- getGroupingListAll(_page){
- get('v2/api/grouping/grouping',{
- id: this.data.groupDetail.id,
- store_id: this.data.store_id || wx.getStorageSync('store_id'),
- page: _page||this.data.pageA,
- limit:this.data.limitA
- },(res)=>{
- if(res.code==200){
- let list = this.data.groupingListAll
- if(_page==1||this.data.pageA==1){
- console.log(1111);
- list = []
- }
- list.push(...res.data.list)
- this.setData({
- groupingListAll:list
- })
- }
- })
- },
- // 查看更多弹窗下拉触底
- refreshGroupList(){
- if(this.data.total>this.data.groupingListAll.length){
- this.getGroupingListAll(++this.data.pageA)
- }
- },
- // 切换swiper
- swiperChange(e) {
- let index = e.detail.current
- this.getGroupingList(index + 1)
- },
- // 检查是否又拼团资格
- getCheckGrouping() {
- get('v2/api/grouping/check', {}, (res) => {
- this.setData({
- // 结果,0不能参团,1可以参团
- checkGrouping: res.data.status
- })
- // 状态:0拼团中,1拼团成功,-1已取消(拼团失败),-2已结束(拼团失败)
- if(this.data.isShare&&this.data.groupStatus==-1||this.data.isShare&&this.data.groupStatus==-2){
- wx.redirectTo({
- url: `/subPackagesB/pages/groupFlow/groupFlow?group_id=${this.data.id}&&groupStatus=${this.data.groupStatus}`,
- })
- }
- if(this.data.isShare&&res.data.status==0){
- wx.redirectTo({
- url: `/subPackagesB/pages/groupFlow/groupFlow?group_id=${this.data.id}`,
- })
- }
- })
- },
- // 获取拼团记录详情
- getGroupOrderDetail() {
- get('v2/api/grouping/log_info', {
- id: this.data.grouping_id
- }, (res) => {
- if (res.code == 200) {
- let status = res.data.status
- if(res.data.status==1){
- status= -2
- }
- this.setData({
- groupStatus:status
- })
- // 防止没有接收到消息重新触发一次
- this.getCheckGrouping()
- console.log(this.data.groupStatus,'groupStatus');
- }
- })
- },
- // 去拼单
- 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.groupDetail.goods_id}&&source=${this.data.source}&&groupPrice=${this.data.groupDetail.price}&&isGrouping=true&&original_price=${this.data.groupDetail.original_price}&&groupID=${this.data.id}&&isSuccess=true&&grouping_id=${grouping_id}`,
- })
- },
- // 单独购买
- toGoodsOrderConfrim() {
- wx.navigateTo({
- url: `/subPackagesB/pages/GroupConfirm/GroupConfirm?store_id=${this.data.store_id}&&productId=${this.data.groupDetail.goods_id}&&source=${this.data.source}&&groupPrice=${this.data.groupDetail.original_price}&&isGrouping=false`,
- })
- },
- // 发起拼团
- toGroupOrderConfrim() {
- wx.navigateTo({
- url: `/subPackagesB/pages/GroupConfirm/GroupConfirm?store_id=${this.data.store_id}&&productId=${this.data.groupDetail.goods_id}&&source=${this.data.source}&&groupPrice=${this.data.groupDetail.price}&&isGrouping=true&&original_price=${this.data.groupDetail.original_price}&&groupID=${this.data.id}`,
- })
- },
- // 分享页面跳转进参与拼团
- ShareGroup() {
- wx.navigateTo({
- url: `/subPackagesB/pages/GroupConfirm/GroupConfirm?store_id=${this.data.store_id}&&productId=${this.data.groupDetail.goods_id}&&source=${this.data.source}&&groupPrice=${this.data.groupDetail.price}&&isGrouping=true&&original_price=${this.data.groupDetail.original_price}&&groupID=${this.data.id}&&isSuccess=true&&grouping_id=${this.data.grouping_id}`,
- })
- },
- // 获取店铺信息
- getStoreInfo() {
- get('api/store/info', {
- store_id: this.data.store_id || wx.getStorageSync('store_id')
- }, (res) => {
- this.setData({
- storeName: res.data.store_name
- })
- })
- },
- // 打开弹窗
- openPop(){
- this.getGroupingListAll(1)
- this.setData({
- isGroupPop:true
- })
- },
- // 关闭弹窗
- closePop(){
- this.setData({
- isGroupPop:false,
- groupingListAll:[]
- })
- },
- })
|