"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 React = _interopRequireWildcard(require("react"));
var _indexModule = _interopRequireDefault(require("./index.module.scss"));
var _base = require("../../../api/base");
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 shop2 = function shop2(shop2Props) {
  var _obj$;
  var shopProperty = shop2Props.shopProperty;
  // eslint-disable-next-line react-hooks/rules-of-hooks
  var _useState = (0, React.useState)([{
      shopStatusA: 1,
      companyName: '进取投资',
      shopImg: ['//img.maimairen.com/low-code/components/shops/shop1.jpg'],
      shopTitle: '商品标题',
      shopTag: ['标签'],
      shopDescribe: '促销描述',
      // shopTag: ['高原蓝莓'],
      shopSellPrice: 100,
      shopMarketPrice: 200,
      // 金融相关 1 是正数  2 是负数
      shopStockStatus: 2,
      // 金融 涨幅日期范围
      shopUpdate: '近一年涨幅',
      shopUnit: '份',
      shopLink: 'www.baidu.com'
    }, {
      shopStatusA: 1,
      companyName: '进取投资',
      shopImg: ['//img.maimairen.com/low-code/components/shops/shop1.jpg'],
      shopTitle: '商品标题',
      shopTag: ['标签'],
      shopDescribe: '促销描述',
      // shopTag: ['高原蓝莓'],
      shopSellPrice: 100,
      shopMarketPrice: 200,
      // 金融相关 1 是正数  2 是负数
      shopStockStatus: 2,
      // 金融 涨幅日期范围
      shopUpdate: '近一年涨幅',
      shopUnit: '份',
      shopLink: 'www.baidu.com'
    }]),
    obj = _useState[0],
    setObj = _useState[1];
  // eslint-disable-next-line react-hooks/rules-of-hooks
  (0, React.useEffect)(function () {
    getMoreMessage();
  }, [shopProperty, (_obj$ = obj[0]) === null || _obj$ === void 0 ? void 0 : _obj$.shopStatusA]);
  var getMoreMessage = /*#__PURE__*/function () {
    var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
      var _shopProperty$data;
      var idArray;
      return _regenerator["default"].wrap(function _callee$(_context) {
        while (1) {
          switch (_context.prev = _context.next) {
            case 0:
              idArray = shopProperty === null || shopProperty === void 0 ? void 0 : (_shopProperty$data = shopProperty.data) === null || _shopProperty$data === void 0 ? void 0 : _shopProperty$data.shopIDarray;
              if (!(!idArray[0] && !idArray[1])) {
                _context.next = 3;
                break;
              }
              return _context.abrupt("return");
            case 3:
              obj.length = 0;
              _context.next = 6;
              return getDetailMessage(idArray[0]);
            case 6:
              _context.next = 8;
              return getDetailMessage(idArray[1]);
            case 8:
              _context.next = 10;
              return getDetailMessage(idArray[2]);
            case 10:
            case "end":
              return _context.stop();
          }
        }
      }, _callee);
    }));
    return function getMoreMessage() {
      return _ref.apply(this, arguments);
    };
  }();
  var getDetailMessage = /*#__PURE__*/function () {
    var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(x) {
      var dataArray, objs, M;
      return _regenerator["default"].wrap(function _callee2$(_context2) {
        while (1) {
          switch (_context2.prev = _context2.next) {
            case 0:
              dataArray = [];
              objs = {}; // const img = [] as any
              if (!x) {
                _context2.next = 10;
                break;
              }
              _context2.next = 5;
              return (0, _base.getShopById)(x);
            case 5:
              dataArray = _context2.sent;
              M = dataArray.data; // M.xc.map(item => {
              //     img.push(item.c)
              //     return img
              // })
              objs = {
                shopStatusA: M.f,
                companyName: '进取投资',
                shopImg: M.xc[0].c,
                // shopImg: '//img.maimairen.com/low-code/components/shops/shop1.jpg',
                shopTitle: M.b,
                shopTag: M.xb.map(function (item) {
                  return (item === null || item === void 0 ? void 0 : item.b).slice(0, 4);
                }),
                shopDescribe: M.xa[0].l,
                // shopTag: ['高原蓝莓'],
                shopSellPrice: M.xa[0].n,
                shopMarketPrice: M.xa[0].p,
                // 金融相关 1 是正数  2 是负数
                shopStockStatus: 2,
                // 金融 涨幅日期范围
                shopUpdate: M.xa[0].l,
                shopUnit: M.i,
                shopLink: returnUrl(JSON.parse(M.n1))
              };
              obj.push(objs);
              setObj([].concat(obj));
            case 10:
            case "end":
              return _context2.stop();
          }
        }
      }, _callee2);
    }));
    return function getDetailMessage(_x) {
      return _ref2.apply(this, arguments);
    };
  }();
  var returnUrl = function returnUrl(x) {
    if (x[0].status === '1') {
      return x[0].url;
    } else if (x[0].status === '2') {
      return x[1].url;
    } else if (x[0].status === '3') {
      return x[2].url;
    }
  };
  var jumpUrl = function jumpUrl(x) {
    window.location.href = x;
  };
  return /*#__PURE__*/React.createElement("div", null, obj[0] && obj[0].shopStatusA === 1 ? /*#__PURE__*/React.createElement("div", {
    className: _indexModule["default"].shopContainer
  }, obj.slice(0, 2).map(function (item, index) {
    var _item$shopTag;
    return /*#__PURE__*/React.createElement("div", {
      key: index,
      className: _indexModule["default"].singShop
    }, /*#__PURE__*/React.createElement("div", {
      className: _indexModule["default"].top
    }, /*#__PURE__*/React.createElement("img", {
      src: item === null || item === void 0 ? void 0 : item.shopImg
    }), /*#__PURE__*/React.createElement("div", {
      className: _indexModule["default"].tag
    }, item === null || item === void 0 ? void 0 : (_item$shopTag = item.shopTag) === null || _item$shopTag === void 0 ? void 0 : _item$shopTag.map(function (items, indexs) {
      return /*#__PURE__*/React.createElement("div", {
        key: indexs,
        className: _indexModule["default"].tags
      }, items + "\xA0");
    }))), /*#__PURE__*/React.createElement("div", {
      className: _indexModule["default"].title
    }, item === null || item === void 0 ? void 0 : item.shopTitle), /*#__PURE__*/React.createElement("div", {
      className: _indexModule["default"].describe
    }, item === null || item === void 0 ? void 0 : item.shopDescribe), /*#__PURE__*/React.createElement("div", {
      className: _indexModule["default"].price
    }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
      className: _indexModule["default"].shopSellPrice
    }, /*#__PURE__*/React.createElement("div", null, "\uFFE5"), /*#__PURE__*/React.createElement("div", null, item === null || item === void 0 ? void 0 : item.shopSellPrice), /*#__PURE__*/React.createElement("div", null, "/", item === null || item === void 0 ? void 0 : item.shopUnit)), /*#__PURE__*/React.createElement("div", {
      className: _indexModule["default"].shopMarketPrice
    }, /*#__PURE__*/React.createElement("s", null, "\uFFE5", item === null || item === void 0 ? void 0 : item.shopMarketPrice))), /*#__PURE__*/React.createElement("div", {
      className: _indexModule["default"].link,
      onClick: function onClick() {
        jumpUrl(item === null || item === void 0 ? void 0 : item.shopLink);
      }
    }, /*#__PURE__*/React.createElement("div", null, "\u62A2"))));
  })) : /*#__PURE__*/React.createElement("div", {
    className: _indexModule["default"].financialContainer
  }, obj.slice(0, 2).map(function (item, index) {
    var _item$shopTag2;
    return /*#__PURE__*/React.createElement("div", {
      key: index,
      className: _indexModule["default"].financial,
      onClick: function onClick() {
        jumpUrl(item === null || item === void 0 ? void 0 : item.shopLink);
      }
    }, /*#__PURE__*/React.createElement("div", {
      className: _indexModule["default"].tag
    }, item === null || item === void 0 ? void 0 : (_item$shopTag2 = item.shopTag) === null || _item$shopTag2 === void 0 ? void 0 : _item$shopTag2.map(function (items, indexs) {
      return /*#__PURE__*/React.createElement("div", {
        key: indexs,
        className: _indexModule["default"].tags
      }, items + "\xA0");
    })), /*#__PURE__*/React.createElement("div", {
      className: _indexModule["default"].title
    }, item === null || item === void 0 ? void 0 : item.shopTitle), /*#__PURE__*/React.createElement("div", {
      className: _indexModule["default"].bottom
    }, /*#__PURE__*/React.createElement("div", {
      className: _indexModule["default"].img
    }, /*#__PURE__*/React.createElement("img", {
      src: item === null || item === void 0 ? void 0 : item.shopImg
    })), /*#__PURE__*/React.createElement("div", {
      className: _indexModule["default"].price
    }, /*#__PURE__*/React.createElement("div", {
      className: _indexModule["default"].exchange
    }, /*#__PURE__*/React.createElement("div", {
      className: Number(item === null || item === void 0 ? void 0 : item.shopSellPrice) > 0 ? _indexModule["default"].red : _indexModule["default"].green
    }, Number(item === null || item === void 0 ? void 0 : item.shopSellPrice) > 0 ? /*#__PURE__*/React.createElement("div", {
      className: _indexModule["default"].text
    }, "+", item === null || item === void 0 ? void 0 : item.shopSellPrice, /*#__PURE__*/React.createElement("sup", null, "%")) : /*#__PURE__*/React.createElement("div", {
      className: _indexModule["default"].text
    }, "-", item === null || item === void 0 ? void 0 : item.shopSellPrice, /*#__PURE__*/React.createElement("sup", null, "%")))), /*#__PURE__*/React.createElement("div", {
      className: _indexModule["default"].shopDescribe
    }, item === null || item === void 0 ? void 0 : item.shopDescribe))));
  })));
};
var _default = shop2;
exports["default"] = _default;