|
|
- "use strict";
- const common_vendor = require("../../common/vendor.js");
- const pages_mixins_pullRefreshMixin = require("../mixins/pullRefreshMixin.js");
- const _sfc_main = {
- mixins: [pages_mixins_pullRefreshMixin.pullRefreshMixin],
- data() {
- return {
- statusBarHeight: 0,
- currentCategory: 0,
- allProducts: {},
- // { [categoryId]: [商品数组] }
- allProductsPage: {},
- // { [categoryId]: 当前已加载页码 }
- allProductsTotal: {},
- // { [categoryId]: 总数 }
- pageSize: 10,
- loadingMore: false,
- finished: false
- };
- },
- computed: {
- categories() {
- const list = getApp().globalData.pricePreviewList || [];
- const extra = [{ id: "unrecyclable", title: "不可回收" }];
- return [...list.filter((item) => item.pid === "0").sort((a, b) => a.sort - b.sort), ...extra];
- },
- currentGoods() {
- var _a;
- const currentCategoryId = (_a = this.categories[this.currentCategory]) == null ? void 0 : _a.id;
- if (currentCategoryId === "unrecyclable") {
- return [{
- id: "unrecyclable-1",
- image: "/static/回收/衣物.png",
- name: "不可回收品类",
- price: "—",
- desc: "允许脏破烂,160码以上",
- quantity: 2,
- amount: ""
- }];
- }
- return this.allProducts[currentCategoryId] || [];
- }
- },
- methods: {
- fetchGoodsList(categoryId, page = 1, callback) {
- this.$api("getClassGoodsList", {
- classId: categoryId,
- pageNo: page,
- pageSize: this.pageSize
- }, (res) => {
- if (res.code === 200 && res.result && Array.isArray(res.result.records)) {
- const oldList = this.allProducts[categoryId] || [];
- const newList = page === 1 ? res.result.records : oldList.concat(res.result.records);
- this.$set(this.allProducts, categoryId, newList);
- this.$set(this.allProductsPage, categoryId, page);
- this.$set(this.allProductsTotal, categoryId, res.result.total);
- }
- if (callback)
- callback();
- });
- },
- goBack() {
- common_vendor.index.navigateBack();
- },
- goNext() {
- common_vendor.index.navigateTo({
- url: "/pages/manager/inspect-result"
- });
- },
- switchCategory(idx) {
- var _a;
- this.currentCategory = idx;
- this.loadingMore = false;
- this.finished = false;
- const categoryId = (_a = this.categories[idx]) == null ? void 0 : _a.id;
- if (categoryId === "unrecyclable") {
- this.$set(this.allProducts, "unrecyclable", [{
- id: "unrecyclable-1",
- image: "/static/回收/衣物.png",
- name: "不可回收品类",
- price: "—",
- desc: "允许脏破烂,160码以上",
- quantity: 2,
- amount: ""
- }]);
- this.$forceUpdate && this.$forceUpdate();
- return;
- }
- if (!this.allProducts[categoryId]) {
- this.fetchGoodsList(categoryId, 1);
- }
- },
- changeNum(item, key, delta) {
- if (key === "qualified") {
- item.qualified = Math.max(0, (item.qualified || 0) + delta);
- } else {
- item.unqualified = Math.max(0, (item.unqualified || 0) + delta);
- }
- },
- refreshData() {
- },
- async onRefresh() {
- await this.refreshData && this.refreshData();
- }
- },
- created() {
- this.currentCategory = 0;
- this.$nextTick(() => {
- var _a;
- if (this.categories.length > 0) {
- const firstCategoryId = (_a = this.categories[0]) == null ? void 0 : _a.id;
- if (firstCategoryId) {
- this.fetchGoodsList(firstCategoryId, 1);
- }
- }
- });
- },
- onLoad() {
- this.statusBarHeight = common_vendor.index.getSystemInfoSync().statusBarHeight;
- },
- onPullDownRefresh() {
- this.refreshData && this.refreshData();
- common_vendor.index.stopPullDownRefresh();
- }
- };
- if (!Array) {
- const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
- _easycom_uni_icons2();
- }
- const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
- if (!Math) {
- _easycom_uni_icons();
- }
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
- return {
- a: common_vendor.p({
- type: "left",
- size: "20",
- color: "#222"
- }),
- b: common_vendor.o((...args) => $options.goBack && $options.goBack(...args)),
- c: common_vendor.p({
- type: "scan",
- size: "24",
- color: "#222"
- }),
- d: common_vendor.f($options.categories, (cat, idx, i0) => {
- return common_vendor.e({
- a: common_vendor.t(cat.title),
- b: cat.badge
- }, cat.badge ? {
- c: common_vendor.t(cat.badge)
- } : {}, {
- d: cat.title,
- e: common_vendor.n({
- active: idx === $data.currentCategory
- }),
- f: common_vendor.o(($event) => $options.switchCategory(idx), cat.title)
- });
- }),
- e: common_vendor.f($options.currentGoods, (item, idx, i0) => {
- return {
- a: item.image,
- b: common_vendor.t(item.name),
- c: common_vendor.t(item.price),
- d: common_vendor.t(item.desc),
- e: common_vendor.o(($event) => $options.changeNum(item, "qualified", -1), item.id),
- f: common_vendor.t(item.qualified),
- g: common_vendor.o(($event) => $options.changeNum(item, "qualified", 1), item.id),
- h: common_vendor.o(($event) => $options.changeNum(item, "unqualified", -1), item.id),
- i: common_vendor.t(item.unqualified),
- j: common_vendor.o(($event) => $options.changeNum(item, "unqualified", 1), item.id),
- k: item.amount,
- l: common_vendor.o(($event) => item.amount = $event.detail.value, item.id),
- m: item.id
- };
- }),
- f: common_vendor.o((...args) => $options.goBack && $options.goBack(...args)),
- g: common_vendor.o((...args) => $options.goNext && $options.goNext(...args))
- };
- }
- const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-e802c881"]]);
- wx.createPage(MiniProgramPage);
- //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/manager/inspect.js.map
|