var webpackRequire = require("./../../../../webpack-require");
webpackRequire(
"./src/packages/wm-cloud-db_index/component/clickGiftModal/index.js",
Object.assign({}, require("./../../../../weimob-cloud-commons.js").modules, {

/***/ "./src/packages/wm-cloud-db_index/component/clickGiftModal/index.js":
/*!**************************************************************************!*\
  !*** ./src/packages/wm-cloud-db_index/component/clickGiftModal/index.js ***!
  \**************************************************************************/
/*! no exports provided */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _utils_db_api_globalData__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../utils/db_api/globalData */ "./src/packages/wm-cloud-db_index/utils/db_api/globalData.js");
/* harmony import */ var _utils_db_api_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils/db_api/index */ "./src/packages/wm-cloud-db_index/utils/db_api/index.js");


const app = getApp();
Component({
  data: {
    isloading: false
  },
  properties: {
    isBindPhone: Boolean
  },
  attached() {
    console.log(this);
    console.error("看看文案", this.data, this.data.isBindPhone);
  },
  methods: {
    onModalClose() {
      this.triggerEvent("onModalClose", 'clickGift');
    },
    checkAuth(e) {
      /**未绑定手机号，先绑定 */
      wx.login({
        success: res => {
          if (res.code) {
            const param = {
              code: res.code,
              phoneEncryptedData: e.detail.encryptedData,
              phoneIv: e.detail.iv
            };
            this.login_db(param);
          } else {
            console.log('获取用户登录态失败！' + res.errMsg);
          }
        }
      });
    },
    openAward() {
      /**已绑定的话直接走扫码逻辑 */
      this.triggerEvent("onOpenAward");
    },
    /**登陆逻辑 */
    login_db(param) {
      if (this.data.isloading) return;
      this.setData({
        isloading: true
      });
      wx.showLoading();
      Object(_utils_db_api_index__WEBPACK_IMPORTED_MODULE_1__["reqDbLogin"])({
        ...param
      }).then(res => {
        wx.hideLoading();
        this.setData({
          isloading: false
        });
        if (res.success) {
          _utils_db_api_globalData__WEBPACK_IMPORTED_MODULE_0__["globalData"].loginToken = encodeURIComponent(res.data.loginToken);
          // wx.setStorageSync('db_loginToken', data.loginToken)
          /** 绑定好后走扫码逻辑*/
          this.openAward();
        } else {
          console.log("获取兑吧免登失败", res);
        }
      });
    }
  }
});

/***/ })

/******/ }));