var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

var _React = React,
    useContext = _React.useContext,
    createContext = _React.createContext,
    useEffect = _React.useEffect;

var CardData = createContext();

var product = function (_React$Component) {
    _inherits(product, _React$Component);

    function product(props) {
        _classCallCheck(this, product);

        // 初始化商品列表数据
        var _this = _possibleConstructorReturn(this, (product.__proto__ || Object.getPrototypeOf(product)).call(this, props));

        _this.state = {
            productList: props.productList, // 商品列表
            sizeFlag: props.sizeFlag, //尺寸图调用
            isSearch: props.isSearch, // 是否是搜索页面
            starsList: [], // 评价列表
            mode: 'listMode', // 显示模式
            scrollList: [], // 滚动加载的商品列表
            SizeList: [], // 尺寸列表
            iconImgList: {}, // 折扣图列表
            maxCount: props.maxCount, // 最大商品数量
            height: null, // 商品列表高度
            ShowPopBtn: false, // 购物车按钮的显示状态
            PopularList: [], // 人气商品列表
            ScrollToTop: false, // 滚动到顶部按钮的显示状态
            ScrollTopPosition: 0, // 当前滚动位置
            discountInfoList: [], //价格带,
            isClass: props.isClass || false
        };
        _this.onscrollLoad = props.onscrollLoad ? props.onscrollLoad : function () {}; // 初始化滚动加载

        _this.loading = false; // 是否正在加载
        if (props.productList && props.productList.length > 0) {
            _this._addStarsList(props.productList); // 添加评价信息
            _this._addDiscount(props.productList); // 获取商品折扣
            _this._addSizeList(props.productList); // 获取尺寸加工图信息
            _this._addDiscountInfo(props.productList); // 获取价格带
        }

        _this.contentEl = React.createRef(); // 创建ref
        return _this;
    }

    // 设置高度


    _createClass(product, [{
        key: "setHeight",
        value: function setHeight(num) {
            this.setState({
                height: num
            });
        }

        // 控制显示购物车按钮

    }, {
        key: "showPopBtn",
        value: function showPopBtn() {
            this.setState({
                ShowPopBtn: true
            });
        }

        // 控制隐藏购物车按钮

    }, {
        key: "hidePopBtn",
        value: function hidePopBtn() {
            this.setState({
                ShowPopBtn: false
            });
        }

        // 控制显示滚动到顶部按钮

    }, {
        key: "showScrollToTopBtn",
        value: function showScrollToTopBtn() {
            this.setState({
                ScrollToTop: true
            });
        }

        // 控制隐藏滚动到顶部按钮

    }, {
        key: "hideScrollToTopBtn",
        value: function hideScrollToTopBtn() {
            this.setState({
                ScrollToTop: false
            });
        }

        // 改变显示模式

    }, {
        key: "changeMode",
        value: function changeMode(string) {
            if (isNull(string)) {
                this.setState({
                    mode: this.state.mode === "listMode" ? "cardMode" : "listMode"
                });
                return;
            }
            if (string == 'listMode') {
                this.setState({
                    mode: 'listMode'
                });
            } else if (string == 'cardMode') {
                this.setState({
                    mode: 'cardMode'
                });
            }
        }

        // 获取当前的显示模式

    }, {
        key: "getMode",
        value: function getMode() {
            return this.state.mode;
        }

        // 添加星星

    }, {
        key: "_addStarsList",
        value: function _addStarsList(list) {
            var _this2 = this;

            getEvaluate({
                seriesCd: list.map(function (el) {
                    return el.seriesCode;
                }).join(',')
            }, function (code, result) {
                var starsData = result ? $.parseJSON(result) : {};
                if (starsData.returnFlg == 0) {
                    _this2.setState({ starsList: [].concat(_toConsumableArray(_this2.state.starsList), _toConsumableArray(starsData.reviewStarsList)) });
                }
            });
        }

        // 获取商品折扣图信息

    }, {
        key: "_addDiscount",
        value: function _addDiscount(list, popular) {
            var _this3 = this;

            // 获取商品折扣
            getSeriesTsvCommon({
                fileName: 'mech_zhekou_mb.tsv',
                target: popular ? list.map(function (el) {
                    return el.itemCd;
                }) : list.map(function (el) {
                    return el.seriesCode;
                })
            }).then(function (iconList) {
                if (iconList && iconList.returnFlg == 0) {
                    var imgData = iconList.data;
                    for (var i in imgData) {
                        imgData[i] = imgData[i].img && imgData[i].img.length > 0 ? imgData[i].img.map(function (el) {
                            return getLinkImgPath(el);
                        }) : [];
                    }
                    _this3.setState({
                        iconImgList: Object.assign({}, _this3.state.iconImgList, imgData)
                    });
                }
            });
        }

        // 获取尺寸加工图信息

    }, {
        key: "_addSizeList",
        value: function _addSizeList(list) {
            var _this4 = this;

            if (this.state.sizeFlag && list[0].categoryList && list[0].categoryList.length > 0) {
                getSeriesTsvCommon({
                    fileName: list[0].categoryList[0].categoryCode + "_chn_drw.tsv",
                    target: list.map(function (el) {
                        return el.seriesCode;
                    })
                }).then(function (sizeList) {
                    if (sizeList && sizeList.returnFlg == 0) {
                        var sizeData = sizeList.data;
                        _this4.setState({
                            SizeList: Object.assign({}, _this4.state.SizeList, sizeData)
                        });
                    }
                });
            }
        }

        // 获取价格带

    }, {
        key: "_addDiscountInfo",
        value: function _addDiscountInfo(list) {
            var _this5 = this;

            var scode = list.map(function (el) {
                return el.seriesCode;
            }).join(',');
            getSeriesCodeApi(scode).then(function (res) {
                if (!isNull(res) && !isNull(res.discountInfoList)) {
                    _this5.setState({ discountInfoList: [].concat(_toConsumableArray(_this5.state.discountInfoList), _toConsumableArray(res.discountInfoList)) });
                }
            });
        }

        // 添加更多的商品信息

    }, {
        key: "addCardList",
        value: function addCardList(list) {
            // 添加评价信息
            this._addStarsList(list);
            // 添加折扣图信息
            this._addDiscount(list);
            this._addSizeList(list);
            this._addDiscountInfo(list);
            // 合并商品列表
            this.setState({
                scrollList: [].concat(_toConsumableArray(this.state.scrollList), _toConsumableArray(list))
            });
        }

        //添人气商品

    }, {
        key: "addPopular",
        value: function addPopular(list) {
            this.setState({
                PopularList: [].concat(_toConsumableArray(list))
            });
            this._addDiscount(list, true);
        }

        // 重载list数据

    }, {
        key: "refreshcard",
        value: function refreshcard(list, maxcout) {

            // 初始化滚动条位置
            this.contentEl.current.scrollTop = 0;
            this.setState({
                productList: list,
                scrollList: [],
                SizeList: {},
                iconImgList: null

            });
            this._addStarsList(list); // 添加评价信息
            this._addDiscount(list); // 获取商品折扣
            this._addSizeList(list);
            this._addDiscountInfo(list);
            // 如果存在最大
            if (maxcout) {
                this.setState({
                    maxCount: maxcout
                });
            }
        }
    }, {
        key: "componentDidMount",
        value: function componentDidMount() {
            var _this6 = this;

            // 滚动加载
            this.contentEl.current.addEventListener('scroll', function (e) {
                var scrollTop = e.target.scrollTop;
                var clientHeight = e.target.clientHeight;
                var scrollHeight = e.target.scrollHeight;
                if (scrollTop + clientHeight + 20 >= scrollHeight) {
                    // 如果目前状态是正在加载 或者已经完全加载则不再触发
                    if (_this6.loading || _this6.state.productList.length + _this6.state.scrollList.length >= _this6.state.maxCount) {
                        return;
                    } else {
                        _this6.loading = true;
                        // 执行用户定义的加载事件
                        _this6.onscrollLoad(_this6);
                    }
                }
            });
        }
    }, {
        key: "render",
        value: function render() {
            var _this7 = this;

            // 商品card 盒子样式
            var scrollBoxstyle = {
                height: this.state.height ? this.state.height : $(document).height() - 40 - 67,
                paddingTop: 0,
                marginTop: 0
            };

            return (
                //
                React.createElement(
                    "ul",
                    { className: "productUl  " + this.state.mode + " infinite-scroll scrollHidden page-content",
                        style: scrollBoxstyle,
                        ref: this.contentEl,
                        onScroll: function onScroll(e) {
                            _this7.setState({
                                ScrollTopPosition: e.target.scrollTop
                            });
                        }

                    },
                    React.createElement(
                        CardData.Provider,
                        { value: {
                                isSearch: this.state.isSearch,
                                starList: this.state.starsList,
                                iconImgList: this.state.iconImgList,
                                showBtn: this.state.ShowPopBtn,
                                sizeData: this.state.SizeList,
                                discountList: this.state.discountInfoList,
                                mode: this.state.mode,
                                isClass: this.state.isClass
                            } },
                        React.createElement(ProductList, { cardList: this.state.productList }),
                        this.state.PopularList.length > 0 ? React.createElement(PopularList, { cardList: this.state.PopularList }) : "",
                        React.createElement(ProductList, { cardList: this.state.scrollList })
                    ),
                    this.state.ScrollToTop && this.state.ScrollTopPosition > 50 ? React.createElement(ScrollToTop, { scrollFun: function scrollFun() {
                            // 控制card容器滚动到顶部
                            $(_this7.contentEl.current).animate({ scrollTop: 0 }, 300);
                        } }) : ""
                )
            );
        }
    }]);

    return product;
}(React.Component);

// 商品列表


function ProductList(props) {
    // 接收商品列表
    var cardList = props.cardList;

    var _useContext = useContext(CardData),
        isSearch = _useContext.isSearch,
        isClass = _useContext.isClass;

    return cardList.map(function (item, index) {
        return React.createElement(
            "li",
            { key: item.seriesCode,
                onClick: function onClick() {
                    if (isSearch) {
                        if (item.seriesStatus == '1') {
                            if (isNull(item.partNumber)) {
                                gotoProductInfo(item.seriesCode);
                                gotoSearchProductInfo(item.seriesStatus, item.seriesCode, '', parseInt((searchListPageNum - 1) * pageSize + index + 1), 'this', formatData(item), item.brandName);
                            } else {
                                gotoProductInfo(item.seriesCode, item.partNumber);
                                gotoSearchProductInfo('999', item.seriesCode, item.partNumber, parseInt((searchListPageNum - 1) * pageSize + index + 1), 'this', formatData(item), item.brandName);
                            }
                        } else if (item.seriesStatus == '3') {
                            gotoProductInfo(item.seriesCode, item.partNumber);
                        } else {

                            gotoSearchProductInfo(item.seriesStatus, item.seriesCode, item.partNumber, parseInt((searchListPageNum - 1) * pageSize + index + 1), 'this', formatData(item), item.brandName);
                        }
                    } else {
                        if (isClass) {
                            if (isMiniProgram()) {
                                var RecommendObj = SensorsSearchPage({ detail: { seriesList: [item] } });
                                sensors.track("ProductClick", Object.assign({
                                    button_type: '商品栏',
                                    button_name: '预览商品'
                                }, RecommendObj));
                            }
                            productClick(item.seriesCode);
                            gotoProductInfo(item.seriesCode);
                        } else {
                            gotoProductInfo(item.seriesCode);
                        }
                    }
                } },
            React.createElement(
                "a",
                { style: { width: '100%' }, href: '/vona2/detail/' + item.seriesCode + '/', onClick: function onClick(e) {
                        e.preventDefault();
                        return false;
                    } },
                React.createElement(Productcard, { cardInfo: item, zhekouicon: true, isclass: isClass })
            )
        );
    });
}

// 人气商品
function PopularList(props) {
    // 获取商品列表
    var cardList = props.cardList;

    var _useContext2 = useContext(CardData),
        isSearch = _useContext2.isSearch,
        isClass = _useContext2.isClass;

    console.log('666', isClass);
    return React.createElement(
        "div",
        { className: "topPopularSeriesView" },
        React.createElement(
            "p",
            { className: "title" },
            "\u4EBA\u6C14\u5546\u54C1"
        ),
        React.createElement(
            "ul",
            { className: "cardbox" },
            cardList.map(function (item, index) {
                if (index < 2) {
                    return React.createElement(
                        "li",
                        { key: item.itemCd,
                            onClick: function onClick() {
                                gotoProductInfo(item.itemCd, '', '', '', '', '', isClass);
                            } },
                        React.createElement(Popularcard, { cardInfo: item, isPopular: true, zhekouicon: true })
                    );
                } else {
                    return "";
                }
            })
        )
    );
}

// 普通商品card
function Productcard(props) {
    var isClass = props.isclass;
    // 获取单个card详情
    var cardInfo = props.cardInfo;
    // 获取当前商品的code信息
    var seriesCode = cardInfo.seriesCode;
    // 是否是人气商品card.
    var isPopular = props.isPopular ? props.isPopular : false;
    // 获取购物按钮.图标icon详情,和评价详情

    var _useContext3 = useContext(CardData),
        showBtn = _useContext3.showBtn,
        iconImgList = _useContext3.iconImgList,
        starList = _useContext3.starList,
        sizeData = _useContext3.sizeData,
        discountList = _useContext3.discountList;
    // 获取当前物品的评价


    var starData = starList.find(function (el) {
        return el.seriesCd == cardInfo.seriesCode;
    });
    var discountInfo = discountList.find(function (el) {
        return el.seriesCode == cardInfo.seriesCode;
    });
    var complexImgUrlList;
    // 活动图片地址
    if (props.zhekouicon) {
        complexImgUrlList = iconImgList && iconImgList[seriesCode] ? iconImgList[seriesCode] : [];
    } else {
        complexImgUrlList = [];
    }
    // 商品图片地址
    var commodityImgSrc = window.location.origin + '/static/html/images/bg/placeholder.png';

    if (cardInfo.productImageList.length > 0) {
        commodityImgSrc = replacePreset(cardInfo.productImageList[0] ? cardInfo.productImageList[0].url : "", 't_product_view_b');
    }
    // 获取蓝色图标icon
    var buleIconList = getBuleList(cardInfo);
    // 获取红色图标icon
    var redIconList = getRedList(cardInfo, discountInfo);
    //商品价格(多少起)
    var price = comparePrice(cardInfo.minStandardUnitPrice, cardInfo.maxStandardUnitPrice);
    // 分离整数和小数部分
    var arrPrice = price !== "-" ? price.split(".") : [];
    var sizeUrl = getSizeChart(seriesCode, sizeData);
    var altUlr = getAltChart(seriesCode, sizeData);
    var drwImgUrl = getImgChart(seriesCode, sizeData);
    var showseriesName = "";
    if (!isNull(cardInfo.partNumber)) {
        showseriesName = cardInfo.partNumber;
    }
    if (!isNull(showseriesName)) {
        if (!isNull(cardInfo.seriesName)) {
            showseriesName += "[" + cardInfo.seriesName + "]";
        }
    } else {
        if (!isNull(cardInfo.seriesName)) {
            showseriesName = cardInfo.seriesName;
        }
    }

    // 小数补零
    if (arrPrice.length == 1) {
        arrPrice.push("00");
    }
    // 参考价格
    var referencePrice = cardInfo.minPricePerPiece ? cardInfo.minPricePerPiece : null;

    return React.createElement(
        "div",
        { className: "card recProductCard" },
        cardInfo.seriesStatus == '3' ? React.createElement(DiscontinuedHead, { discontinuedDate: cardInfo.discontinuedDate,
            alternativeMessage: cardInfo.alternativeMessage }) : "",
        React.createElement(
            "div",
            { className: "cardIcon" },
            cardInfo.seriesStatus == '2' ? React.createElement(
                "div",
                { style: {
                        "fontSize": '11px',
                        "color": '#ff730a',
                        "paddingBottom": '3px',
                        "display": 'flex',
                        "alignItems": 'center'
                    } },
                React.createElement(
                    "span",
                    { className: "tag_list_border_unopen" },
                    "\u6682\u672A\u516C\u5F00\u5546\u54C1\u4FE1\u606F"
                )
            ) : '',
            cardInfo.cValueFlag && cardInfo.cValueFlag === "1" ? React.createElement("span", { className: "tag_c_value", style: {
                    marginRight: "5px"
                } }) : "",
            complexImgUrlList.map(function (item, index) {
                return React.createElement(Icon, { key: index, type: "img", url: item });
            }),
            !isPopular ? cardInfo.promptDeliveryFlag && cardInfo.promptDeliveryFlag == "1" ? React.createElement(Icon, { type: "yellow" }) : "" : "",
            !isPopular ? redIconList.map(function (item) {
                return React.createElement(Icon, { type: "red", text: item });
            }) : "",
            !isPopular ? buleIconList.map(function (item) {
                return React.createElement(Icon, { type: "blue", text: item });
            }) : ""
        ),
        React.createElement(
            "div",
            { className: "cardInfo" },
            React.createElement(
                "div",
                { className: "cardInfoleft" },
                React.createElement(
                    "div",
                    { className: "img-box", style: { 'border-radius': '0' } },
                    React.createElement("img", {
                        src: drwImgUrl ? drwImgUrl : commodityImgSrc,
                        onError: function onError(event) {
                            return imgLoadError(event.target);
                        },
                        className: "cardImg",
                        alt: showseriesName }),
                    cardInfo.seriesStatus == '3' ? React.createElement(
                        "div",
                        { className: "img-label", style: {
                                'background': "rgba(205,205,205,.8)",
                                'color': '#333333',
                                'height': '26px',
                                'line-height': '26px'
                            } },
                        "\u5DF2\u505C\u552E"
                    ) : ''
                ),
                React.createElement(
                    "p",
                    { className: "drawing" },
                    sizeUrl ? React.createElement(
                        "span",
                        { className: "tag_list_blue2 drwspan", onClick: function onClick(e) {
                                e.preventDefault();
                                e.stopPropagation();
                                openDrwPath(sizeUrl);
                            } },
                        "\u5C3A\u5BF8\u56FE"
                    ) : "",
                    altUlr ? React.createElement(
                        "span",
                        { className: "tag_list_blue2 drwspan", onClick: function onClick(e) {
                                e.preventDefault();
                                e.stopPropagation();
                                openDrwPathZ(altUlr);
                            } },
                        "\u8FFD\u52A0\u5DE5\u56FE"
                    ) : ""
                )
            ),
            React.createElement(
                "div",
                { className: "cardInfoRight" },
                React.createElement(
                    "p",
                    { className: "cardtitle" },
                    showseriesName
                ),
                React.createElement(
                    "p",
                    { style: {
                            display: "flex",
                            width: "100%",
                            justifContent: "space-between",
                            algignItems: "center",
                            flexWrap: "wrap"
                        } },
                    React.createElement(
                        "span",
                        { className: "brandName" },
                        cardInfo.brandName
                    ),
                    !isPopular ? React.createElement(CardStatus, { cardInfo: cardInfo }) : ""
                ),
                price !== "-" && !isPopular ? React.createElement(
                    "p",
                    { className: "priceLine" },
                    React.createElement(
                        "span",
                        { className: "priceSymbol" },
                        "\xA5"
                    ),
                    React.createElement(
                        "span",
                        { className: "price int" },
                        arrPrice[0] + "."
                    ),
                    React.createElement(
                        "span",
                        { className: "price float" },
                        arrPrice[1]
                    ),
                    React.createElement(
                        "span",
                        { className: "referencePrice" },
                        "(",
                        "\u53C2\u8003\u5355\u4EF7:\xA5" + referencePrice,
                        ")"
                    ),
                    showBtn ? React.createElement(
                        "div",
                        { className: "buyBtn",

                            onClick: function onClick(e) {
                                if (isClass && isMiniProgram()) {
                                    var RecommendObj = sensorsProductPage(cardInfo);
                                    sensors.track("ProductClick", Object.assign({
                                        button_type: '商品栏',
                                        button_name: '加入购物车'
                                    }, RecommendObj));
                                }
                                // 阻止react上的事件冒泡
                                e.preventDefault();
                                e.stopPropagation();
                                // 调用底部弹窗
                                openModelListPop(seriesCode);
                            }
                        },
                        React.createElement("img", { src: "/static/html/images/icon/icon_addCart_endclass.png" })
                    ) : ""
                ) : ""
            )
        )
    );
}

// 人气商品card
function Popularcard(props) {
    // 获取单个card详情
    var cardInfo = props.cardInfo;
    // 获取当前商品的code信息
    var seriesCode = cardInfo.itemCd;
    // 是否是人气商品card.
    var isPopular = props.isPopular ? props.isPopular : false;
    // 获取购物按钮.图标icon详情,和评价详情

    var _useContext4 = useContext(CardData),
        showBtn = _useContext4.showBtn,
        iconImgList = _useContext4.iconImgList,
        starList = _useContext4.starList,
        sizeData = _useContext4.sizeData,
        discountList = _useContext4.discountList;
    // 获取当前物品的评价


    var starData = starList.find(function (el) {
        return el.seriesCd == cardInfo.seriesCode;
    });
    var discountInfo = discountList.find(function (el) {
        return el.seriesCode == cardInfo.seriesCode;
    });
    var complexImgUrlList;
    // 活动图片地址
    if (props.zhekouicon) {
        complexImgUrlList = iconImgList && iconImgList[seriesCode] ? iconImgList[seriesCode] : [];
    } else {
        complexImgUrlList = [];
    }
    // 商品图片地址
    var commodityImgSrc = cardInfo.imgUrl;
    // 获取红色图标icon
    //商品价格(多少起)
    var price = comparePrice(cardInfo.minStandardUnitPrice, cardInfo.maxStandardUnitPrice);
    // 分离整数和小数部分
    var arrPrice = price !== "-" ? price.split(".") : [];
    var sizeUrl = getSizeChart(seriesCode, sizeData);
    var altUlr = getAltChart(seriesCode, sizeData);
    var drwImgUrl = getImgChart(seriesCode, sizeData);
    var showseriesName = "";
    if (!isNull(cardInfo.partNumber)) {
        showseriesName = cardInfo.partNumber;
    }
    if (!isNull(showseriesName)) {
        if (!isNull(cardInfo.seriesName)) {
            showseriesName += "[" + cardInfo.name + "]";
        }
    } else {
        if (!isNull(cardInfo.name)) {
            showseriesName = cardInfo.name;
        }
    }

    // 小数补零
    if (arrPrice.length == 1) {
        arrPrice.push("00");
    }
    // 参考价格
    var referencePrice = cardInfo.minPricePerPiece ? cardInfo.minPricePerPiece : null;

    return React.createElement(
        "div",
        { className: "card recProductCard" },
        React.createElement(
            "div",
            { className: "cardIcon" },
            cardInfo.seriesStatus == '2' ? React.createElement(
                "div",
                { style: {
                        "fontSize": '11px',
                        "color": '#ff730a',
                        "paddingBottom": '3px',
                        "display": 'flex',
                        "alignItems": 'center'
                    } },
                React.createElement(
                    "span",
                    { className: "tag_list_border_unopen" },
                    "\u6682\u672A\u516C\u5F00\u5546\u54C1\u4FE1\u606F"
                )
            ) : '',
            cardInfo.cValueFlag && cardInfo.cValueFlag === "1" ? React.createElement("span", { className: "tag_c_value", style: {
                    marginRight: "5px"
                } }) : "",
            complexImgUrlList.map(function (item, index) {
                return React.createElement(Icon, { key: index, type: "img", url: item });
            }),
            !isPopular ? cardInfo.promptDeliveryFlag && cardInfo.promptDeliveryFlag == "1" ? React.createElement(Icon, { type: "yellow" }) : "" : "",
            !isPopular ? redIconList.map(function (item) {
                return React.createElement(Icon, { type: "red", text: item });
            }) : "",
            !isPopular ? buleIconList.map(function (item) {
                return React.createElement(Icon, { type: "blue", text: item });
            }) : ""
        ),
        React.createElement(
            "div",
            { className: "cardInfo" },
            React.createElement(
                "div",
                { className: "cardInfoleft" },
                React.createElement("img", {
                    src: drwImgUrl ? drwImgUrl : commodityImgSrc,
                    onError: function onError(event) {
                        return imgLoadError(event.target);
                    },
                    className: "cardImg",
                    alt: showseriesName }),
                React.createElement(
                    "p",
                    { className: "drawing" },
                    sizeUrl ? React.createElement(
                        "span",
                        { className: "tag_list_blue2 drwspan", onClick: function onClick(e) {
                                e.stopPropagation();
                                openDrwPath(sizeUrl);
                            } },
                        "\u5C3A\u5BF8\u56FE"
                    ) : "",
                    altUlr ? React.createElement(
                        "span",
                        { className: "tag_list_blue2 drwspan", onClick: function onClick(e) {
                                e.stopPropagation();
                                openDrwPathZ(altUlr);
                            } },
                        "\u8FFD\u52A0\u5DE5\u56FE"
                    ) : ""
                )
            ),
            React.createElement(
                "div",
                { className: "cardInfoRight" },
                React.createElement(
                    "p",
                    { className: "cardtitle" },
                    showseriesName
                ),
                React.createElement(
                    "p",
                    { style: {
                            display: "flex",
                            width: "100%",
                            justifContent: "space-between",
                            algignItems: "center",
                            flexWrap: "wrap"
                        } },
                    React.createElement(
                        "span",
                        { className: "brandName" },
                        cardInfo.maker
                    ),
                    !isPopular ? React.createElement(CardStatus, { cardInfo: cardInfo }) : ""
                ),
                price !== "-" && !isPopular ? React.createElement(
                    "p",
                    { className: "priceLine" },
                    React.createElement(
                        "span",
                        { className: "priceSymbol" },
                        "\xA5"
                    ),
                    React.createElement(
                        "span",
                        { className: "price int" },
                        arrPrice[0] + "."
                    ),
                    React.createElement(
                        "span",
                        { className: "price float" },
                        arrPrice[1]
                    ),
                    React.createElement(
                        "span",
                        { className: "referencePrice" },
                        "(",
                        "\u53C2\u8003\u5355\u4EF7:\xA5" + referencePrice,
                        ")"
                    ),
                    showBtn ? React.createElement(
                        "div",
                        { className: "buyBtn",

                            onClick: function onClick(e) {
                                // 阻止react上的事件冒泡
                                e.stopPropagation();
                                // 调用底部弹窗
                                openModelListPop(seriesCode);
                            }
                        },
                        React.createElement("img", { src: "/static/html/images/icon/icon_addCart_endclass.png" })
                    ) : ""
                ) : ""
            )
        )
    );
}

function DiscontinuedHead(props) {
    // 获取模式 卡片?列表
    var _useContext5 = useContext(CardData),
        mode = _useContext5.mode;
    // 替代品型号


    var partNumber = extractFirstModel(props.alternativeMessage);
    var discontinuedDate = props.discontinuedDate ? new Date(props.discontinuedDate) : '';
    return React.createElement(
        "div",
        { className: "discontinued", onClick: function onClick(event) {
                event.preventDefault();
                event.stopPropagation();
            } },
        mode === "listMode" ? partNumber && discontinuedDate ? React.createElement(
            "div",
            { className: "text" },
            "*\u81EA",
            discontinuedDate.getFullYear(),
            "\u5E74",
            parseInt(discontinuedDate.getMonth() + 1),
            "\u6708\u8D77\u6B64\u5546\u54C1\u5DF2\u505C\u6B62\u9500\u552E\uFF0C\u578B\u53F7\u5347\u7EA7\u4E3A",
            React.createElement(
                "span",
                { style: {
                        color: '#003399',
                        overflow: 'hidden',
                        textOverflow: 'ellipsis',
                        whiteSpace: 'nowrap',
                        display: 'inherit',
                        width: '100%',
                        textIndent: '6px'
                    } },
                partNumber
            )
        ) : partNumber && !discontinuedDate ? React.createElement(
            "div",
            { className: "text" },
            "\u6B64\u5546\u54C1\u5DF2\u505C\u6B62\u9500\u552E\uFF0C\u578B\u53F7\u5347\u7EA7\u4E3A",
            React.createElement(
                "span",
                { style: {
                        color: '#003399',
                        overflow: 'hidden',
                        textOverflow: 'ellipsis',
                        whiteSpace: 'nowrap',
                        display: 'inherit',
                        width: '100%',
                        textIndent: '6px'
                    } },
                partNumber
            )
        ) : !partNumber && discontinuedDate ? React.createElement(
            "div",
            { className: "text" },
            "*\u81EA",
            discontinuedDate.getFullYear(),
            "\u5E74",
            parseInt(discontinuedDate.getMonth() + 1),
            "\u6708\u8D77\u6B64\u5546\u54C1\u5DF2\u505C\u6B62\u9500\u552E "
        ) : React.createElement(
            "div",
            { className: "text" },
            "\u6B64\u5546\u54C1\u5DF2\u505C\u6B62\u9500\u552E"
        ) : React.createElement(
            "div",
            { className: "text" },
            "\u6B64\u5546\u54C1\u5DF2\u505C\u6B62\u9500\u552E"
        ),
        partNumber ? mode === "listMode" ? React.createElement(
            "div",
            { className: "discontinuedBtn", onClick: function onClick(event) {
                    event.preventDefault();
                    event.stopPropagation();
                    openTipsModal(props, mode);
                } },
            "\u67E5\u770B"
        ) : React.createElement(
            "div",
            { style: { color: '#003399', fontSize: '12px' }, onClick: function onClick(event) {
                    event.preventDefault();
                    event.stopPropagation();
                    openTipsModal(props, mode);
                } },
            "\u67E5\u770B\xA0>"
        ) : ""
    );
}

function openTipsModal(props, mode) {
    // 获取模式 卡片?列表
    if (mode == 'listMode') {
        sensors.track("CommonClick", {
            button_type: '搜索结果-列表模式',
            button_name: '查看代替品',
            content: '停售改善',
            current_page: '搜索结果页'
        });
    } else {
        sensors.track("CommonClick", {
            button_type: '搜索结果-大图模式',
            button_name: '查看代替品',
            content: '停售改善',
            current_page: '搜索结果页'
        });
    }
    var partNumber = extractFirstModel(props.alternativeMessage);
    var discontinuedDate = props.discontinuedDate ? new Date(props.discontinuedDate) : '';
    if (partNumber) {

        var text = "\u81EA" + discontinuedDate.getFullYear() + "\u5E74" + parseInt(discontinuedDate.getMonth() + 1) + "\u6708\u8D77\u6B64\u5546\u54C1\u5DF2\u505C\u6B62\u9500\u552E\uFF0C\u578B\u53F7\u5347\u7EA7\u4E3A<br/><span style=\"color:#003399;width: 91%;\n        display: block;\n        word-wrap: break-word;margin: 0 auto\n        \">" + partNumber + "</span>";
        openDiscontinuedPopup(text, '查看替代品', true, true, function () {
            sensors.track("CommonClick", {
                button_type: '代替品提示弹窗',
                button_name: '查看代替品',
                content: '停售改善',
                current_page: '搜索结果页'
            });
            try {
                var requestBody = {
                    requestList: [{
                        apiId: "API011",
                        request: {
                            keyword: partNumber,
                            size: 10
                        }
                    }, {
                        apiId: "API012",
                        request: {
                            keyword: partNumber,
                            size: 10
                        }
                    }]
                };
                var action = WebUtils.preEcApi(api_batch);
                WebUtils.ajaxPostSubmitJson(action, JSON.stringify(requestBody), function (result) {
                    var responseList = result.responseList ? result.responseList : [];
                    var partNumberList = responseList.find(function (el) {
                        return el.apiId == "API012";
                    }).response.partNumberList;
                    var seriesCodeItem = partNumberList.find(function (el) {
                        return el.partNumber == partNumber;
                    });
                    var seriesCode = seriesCodeItem ? seriesCodeItem.seriesCode ? seriesCodeItem.seriesCode : '' : '';
                    if (!isNull(seriesCode)) {
                        gotoProductInfo(seriesCode, partNumber, '', '', true);
                    } else {
                        var url = jumpUrl + "/vona2/result/?Keyword=" + encodeURIComponent(partNumber) + '&isDiscount=1';
                        window.location.href = url;
                    }
                }, function (error) {
                    var url = jumpUrl + "/vona2/result/?Keyword=" + encodeURIComponent(partNumber) + '&isDiscount=1';
                    window.location.href = url;
                }, function (XHR, TS) {//complete

                });
            } catch (err) {}
        }, function () {
            sensors.track("CommonClick", {
                button_type: '代替品提示弹窗',
                button_name: '我知道了',
                content: '停售改善',
                current_page: '搜索结果页'
            });
        });
    } else {
        var _text = "\u81EA" + discontinuedDate + "\u8D77\u6B64\u5546\u54C1\u5DF2\u505C\u6B62\u9500\u552E";
        openDiscontinuedPopup(_text, '', false, true, function () {}, function () {
            sensors.track("CommonClick", {
                button_type: '代替品提示弹窗',
                button_name: '我知道了',
                content: '停售改善',
                current_page: '搜索结果页'
            });
        });
    }
}

function openDiscontinuedPopup(text, btnText, isTwo, isClose, btnCallback, closeCallback) {
    $('.discontinued-popup-bg').remove();
    $('.discontinued-popup-wrap').remove();
    var body = document.body;
    var bg = document.createElement('div');
    bg.className = 'discontinued-popup-bg';

    var wrap = document.createElement('div');
    wrap.className = "discontinued-popup-wrap";

    var html = "";
    html += "<img class=\"icon\" src=\"/static/html/images/returnImg/img20210511_3.png\">";
    html += "<div class=\"text\">" + text + "</div>";
    if (isTwo) {
        html += "<div class=\"btnTwo\">";
        html += "<a href=\"#\" class=\"btn ok-btn \" style=\"font-size:0.28rem\">\u6211\u77E5\u9053\u4E86</a>";
        html += "<a href=\"#\" class=\"btn look-similar \" style=\"font-size:0.28rem\">" + btnText + "</a>";
        html += "</div>";
    } else {
        html += "<a href=\"#\" class=\"btn1 ok-btn\" style=\"font-size:0.28rem\">\u6211\u77E5\u9053\u4E86</a>";
    }
    if (isClose) {
        html += "<div class=\"close-btn\"></div>";
    }

    body.appendChild(bg);
    body.appendChild(wrap);
    $(wrap).html(html);
    // wrap.appendChild(html)

    $(bg).show().animate({
        opacity: 1
    });
    $(wrap).show();

    $('.look-similar').unbind('click').click(function () {
        $(bg).remove();
        $(wrap).remove();
        if (btnCallback && typeof btnCallback == 'function') {
            btnCallback();
        }
    });
    $('.ok-btn').unbind('click').click(function () {
        $(bg).remove();
        $(wrap).remove();
        if (closeCallback && typeof closeCallback == 'function') {
            closeCallback && closeCallback();
        }
    });
    $('.close-btn').unbind('click').click(function () {
        $(bg).remove();
        $(wrap).remove();
        if (closeCallback && typeof closeCallback == 'function') {
            // closeCallback && closeCallback()
        }
    });
}

function extractFirstModel(str) {
    if (str) {
        var regex = /<([^>]+)>/;
        var match = str.match(regex);
        return match ? match[1] : null;
    } else {
        return '';
    }
}

// Icon组件
function Icon(props) {
    // icon类型
    var type = props.type;
    // 获取用户自定义样式
    var iconStyle = {};
    if (!isNull(props.style)) {
        iconStyle = props.style;
    }
    if (type === "yellow") {
        return React.createElement(
            "div",
            { className: "tag_shanda_yellow" },
            "\u7C73\u601D\u7C73\u95EA\u8FBE"
        );
    }

    if (type === 'red' || type === 'blue') {
        // 文字图标
        return React.createElement(
            "div",
            { className: "icon" + type, style: iconStyle },
            props.text
        );
    } else if (type === 'img' && !isNull(props.url)) {
        // 图片图标
        return React.createElement("img", { style: { zoom: "0.5" }, src: props.url, alt: "" });
    } else if (type === "customize") {
        // 自定义图标
        return React.createElement(
            "div",
            { style: iconStyle },
            props.children
        );
    } else {
        return null;
    }
}

function CardStatus(props) {
    var Status = props.cardInfo.seriesStatus;
    if (Status === "3") {
        var style = {
            float: "right",
            marginTop: "8px",
            padding: "0 8px",
            borderRadius: "6px",
            textAlign: "center",
            backgroundColor: "#F6F6F6",
            fontSize: "10px",
            color: "#999999",
            lineHeight: "20px",
            fontWeight: "800"

        };

        return React.createElement("div", {
            style: style });
    } else if (Status === "2") {
        var _style = {
            float: "right",
            marginTop: "8px",
            padding: "0 8px",
            borderRadius: "6px",
            textAlign: "center",
            backgroundColor: "#003399",
            fontSize: "10px",
            color: "white",
            lineHeight: "20px",
            fontWeight: "800"
        };

        return React.createElement(
            "div",
            { className: "buyUnopenBtn",
                style: _style },
            "\u53EF\u8BA2\u8D2D"
        );
    } else {
        return React.createElement(
            "span",
            {
                className: "shipDate" },
            calCulatedeliveryDateNew(props.cardInfo.minStandardDaysToShip, props.cardInfo.maxStandardDaysToShip)
        );
    }
}

// 星星组件
function Stars(props) {
    var starData = props.starData;

    var starsList = new Array(5).fill("");
    // 评价为0时
    if (isNull(starData) || starData.stars == 0) {
        return React.createElement(
            "p",
            null,
            React.createElement(
                "div",
                { className: "nostar" },
                "\u6682\u65E0\u8BC4\u4EF7"
            )
        );
    }
    var stars = starData.stars;
    //商品评价分数格式化 3舍7入
    starsList.forEach(function (item, index) {
        // 剩余评价大于0.7时为一整颗星
        if (stars - index >= 0.7) {
            starsList[index] = "full";
        } else if (stars - index >= 0.3) {
            // 剩余评价大于0.3小于0.7为半颗星
            starsList[index] = "half";
        }
    });
    var reviewStars = starData.stars * 10;
    var subStars = reviewStars % 10;
    var level_num = 0;
    if (subStars <= 3) {
        level_num = Math.floor(reviewStars / 10).toFixed(1);
    } else if (subStars >= 7) {
        level_num = Math.ceil(reviewStars / 10).toFixed(1);
    } else {
        level_num = Number(Math.floor(reviewStars / 10).toFixed(1)) + 0.5;
    }

    return React.createElement(
        "p",
        { style: {
                lineHeight: 1,
                textAlign: "center",
                height: "10px"
            } },
        starsList.map(function (item) {
            return React.createElement("label", { className: item + " star" });
        }),
        React.createElement(
            "span",
            { className: "starNum" },
            level_num
        )
    );
}

// 滚动到顶部的按钮
function ScrollToTop(props) {
    return React.createElement("img", {
        onClick: function onClick() {
            // 执行接受到的回调函数
            props.scrollFun();
        },
        id: "productInfoScrollToTopComplex", src: "../images/icon/ic_goTop.png", alt: "回到顶部", style: {
            position: 'fixed',
            width: '40px',
            right: '15px',
            bottom: '10px'
        } });
}