"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _react = _interopRequireDefault(require("react"));
var _base = require("../../../api/base");
var _indexModule = _interopRequireDefault(require("./index.module.scss"));
var defaultShop = {
  mainImg: '//img.maimairen.com/low-code/components/shops/shop1.jpg',
  title: '商品标题',
  tagsList: ['标签'],
  salesWord: '促销描述',
  sellingPrice: 100,
  marketPrice: 200,
  unit: '份'
};
var bigPicture = function bigPicture(bigPictureProps) {
  var _shopProperty$data;
  var shopProperty = bigPictureProps.shopProperty,
    handerShopChange = bigPictureProps.handerShopChange,
    ideaId = bigPictureProps.ideaId;
  var obj = shopProperty !== null && shopProperty !== void 0 && (_shopProperty$data = shopProperty.data) !== null && _shopProperty$data !== void 0 && _shopProperty$data.length ? shopProperty.data : [].concat(Array(1)).map(function () {
    return (0, _extends2["default"])({}, defaultShop);
  });
  var changeShopNumber = /*#__PURE__*/function () {
    var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(_ref) {
      var productId, _ref3, code;
      return _regenerator["default"].wrap(function _callee$(_context) {
        while (1) switch (_context.prev = _context.next) {
          case 0:
            productId = _ref.productId;
            if (ideaId) {
              _context.next = 3;
              break;
            }
            return _context.abrupt("return");
          case 3:
            _context.next = 5;
            return (0, _base.updateShop)({
              ideaId: ideaId,
              productId: productId,
              action: 'add'
            });
          case 5:
            _ref3 = _context.sent;
            code = _ref3.code;
            if (code === 10200) handerShopChange && handerShopChange();
          case 8:
          case "end":
            return _context.stop();
        }
      }, _callee);
    }));
    return function changeShopNumber(_x) {
      return _ref2.apply(this, arguments);
    };
  }();
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: _indexModule["default"] === null || _indexModule["default"] === void 0 ? void 0 : _indexModule["default"].shop
  }, obj.map(function (item, index) {
    return /*#__PURE__*/_react["default"].createElement("div", {
      key: index,
      className: _indexModule["default"].shopContent
    }, /*#__PURE__*/_react["default"].createElement("img", {
      src: item.mainImg
    }), /*#__PURE__*/_react["default"].createElement("div", {
      className: _indexModule["default"].shopTitle
    }, item.title), /*#__PURE__*/_react["default"].createElement("div", {
      className: _indexModule["default"].shopTag
    }, item.salesWord), /*#__PURE__*/_react["default"].createElement("div", {
      className: _indexModule["default"].shopBottom
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: _indexModule["default"].price
    }, /*#__PURE__*/_react["default"].createElement("span", null, "\uFFE5"), /*#__PURE__*/_react["default"].createElement("span", null, item.sellingPrice), /*#__PURE__*/_react["default"].createElement("div", null, "/", item.unit), /*#__PURE__*/_react["default"].createElement("s", null, "\uFFE5", item.marketPrice)), /*#__PURE__*/_react["default"].createElement("div", {
      className: _indexModule["default"].link
    }, /*#__PURE__*/_react["default"].createElement("div", {
      onClick: item !== null && item !== void 0 && item.productId ? function () {
        return changeShopNumber(item);
      } : function () {}
    }, "\u62A2"))));
  }));
};
var _default = bigPicture;
exports["default"] = _default;