"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _message = _interopRequireDefault(require("@alifd/next/lib/message"));
var React = _interopRequireWildcard(require("react"));
require("./index.scss");
var _Gift = _interopRequireDefault(require("./components/Gift"));
var _LuckDrawSucc = _interopRequireDefault(require("../../common/LuckDrawSucc"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var BlindSingleBox = function BlindSingleBox(_ref) {
  var isBgColor = _ref.isBgColor,
    bgColor = _ref.bgColor,
    opacity = _ref.opacity,
    btnText = _ref.btnText;
  var _wrapStyle = {
    style: {
      // width: size[0]?.value === undefined ? 'auto' : `${size[0]?.value}${size[0]?.unit}`,
      // height: size[1]?.value === undefined ? 'auto' : `${size[1]?.value}${size[1]?.unit}`,
      backgroundColor: isBgColor === false ? 'transparent' : bgColor
    }
  };
  var _pkgStyle = {
    style: {
      opacity: opacity / 100
    }
  };

  // const winnerStyle = {
  //   style: {
  //     opacity: winnerOpacity / 100,
  //     fontSize: `${winnerSize}px`,
  //     fontFamily: winnerFontFamily,
  //     position: 'relative',
  //     color: winnerTextColor,
  //     padding: `${winnerTop}px`,
  //     lineHeight: '1.8em',
  //   },
  // };
  // const list = [
  //   { phone: '17879830000', prize: '领取10元现金券' },
  //   { phone: '15737780000', prize: '领取10元现金券' },
  //   { phone: '15737780000', prize: '领取50元现金券' },
  //   { phone: '15737780000', prize: '领取10元现金券' },
  //   { phone: '15737780000', prize: '领取20元现金券' },
  //   { phone: '15737780000', prize: '领取10元现金券' },
  //   { phone: '15737780000', prize: '领取40元现金券' },
  // ];

  // const prizeList = [
  //   {
  //     text: '15天vip',
  //     img: '//img.maimairen.com/low-code/components/prize-list001/day15.png',
  //   },
  //   {
  //     text: '7天vip',
  //     img: '//img.maimairen.com/low-code/components/prize-list001/day7.png',
  //   },
  //   {
  //     text: '1天vip',
  //     img: '//img.maimairen.com/low-code/components/prize-list001/day1.png',
  //   },
  //   {
  //     text: '1豆',
  //     img: '//img.maimairen.com/low-code/components/prize-list001/bean1.png',
  //   },
  //   {
  //     text: '3豆',
  //     img: '//img.maimairen.com/low-code/components/prize-list001/bean3.png',
  //   },
  //   {
  //     text: '5豆',
  //     img: '//img.maimairen.com/low-code/components/prize-list001/bean5.png',
  //   },
  // ];
  // const prizeStyle = {
  //   style: {
  //     // // opacity: winnerOpacity / 100,
  //     // fontSize: `${prizeFontSize}px`,
  //     // fontFamily: prizeFontFamily,
  //     // // position: 'relative',
  //     // color: prizeFontColor
  //   },
  // };
  // const isOpenPrizeStyle = {
  //     style: {
  //         display: 'block'
  //     }
  // }

  var prizeTextList = {
    // icon: '//img.maimairen.com/low-code/components/blind-box/prize.png',
    // icon: 'no-prize',
    icon: 'prize',
    msg: '恭喜您中奖啦!',
    // msg: '很遗憾空无一物',
    prizeLv: ['特等奖', '冬奥冰墩墩钥匙扣 × 1']
    // prizeLv: ['谢谢参于', '']
  };

  var _React$useState = React.useState({
      isOpenPrize: false,
      countPrized: 5
    }),
    state = _React$useState[0],
    setState = _React$useState[1];
  var btnState = function btnState() {
    setState({
      countPrized: state.countPrized,
      isOpenPrize: !state.isOpenPrize
    });
  };
  var btnOnclick = function btnOnclick() {
    if (state.countPrized < 1) {
      _message["default"].error('你剩余的抽奖次数已用完。');
      return;
    }
    setState({
      countPrized: --state.countPrized,
      isOpenPrize: !state.isOpenPrize
    });
  };
  var isOpenPrize = state.isOpenPrize;
  return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({
    className: "blind-box"
  }, _wrapStyle), /*#__PURE__*/React.createElement(_LuckDrawSucc["default"], {
    btnState: btnState,
    prizeTextList: prizeTextList,
    isOpenPrize: isOpenPrize
  }), /*#__PURE__*/React.createElement(_Gift["default"], {
    style: _pkgStyle,
    btnFn: btnOnclick,
    btnText: btnText
  }));
};
var _default = BlindSingleBox;
exports["default"] = _default;