"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
require("./index.scss");
var React = _interopRequireWildcard(require("react"));
var _react2 = require("@lucky-canvas/react");
var _index2 = _interopRequireDefault(require("../common/winner/index"));
var _ActivityBoxReset = _interopRequireDefault(require("../common/ActivityBoxReset"));
var _activityHead = _interopRequireDefault(require("../common/activity-head"));
var _prize = _interopRequireDefault(require("../common/prize"));
var _LuckDrawSucc = _interopRequireDefault(require("../common/LuckDrawSucc"));
var _activityRules = _interopRequireDefault(require("../common/activity-rules"));
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 wheel2 = function wheel2(wheelProps) {
  var _widthHeight$, _widthHeight$2, _widthHeight$3, _widthHeight$4, _XYmoves$, _XYmoves$2, _XYmoves$3, _XYmoves$4;
  var bgColor = wheelProps.bgColor,
    XYmoves = wheelProps.XYmoves,
    widthHeight = wheelProps.widthHeight;
  var bigwheelsryle = {
    style: {
      width: widthHeight ? "" + ((_widthHeight$ = widthHeight[0]) === null || _widthHeight$ === void 0 ? void 0 : _widthHeight$.value) + ((_widthHeight$2 = widthHeight[0]) === null || _widthHeight$2 === void 0 ? void 0 : _widthHeight$2.unit) : '',
      height: widthHeight ? "" + ((_widthHeight$3 = widthHeight[1]) === null || _widthHeight$3 === void 0 ? void 0 : _widthHeight$3.value) + ((_widthHeight$4 = widthHeight[1]) === null || _widthHeight$4 === void 0 ? void 0 : _widthHeight$4.unit) : '',
      background: bgColor,
      position: 'relative',
      marginTop: XYmoves && XYmoves.length > 0 ? "" + ((_XYmoves$ = XYmoves[1]) === null || _XYmoves$ === void 0 ? void 0 : _XYmoves$.value) + ((_XYmoves$2 = XYmoves[1]) === null || _XYmoves$2 === void 0 ? void 0 : _XYmoves$2.unit) : 0,
      marginLeft: XYmoves && XYmoves.length > 0 ? "" + ((_XYmoves$3 = XYmoves[0]) === null || _XYmoves$3 === void 0 ? void 0 : _XYmoves$3.value) + ((_XYmoves$4 = XYmoves[0]) === null || _XYmoves$4 === void 0 ? void 0 : _XYmoves$4.unit) : 0,
      overflow: 'auto'
      // marginTop: "-8vw",
    }
  };

  // eslint-disable-next-line react-hooks/rules-of-hooks
  var _useState = (0, React.useState)({
      isOpenPrize: false,
      countPrized: 5,
      prizeTextList: {
        icon: 'prize',
        msg: '恭喜您中奖啦!',
        prizeLv: ['特等奖', '冬奥冰墩墩钥匙扣 × 1']
      }
    }),
    state = _useState[0],
    setState = _useState[1];
  var btnState = function btnState(prize) {
    setState({
      countPrized: state.countPrized,
      isOpenPrize: !state.isOpenPrize,
      prizeTextList: {
        icon: prize.imgs && prize.imgs[0].src,
        msg: '恭喜您中奖啦!',
        prizeLv: [prize.fonts && prize.fonts[0].text, '']
      }
    });
  };
  var isOpenPrize = state.isOpenPrize,
    prizeTextList = state.prizeTextList;
  return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({
    className: "bigWheel"
  }, bigwheelsryle), /*#__PURE__*/React.createElement(_LuckDrawSucc["default"], {
    btnState: btnState,
    prizeTextList: prizeTextList,
    isOpenPrize: isOpenPrize
  }), /*#__PURE__*/React.createElement(BigWheelChild, {
    wheelProps: wheelProps,
    btnState: btnState
  }));
};
var BigWheelChild = /*#__PURE__*/function (_Component) {
  (0, _inheritsLoose2["default"])(BigWheelChild, _Component);
  function BigWheelChild(props) {
    var _this;
    _this = _Component.call(this, props) || this;
    _this.onStart = function () {
      _this.myLucky.current.play();
      setTimeout(function () {
        var index = Math.random() * 6 >> 0;
        _this.myLucky.current.stop(index);
      }, 3000);
    };
    _this.myLucky = /*#__PURE__*/React.createRef();
    return _this;
  }
  var _proto = BigWheelChild.prototype;
  _proto.render = function render() {
    var _this2 = this;
    var _this$props$wheelProp = this.props.wheelProps,
      isAbsolute = _this$props$wheelProp.isAbsolute,
      winnerTop = _this$props$wheelProp.winnerTop,
      winnerTextColor = _this$props$wheelProp.winnerTextColor,
      winnerFontFamily = _this$props$wheelProp.winnerFontFamily,
      wheelHeight = _this$props$wheelProp.wheelHeight,
      winnerSize = _this$props$wheelProp.winnerSize,
      prizeFontSize = _this$props$wheelProp.prizeFontSize,
      prizeFontFamily = _this$props$wheelProp.prizeFontFamily,
      prizeFontTop = _this$props$wheelProp.prizeFontTop,
      prizeImgTop = _this$props$wheelProp.prizeImgTop,
      prizeImgWidth = _this$props$wheelProp.prizeImgWidth,
      prizeSpeed = _this$props$wheelProp.prizeSpeed,
      winnerOpacity = _this$props$wheelProp.winnerOpacity,
      wheelBgImg = _this$props$wheelProp.wheelBgImg,
      pointBgImg = _this$props$wheelProp.pointBgImg,
      wheelBgPadding = _this$props$wheelProp.wheelBgPadding,
      lineHeight = _this$props$wheelProp.lineHeight,
      awardTextColor = _this$props$wheelProp.awardTextColor,
      awardFontFamily = _this$props$wheelProp.awardFontFamily,
      awardFontSize = _this$props$wheelProp.awardFontSize,
      rulesText = _this$props$wheelProp.rulesText;
    var _split = (isAbsolute || 'cc').split(''),
      bgH = _split[0],
      bgV = _split[1];
    var justifyContent = {
      l: 'flex-start',
      c: 'center',
      r: 'flex-end'
    };
    var alignItems = {
      t: 'flex-start',
      c: 'center',
      b: 'flex-end'
    };
    var wheelstyle = {
      style: {
        display: 'flex',
        flexDirection: 'row',
        justifyContent: justifyContent[bgH],
        alignItems: alignItems[bgV],
        paddingBottom: '20px'
      }
    };
    var winnerStyle = {
      style: {
        opacity: winnerOpacity,
        fontSize: winnerSize + "px",
        fontFamily: winnerFontFamily,
        position: 'relative',
        color: winnerTextColor,
        padding: winnerTop + "px",
        lineHeight: lineHeight + "px"
      }
    };
    // 转盘配置详情 https://100px.net/docs/wheel.html 或 https://blog.csdn.net/crazy_jialin/article/details/115613060
    // 背景
    var blocks = [{
      padding: wheelBgPadding + "vw",
      imgs: [{
        src: wheelBgImg,
        width: '100%',
        height: '100%',
        top: '0',
        rotate: false
      }]
    }];
    var prizes = [{
      background: '#FCDEA0',
      fonts: [{
        text: '随机红包',
        fontSize: prizeFontSize,
        fontStyle: prizeFontFamily,
        fontColor: '#D16C3B',
        top: prizeFontTop + "%"
      }],
      imgs: [{
        src: '//img.maimairen.com/low-code/components/bigWheel2/hongbao01.png',
        width: prizeImgWidth + "%",
        top: prizeImgTop + "%"
      }]
    }, {
      background: '#FFD8C9',
      fonts: [{
        text: '50元优惠券',
        fontSize: prizeFontSize,
        fontStyle: prizeFontFamily,
        fontColor: '#D16C3B',
        top: prizeFontTop + "%"
      }],
      imgs: [{
        src: '//img.maimairen.com/low-code/components/bigWheel2/youhuiquan01.png',
        width: prizeImgWidth + "%",
        top: prizeImgTop + "%"
      }]
    }, {
      background: '#FCDEA0',
      fonts: [{
        text: 'DIOR39号',
        fontSize: prizeFontSize,
        fontStyle: prizeFontFamily,
        fontColor: '#D16C3B',
        top: prizeFontTop + "%"
      }],
      imgs: [{
        src: '//img.maimairen.com/low-code/components/bigWheel2/kouhong01.png',
        width: prizeImgWidth + "%",
        top: prizeImgTop + "%"
      }]
    }, {
      background: '#FFD8C9',
      fonts: [{
        text: '随机红包',
        fontSize: prizeFontSize,
        fontStyle: prizeFontFamily,
        fontColor: '#D16C3B',
        top: prizeFontTop + "%"
      }],
      imgs: [{
        src: '//img.maimairen.com/low-code/components/bigWheel2/hongbao01.png',
        width: prizeImgWidth + "%",
        top: prizeImgTop + "%"
      }]
    }, {
      background: '#FCDEA0',
      fonts: [{
        text: '50元优惠券',
        fontSize: prizeFontSize,
        fontStyle: prizeFontFamily,
        fontColor: '#D16C3B',
        top: prizeFontTop + "%"
      }],
      imgs: [{
        src: '//img.maimairen.com/low-code/components/bigWheel2/youhuiquan01.png',
        width: prizeImgWidth + "%",
        top: prizeImgTop + "%"
      }]
    }, {
      background: '#FFD8C9',
      fonts: [{
        text: 'DIOR39号',
        fontSize: prizeFontSize,
        fontStyle: prizeFontFamily,
        fontColor: '#D16C3B',
        top: prizeFontTop + "%"
      }],
      imgs: [{
        src: '//img.maimairen.com/low-code/components/bigWheel2/kouhong01.png',
        width: prizeImgWidth + "%",
        top: prizeImgTop + "%"
      }]
    }];
    var buttons = [{
      radius: '50%',
      imgs: [{
        src: pointBgImg,
        height: '100%',
        top: '-100%'
      }]
    }];
    var defaultConfig = {
      speed: prizeSpeed,
      gutter: '1vw',
      offsetDegree: '30',
      stopRange: 0.2
    };
    var 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元现金券'
    }];
    var awardStyle = {
      style: {
        color: awardTextColor,
        fontFamily: awardFontFamily,
        fontSize: awardFontSize + "px"
      }
    };
    var prizeList = [{
      text: 'DIOR39号',
      img: '//img.maimairen.com/low-code/components/bigWheel2/kouhong01.png'
    }, {
      text: '50元优惠券',
      img: '//img.maimairen.com/low-code/components/bigWheel2/youhuiquan01.png'
    }, {
      text: '随机红包',
      img: '//img.maimairen.com/low-code/components/bigWheel2/hongbao01.png'
    }];
    var ruleStyle = {
      style: {
        color: '#AD905C',
        lineHeight: '1em',
        paddingBottom: '2vw'
      }
    };
    return /*#__PURE__*/React.createElement("div", {
      className: "bigWheel-content"
    }, this.props.children, /*#__PURE__*/React.createElement(_activityHead["default"], {
      title: "\u9080\u597D\u53CB\u4E2D\u5927\u5956",
      content: "\u5E74\u7EC8\u9526\u9CA4\u5B63"
    }), /*#__PURE__*/React.createElement("div", {
      className: "wheel-Box"
    }, /*#__PURE__*/React.createElement(_ActivityBoxReset["default"], {
      title: /*#__PURE__*/React.createElement("span", null, "\u5269\u4F59\u62BD\u5956\u6B21\u6570\uFF1A", /*#__PURE__*/React.createElement("span", {
        className: "acitivity-nums"
      }, "1"))
    }, /*#__PURE__*/React.createElement("div", wheelstyle, /*#__PURE__*/React.createElement(_react2.LuckyWheel, {
      ref: this.myLucky,
      width: wheelHeight + "vw",
      height: wheelHeight + "vw",
      blocks: blocks,
      prizes: prizes,
      buttons: buttons,
      defaultConfig: defaultConfig,
      onStart: this.onStart,
      onEnd: function onEnd(prize) {
        _this2.myLucky.current.$lucky.step = 0;
        _this2.props.btnState(prize);
      }
    }))), /*#__PURE__*/React.createElement(_ActivityBoxReset["default"], {
      title: "\u4E2D\u5956\u540D\u5355"
    }, /*#__PURE__*/React.createElement(_index2["default"], {
      className: "bigWheel-LuckyWheel",
      list: list,
      winnerStyle: winnerStyle
    })), /*#__PURE__*/React.createElement(_ActivityBoxReset["default"], {
      title: "\u7CBE\u9009\u5956\u54C1"
    }, /*#__PURE__*/React.createElement("div", {
      className: "wheel-prize"
    }, /*#__PURE__*/React.createElement(_prize["default"], {
      className: "bigWheel-LuckyWheel",
      list: prizeList,
      Style: awardStyle
    }))), /*#__PURE__*/React.createElement(_ActivityBoxReset["default"], {
      title: "\u6D3B\u52A8\u89C4\u5219"
    }, /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({
      className: "wheel-rules"
    }, ruleStyle), /*#__PURE__*/React.createElement(_activityRules["default"], {
      rulesText: rulesText
    }))), /*#__PURE__*/React.createElement("div", {
      className: "wheel-logo"
    }, /*#__PURE__*/React.createElement("div", {
      className: "logo"
    }))));
  };
  return BigWheelChild;
}(React.Component);
BigWheelChild.displayName = 'BigWheelChild';
var _default = wheel2;
exports["default"] = _default;