123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- // pages/cardBag/cardBag.js
- import {
- get,
- post
- } from '../../../utils/http.js'
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- current: 1,
- list: [],
- page: 1,
- limit: 50,
- storeId: wx.getStorageSync('store_id'),
- // loadMore: false, //上拉加载"的变量,默认false,隐藏
- // loadAll: false //没有数据”的变量,默认false,隐藏
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- // 获取卡包列表
- this.getList()
- },
- /**
- * 切换状态
- */
- onTabsChange(e) {
- let current = e.currentTarget.dataset.id
- if (current == this.data.current) {
- return
- }
- this.setData({
- current,
- page: 1,
- list: []
- // loadMore: false,
- // loadAll: false
- },
- () => {
- // 获取卡包列表
- this.getList()
- }
- )
- },
- // 获取卡包列表
- getList(){
- console.log(this,'shit')
- let { page,limit,current } = this.data
- get('v2/api/user/card/list',{
- page,
- limit,
- type: current
- },(res) => {
- console.log(res,'res')
- if(res.data && res.data.list.length > 0){
- let page = this.data.page + 1
- let concntList = this.data.list.concat(res.data.list)
- this.setData({
- page,
- list: concntList,
- // loadMore: false //把上拉加载"的变量设为false,隐藏
- })
- if (res.data.list.length < this.data.limit) {
- // this.setData({
- // loadMore: false, //隐藏加载中。。
- // loadAll: true //所有数据都加载完了
- // });
- }
- } else {
- // this.setData({
- // loadMore: false, //把上拉加载"的变量设为false,隐藏
- // loadAll: true, //把没有数据”设为true,显示
- // });
- }
- },(error) =>{
- console.log("请求失败", error)
- // this.setData({
- // loadAll: false,
- // loadMore: false
- // });
- })
- },
- // 下拉触底触发
- toLower(){
- // if(!this.data.loadMore){
- // this.setData({
- // loadMore: true, //加载中
- // loadAll: false //是否加载完所有数据
- // });
- // }
- // 获取卡包列表
- this.getList()
- },
- // 跳转到次卡详情
- jumpCard(e){
- console.log(e.currentTarget.dataset,'currentTarget.dataset');
- let id = e.currentTarget.dataset.id
- wx.navigateTo({
- url: `/subPackages/pages/subCardDetails/subCardDetails?source=project&id=${id}&store_id=${this.data.storeId}`,
- })
- },
- // 跳转到项目详情
- jumpProject(e){
- let project_id = e.currentTarget.dataset.project_id
- console.log(project_id,'project_id');
- wx.navigateTo({
- url: `/pages/projectDetail/projectDetail?source=project&id=${project_id}&store_id=${this.data.storeId}`,
- })
- },
- // 跳转到历史记录页面
- jumpHis(){
- wx.navigateTo({
- url: `/subPackages/pages/couponHistory/couponHistory`,
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|