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

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

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

const app = getApp();
Component({
  data: {
    firstPrize: {},
    lastPrize: []
  },
  properties: {
    prizeInfoVO: Array
  },
  attached() {
    this.time = 0;
    console.log(this);
    console.error("看看文案3123123", this.data);
    const firstPrize = this.data.prizeInfoVO.filter(item => {
      return item.type == 1 || item.type == 2;
    })[0];
    const lastPrize = this.data.prizeInfoVO.filter(item => {
      return item.type != 1 && item.type != 2;
    });
    this.setData({
      firstPrize,
      lastPrize
    });
  },
  methods: {
    onModalClose() {
      this.triggerEvent("onModalClose", 'openAward');
    },
    checkAuth() {
      this.triggerEvent("checkAuth");
    },
    async happyAccept() {
      console.warn("happyAccept");
      if (this.data.firstPrize.type == 1) {
        wx.showLoading({
          mask: true
        });
        this.getorderIddd(no => {
          wx.hideLoading();
          //微信红包
          this.triggerEvent("onModalClose", {
            type: 'openWxMoneyAward',
            projectOrderNo: no,
            recordId: this.data.firstPrize.recordId
          });
        });
      } else {
        this.triggerEvent("onModalClose", 'openAward');
      }
    },
    //轮询projectOrderNo
    // async getProjectOrderNo() {
    //   return new Promise(async (r) => {
    //     const projectOrderNo = await this.getorderIddd()
    //     if (projectOrderNo) {
    //       r()
    //     } else {

    //     }
    //   })
    // },

    async getorderIddd(cb) {
      if (this.time >= 5) {
        cb && cb(null);
        return;
      }
      this.time++;
      const apiQueryOrderIdResp = await Object(_utils_db_api__WEBPACK_IMPORTED_MODULE_0__["apiQueryOrderId"])({
        orderId: this.data.firstPrize.recordId
      });
      if (apiQueryOrderIdResp.success && apiQueryOrderIdResp.data) {
        cb && cb(apiQueryOrderIdResp.data);
      } else {
        setTimeout(() => {
          this.getorderIddd();
        }, 500);
      }
    }
  }
});

/***/ })

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