// pages/index/sw/index.js
const Http = require("../../utils/HttpBasics");
var config = require("../../config/config.js");
Component({
  properties: {
    gamedata: {
      type: Object,
      value: {}
    }
  },
  data: {
    flag: false,
    gameUrl: ''
  },
  methods:{
    gotogame: function (e) {
      let that=this;
      Http.post({
        url: config.api.checkPhoneStatus,
        data: {}
      })
      .then(res => {
        console.log(res);
        var data = {
          couponChannelId: "" + that.data.couponChannelId,
          couponId: "" + that.data.couponId
        };
        if (that.data.couponChannelId == null) {
          var data = {
            couponId: "" + that.data.couponId
          };
        }
        wx.navigateTo({
          url: '/pages/game/index?url=' + e.target.dataset.data.url + "&id=" + e.target.dataset.data.id + "&gameId=" + e.target.dataset.data.gameId,
        })
      })
      .catch(err => {
        if (err.code == 11005) {
          // 用户手机未授权
          /**
           * 将值传到用户手机号授权的页面
           *
           */
          wx.redirectTo({
            url: "/pages/getphoneInfo/index?path=index"
          });
        } else if (err.code == 11006){
          // 用户手机已加密
          wx.redirectTo({
            url: "/pages/phoneinput/phoneinput?path=index"
          });
        }else {
          wx.showToast({
            title: err.message,
            image: "../../assets/img/fail.png",
            duration: 2000,
            mask: false
          });
        }
      })
    },
    a: function () {
      this.setData({ flag: false })
    },
    closeGame: function () {
      this.setData({ flag: true })
    },
  },
  onReady: function () {
    console.log(this.gamedata, 999999999)
  },
  onLoad: function (options) {
    console.log(this.gamedata, 999999999)
  },
  onShow: function () {
    console.log(this.gamedata, 999999999)
  }
});