123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- // subPackagesB/pages/groupRecord/groupRecord.js
- import {
- get,
- post
- } from '../../../utils/http.js'
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- current: 0, //切换拼团状态下标
- type: 0, //拼团记录类型 0拼团中,1拼团成功,2拼团失败
- groupRecordList: [], //拼团记录列表
- total:'',
- limit:10,
- page:1,
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- // 禁用分享
- wx.hideShareMenu()
- // 获取拼团记录列表
- this.getGroupRecordList()
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- if(this.data.groupRecordList.length<this.data.total){
- this.getGroupRecordList(++this.data.page)
- }
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- },
- // 切换tab栏状态
- changeTabs(e) {
- let index = e.currentTarget.dataset.index
- this.setData({
- current: index,
- type:index
- })
- this.getGroupRecordList(1)
- },
- // 拼团记录列表
- getGroupRecordList(_page) {
- let { groupRecordList, page,type } = this.data;
- get('v2/api/grouping/log', {
- type: type,
- limit:10,
- page:_page||page
- }, (res) => {
- if (res.code == 200) {
- if (_page == 1 || page == 1) {
- groupRecordList = []
- this.data.page = 1
- }
- groupRecordList.push(...res.data.list)
- this.setData({
- groupRecordList,
- total:res.data.total
- })
- }
- })
- },
- // 跳转到不同拼团状态页面
- goGroupType(e){
- // 状态,0拼团中,1拼团成功,-1已取消(拼团失败),-2已结束(拼团失败)
- let type = e.currentTarget.dataset.type
- let id = e.currentTarget.dataset.id //用户拼团id
- let group_id = e.currentTarget.dataset.group_id
- if(type==0){
- wx.navigateTo({
- url: `/subPackagesB/pages/groupOrder/groupOrder?userGroupId=${id}&&groupStatus=${type}&&group_id=${group_id}`,
- })
- }else if(type==1){
- wx.navigateTo({
- url: `/subPackagesB/pages/groupOrder/groupOrder?userGroupId=${id}&&groupStatus=${type}`,
- })
- }else if(type==-1){
- wx.navigateTo({
- url: `/subPackagesB/pages/groupFlow/groupFlow?groupStatus=${type}&&self=true&&group_id=${group_id}`,
- })
- }else if(type==-2){
- wx.navigateTo({
- url: `/subPackagesB/pages/groupFlow/groupFlow?groupStatus=${type}&&self=true&&group_id=${group_id}`,
- })
- }
- },
- // 取消拼团
- cancelGroup(e){
- let id = e.currentTarget.dataset.id //用户拼团ID
- post('v2/api/grouping/cancel',{
- id:id
- },(res)=>{
- wx.showToast({
- title: '取消成功',
- })
- // 获取刷新拼团记录列表
- this.getGroupRecordList(1)
- })
- },
- })
|