// pages/Voucher/Voucher.js
let app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tcId: null,
  },
  
  bindgetuserinfo: function (e){
    wx.showLoading({
      title: '加载中',
    });
    if (e.detail.userInfo !== undefined) { 
      wx.setStorage({
        key: "wxInfo",
        data: {
          avatarUrl: e.detail.userInfo.avatarUrl,
          nickName: e.detail.userInfo.nickName,
        }
      })
      
    } else {
      wx.setStorage({
        key: "wxInfo",
        data: {
          avatarUrl: '',
          nickName: '',
        }
      })
    }
    wx.hideLoading()
    wx.navigateTo({
      url: '/pages/Voucher/authenticat/authenticat?type=' + 1 + '&TCID=' + this.data.tcId
    })
  },
  bindgetuserinfo2: function (e) {
    wx.showLoading({
      title: '加载中',
    });
    if (e.detail.userInfo !== undefined) {
      wx.setStorage({
        key: "wxInfo",
        data: {
          avatarUrl: e.detail.userInfo.avatarUrl,
          nickName: e.detail.userInfo.nickName,
        }
      })

    } else {
      wx.setStorage({
        key: "wxInfo",
        data: {
          avatarUrl: '',
          nickName: '',
        }
      })
    }
    wx.hideLoading()
    wx.navigateTo({
      url: '/pages/Voucher/authenticat/authenticat?&type=' + 2 + '&TCID=' + this.data.tcId
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    const scene = decodeURIComponent(options.scene)
    console.log(scene)
    if (scene) {
      let tcId = scene.split('=')[1] ? scene.split('=')[1] : options.tcid;
      this.setData({
        tcId: tcId
      })
    }else{
      
    }
    //修改title
    wx.setNavigationBarTitle({
      title: '意见调查'  
    })
  },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  }
})