index.js 4.8 KB
function t(t, a, e) {
    return a in t ? Object.defineProperty(t, a, {
        value: e,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : t[a] = e, t;
}

var a, e = require("../../../utils/util"),
    o = require("../../restapi"),
    d = getApp();

Page((a = {
    data: {
        searchText: "",
        historyList: [],
        queryCondition: {},
        list: [],
        spaProductCode: "",
        code: "",
        yearActive: "",
        yearList: [],
        modelList: [],
        checkList: [],
        maxNumber: 9999,
        showPopup: !1,
        popupTitle: "",
        secondTitle: "",
        popupId: "",
        popupHeight: "0%",
        showNodata: !1
    },
    onLoad: function (t) {
        wx.setNavigationBarTitle({
            title: "搜索"
        }), this.setData({
            code: t.code,
            audiId: t.audiId,
            motorcycle: t.motorcycle
        });
    },
    onReady: function () {},
    onShow: function () {
        var t = wx.getStorageSync("history") || [];
        this.setData({
            historyList: t
        });
    },
    clearHistory: function () {
        this.setData({
            historyList: []
        }), wx.removeStorageSync("history");
    },
    onChange: function (t) {
        this.setData({
            spaProductCode: t.detail
        });
    },
    getParams: function () {
        var t = d.globalData.userInfo,
            a = {};
        return a.merchantCode = t.merchant.merchantId, a;
    },
    onSearch: function () {
        var t = this,
            a = wx.getStorageSync("history") || [],
            e = t.data.spaProductCode,
            o = t.data.queryCondition || {};
        if (!e) return !1;
        a.findIndex(function (t) {
                return t == e;
            }) < 0 && a.push(e), t.data.audiId && "undefined" != t.data.audiId && (o.audiId = t.data.audiId),
            t.data.motorcycle && "undefined" != t.data.motorcycle && (o.motorcycle = t.data.motorcycle),
            console.log(o), wx.setStorageSync("history", a), t.setData({
                spaProductCode: e,
                queryCondition: o
            }), this.getType();
    }
}, t(a, "getParams", function () {
    var t = d.globalData.userInfo,
        a = {};
    return a.merchantCode = t.merchant.merchantId, a.spaProductCode = this.data.spaProductCode,
        a;
}), t(a, "inputEvent", function (t) {
    var a = {};
    a[t.currentTarget.id] = t.detail.value, this.setData(a);
}), t(a, "clickEvent", function (t) {
    var a = t.currentTarget.dataset.name,
        e = this.data.queryCondition || {};
    this.data.audiId && "undefined" != this.data.audiId && (e.audiId = this.data.audiId),
        this.data.motorcycle && "undefined" != this.data.motorcycle && (e.motorcycle = this.data.motorcycle),
        this.setData({
            spaProductCode: a,
            queryCondition: e
        }), this.getType();
}), t(a, "openShoppingCar", function (t) {
    var a = t.currentTarget.id,
        e = t.currentTarget.dataset.code,
        o = t.currentTarget.dataset.config,
        d = t.currentTarget.dataset.id,
        i = t.currentTarget.dataset.name;
    this.setData({
        showPopup: !0,
        popupTitle: i,
        secondTitle: d,
        popupId: a,
        glsxProductCode: e,
        productConfigCode: o
    });
}), t(a, "closeDialog", function () {
    this.setData({
        showPopup: !1
    });
}), t(a, "configChange", function (t) {
    var a = t.detail,
        e = 0 != a.close;
    a && this.setData({
        showPopup: e
    });
}), t(a, "batchAddEvent", function () {
    var t = this.data.popupId;
    "car" != t && this.selectComponent("#" + t).addEvent();
}), t(a, "getType", function () {
    var t = this,
        a = {},
        d = t.getParams();
    t.data.audiId && "undefined" != t.data.audiId && (d.audiId = t.data.audiId), t.data.motorcycle && "undefined" != t.data.motorcycle && (d.motorcycle = t.data.motorcycle),
        a.pageSize = 1e6, a.pageNo = 1, a.queryCondition = d, (0, o.PAGEPRODUCTBYSPACODE)(a, function (a) {
            if (console.log(a), 0 != a.returnCode) return (0, e.showToast)(a.message), !1;
            var o = ((a.data || {}).listGhProductConfig || [])[0] || {},
                d = "";
            if (!o.categoryId) return (0, e.showToast)("暂无产品信息"), !1;
            "N" == o.displayConfig && (d = "setting"), "C" == o.displayConfig && (d = "setting"),
                "Y" == o.displayConfig && (d = "model"), console.log("555555555555"), t.setData({
                    popupId: d,
                    showPopup: !0,
                    productConfigCode: o.productConfigCode,
                    displayConfig: o.displayConfig,
                    popupTitle: o.spaProductName,
                    secondTitle: o.spaProductCode,
                    showNodata: !o.categoryId
                });
        });
}), a));