// pages/personalCenter/personalCenter.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    myTicketArrows: false,
    historyTicketArrows: false,
    getUser:false,
    getUserArr:[],
    mydeg: -90,
    historydeg: -90,
    historyArr: [
      {
        "code": "11111",
        "name": "80元抵100元优惠券",
        "type": "未使用"
      },
      {
        "code": "11111",
        "name": "80元抵100元优惠券",
        "type": "未使用"
      },
      {
        "code": "11111",
        "name": "80元抵100元优惠券",
        "type": "未使用"
      },
      {
        "code": "11111",
        "name": "80元抵100元优惠券",
        "type": "未使用"
      },
    ],
    myTicketArr: [
      {
        "image": "../images/ticketImg.jpg",
        "name": "80抵100",
        "time": "2020.2.18-2020.12.31"
      },
      {
        "image": "../images/ticketImg.jpg",
        "name": "80抵100",
        "time": "2020.2.18-2020.12.31"
      },
      {
        "image": "../images/ticketImg.jpg",
        "name": "80抵100",
        "time": "2020.2.18-2020.12.31"
      },
      {
        "image": "../images/ticketImg.jpg",
        "name": "80抵100",
        "time": "2020.2.18-2020.12.31"
      },
    ],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // wx.getUserInfo({
    //   success: function (res) {
    //     console.log(res)
    //   }
    // })
  },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  },
  lookMyTicket:function(){
    this.setData({
      myTicketArrows: !this.data.myTicketArrows,
    })
    if (this.data.myTicketArrows){
      this.setData({
        mydeg: 0,
      })
    }else{
      this.setData({
        mydeg: -90,
      })
    }
  },
  lookHistory:function(){
    this.setData({
      historyTicketArrows: !this.data.historyTicketArrows,
    })
    if (this.data.historyTicketArrows) {
      this.setData({
        historydeg: 0,
      })
    } else {
      this.setData({
        historydeg: -90,
      })
    }
  },
  lookTicket:function(e){
    console.log(e)
    var index = e.target.dataset.index;
    wx.navigateTo({
      url: '../TicketDetails/TicketDetails',
    })
  },
  giveTicket:function(e){
    var index = e.target.dataset.index;
    wx.navigateTo({
      url: '../givePage/givePage',
    })
  },
  getUser:function(e){
    console.log(e)
    this.setData({
      getUserArr: e.detail.userInfo
    })
    if (this.data.getUserArr){
      this.setData({
        getUser: true
      })
    }
    console.log(this.data.getUserArr)
  }
})