myCoupon.js 2.0 KB
// pages/person/myCoupon/myCoupon.js
const app=getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    currTab: 0,
    couponlist:'',
    rulecontent:[],
    ruleshow:false
  },

  //点击切换
  clickTab: function (e) {
    var that = this;
    if (this.data.currTab === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currTab: e.target.dataset.current
      })

      that.mycouponlist();
    }
  },

  //使用规则
  userule(e){

    let that=this;
    that.setData({
      ruleshow:true
    })


    let logoid = e.currentTarget.dataset.logid;
    let couponlist = that.data.couponlist;
    for (var obj of couponlist){
      if (logoid == obj.logId){
          that.setData({
            rulecontent: obj.msg
          })
      }
    }

  },

  //隐藏使用规则
  hideruleshow(){
    this.setData({
      ruleshow:false
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.mycouponlist()

  },

  mycouponlist(){
    let that = this;
    var url = '/api/portal/Mine/coupon';

    let type = parseInt(that.data.currTab)+1
    var params = {
      token: wx.getStorageSync('token'),
      type: type

    }
    app.post(url, params).then((res) => {
      console.log(res);

      that.setData({
        couponlist:res
      })



    }).catch((err) => {

    })
  },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  }
})