"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _react = _interopRequireDefault(require("react"));

require("./index.less");

var _reactSlick = _interopRequireDefault(require("react-slick"));

var _mobx = require("../../../../../mobx");

var _Iconfont = _interopRequireDefault(require("../../../../../common/Iconfont"));

require("slick-carousel/slick/slick.css");

require("slick-carousel/slick/slick-theme.css");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

var __extends = void 0 && (void 0).__extends || function () {
  var _extendStatics = function extendStatics(d, b) {
    _extendStatics = Object.setPrototypeOf || {
      __proto__: []
    } instanceof Array && function (d, b) {
      d.__proto__ = b;
    } || function (d, b) {
      for (var p in b) {
        if (b.hasOwnProperty(p)) d[p] = b[p];
      }
    };

    return _extendStatics(d, b);
  };

  return function (d, b) {
    _extendStatics(d, b);

    function __() {
      this.constructor = d;
    }

    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  };
}();

var CarouselMobile =
/** @class */
function (_super) {
  __extends(CarouselMobile, _super);

  function CarouselMobile() {
    var _this = _super !== null && _super.apply(this, arguments) || this;

    _this.sliderRef = /*#__PURE__*/_react["default"].createRef();
    _this.state = {
      slideIndex: 0
    };
    _this.carouselRef = /*#__PURE__*/_react["default"].createRef();
    _this.destroy = null;

    _this.changeSlideIndex = function (type) {
      var current = _this.state.slideIndex;

      if (type === 'prev') {
        current -= 1;
      } else {
        current += 1;
      }

      _this.sliderRef.slickGoTo(current);
    };

    return _this;
  }

  CarouselMobile.prototype.componentDidMount = function () {
    this.destroy = (0, _mobx.autorun)(function () {});
  };

  CarouselMobile.prototype.componentWillReceiveProps = function (nextProps) {};

  CarouselMobile.prototype.componentWillUnmount = function () {
    this.destroy();
  };

  CarouselMobile.prototype.render = function () {
    var _this = this;

    var data = this.props.data;
    console.log('this.props.data', data);
    var settings = {
      className: 'slider-wrap',
      arrows: false,
      dots: true,
      infinite: true,
      autoplay: true,
      speed: 500,
      slidesToShow: 3,
      slidesToScroll: 1,
      beforeChange: function beforeChange(current, next) {
        _this.setState({
          slideIndex: next
        });
      }
    };
    return /*#__PURE__*/_react["default"].createElement("div", {
      className: "m-carousel-mobile"
    }, /*#__PURE__*/_react["default"].createElement(_Iconfont["default"], {
      className: "carousel-icon-left",
      color: "#2F54EB",
      onClick: function onClick() {
        return _this.changeSlideIndex('prev');
      },
      size: 20,
      type: "icon-left"
    }), /*#__PURE__*/_react["default"].createElement(_reactSlick["default"], _extends({
      ref: function ref(slider) {
        return _this.sliderRef = slider;
      }
    }, settings), data.groupSource.map(function (item) {
      return /*#__PURE__*/_react["default"].createElement("div", {
        key: item.id,
        className: "img-wrap"
      }, /*#__PURE__*/_react["default"].createElement("img", {
        alt: "",
        src: item.image.content.imgSrc
      }));
    })), /*#__PURE__*/_react["default"].createElement(_Iconfont["default"], {
      className: "carousel-icon-right",
      color: "#2F54EB",
      onClick: function onClick() {
        return _this.changeSlideIndex('next');
      },
      size: 20,
      type: "icon-right"
    }));
  };

  CarouselMobile.defaultProps = {
    data: {
      setting: {},
      groupSource: []
    }
  };
  return CarouselMobile;
}(_react["default"].Component);

var _default = CarouselMobile;
exports["default"] = _default;