const _Http = getApp().globalData.http;

Page({
  data: {
    text: "",
    code: ""
  },
  onLoad(options) {
    console.log(options)
    if (options.code == 0) {
      this.setData({
        text: "绑定出错 请稍后再试"
      })
    } else {
      this.WechatServceBinding(options.code);
    }
  },
  WechatServceBinding(wechat_code) {
    _Http.basic({
      "classname": "common.usercenter.usercenter",
      "method": "WechatServceBinding",
      "content": {
        "accesstoken": wx.getStorageSync('userMsg').token,
        "systemclient": "wservice",
        wechat_code
      }
    }).then(res => {
      console.log("绑定公众号", res)
      this.setData({
        code: res.msg == '成功' ? "" : wechat_code
      })
    })
  },
  onShow() {
    this.data.code && this.WechatServceBinding(this.data.code);
  }
})