import _Slider from "@alifd/next/es/slider";
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
import _regeneratorRuntime from "@babel/runtime/regenerator";
import * as React from 'react';
import { useState, useEffect } from 'react';
import styles from "./index.module.scss";
import { getShopById } from "../../../api/base";
var bigPicture = function bigPicture(bigPictureProps) {
  var _obj$, _obj$2, _obj$3, _obj$4, _obj$5, _obj$7, _obj$8, _obj$9, _obj$9$shopTag, _obj$10, _obj$11, _obj$12, _obj$13;
  var shopProperty = bigPictureProps.shopProperty;
  // console.log("shopProperty", shopProperty)
  // eslint-disable-next-line react-hooks/rules-of-hooks
  var _useState = 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: 1,
      // 金融 涨幅日期范围
      shopUpdate: '近一年涨幅',
      shopUnit: '份',
      shopLink: 'www.baidu.com'
    }]),
    obj = _useState[0],
    setObj = _useState[1];
  // eslint-disable-next-line react-hooks/rules-of-hooks
  // const thePropsUpdate = useRef(true)
  // eslint-disable-next-line react-hooks/rules-of-hooks
  useEffect(function () {
    // if (thePropsUpdate.current) {
    //     thePropsUpdate.current = false;
    //     handles()
    //     return
    // }
    getDetailMessage();
  }, [shopProperty, obj[0].shopStatusA]);
  // const handles = () => {
  //     // const objs = [] as any;
  //     obj.push({
  //         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'
  //     } as any)
  //     setObj([...obj])
  // }
  var getDetailMessage = /*#__PURE__*/function () {
    var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
      var idArray, dataArray, objs, img, M;
      return _regeneratorRuntime.wrap(function _callee$(_context) {
        while (1) switch (_context.prev = _context.next) {
          case 0:
            idArray = shopProperty.data.shopIDarray || null;
            dataArray = [];
            objs = {};
            img = [];
            if (!idArray[0]) {
              _context.next = 14;
              break;
            }
            _context.next = 7;
            return 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.f,
              companyName: '进取投资',
              shopImg: img,
              shopTitle: M.b,
              shopTag: M.xb.map(function (item) {
                return item.b;
              }),
              shopDescribe: M.xa[0].l,
              // shopTag: ['高原蓝莓'],
              shopSellPrice: M.xa[0].n,
              shopMarketPrice: M.xa[0].p,
              // 金融相关 1 是正数  2 是负数
              shopStockStatus: 1,
              // 金融 涨幅日期范围
              shopUpdate: M.xa[0].l,
              shopUnit: M.i,
              shopLink: returnUrl(JSON.parse(M.n1))
            };
            // console.log("dataArraydataArray", dataArray)
            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
  //     }
  // }

  var jumpUrl = function jumpUrl(x) {
    window.location.href = x;
  };
  // const renderShopStockStatus = () => {
  //     if (obj[0] && obj[0].shopStockStatus === 1) {
  //         return (
  //             <div className={styles.priceSingle}>
  //                 <div>+</div>
  //                 <div>{obj[0].shopPrice} <sup>%</sup> </div>
  //             </div>
  //         )
  //     } else {
  //         return (
  //             <div className={styles.priceSingle}>
  //                 <div>-</div>
  //                 <div>{obj[0].shopPrice} <sup>%</sup></div>
  //             </div>
  //         )
  //     }
  // }
  // const renderShop = () => {
  //     // 1 为商品  2为金融
  //     if (obj[0] && obj[0].shopStatusA === 1) {
  //         return (
  //             <div className={styles?.shop}>
  //                 <div className={styles.shopContent}>
  //                     <div className={styles.shopImg}>
  //                         <img src={obj[0]?.shopImg} />
  //                     </div>
  //                     <div className={styles.shopTitle}>{obj[0]?.shopTitle}</div>
  //                     <div className={styles.shopTag}>{
  //                         obj[0]?.shopTag?.map(item => {
  //                             return <div className={styles.Tag}>{item}</div>
  //                         })
  //                     }</div>
  //                     <div className={styles.shopBottom}>
  //                         <div className={styles.price}>
  //                             <div>￥</div>
  //                             <div>{obj[0]?.shopPrice}</div>
  //                             <div>/{obj[0].shopUnit}</div>
  //                         </div>
  //                         <div className={styles.link} onClick={() => { window.location.href = obj[0]?.shopLink }}><div>抢</div></div>
  //                     </div>
  //                 </div>
  //             </div>
  //         )
  //     } else {
  //         return (
  //             <div className={styles.financial}>
  //                 <div className={styles.companyName}>{obj[0]?.companyName}</div>
  //                 <div className={styles.card}>
  //                     <div className={styles.chart}>
  //                         <img src={obj[0]?.shopImg} />
  //                     </div>
  //                     <div className={styles.message}>
  //                         <div className={styles.shopTag}>{
  //                             obj[0]?.shopTag?.map(item => {
  //                                 return (
  //                                     <div className={styles.Tag}>{item}</div>
  //                                 )
  //                             })
  //                         }</div>
  //                         <div className={styles.title}>{obj[0]?.shopTitle}</div>
  //                         <div className={styles.ShopStockStatus}>{renderShopStockStatus()}</div>
  //                         <div className={styles.shopUpdate}>{obj[0]?.shopUpdate}</div>
  //                         <div className={styles.link}>
  //                             <div >申购</div>
  //                         </div>
  //                     </div>
  //                 </div>
  //             </div>
  //         )
  //     }
  // }
  return /*#__PURE__*/React.createElement("div", null, obj[0] && obj[0].shopStatusA === 1 ? /*#__PURE__*/React.createElement("div", {
    className: styles === null || styles === void 0 ? void 0 : styles.shop
  }, /*#__PURE__*/React.createElement("div", {
    className: styles.shopContent
  }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_Slider, {
    speed: 1000,
    autoplay: true,
    autoplaySpeed: 2000,
    slidesToShow: 1,
    slidesToScroll: 1,
    arrowPosition: "inner",
    dots: false,
    lazyLoad: true
  }, (_obj$ = obj[0]) === null || _obj$ === void 0 ? void 0 : _obj$.shopImg.map(function (item, index) {
    return /*#__PURE__*/React.createElement("div", {
      key: index,
      className: styles.shopImg
    }, /*#__PURE__*/React.createElement("img", {
      src: item || '//img.maimairen.com/low-code/components/shops/shoplink.jpg'
    }));
  }))), /*#__PURE__*/React.createElement("div", {
    className: styles.shopTitle
  }, (_obj$2 = obj[0]) === null || _obj$2 === void 0 ? void 0 : _obj$2.shopTitle), /*#__PURE__*/React.createElement("div", {
    className: styles.shopTag
  }, // obj[0]?.shopTag?.map(item => {
  //     return <div className={styles.Tag}>{item}</div>
  // })
  (_obj$3 = obj[0]) === null || _obj$3 === void 0 ? void 0 : _obj$3.shopDescribe), /*#__PURE__*/React.createElement("div", {
    className: styles.shopBottom
  }, /*#__PURE__*/React.createElement("div", {
    className: styles.price
  }, /*#__PURE__*/React.createElement("div", null, "\uFFE5"), /*#__PURE__*/React.createElement("div", null, (_obj$4 = obj[0]) === null || _obj$4 === void 0 ? void 0 : _obj$4.shopSellPrice), /*#__PURE__*/React.createElement("div", null, "/", obj[0].shopUnit), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("s", null, "\uFFE5", (_obj$5 = obj[0]) === null || _obj$5 === void 0 ? void 0 : _obj$5.shopMarketPrice))), /*#__PURE__*/React.createElement("div", {
    className: styles.link
  }, /*#__PURE__*/React.createElement("div", {
    onClick: function onClick() {
      var _obj$6;
      jumpUrl((_obj$6 = obj[0]) === null || _obj$6 === void 0 ? void 0 : _obj$6.shopLink);
    }
  }, "\u62A2"))))) : /*#__PURE__*/React.createElement("div", {
    className: styles.financial
  }, /*#__PURE__*/React.createElement("div", {
    className: styles.companyName
  }, (_obj$7 = obj[0]) === null || _obj$7 === void 0 ? void 0 : _obj$7.companyName), /*#__PURE__*/React.createElement("div", {
    className: styles.card
  }, /*#__PURE__*/React.createElement("div", {
    className: styles.chart
  }, /*#__PURE__*/React.createElement("img", {
    src: ((_obj$8 = obj[0]) === null || _obj$8 === void 0 ? void 0 : _obj$8.shopImg) || '//img.maimairen.com/low-code/components/shops/shoplink.jpg'
  })), /*#__PURE__*/React.createElement("div", {
    className: styles.message
  }, /*#__PURE__*/React.createElement("div", {
    className: styles.shopTag
  }, (_obj$9 = obj[0]) === null || _obj$9 === void 0 ? void 0 : (_obj$9$shopTag = _obj$9.shopTag) === null || _obj$9$shopTag === void 0 ? void 0 : _obj$9$shopTag.map(function (item) {
    return /*#__PURE__*/React.createElement("div", {
      className: styles.Tag
    }, item);
  })), /*#__PURE__*/React.createElement("div", {
    className: styles.title
  }, (_obj$10 = obj[0]) === null || _obj$10 === void 0 ? void 0 : _obj$10.shopTitle), /*#__PURE__*/React.createElement("div", {
    className: styles.ShopStockStatus
  }, obj[0] && obj[0].shopStockStatus === 1 ? /*#__PURE__*/React.createElement("div", {
    className: styles.priceSingle
  }, /*#__PURE__*/React.createElement("div", null, "+"), /*#__PURE__*/React.createElement("div", null, (_obj$11 = obj[0]) === null || _obj$11 === void 0 ? void 0 : _obj$11.shopSellPrice, " ", /*#__PURE__*/React.createElement("sup", null, "%"), " ")) : /*#__PURE__*/React.createElement("div", {
    className: styles.priceSingle
  }, /*#__PURE__*/React.createElement("div", null, "-"), /*#__PURE__*/React.createElement("div", null, (_obj$12 = obj[0]) === null || _obj$12 === void 0 ? void 0 : _obj$12.shopSellPrice, " ", /*#__PURE__*/React.createElement("sup", null, "%")))), /*#__PURE__*/React.createElement("div", {
    className: styles.shopUpdate
  }, (_obj$13 = obj[0]) === null || _obj$13 === void 0 ? void 0 : _obj$13.shopUpdate), /*#__PURE__*/React.createElement("div", {
    className: styles.link
  }, /*#__PURE__*/React.createElement("div", {
    className: styles.link,
    onClick: function onClick() {
      var _obj$14;
      jumpUrl((_obj$14 = obj[0]) === null || _obj$14 === void 0 ? void 0 : _obj$14.shopLink);
    }
  }, "\u7533\u8D2D"))))));
};
export default bigPicture;