index.js 8.48 KB
var t = function(t) {
    return t && t.__esModule ? t : {
        default: t
    };
}(require("../../../utils/filter.js")), e = require("./restapi.js"), a = require("../../../utils/util"), i = getApp();

Page(t.default.identityFilter({
    data: {
        menuActive: 1,
        menuList: [ {
            name: "车载导航",
            id: 1
        }, {
            name: "爱车保镖",
            id: 2
        }, {
            name: "电子辅助",
            id: 3
        }, {
            name: "配件",
            id: 4
        } ],
        showPopup: !1,
        popupTitle: "",
        secondTitle: "",
        popupId: "",
        showSelectCar: !1,
        productList: [],
        glsxProductCode: "",
        queryCondition: {},
        seriesList: [],
        modelList: [],
        showSeries: "",
        seriesInfo: {},
        modelInfo: {},
        pageSize: 10,
        currentPage: 0,
        tabActive: "1",
        shoppingNumber: 0,
        userInfo: "",
        icon: {
            active: "https://img01.glsx.com.cn/weapp/resource/eims/radio_active.png",
            normal: "https://img01.glsx.com.cn/weapp/resource/eims/radio_normal.png"
        },
        allcheck: !1,
        displayConfig: ""
    },
    onLoad: function(t) {
        var e = this;
        wx.setNavigationBarTitle({
            title: "在线采购"
        });
        var n = setInterval(function() {
            i.globalData.userInfo && (clearInterval(n), (0, a.hideLoading)(), e.setData({
                userInfo: i.globalData.userInfo
            }), e.getList(), e.getBrand());
        }, 100);
    },
    onReady: function() {},
    onLogin: function() {},
    onShow: function() {
        this.getShoppingCarList();
    },
    onReachBottom: function() {
        console.log("55555555555"), 3 == this.data.tabActive && this.selectComponent("#orderList").getList(), 
        this.getProduct();
    },
    menuEvent: function(t) {
        var e = t.currentTarget.dataset.id;
        this.setData({
            menuActive: e,
            currentPage: 0,
            isLast: !1
        }), this.getProduct();
    },
    openShoppingCar: function(t) {
        var e = t.currentTarget.id, a = t.currentTarget.dataset.code, i = t.currentTarget.dataset.config, n = t.currentTarget.dataset.id, o = t.currentTarget.dataset.name, r = t.currentTarget.dataset.type;
        this.setData({
            showPopup: !0,
            popupTitle: o,
            secondTitle: n,
            popupId: e,
            glsxProductCode: a,
            productConfigCode: i,
            displayConfig: r
        });
    },
    closeDialog: function() {
        this.setData({
            showPopup: !1,
            isDelete: !1,
            allcheck: !1
        }), this.getShoppingCarList();
    },
    getList: function() {
        var t = this, a = t.getParams();
        a.type = 27, (0, e.GETTYPELIST)(a, function(e) {
            if (0 == e.returnCode) {
                var a = e.data || [];
                t.setData({
                    menuList: a,
                    menuActive: a[0].id
                }), t.getProduct();
            }
        });
    },
    getBrand: function() {
        var t = this, i = t.getParams();
        i.pageSize = 1e4, i.pageNo = 1, (0, e.GETBRANDLIST)(i, function(e) {
            if (0 == e.returnCode) {
                var i = e.data || {};
                t.setData({
                    seriesList: i.listAudiMotorcycle
                });
            } else (0, a.showToast)(e.message);
        });
    },
    getProduct: function() {
        var t = this, i = {}, n = t.getParams(), o = t.data.currentPage + 1;
        if (n.categoryId = t.data.menuActive, n.audiId = t.data.seriesInfo.id, n.motorcycle = t.data.modelInfo.name, 
        i.queryCondition = n, i.pageSize = t.data.pageSize, i.pageNo = o, t.data.isLast) return !1;
        (0, a.showLoading)("加载中..."), (0, e.GETPRODUCTLIST)(i, function(e) {
            if ((0, a.hideLoading)(), 0 == e.returnCode) {
                var i = e.data || {}, n = i.listGhProductConfig || [], r = t.data.productList || [], s = [];
                n.length < 10 && t.setData({
                    isLast: !0
                }), t.setData({
                    currentPage: o
                }), s = o > 1 ? n.concat(r) : n, t.setData({
                    productList: s,
                    queryCondition: i.queryCondition
                });
            }
        });
    },
    goSearch: function() {
        var t = this.data.seriesInfo || {}, e = this.data.modelInfo || {};
        wx.navigateTo({
            url: "/packageIndex/pages/search/index?code=" + this.data.glsxProductCode + "&audiId=" + t.id + "&motorcycle=" + e.name
        });
    },
    getParams: function() {
        var t = i.globalData.userInfo, e = {};
        console.log(t)
        return e.merchantCode = t.merchant.merchantId, e;
    },
    openDialog: function(t) {
        var e = t.currentTarget.dataset.id;
        this.setData({
            showSelectCar: !0,
            showSeries: e
        });
    },
    closeCarDialog: function() {
        this.setData({
            showSelectCar: !1
        });
    },
    configChange: function(t) {
        var e = t.detail;
        0 == e.close && this.closeDialog(), this.setData(e);
    },
    addEvent: function(t) {
        var i = this, n = t.currentTarget.dataset.code, o = i.data.productList, r = i.getParams();
        r.productConfigCode = n, r.total = 1, r.remark = "";
        var s = [];
        (o.find(function(t) {
            return t.productConfigCode == n;
        }).listConfigOther || []).map(function(t) {
            "F" == t.option && s.push(t.attribInfoId);
        }), r.listCartConfig = s, (0, e.ADDGHPRODUCTCONFIGCART)(r, function(t) {
            0 == t.returnCode && ((0, a.showToast)("已加入购物车"), i.getShoppingCarList());
        });
    },
    changeSeries: function(t) {
        var e = t.currentTarget.dataset.id, a = t.currentTarget.dataset.name, i = this.data.seriesList, n = {};
        n.id = e, n.name = a;
        var o = i.find(function(t) {
            return t.audiId == e;
        });
        this.setData({
            seriesInfo: n,
            modelList: o ? o.listMotocyleDto : [],
            modelInfo: {},
            currentPage: 0,
            isLast: !1
        }), this.closeCarDialog(), this.getProduct();
    },
    changeModel: function(t) {
        var e = t.currentTarget.dataset.id, a = t.currentTarget.dataset.name, i = {};
        i.id = e, i.name = a, this.setData({
            modelInfo: i,
            currentPage: 0,
            isLast: !1
        }), this.closeCarDialog(), this.getProduct();
    },
    closeTagEvent: function(t) {
        var e = t.currentTarget.dataset.id, a = {};
        "seriesInfo" == e && (a.modelInfo = {}), a[e] = {}, a.isLast = !1, a.currentPage = 0, 
        a.productList = [], this.setData(a), this.getProduct();
    },
    tabClickEvent: function(t) {
        t.detail, this.setData({
            tabActive: t.detail
        });
        var e = "在线采购", a = this.data.userInfo;
        switch (t.detail) {
          case "2":
            e = a.merchant ? a.merchant.merchantName : "";
            break;

          case "3":
            e = "采购订单";
            break;

          default:
            e = "在线采购";
        }
        wx.setNavigationBarTitle({
            title: e
        });
    },
    getShoppingCarList: function() {
        var t = this, i = t.getParams();
        i.pageSize = 1e5, i.pageNo = 1, (0, e.LISTGHSHOPPINGCART)(i, function(e) {
            if (0 == e.returnCode) {
                var i = (e.data || {}).listGhShoppingCart || [];
                t.setData({
                    shoppingNumber: i.length
                });
            } else (0, a.showToast)(e.message);
        });
    },
    goLogin: function() {
        wx.reLaunch({
            url: "/pages/index/index"
        });
    },
    batchAddEvent: function() {
        var t = this.data.popupId;
        "car" != t && this.selectComponent("#" + t).addEvent();
    },
    allcheckEvent: function(t) {
        var e = this.data.popupId;
        this.setData({
            allcheck: t.detail
        }), this.selectComponent("#" + e).allcheckEvent(t);
    },
    clearEvent: function() {
        var t = this.data.popupId;
        this.selectComponent("#" + t).clearEvent();
    },
    submitOrder: function() {
        var t = this.data.popupId;
        this.selectComponent("#" + t).submitOrder();
    },
    batchDelete: function() {
        var t = this.data.popupId;
        this.selectComponent("#" + t).batchDelete();
    }
}));