"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 _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var _react = _interopRequireDefault(require("react"));
var _carousel = _interopRequireDefault(require("../carousel/carousel"));
require("./goods-card-list-common.scss");
var _excluded = ["dataList", "maxSales", "onClick"];
var GoodsCardListCommon = function GoodsCardListCommon(_ref) {
  var _ref$dataList = _ref.dataList,
    dataList = _ref$dataList === void 0 ? [] : _ref$dataList,
    _ref$maxSales = _ref.maxSales,
    maxSales = _ref$maxSales === void 0 ? 1000 : _ref$maxSales,
    _ref$onClick = _ref.onClick,
    _onClick = _ref$onClick === void 0 ? function () {} : _ref$onClick,
    otherProps = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
  var _otherProps = otherProps || {};
  var resolveResultDesc = function resolveResultDesc(desc) {
    var htmlString = "<div>" + desc + "</div>";
    // 创建一个虚拟的 DOM 容器
    var tempDiv = document.createElement('div');
    tempDiv.innerHTML = htmlString;
    // 提取文本
    return tempDiv.textContent || tempDiv.innerText;
  };
  return /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({
    className: "card-list-goods-common__container"
  }, _otherProps), dataList.map(function (item) {
    return /*#__PURE__*/_react["default"].createElement("div", {
      key: item.key,
      className: "card-list-goods__item",
      onClick: function onClick() {
        return _onClick(item);
      }
    }, item.imageList && item.imageList.length > 0 && /*#__PURE__*/_react["default"].createElement("div", {
      className: "card-list-goods__image"
    }, /*#__PURE__*/_react["default"].createElement(_carousel["default"], {
      images: item.imageList,
      interval: 3000
    })), /*#__PURE__*/_react["default"].createElement("div", {
      className: "card-list-goods__content"
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: "card-list-goods__title"
    }, item.title), /*#__PURE__*/_react["default"].createElement("div", {
      className: "card-list-goods__desc"
    }, resolveResultDesc(item.desc)), /*#__PURE__*/_react["default"].createElement("div", {
      className: "card-list-goods__bottom"
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: "card-list-goods__unit"
    }, "\uFFE5"), /*#__PURE__*/_react["default"].createElement("div", {
      className: "card-list-goods__price"
    }, item.activePrice || item.price), item.activePrice && /*#__PURE__*/_react["default"].createElement("div", {
      className: "card-list-goods__unit__delete"
    }, "\uFFE5"), item.activePrice && /*#__PURE__*/_react["default"].createElement("div", {
      className: "card-list-goods__price__delete"
    }, item.price), /*#__PURE__*/_react["default"].createElement("div", {
      className: "card-list-goods__sales"
    }, "\u5DF2\u552E", item.sales > maxSales ? maxSales + "+" : item.sales))));
  }));
};
GoodsCardListCommon.displayName = 'GoodsCardListCommon';
var _default = exports["default"] = GoodsCardListCommon;