|
|
- "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,
- navBarHeight: 14,
- navBarTotalHeight: 14,
- featureTags: ["透明检", "专业验", "公正评", "逐件验"],
- goodsList: [],
- // 质检合格
- problemList: [],
- // 质量问题
- unrecyclableList: [],
- // 不可回收
- reportData: null,
- showQualified: false,
- showProblem: false,
- showUnrecyclable: false
- };
- },
- computed: {
- totalCount() {
- return this.goodsList.reduce((sum, item) => sum + item.count, 0);
- },
- totalAmount() {
- return this.goodsList.reduce((sum, item) => sum + item.total, 0).toFixed(1);
- },
- problemCount() {
- return this.problemList.reduce((sum, item) => sum + item.count, 0);
- },
- problemAmount() {
- return this.problemList.reduce((sum, item) => sum + item.total, 0).toFixed(1);
- },
- unrecyclableCount() {
- return this.unrecyclableList.reduce((sum, item) => sum + item.count, 0);
- }
- },
- onLoad(options) {
- const sysInfo = common_vendor.index.getSystemInfoSync();
- this.statusBarHeight = sysInfo.statusBarHeight;
- this.navBarHeight = 14;
- this.navBarTotalHeight = this.statusBarHeight + this.navBarHeight;
- const goodsId = options.id || options.goodsId;
- if (goodsId) {
- this.fetchQualityReport(goodsId);
- }
- },
- methods: {
- async fetchQualityReport(goodsId) {
- this.$api && this.$api("getQualityReport", { goodsId }, (res) => {
- if (res && res.code === 200 && res.result) {
- this.reportData = res.result;
- const status = Number(res.result.testingStatus);
- this.showQualified = status === 1 || status === 0;
- this.showProblem = status === 0 || status === 1;
- this.showUnrecyclable = status === 2;
- if (status === 1) {
- this.goodsList = [this.mapReportToGoods(res.result)];
- this.problemList = [];
- this.unrecyclableList = [];
- } else if (status === 0) {
- this.goodsList = [];
- this.problemList = [this.mapReportToGoods(res.result, true)];
- this.unrecyclableList = [];
- } else if (status === 2) {
- this.goodsList = [];
- this.problemList = [];
- this.unrecyclableList = [this.mapReportToGoods(res.result)];
- }
- }
- });
- },
- mapReportToGoods(data, isProblem = false) {
- return {
- img: data.image,
- name: data.title || "未知品类",
- desc: data.details || "",
- price: data.onePrice || 0,
- count: data.num || 1,
- total: (data.onePrice || 0) * (data.num || 1),
- detail: true,
- problemDesc: isProblem ? data.testingInstructions || "" : ""
- };
- },
- async onRefresh() {
- await new Promise((resolve) => setTimeout(resolve, 1e3));
- common_vendor.index.stopPullRefresh();
- },
- navigateBack() {
- common_vendor.index.navigateBack();
- },
- goToInspectionDetail(status) {
- const d = this.reportData || {};
- common_vendor.index.navigateTo({
- url: `/pages/subcomponent/inspection-detail?status=${status}&testingStatus=${d.testingStatus || ""}&testingInstructions=${encodeURIComponent(d.testingInstructions || "")}&testingTime=${encodeURIComponent(d.testingTime || "")}&testingImages=${encodeURIComponent(d.testingImages || "")}`
- });
- }
- }
- };
- 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 common_vendor.e({
- a: common_vendor.p({
- type: "left",
- size: "22",
- color: "#fff"
- }),
- b: common_vendor.o((...args) => $options.navigateBack && $options.navigateBack(...args)),
- c: common_vendor.p({
- type: "more-filled",
- size: "22",
- color: "#fff"
- }),
- d: $data.navBarTotalHeight + "px",
- e: $data.statusBarHeight + "px",
- f: common_vendor.f($data.featureTags, (t, i, i0) => {
- return {
- a: common_vendor.t(t),
- b: i
- };
- }),
- g: $data.navBarTotalHeight + $data.statusBarHeight + "px",
- h: $data.showQualified && $data.goodsList.length
- }, $data.showQualified && $data.goodsList.length ? {
- i: common_vendor.f($data.goodsList, (item, i, i0) => {
- return common_vendor.e({
- a: item.img,
- b: common_vendor.t(item.name),
- c: item.detail
- }, item.detail ? {
- d: "c1d95640-2-" + i0,
- e: common_vendor.p({
- type: "right",
- size: "16",
- color: "#bbb"
- })
- } : {}, {
- f: common_vendor.t(item.desc),
- g: common_vendor.t(item.price),
- h: common_vendor.t(item.count),
- i,
- j: common_vendor.o(($event) => $options.goToInspectionDetail("qualified"), i)
- });
- }),
- j: common_vendor.t($options.totalCount),
- k: common_vendor.t($options.totalAmount)
- } : {}, {
- l: $data.showProblem && $data.problemList.length
- }, $data.showProblem && $data.problemList.length ? {
- m: common_vendor.f($data.problemList, (item, i, i0) => {
- return common_vendor.e({
- a: item.img,
- b: common_vendor.t(item.name),
- c: item.detail
- }, item.detail ? {
- d: "c1d95640-3-" + i0,
- e: common_vendor.p({
- type: "right",
- size: "16",
- color: "#bbb"
- })
- } : {}, {
- f: common_vendor.t(item.desc),
- g: common_vendor.t(item.price),
- h: common_vendor.t(item.count),
- i,
- j: common_vendor.o(($event) => $options.goToInspectionDetail("problem"), i)
- });
- }),
- n: common_vendor.t($options.problemCount),
- o: common_vendor.t($options.problemAmount)
- } : {}, {
- p: $data.showUnrecyclable && $data.unrecyclableList.length
- }, $data.showUnrecyclable && $data.unrecyclableList.length ? {
- q: common_vendor.f($data.unrecyclableList, (item, i, i0) => {
- return {
- a: item.img,
- b: common_vendor.t(item.name),
- c: common_vendor.t(item.desc),
- d: common_vendor.t(item.price),
- e: common_vendor.t(item.count),
- f: i
- };
- }),
- r: common_vendor.t($options.unrecyclableCount)
- } : {});
- }
- const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-c1d95640"]]);
- wx.createPage(MiniProgramPage);
- //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/subcomponent/inspection-report.js.map
|