card-detail.js 2.0 KB
// pages/card-detail/card-detail.js
let method = require("../../utils/reuqest.js")
Page({
  data: {
    postData: {
      number: '20000'
    },
    tabList: [{
      title: '积分明细'
    }, {
      title: '兑换记录'
    }],
    list: [],
    integralList: [{
      title: '积分明细',
      time: '2020/12/25 12:09',
      num: '+176'
    }],
    exchangeList: [{
      title: '兑换记录',
      time: '2020/12/25 12:09',
      num: '-176'
    }],
    t:'1'
  },
  //第一次数据加载
  getList() {
    method.getRequest("/myUser/myMemberDetails", data => {
      if (data.statusCode == 0) {
        this.setData({
          postData: data.data
        })
      }
    })
  },
  //会员卡详情
  cardDetail() {
    let postData = {
      currPage: 1,
      pageSize: 10,
      t: this.data.t
    }
    method.postRequest("/myUser/myMembershipCardDetails", postData, data => {
      if (data.statusCode == 0) {
         this.setData({
           list:data.data
         })
      }
    })
  },
  //tab切换
  onChange: function (e) {
    let idx = e.detail.index;
    switch (idx) {
      case 0:
        this.setData({
          t:'1'
        })
        this.cardDetail()
        break;
      case 1:
        this.setData({
          t:'2'
        })
        this.cardDetail()
        break;
    }
  },
  onLoad: function (options) {
    let that = this;
    that.getList();
    that.cardDetail()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})