index.js 1.44 KB
let app = getApp();
Page({
  data: {
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
    tipsRuleVisible: false,
    indexInfo: {}
  },
  onShareAppMessage() {},
  onLoad(options) {
    this.initData();
  },
  initData() {
    app.queryIndex({
      auth: false
    }).then((result) => {
      this.setData({
        indexInfo: app.globalData.indexInfo
      })
    })
  },
  // 开始互动游戏 判断是否会员
  onStartHandler() {
    let {
      wishBillCode
    } = app.globalData.indexInfo;
    let path = "createWish";
    if (wishBillCode) {
      path = "wish"
    }
    app.router.push({
      path: path
    })
  },
  // 显示规则页面
  onShowRuleHandler() {
    this.setData({
      tipsRuleVisible: true
    })
  },
  // 子组件事件
  evtcomp(evt) {
    let {
      name,
      data
    } = evt.detail;
    switch (name) {

      case "_evt_hide_mask":
        this.setData({
          tipsRuleVisible: false
        })
        break;

      default:
        break;
    }
  },

  bindGetUserInfo(e) {
    wx.showLoading();
    this.getUserInfo(e.detail);
  },
  getUserInfo(e) {
    let _this = this;
    app.post({
      url: app.api.register,
      sid: false,
      data: {
        encryptedData: e.encryptedData,
        iv: e.iv,
        code: app.globalData.wxcode,
        tlMemberCode: app.globalData.tlMemberCode
      }
    }).then((res2) => {
      wx.hideLoading();
      _this.onStartHandler();
    }).catch((err) => {})
  },

})