爱简收旧衣按件回收前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

200 lines
6.7 KiB

  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const pages_mixins_pullRefreshMixin = require("../mixins/pullRefreshMixin.js");
  4. const _sfc_main = {
  5. mixins: [pages_mixins_pullRefreshMixin.pullRefreshMixin],
  6. data() {
  7. return {
  8. statusBarHeight: 0,
  9. navBarHeight: 14,
  10. navBarTotalHeight: 14,
  11. featureTags: ["透明检", "专业验", "公正评", "逐件验"],
  12. goodsList: [],
  13. // 质检合格
  14. problemList: [],
  15. // 质量问题
  16. unrecyclableList: [],
  17. // 不可回收
  18. reportData: null,
  19. showQualified: false,
  20. showProblem: false,
  21. showUnrecyclable: false
  22. };
  23. },
  24. computed: {
  25. totalCount() {
  26. return this.goodsList.reduce((sum, item) => sum + item.count, 0);
  27. },
  28. totalAmount() {
  29. return this.goodsList.reduce((sum, item) => sum + item.total, 0).toFixed(1);
  30. },
  31. problemCount() {
  32. return this.problemList.reduce((sum, item) => sum + item.count, 0);
  33. },
  34. problemAmount() {
  35. return this.problemList.reduce((sum, item) => sum + item.total, 0).toFixed(1);
  36. },
  37. unrecyclableCount() {
  38. return this.unrecyclableList.reduce((sum, item) => sum + item.count, 0);
  39. }
  40. },
  41. onLoad(options) {
  42. const sysInfo = common_vendor.index.getSystemInfoSync();
  43. this.statusBarHeight = sysInfo.statusBarHeight;
  44. this.navBarHeight = 14;
  45. this.navBarTotalHeight = this.statusBarHeight + this.navBarHeight;
  46. const goodsId = options.id || options.goodsId;
  47. if (goodsId) {
  48. this.fetchQualityReport(goodsId);
  49. }
  50. },
  51. methods: {
  52. async fetchQualityReport(goodsId) {
  53. this.$api && this.$api("getQualityReport", { goodsId }, (res) => {
  54. if (res && res.code === 200 && res.result) {
  55. this.reportData = res.result;
  56. const status = Number(res.result.testingStatus);
  57. this.showQualified = status === 1 || status === 0;
  58. this.showProblem = status === 0 || status === 1;
  59. this.showUnrecyclable = status === 2;
  60. if (status === 1) {
  61. this.goodsList = [this.mapReportToGoods(res.result)];
  62. this.problemList = [];
  63. this.unrecyclableList = [];
  64. } else if (status === 0) {
  65. this.goodsList = [];
  66. this.problemList = [this.mapReportToGoods(res.result, true)];
  67. this.unrecyclableList = [];
  68. } else if (status === 2) {
  69. this.goodsList = [];
  70. this.problemList = [];
  71. this.unrecyclableList = [this.mapReportToGoods(res.result)];
  72. }
  73. }
  74. });
  75. },
  76. mapReportToGoods(data, isProblem = false) {
  77. return {
  78. img: data.image,
  79. name: data.title || "未知品类",
  80. desc: data.details || "",
  81. price: data.onePrice || 0,
  82. count: data.num || 1,
  83. total: (data.onePrice || 0) * (data.num || 1),
  84. detail: true,
  85. problemDesc: isProblem ? data.testingInstructions || "" : ""
  86. };
  87. },
  88. async onRefresh() {
  89. await new Promise((resolve) => setTimeout(resolve, 1e3));
  90. common_vendor.index.stopPullRefresh();
  91. },
  92. navigateBack() {
  93. common_vendor.index.navigateBack();
  94. },
  95. goToInspectionDetail(status) {
  96. const d = this.reportData || {};
  97. common_vendor.index.navigateTo({
  98. url: `/pages/subcomponent/inspection-detail?status=${status}&testingStatus=${d.testingStatus || ""}&testingInstructions=${encodeURIComponent(d.testingInstructions || "")}&testingTime=${encodeURIComponent(d.testingTime || "")}&testingImages=${encodeURIComponent(d.testingImages || "")}`
  99. });
  100. }
  101. }
  102. };
  103. if (!Array) {
  104. const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
  105. _easycom_uni_icons2();
  106. }
  107. const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
  108. if (!Math) {
  109. _easycom_uni_icons();
  110. }
  111. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  112. return common_vendor.e({
  113. a: common_vendor.p({
  114. type: "left",
  115. size: "22",
  116. color: "#fff"
  117. }),
  118. b: common_vendor.o((...args) => $options.navigateBack && $options.navigateBack(...args)),
  119. c: common_vendor.p({
  120. type: "more-filled",
  121. size: "22",
  122. color: "#fff"
  123. }),
  124. d: $data.navBarTotalHeight + "px",
  125. e: $data.statusBarHeight + "px",
  126. f: common_vendor.f($data.featureTags, (t, i, i0) => {
  127. return {
  128. a: common_vendor.t(t),
  129. b: i
  130. };
  131. }),
  132. g: $data.navBarTotalHeight + $data.statusBarHeight + "px",
  133. h: $data.showQualified && $data.goodsList.length
  134. }, $data.showQualified && $data.goodsList.length ? {
  135. i: common_vendor.f($data.goodsList, (item, i, i0) => {
  136. return common_vendor.e({
  137. a: item.img,
  138. b: common_vendor.t(item.name),
  139. c: item.detail
  140. }, item.detail ? {
  141. d: "c1d95640-2-" + i0,
  142. e: common_vendor.p({
  143. type: "right",
  144. size: "16",
  145. color: "#bbb"
  146. })
  147. } : {}, {
  148. f: common_vendor.t(item.desc),
  149. g: common_vendor.t(item.price),
  150. h: common_vendor.t(item.count),
  151. i,
  152. j: common_vendor.o(($event) => $options.goToInspectionDetail("qualified"), i)
  153. });
  154. }),
  155. j: common_vendor.t($options.totalCount),
  156. k: common_vendor.t($options.totalAmount)
  157. } : {}, {
  158. l: $data.showProblem && $data.problemList.length
  159. }, $data.showProblem && $data.problemList.length ? {
  160. m: common_vendor.f($data.problemList, (item, i, i0) => {
  161. return common_vendor.e({
  162. a: item.img,
  163. b: common_vendor.t(item.name),
  164. c: item.detail
  165. }, item.detail ? {
  166. d: "c1d95640-3-" + i0,
  167. e: common_vendor.p({
  168. type: "right",
  169. size: "16",
  170. color: "#bbb"
  171. })
  172. } : {}, {
  173. f: common_vendor.t(item.desc),
  174. g: common_vendor.t(item.price),
  175. h: common_vendor.t(item.count),
  176. i,
  177. j: common_vendor.o(($event) => $options.goToInspectionDetail("problem"), i)
  178. });
  179. }),
  180. n: common_vendor.t($options.problemCount),
  181. o: common_vendor.t($options.problemAmount)
  182. } : {}, {
  183. p: $data.showUnrecyclable && $data.unrecyclableList.length
  184. }, $data.showUnrecyclable && $data.unrecyclableList.length ? {
  185. q: common_vendor.f($data.unrecyclableList, (item, i, i0) => {
  186. return {
  187. a: item.img,
  188. b: common_vendor.t(item.name),
  189. c: common_vendor.t(item.desc),
  190. d: common_vendor.t(item.price),
  191. e: common_vendor.t(item.count),
  192. f: i
  193. };
  194. }),
  195. r: common_vendor.t($options.unrecyclableCount)
  196. } : {});
  197. }
  198. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-c1d95640"]]);
  199. wx.createPage(MiniProgramPage);
  200. //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/subcomponent/inspection-report.js.map