384 lines
14 KiB
JavaScript
384 lines
14 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const api_goods = require("../../api/goods.js");
|
|
const utils_helper = require("../../utils/helper.js");
|
|
if (!Array) {
|
|
const _easycom_nut_button2 = common_vendor.resolveComponent("nut-button");
|
|
const _easycom_nut_searchbar2 = common_vendor.resolveComponent("nut-searchbar");
|
|
const _easycom_nut_menu_item2 = common_vendor.resolveComponent("nut-menu-item");
|
|
const _easycom_nut_menu2 = common_vendor.resolveComponent("nut-menu");
|
|
const _easycom_nut_tag2 = common_vendor.resolveComponent("nut-tag");
|
|
const _easycom_z_paging2 = common_vendor.resolveComponent("z-paging");
|
|
(_easycom_nut_button2 + _easycom_nut_searchbar2 + _easycom_nut_menu_item2 + _easycom_nut_menu2 + _easycom_nut_tag2 + _easycom_z_paging2)();
|
|
}
|
|
const _easycom_nut_button = () => "../../uni_modules/nutui-uni/components/button/button.js";
|
|
const _easycom_nut_searchbar = () => "../../uni_modules/nutui-uni/components/searchbar/searchbar.js";
|
|
const _easycom_nut_menu_item = () => "../../uni_modules/nutui-uni/components/menuitem/menuitem.js";
|
|
const _easycom_nut_menu = () => "../../uni_modules/nutui-uni/components/menu/menu.js";
|
|
const _easycom_nut_tag = () => "../../uni_modules/nutui-uni/components/tag/tag.js";
|
|
const _easycom_z_paging = () => "../../uni_modules/z-paging/components/z-paging/z-paging.js";
|
|
if (!Math) {
|
|
(_easycom_nut_button + _easycom_nut_searchbar + _easycom_nut_menu_item + _easycom_nut_menu + _easycom_nut_tag + _easycom_z_paging)();
|
|
}
|
|
const _sfc_main = {
|
|
__name: "goodsList",
|
|
setup(__props) {
|
|
const getImg = (goods) => {
|
|
var _a, _b;
|
|
const url = (_b = (_a = goods == null ? void 0 : goods.image) == null ? void 0 : _a[0]) == null ? void 0 : _b.file_path;
|
|
return url ? url + "?imageView2/1/w/200/h/200" : "";
|
|
};
|
|
const paging = common_vendor.ref(null);
|
|
const dataList = common_vendor.ref([]);
|
|
const selectPriceSortRef = common_vendor.ref(null);
|
|
const selectDegreeRef = common_vendor.ref(null);
|
|
const selectProductRef = common_vendor.ref(null);
|
|
const state = common_vendor.reactive({
|
|
type_params: [],
|
|
// 产品类型
|
|
drop_down_options: [],
|
|
// 产品类型下的品牌列表
|
|
o_drop_down_options: [],
|
|
// 价格排序
|
|
price_sort_params: [
|
|
{
|
|
text: "默认排序",
|
|
value: ""
|
|
},
|
|
{
|
|
text: "价格升序",
|
|
value: "ascend"
|
|
},
|
|
{
|
|
text: "价格降序",
|
|
value: "descend"
|
|
}
|
|
],
|
|
// 成色所有选项
|
|
degree_params: [],
|
|
price_sort: "",
|
|
price_sort_name: "默认排序",
|
|
degree_ids: [],
|
|
degree_name: "成色",
|
|
product_name: "机型",
|
|
type_id: 1,
|
|
// 产品类型id 默认 1 手机
|
|
type_name: "手机",
|
|
brand_id: 0,
|
|
// 品牌id // 默认 0 全部
|
|
brand_name: "全部",
|
|
product_ids: [0],
|
|
// 机型ids 默认 0 全部
|
|
search_val: ""
|
|
// 搜索
|
|
});
|
|
const onSearch = () => {
|
|
common_vendor.index.__f__("log", "at pages/config/goodsList.vue:241", "搜索:", state.search_val);
|
|
paging.value.reload();
|
|
};
|
|
const onClear = () => {
|
|
common_vendor.index.__f__("log", "at pages/config/goodsList.vue:247", "搜索:", state.search_val);
|
|
paging.value.reload();
|
|
};
|
|
const onResetProduct = () => {
|
|
common_vendor.index.__f__("log", "at pages/config/goodsList.vue:255", "重置产品");
|
|
state.type_id = 1;
|
|
state.type_name = "手机";
|
|
state.brand_id = 0;
|
|
state.brand_name = "全部";
|
|
state.product_ids = [0];
|
|
state.product_name = "机型";
|
|
};
|
|
const onConfirmProduct = () => {
|
|
var _a;
|
|
common_vendor.index.__f__("log", "at pages/config/goodsList.vue:265", "当前产品类型", {
|
|
"type_id": state.type_id,
|
|
"type_name": state.type_name,
|
|
"brand_id": state.brand_id,
|
|
"brand_name": state.brand_name,
|
|
"product_ids": state.product_ids
|
|
});
|
|
(_a = selectProductRef.value) == null ? void 0 : _a.toggle(false);
|
|
paging.value.reload();
|
|
};
|
|
const selectProduct = (product) => {
|
|
if (product.value === 0) {
|
|
state.product_ids = [0];
|
|
} else {
|
|
state.product_ids = state.product_ids.filter((e) => e != 0);
|
|
const index = state.product_ids.indexOf(product.value);
|
|
if (index > -1) {
|
|
state.product_ids.splice(index, 1);
|
|
if (state.product_ids.length === 0) {
|
|
state.product_ids = [0];
|
|
}
|
|
} else {
|
|
state.product_ids.push(product.value);
|
|
}
|
|
}
|
|
common_vendor.index.__f__("log", "at pages/config/goodsList.vue:294", product);
|
|
};
|
|
const productOptions = common_vendor.computed(() => {
|
|
var _a;
|
|
return (_a = state == null ? void 0 : state.o_drop_down_options[state.type_id]) == null ? void 0 : _a.children[state.brand_id].children;
|
|
});
|
|
const selectBrand = (brand) => {
|
|
common_vendor.index.__f__("log", "at pages/config/goodsList.vue:304", brand);
|
|
state.brand_id = brand.value;
|
|
state.brand_name = brand.label;
|
|
state.product_ids = [0];
|
|
state.product_name = brand.label;
|
|
};
|
|
const selectType = (type) => {
|
|
common_vendor.index.__f__("log", "at pages/config/goodsList.vue:314", type);
|
|
state.type_id = type.type_id;
|
|
state.type_name = type.name;
|
|
state.brand_id = 0;
|
|
state.brand_name = "全部";
|
|
state.product_ids = [0];
|
|
};
|
|
const selectPriceSort = (item) => {
|
|
var _a;
|
|
if (state.price_sort !== item.value) {
|
|
state.price_sort = item.value;
|
|
state.price_sort_name = item.text;
|
|
} else {
|
|
state.price_sort_name = "默认排序";
|
|
state.price_sort = "";
|
|
}
|
|
(_a = selectPriceSortRef.value) == null ? void 0 : _a.toggle(false);
|
|
paging.value.reload();
|
|
};
|
|
const selectDegree = (item) => {
|
|
const index = state.degree_ids.indexOf(item.value);
|
|
if (index > -1) {
|
|
state.degree_ids.splice(index, 1);
|
|
} else {
|
|
state.degree_ids.push(item.value);
|
|
}
|
|
if (state.degree_ids.length > 0) {
|
|
state.degree_name = "已选" + state.degree_ids.length.toString() + "项";
|
|
} else {
|
|
state.degree_name = "成色";
|
|
}
|
|
};
|
|
const onResetDegree = () => {
|
|
var _a;
|
|
state.degree_ids = [];
|
|
state.degree_name = "成色";
|
|
(_a = selectDegreeRef.value) == null ? void 0 : _a.toggle(false);
|
|
paging.value.reload();
|
|
};
|
|
const onConfirmDegree = () => {
|
|
var _a;
|
|
if (state.degree_ids.length > 0) {
|
|
state.degree_name = "已选" + state.degree_ids.length.toString() + "项";
|
|
} else {
|
|
state.degree_name = "成色";
|
|
}
|
|
(_a = selectDegreeRef.value) == null ? void 0 : _a.toggle(false);
|
|
paging.value.reload();
|
|
};
|
|
const queryList = (pageNo, pageSize) => {
|
|
const params = {
|
|
pageSize,
|
|
page: pageNo,
|
|
price_sort: state.price_sort,
|
|
degree_ids: state.degree_ids,
|
|
type_id: state.type_id,
|
|
brand_id: state.brand_id,
|
|
product_ids: state.product_ids,
|
|
search: state.search_val
|
|
};
|
|
common_vendor.index.__f__("log", "at pages/config/goodsList.vue:387", params);
|
|
api_goods.fetchSysGoodsList(params).then((res) => {
|
|
common_vendor.index.__f__("log", "at pages/config/goodsList.vue:389", "res=>", res.list);
|
|
paging.value.complete(res.list);
|
|
}).catch((res) => {
|
|
paging.value.complete(false);
|
|
});
|
|
};
|
|
const init = () => {
|
|
common_vendor.index.__f__("log", "at pages/config/goodsList.vue:406", "init111");
|
|
api_goods.fetchFilterParmas().then((res) => {
|
|
common_vendor.index.__f__("log", "at pages/config/goodsList.vue:409", res);
|
|
let degree_params = res.degree_list;
|
|
state.degree_params = degree_params.reduce((it, cit) => {
|
|
it.push({
|
|
text: cit.degree_name,
|
|
value: cit.degree_id
|
|
});
|
|
return it;
|
|
}, state.degree_params) || [];
|
|
state.type_params = res.type_list;
|
|
state.drop_down_options = res.drop_down_options;
|
|
state.o_drop_down_options = res.o_drop_down_options;
|
|
});
|
|
};
|
|
common_vendor.onShow(() => {
|
|
common_vendor.index.__f__("log", "at pages/config/goodsList.vue:428", "onshow---");
|
|
common_vendor.index.__f__("log", "at pages/config/goodsList.vue:429", "paging.value", paging.value);
|
|
if (paging.value) {
|
|
paging.value.refresh();
|
|
}
|
|
});
|
|
common_vendor.onMounted(() => {
|
|
init();
|
|
});
|
|
return (_ctx, _cache) => {
|
|
var _a;
|
|
return {
|
|
a: common_vendor.o(($event) => common_vendor.unref(utils_helper.navigateTo)("/pages/config/goodsAdd")),
|
|
b: common_vendor.p({
|
|
type: "primary",
|
|
block: true,
|
|
plain: true
|
|
}),
|
|
c: common_vendor.o(onSearch),
|
|
d: common_vendor.p({
|
|
type: "primary"
|
|
}),
|
|
e: common_vendor.o(onSearch),
|
|
f: common_vendor.o(onClear),
|
|
g: common_vendor.o(($event) => state.search_val = $event),
|
|
h: common_vendor.p({
|
|
placeholder: "请输入商品名称",
|
|
clearable: true,
|
|
["input-background"]: "#eee",
|
|
modelValue: state.search_val
|
|
}),
|
|
i: common_vendor.f(state.price_sort_params, (item, idx, i0) => {
|
|
return {
|
|
a: common_vendor.t(item.text),
|
|
b: state.price_sort === item.value ? 1 : "",
|
|
c: idx,
|
|
d: common_vendor.o(($event) => selectPriceSort(item), idx)
|
|
};
|
|
}),
|
|
j: common_vendor.sr(selectPriceSortRef, "d044a737-5,d044a737-4", {
|
|
"k": "selectPriceSortRef"
|
|
}),
|
|
k: common_vendor.p({
|
|
title: state.price_sort_name
|
|
}),
|
|
l: common_vendor.f(state.type_params, (type, idx, i0) => {
|
|
return {
|
|
a: common_vendor.t(type.name),
|
|
b: idx,
|
|
c: common_vendor.o(($event) => selectType(type), idx),
|
|
d: state.type_id == type.type_id ? 1 : ""
|
|
};
|
|
}),
|
|
m: common_vendor.f((_a = state == null ? void 0 : state.drop_down_options[state.type_id]) == null ? void 0 : _a.children, (item, idx, i0) => {
|
|
return {
|
|
a: common_vendor.t(item.label),
|
|
b: idx,
|
|
c: common_vendor.o(($event) => selectBrand(item), idx),
|
|
d: item.value == state.brand_id ? 1 : ""
|
|
};
|
|
}),
|
|
n: common_vendor.f(productOptions.value, (item, idx, i0) => {
|
|
return {
|
|
a: common_vendor.t(item.label),
|
|
b: idx,
|
|
c: state.product_ids.includes(item.value) ? 1 : "",
|
|
d: common_vendor.o(($event) => selectProduct(item), idx)
|
|
};
|
|
}),
|
|
o: common_vendor.o(($event) => onResetProduct()),
|
|
p: common_vendor.p({
|
|
plain: true,
|
|
type: "default"
|
|
}),
|
|
q: common_vendor.o(($event) => onConfirmProduct()),
|
|
r: common_vendor.p({
|
|
block: true,
|
|
type: "primary"
|
|
}),
|
|
s: common_vendor.sr(selectProductRef, "d044a737-6,d044a737-4", {
|
|
"k": "selectProductRef"
|
|
}),
|
|
t: common_vendor.p({
|
|
title: state.product_name
|
|
}),
|
|
v: common_vendor.f(state.degree_params, (item, idx, i0) => {
|
|
return {
|
|
a: common_vendor.t(item.text),
|
|
b: state.degree_ids.includes(item.value) ? 1 : "",
|
|
c: idx,
|
|
d: common_vendor.o(($event) => selectDegree(item), idx)
|
|
};
|
|
}),
|
|
w: common_vendor.o(($event) => onResetDegree()),
|
|
x: common_vendor.p({
|
|
plain: true,
|
|
type: "default"
|
|
}),
|
|
y: common_vendor.o(($event) => onConfirmDegree()),
|
|
z: common_vendor.p({
|
|
block: true,
|
|
type: "primary"
|
|
}),
|
|
A: common_vendor.sr(selectDegreeRef, "d044a737-9,d044a737-4", {
|
|
"k": "selectDegreeRef"
|
|
}),
|
|
B: common_vendor.p({
|
|
title: state.degree_name
|
|
}),
|
|
C: common_vendor.p({
|
|
["title-class"]: "titleClass"
|
|
}),
|
|
D: common_vendor.s("top:0px"),
|
|
E: common_vendor.f(dataList.value, (item, index, i0) => {
|
|
return common_vendor.e({
|
|
a: getImg(item),
|
|
b: common_vendor.o(($event) => common_vendor.unref(utils_helper.navigateTo)("/pages/config/goodsDetail?id=" + item.goods_id), index),
|
|
c: common_vendor.t(item.degree.degree_name),
|
|
d: "d044a737-12-" + i0 + ",d044a737-0",
|
|
e: common_vendor.t(item.goods_name),
|
|
f: common_vendor.t(item.content),
|
|
g: common_vendor.t(item.goods_price),
|
|
h: common_vendor.t(item.status.text),
|
|
i: item.status.value == 10 || item.status.value == 20
|
|
}, item.status.value == 10 || item.status.value == 20 ? {
|
|
j: common_vendor.o(($event) => common_vendor.unref(utils_helper.navigateTo)("/pages/config/goodsEdit?id=" + item.goods_id), index),
|
|
k: "d044a737-13-" + i0 + ",d044a737-0",
|
|
l: common_vendor.p({
|
|
size: "small",
|
|
type: "primary"
|
|
})
|
|
} : {}, {
|
|
m: item.status.value == 40
|
|
}, item.status.value == 40 ? {
|
|
n: common_vendor.o(($event) => common_vendor.unref(utils_helper.navigateTo)("/pages/config/goodsEdit?id=" + item.goods_id), index),
|
|
o: "d044a737-14-" + i0 + ",d044a737-0",
|
|
p: common_vendor.p({
|
|
size: "small",
|
|
type: "primary"
|
|
})
|
|
} : {}, {
|
|
q: index
|
|
});
|
|
}),
|
|
F: common_vendor.p({
|
|
["custom-color"]: "#1a1a1a"
|
|
}),
|
|
G: common_vendor.sr(paging, "d044a737-0", {
|
|
"k": "paging"
|
|
}),
|
|
H: common_vendor.o(queryList),
|
|
I: common_vendor.o(($event) => dataList.value = $event),
|
|
J: common_vendor.p({
|
|
["refresher-enabled"]: false,
|
|
["auto-clean-list-when-reload"]: false,
|
|
["auto-scroll-to-top-when-reload"]: false,
|
|
modelValue: dataList.value
|
|
})
|
|
};
|
|
};
|
|
}
|
|
};
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-d044a737"]]);
|
|
wx.createPage(MiniProgramPage);
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/config/goodsList.js.map
|