"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 _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
require("./index.scss");
var _index2 = _interopRequireDefault(require("../common/ActivityBox/index"));
var _index3 = _interopRequireDefault(require("../common/winner/index"));
var _index4 = _interopRequireDefault(require("../common/prize/index"));
var _LuckDrawSucc = _interopRequireDefault(require("../common/LuckDrawSucc"));
var _excluded = ["bgImgEgg", "bgImgSmart", "bgOpacity", "isBgColor", "bgColor", "bgSize", "bgPosition", "text", "font", "fontSize", "fontPosition", "fontColor", "fontOpacity", "btnOpacity", "btnSize", "btnFontFamily", "btnTextColor", "winnerOpacity", "winnerSize", "winnerFontFamily", "winnerTextColor", "prizeFontSize", "prizeFontFamily", "prizeFontColor"];
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 GoldEgg = function GoldEgg(_ref) {
  var bgImgEgg = _ref.bgImgEgg,
    bgImgSmart = _ref.bgImgSmart,
    bgOpacity = _ref.bgOpacity,
    isBgColor = _ref.isBgColor,
    bgColor = _ref.bgColor,
    bgSize = _ref.bgSize,
    bgPosition = _ref.bgPosition,
    text = _ref.text,
    font = _ref.font,
    fontSize = _ref.fontSize,
    fontPosition = _ref.fontPosition,
    fontColor = _ref.fontColor,
    fontOpacity = _ref.fontOpacity,
    btnOpacity = _ref.btnOpacity,
    btnSize = _ref.btnSize,
    btnFontFamily = _ref.btnFontFamily,
    btnTextColor = _ref.btnTextColor,
    winnerOpacity = _ref.winnerOpacity,
    winnerSize = _ref.winnerSize,
    winnerFontFamily = _ref.winnerFontFamily,
    winnerTextColor = _ref.winnerTextColor,
    prizeFontSize = _ref.prizeFontSize,
    prizeFontFamily = _ref.prizeFontFamily,
    prizeFontColor = _ref.prizeFontColor,
    otherProps = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
  var _split = (fontPosition || 'cc').split(''),
    fontH = _split[0],
    fontV = _split[1];
  var fontTextCss = {
    opacity: fontOpacity / 100,
    color: fontColor,
    fontSize: fontSize + "px",
    fontFamily: font
  };
  switch (fontH) {
    case 'l':
      Object.assign(fontTextCss, {
        left: '2%'
      });
      break;
    case 'r':
      Object.assign(fontTextCss, {
        right: '2%'
      });
      break;
    case 'c':
      Object.assign(fontTextCss, {
        transform: 'translateX(-50%)'
      });
    // eslint-disable-next-line no-fallthrough

    default:
      Object.assign(fontTextCss, {
        left: '50%'
      });
  }
  switch (fontV) {
    case 't':
      Object.assign(fontTextCss, {
        top: '2%'
      });
      break;
    case 'b':
      Object.assign(fontTextCss, {
        bottom: '2%'
      });
      break;
    case 'c':
      Object.assign(fontTextCss, {
        transform: 'translateY(-50%)'
      });
    // eslint-disable-next-line no-fallthrough

    default:
      Object.assign(fontTextCss, {
        top: '50%'
      });
      break;
  }
  if (fontPosition === 'cc') Object.assign(fontTextCss, {
    transform: 'translate(-50%)'
  });

  // transform: rotate(45deg);

  var _split2 = (bgPosition || 'cc').split(''),
    bgH = _split2[0],
    bgV = _split2[1];
  var justifyContent = {
    l: 'flex-start',
    c: 'center',
    r: 'flex-end'
  };
  var alignItems = {
    t: 'flex-start',
    c: 'center',
    b: 'flex-end'
  };
  // console.log(bgH, bgV);
  var _useState = (0, React.useState)({
      isChecked: false,
      isOpenPrize: false,
      countPrized: '3'
    }),
    state = _useState[0],
    setState = _useState[1];
  var btnState = function btnState() {
    setState({
      // countPrized: state.countPrized,
      isOpenPrize: !state.isOpenPrize
    });
  };
  var trans = function trans() {
    if (Number(state.countPrized) < 1) {
      _message["default"].error('你剩余的抽奖次数已用完。');
      return;
    }
    setState({
      isChecked: true,
      isOpen: false
    });
    setTimeout(function () {
      setState({
        isOpen: true,
        isChecked: false,
        countPrized: (Number(state.countPrized) - 1).toString()
      });
    }, 1000);
    // setTimeout(() => {
    //   setState({
    //     ...state,
    //     isOpenPrize: !state.isOpenPrize
    //   });
    // }, 3000)
  };

  var container = {
    style: {
      backgroundColor: isBgColor ? bgColor : '',
      opacity: bgOpacity / 100,
      width: bgSize[0].value === undefined ? 'auto' : "" + bgSize[0].value + bgSize[0].unit,
      height: bgSize[1].value === undefined ? 'auto' : "" + bgSize[1].value + bgSize[1].unit,
      overflow: "auto"
    }
  };
  var SmartStyle = {
    style: {
      backgroundRepeat: "no-repeat",
      backgroundImage: "url(" + bgImgSmart + "?imageMogr2/interlace/1)"
    }
  };
  var _otherProps = Object.assign({
    container: container
  }, otherProps) || {};
  var btnStyle = {
    style: {
      opacity: btnOpacity / 100,
      fontSize: btnSize + "px",
      fontFamily: btnFontFamily,
      position: 'relative',
      color: btnTextColor
    }
  };
  var eggPOsition = {
    style: {
      display: 'flex',
      flexDirection: 'row',
      justifyContent: justifyContent[bgH],
      alignItems: alignItems[bgV]
    }
  };
  var winlist = [{
    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元现金券'
  }];
  var winnerStyle = {
    style: {
      opacity: winnerOpacity / 100,
      fontSize: winnerSize + "px",
      fontFamily: winnerFontFamily,
      position: 'relative',
      color: winnerTextColor
    }
  };
  var 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'
  }];
  var prizeStyle = {
    style: {
      fontSize: prizeFontSize + "px",
      fontFamily: prizeFontFamily,
      color: prizeFontColor
    }
  };
  var prizeTextList = {
    // icon: '//img.maimairen.com/low-code/components/blind-box/prize.png',
    // icon: 'no-prize',
    icon: 'prize',
    msg: '恭喜您中奖啦!',
    // msg: '很遗憾空无一物',
    prizeLv: ['特等奖', '冬奥冰墩墩钥匙扣 × 1']
    // prizeLv: ['谢谢参于', '']
  };

  var isOpenPrize = state.isOpenPrize;
  var EggStyle = {
    style: {
      backgroundRepeat: "no-repeat",
      backgroundImage: "url(" + bgImgEgg + "?imageMogr2/interlace/1)"
    }
  };
  var EggOpenStyle = {
    style: {
      backgroundRepeat: "no-repeat",
      backgroundImage: "url(https://img.maimairen.com/low-code/components/golden-eggs/egg-open.gif)"
    }
  };
  // 默认金蛋
  var defaultEgg = /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({
    className: "egg-g"
  }, EggStyle));
  // 砸开的金蛋
  var openEgg = /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({
    className: "egg-gs"
  }, EggOpenStyle));
  return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({
    className: "egg"
  }, _otherProps.container, _otherProps), /*#__PURE__*/React.createElement(_LuckDrawSucc["default"], {
    btnState: btnState,
    prizeTextList: prizeTextList,
    isOpenPrize: isOpenPrize
  }), /*#__PURE__*/React.createElement(_index2["default"], {
    title: /*#__PURE__*/React.createElement("span", null, "\u5269\u4F59\u62BD\u5956\u6B21\u6570\uFF1A", /*#__PURE__*/React.createElement("span", {
      className: "acitivity-nums"
    }, state.countPrized))
  }, /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({
    style: {
      fontSize: '48px'
    }
  }, eggPOsition), /*#__PURE__*/React.createElement("div", {
    className: "eggPosition"
  }, /*#__PURE__*/React.createElement("div", {
    className: "eggBorder"
  }, state !== null && state !== void 0 && state.isOpen ? openEgg : defaultEgg, /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({
    className: state !== null && state !== void 0 && state.isChecked ? 'egg-T egg-attacded' : 'egg-T'
  }, SmartStyle), state === null || state === void 0 ? void 0 : state.isChecked), /*#__PURE__*/React.createElement("div", {
    className: "click",
    onClick: trans,
    style: {
      border: "2px solid " + btnStyle.style.color
    }
  }, /*#__PURE__*/React.createElement("span", (0, _extends2["default"])({
    className: "clickText"
  }, btnStyle), "\u6211\u8981\u7838\u91D1\u86CB")))))), /*#__PURE__*/React.createElement(_index2["default"], {
    title: "\u4E2D\u5956\u540D\u5355"
  }, /*#__PURE__*/React.createElement("div", {
    style: {
      fontSize: '48px'
    }
  }, /*#__PURE__*/React.createElement(_index3["default"], {
    className: "bigWheel-LuckyWheel",
    list: winlist,
    winnerStyle: winnerStyle
  }))), /*#__PURE__*/React.createElement(_index2["default"], {
    title: "\u7CBE\u9009\u5956\u54C1"
  }, /*#__PURE__*/React.createElement("div", {
    style: {
      fontSize: '48px'
    }
  }, /*#__PURE__*/React.createElement(_index4["default"], {
    className: "bigWheel-LuckyWheel",
    list: prizeList,
    Style: prizeStyle
  })))));
};
var _default = GoldEgg;
exports["default"] = _default;