123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- import {
- get,
- post
- } from "../../../utils/http"
- // subPackagesB/pages/groupOrder/groupOrder.js
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- // 状态:0拼团中,1拼团成功,-1已取消(拼团失败),-2已结束(拼团失败)
- GroupOrderList: '', //拼团记录详情
- grouping_id: '', //拼团记录ID
- groupStatus: '', //拼团状态
- store_id: '', //店铺ID
- groupGoodsDetail: '', //拼团商品详情
- group_id: "", //拼团活动ID
- isShow: true, //显示问号被邀请人
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- this.setData({
- grouping_id: options.userGroupId, //拼团记录ID
- groupStatus: options.groupStatus, //拼团状态
- store_id: wx.getStorageSync('store_id'), //店铺ID
- group_id: options.group_id, //拼团活动ID
- })
- // 获取拼团记录详情
- this.getGroupOrderDetail()
- // 获取拼团商品详情
- if (this.data.groupStatus != 1) {
- this.getGroupGoodsDetail()
- }
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage(res) {
- if (res.from == 'button') {
- console.log(res.target, res)
- }
- return {
- title: this.data.GroupOrderList.share_text, //分享内容标题
- path: `/subPackagesB/pages/groupDetail/groupDetail?isShare=true&&id=${this.data.group_id}&&grouping_id=${this.data.grouping_id}&&groupStatus=${this.data.groupStatus}`, //这里是被分享的人点击进来之后的页面
- imageUrl: this.data.GroupOrderList.share_image //这里是图片的路径
- }
- },
- // 获取拼团记录详情
- getGroupOrderDetail() {
- get('v2/api/grouping/log_info', {
- id: this.data.grouping_id
- }, (res) => {
- if (res.code == 200) {
- res.data.users.forEach(item => {
- if (item.is_host == 0) {
- this.setData({
- isShow: false
- })
- }
- })
- this.setData({
- GroupOrderList: res.data,
- })
- let statusTitle = res.data.status == 0 ? '拼团中' : "拼团"
- wx.setNavigationBarTitle({
- title: statusTitle,
- })
- }
- })
- },
- // 获取拼团商品详情
- 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
- })
- }
- })
- },
- // 取消拼团
- cancelGroup() {
- let source = this.data.groupGoodsDetail.goods_type == 1 ? 'goods' : 'secondaryCard'
- let that = this
- post('v2/api/grouping/cancel', {
- id: that.data.grouping_id
- }, (res) => {
- wx.showToast({
- title: '取消成功',
- success: setTimeout(function () {
- //要延时执行的代码
- wx.redirectTo({
- url: `/subPackagesB/pages/GroupConfirm/GroupConfirm?store_id=${that.data.store_id}&&productId=${that.data.groupGoodsDetail.goods_id}&&source=${source}&&groupPrice=${that.data.groupGoodsDetail.original_price}&&isGrouping=false`,
- })
- }, 2000) //延迟时间
- })
- })
- },
- // 拼团成功返回首页
- goHome() {
- wx.switchTab({
- url: '/pages/home/home',
- })
- },
- })
|