"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 shop1 = function shop1(shop1Props) {
  var _obj$, _obj$2, _obj$2$shopTag, _obj$3, _obj$4, _obj$5, _obj$6, _obj$9, _obj$10, _obj$10$shopTag, _obj$11, _obj$12, _obj$13, _obj$14, _obj$15, _obj$16;
  var shopProperty = shop1Props.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', '//img.maimairen.com/low-code/components/shops/shoplink.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 () {
    getDetailMessage();
  }, [shopProperty, obj[0].shopStatusA]);
  var getDetailMessage = /*#__PURE__*/function () {
    var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
      var idArray, dataArray, objs, img, _M$xa$, _M$xa$2, _M$xa$3, M;
      return _regenerator["default"].wrap(function _callee$(_context) {
        while (1) switch (_context.prev = _context.next) {
          case 0:
            idArray = shopProperty.data.shopIDarray;
            dataArray = [];
            objs = {};
            img = [];
            if (!idArray[0]) {
              _context.next = 14;
              break;
            }
            _context.next = 7;
            return (0, _base.getShopById)(idArray[0]);
          case 7:
            dataArray = _context.sent;
            M = dataArray.data;
            M.xc.map(function (item) {
              img.push(item.c);
              return img;
            });
            objs = {
              shopStatusA: M === null || M === void 0 ? void 0 : M.f,
              companyName: '进取投资',
              shopImg: img,
              shopTitle: M === null || M === void 0 ? void 0 : M.b,
              shopTag: M.xb.map(function (item) {
                return item.b;
              }),
              shopDescribe: M === null || M === void 0 ? void 0 : (_M$xa$ = M.xa[0]) === null || _M$xa$ === void 0 ? void 0 : _M$xa$.l,
              // shopTag: ['高原蓝莓'],
              shopSellPrice: M === null || M === void 0 ? void 0 : (_M$xa$2 = M.xa[0]) === null || _M$xa$2 === void 0 ? void 0 : _M$xa$2.n,
              shopMarketPrice: M === null || M === void 0 ? void 0 : (_M$xa$3 = M.xa[0]) === null || _M$xa$3 === void 0 ? void 0 : _M$xa$3.p,
              // 金融相关 1 是正数  2 是负数
              shopStockStatus: 2,
              // 金融 涨幅日期范围
              shopUpdate: '近一年涨幅',
              shopUnit: M === null || M === void 0 ? void 0 : M.i,
              shopLink: returnUrl(JSON.parse(M.n1))
            };
            obj.length = 0;
            obj.push(objs);
            setObj([].concat(obj));
          case 14:
          case "end":
            return _context.stop();
        }
      }, _callee);
    }));
    return function getDetailMessage() {
      return _ref.apply(this, arguments);
    };
  }();
  var returnUrl = function returnUrl(x) {
    return x[x[0].status - 1].url;
  };
  // const returnUrl = (x) => {
  //     console.log("xxx", 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
  //     }
  // }
  return /*#__PURE__*/React.createElement("div", null, obj[0] && obj[0].shopStatusA === 1 ? /*#__PURE__*/React.createElement("div", {
    className: _indexModule["default"].shop
  }, /*#__PURE__*/React.createElement("div", {
    className: _indexModule["default"].left
  }, /*#__PURE__*/React.createElement("img", {
    src: (_obj$ = obj[0]) === null || _obj$ === void 0 ? void 0 : _obj$.shopImg[0]
  }), /*#__PURE__*/React.createElement("div", {
    className: _indexModule["default"].tag
  }, (_obj$2 = obj[0]) === null || _obj$2 === void 0 ? void 0 : (_obj$2$shopTag = _obj$2.shopTag) === null || _obj$2$shopTag === void 0 ? void 0 : _obj$2$shopTag.map(function (item) {
    return item + "\xA0";
  }))), /*#__PURE__*/React.createElement("div", {
    className: _indexModule["default"].right
  }, /*#__PURE__*/React.createElement("div", {
    className: _indexModule["default"].title
  }, (_obj$3 = obj[0]) === null || _obj$3 === void 0 ? void 0 : _obj$3.shopTitle), /*#__PURE__*/React.createElement("div", {
    className: _indexModule["default"].shopDescribe
  }, (_obj$4 = obj[0]) === null || _obj$4 === void 0 ? void 0 : _obj$4.shopDescribe), /*#__PURE__*/React.createElement("div", {
    className: _indexModule["default"].bottom
  }, /*#__PURE__*/React.createElement("div", {
    className: _indexModule["default"].price
  }, /*#__PURE__*/React.createElement("div", null, "\uFFE5"), /*#__PURE__*/React.createElement("div", null, (_obj$5 = obj[0]) === null || _obj$5 === void 0 ? void 0 : _obj$5.shopSellPrice), /*#__PURE__*/React.createElement("div", null, "/", obj[0].shopUnit), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("s", null, "\uFFE5", (_obj$6 = obj[0]) === null || _obj$6 === void 0 ? void 0 : _obj$6.shopMarketPrice), /*#__PURE__*/React.createElement("span", null, "/", obj[0].shopUnit))), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
    className: _indexModule["default"].link,
    onClick: function onClick() {
      var _obj$7;
      jumpUrl((_obj$7 = obj[0]) === null || _obj$7 === void 0 ? void 0 : _obj$7.shopLink);
    }
  }, /*#__PURE__*/React.createElement("div", null, "\u62A2")))))) : /*#__PURE__*/React.createElement("div", {
    className: _indexModule["default"].shopBanking,
    onClick: function onClick() {
      var _obj$8;
      jumpUrl((_obj$8 = obj[0]) === null || _obj$8 === void 0 ? void 0 : _obj$8.shopLink);
    }
  }, /*#__PURE__*/React.createElement("div", {
    className: _indexModule["default"].top
  }, /*#__PURE__*/React.createElement("div", {
    className: _indexModule["default"].title
  }, (_obj$9 = obj[0]) === null || _obj$9 === void 0 ? void 0 : _obj$9.shopTitle), /*#__PURE__*/React.createElement("div", {
    className: _indexModule["default"].tagls
  }, (_obj$10 = obj[0]) === null || _obj$10 === void 0 ? void 0 : (_obj$10$shopTag = _obj$10.shopTag) === null || _obj$10$shopTag === void 0 ? void 0 : _obj$10$shopTag.map(function (item) {
    return /*#__PURE__*/React.createElement("div", {
      className: _indexModule["default"].tag
    }, item);
  }))), /*#__PURE__*/React.createElement("div", {
    className: _indexModule["default"].bottom
  }, /*#__PURE__*/React.createElement("div", {
    className: _indexModule["default"].img
  }, /*#__PURE__*/React.createElement("img", {
    src: (_obj$11 = obj[0]) === null || _obj$11 === void 0 ? void 0 : _obj$11.shopImg[0]
  })), /*#__PURE__*/React.createElement("div", {
    className: _indexModule["default"].price
  }, /*#__PURE__*/React.createElement("div", {
    className: Number((_obj$12 = obj[0]) === null || _obj$12 === void 0 ? void 0 : _obj$12.shopSellPrice) > 0 ? _indexModule["default"].red : _indexModule["default"].green
  }, Number((_obj$13 = obj[0]) === null || _obj$13 === void 0 ? void 0 : _obj$13.shopSellPrice) > 0 ? /*#__PURE__*/React.createElement("div", {
    className: _indexModule["default"].text
  }, "+", (_obj$14 = obj[0]) === null || _obj$14 === void 0 ? void 0 : _obj$14.shopSellPrice, /*#__PURE__*/React.createElement("sup", null, "%")) : /*#__PURE__*/React.createElement("div", {
    className: _indexModule["default"].text
  }, "-", (_obj$15 = obj[0]) === null || _obj$15 === void 0 ? void 0 : _obj$15.shopSellPrice, /*#__PURE__*/React.createElement("sup", null, "%"))), /*#__PURE__*/React.createElement("div", {
    classsName: _indexModule["default"].descript
  }, "\u8FD1\u4E00\u5E74\u6DA8\u5E45")), /*#__PURE__*/React.createElement("div", {
    className: _indexModule["default"].shopDescribe
  }, (_obj$16 = obj[0]) === null || _obj$16 === void 0 ? void 0 : _obj$16.shopDescribe))));
};
var _default = shop1;
exports["default"] = _default;