爱简收旧衣按件回收前端代码仓库
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.

310 lines
10 KiB

  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const pages_mixins_pullRefreshMixin = require("../mixins/pullRefreshMixin.js");
  4. const common_assets = require("../../common/assets.js");
  5. const _sfc_main = {
  6. mixins: [pages_mixins_pullRefreshMixin.pullRefreshMixin],
  7. data() {
  8. return {
  9. value: 0,
  10. processes: [],
  11. priceList: [],
  12. records: [],
  13. destinations: [
  14. {
  15. icon: "/static/home/爱心援乡.png",
  16. title: "爱心援乡",
  17. desc: "精准帮扶贫困群体"
  18. },
  19. {
  20. icon: "/static/home/回塑新源.png",
  21. title: "回塑新源",
  22. desc: "塑料的第二次成型"
  23. },
  24. {
  25. icon: "/static/home/织物出海.png",
  26. title: "织物出海",
  27. desc: "分拣出最高价值"
  28. },
  29. {
  30. icon: "/static/home/碳循再生.png",
  31. title: "碳循再生",
  32. desc: "减碳从出发生系统"
  33. }
  34. ],
  35. bannerList: [],
  36. pricePreviewList: [],
  37. cityList: [],
  38. addressCion: "",
  39. sbkCion: ""
  40. };
  41. },
  42. computed: {
  43. cityListStr() {
  44. const names = this.cityList.map((c) => c.name);
  45. const max = 8;
  46. if (names.length > max) {
  47. return names.slice(0, max).join("、") + "...";
  48. }
  49. return names.join("、");
  50. },
  51. address_cion() {
  52. common_vendor.index.__f__("log", "at pages/component/home.vue:224", getApp().globalData.configData, "home-getApp().globalData.configData");
  53. const item = getApp().globalData.configData.find((i) => i.keyName === "address_cion");
  54. return item ? item.keyContent : "";
  55. },
  56. sbk_cion() {
  57. const item = getApp().globalData.configData.find((i) => i.keyName === "sbk_cion");
  58. return item ? item.keyContent : "";
  59. }
  60. },
  61. methods: {
  62. changeTo(e) {
  63. this.value = e;
  64. common_vendor.index.__f__("log", "at pages/component/home.vue:236", e, "111");
  65. if (e == 1) {
  66. common_vendor.index.reLaunch({
  67. url: "/pages/component/recycle"
  68. }, true);
  69. } else if (e == 2) {
  70. common_vendor.index.reLaunch({
  71. url: "/pages/component/my"
  72. }, true);
  73. }
  74. },
  75. goAbout() {
  76. common_vendor.index.navigateTo({
  77. url: "/pages/subcomponent/about"
  78. });
  79. },
  80. goCity() {
  81. common_vendor.index.navigateTo({
  82. url: "/pages/baoyou-city/baoyou-city"
  83. });
  84. },
  85. getPickupto() {
  86. common_vendor.index.switchTab({
  87. url: "/pages/component/recycle"
  88. });
  89. },
  90. async onRefresh() {
  91. await new Promise((resolve) => setTimeout(resolve, 1e3));
  92. },
  93. getAreaList() {
  94. this.$api("getAreaList", {}, (res) => {
  95. common_vendor.index.__f__("log", "at pages/component/home.vue:267", res, "getAreaList");
  96. if (res.code == 200 && Array.isArray(res.result)) {
  97. const sorted = res.result.slice().sort((a, b) => a.sort - b.sort);
  98. this.processes = sorted.map((item) => ({
  99. // id: item.id,
  100. icon: item.image,
  101. text: item.title
  102. }));
  103. }
  104. });
  105. },
  106. goService() {
  107. common_vendor.index.navigateTo({
  108. url: "/pages/subcomponent/admin_faq"
  109. });
  110. },
  111. goToRecycleCategory(id) {
  112. getApp().globalData.targetRecycleCategoryId = id;
  113. common_vendor.index.__f__("log", "at pages/component/home.vue:286", getApp().globalData.targetRecycleCategoryId, "getApp().globalData.targetRecycleCategoryId");
  114. common_vendor.index.switchTab({
  115. url: "/pages/component/recycle"
  116. });
  117. },
  118. getPricePreview() {
  119. const resList = this.pricePreviewList || [];
  120. if (Array.isArray(resList)) {
  121. const firstLevel = resList.filter((item) => item.pid === "0").sort((a, b) => a.sort - b.sort);
  122. this.priceList = firstLevel.map((item) => {
  123. return {
  124. id: item.id,
  125. // 保证有id
  126. icon: item.icon ? item.icon : "",
  127. name: item.title,
  128. price: item.priceNo ? item.priceNo : "",
  129. unit: item.unit ? item.unit : ""
  130. };
  131. });
  132. }
  133. },
  134. getRecentGoods() {
  135. this.$api("getRecentGoodsList", {}, (res) => {
  136. if (res && res.code === 200 && Array.isArray(res.result) && res.result.length > 0) {
  137. this.records = res.result.map((item) => ({
  138. id: item.id,
  139. image: item.image,
  140. name: item.name,
  141. phone: item.phone,
  142. price: item.price
  143. }));
  144. } else {
  145. this.records = [];
  146. }
  147. });
  148. },
  149. goToInspectionReport(item) {
  150. common_vendor.index.navigateTo({
  151. url: `/pages/subcomponent/inspection-report?id=${item.id}`
  152. });
  153. },
  154. getFreeCityList() {
  155. this.$api("getFreeCityList", {}, (res) => {
  156. if (res && res.code === 200 && Array.isArray(res.result)) {
  157. this.cityList = res.result.map((item) => ({ name: item.name })).filter((item) => item.name);
  158. } else {
  159. this.cityList = [];
  160. }
  161. });
  162. },
  163. updateCionData() {
  164. const configData = getApp().globalData.configData || [];
  165. const address = configData.find((i) => i.keyName === "address_cion");
  166. const sbk = configData.find((i) => i.keyName === "sbk_cion");
  167. this.addressCion = address ? address.keyContent : "";
  168. this.sbkCion = sbk ? sbk.keyContent : "";
  169. }
  170. },
  171. onLoad() {
  172. this.getAreaList();
  173. this.getPricePreview();
  174. this.getRecentGoods();
  175. this.pricePreviewList = getApp().globalData.pricePreviewList || [];
  176. this.bannerList = getApp().globalData.bannerList || [];
  177. this.getFreeCityList();
  178. common_vendor.index.$on("pricePreviewListUpdated", () => {
  179. this.pricePreviewList = getApp().globalData.pricePreviewList || [];
  180. this.getPricePreview();
  181. });
  182. common_vendor.index.$on("bannerListUpdated", () => {
  183. this.bannerList = getApp().globalData.bannerList || [];
  184. });
  185. },
  186. onUnload() {
  187. common_vendor.index.$off("pricePreviewListUpdated");
  188. common_vendor.index.$off("bannerListUpdated");
  189. common_vendor.index.$off("configDataUpdated", this.updateCionData);
  190. },
  191. onShow() {
  192. this.updateCionData();
  193. common_vendor.index.$on("configDataUpdated", this.updateCionData);
  194. this.getPricePreview();
  195. }
  196. };
  197. if (!Array) {
  198. const _easycom_uv_divider2 = common_vendor.resolveComponent("uv-divider");
  199. const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
  200. const _easycom_uv_tabbar_item2 = common_vendor.resolveComponent("uv-tabbar-item");
  201. const _easycom_uv_tabbar2 = common_vendor.resolveComponent("uv-tabbar");
  202. (_easycom_uv_divider2 + _easycom_uni_icons2 + _easycom_uv_tabbar_item2 + _easycom_uv_tabbar2)();
  203. }
  204. const _easycom_uv_divider = () => "../../uni_modules/uv-divider/components/uv-divider/uv-divider.js";
  205. const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
  206. const _easycom_uv_tabbar_item = () => "../../uni_modules/uv-tabbar/components/uv-tabbar-item/uv-tabbar-item.js";
  207. const _easycom_uv_tabbar = () => "../../uni_modules/uv-tabbar/components/uv-tabbar/uv-tabbar.js";
  208. if (!Math) {
  209. (_easycom_uv_divider + _easycom_uni_icons + _easycom_uv_tabbar_item + _easycom_uv_tabbar)();
  210. }
  211. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  212. return {
  213. a: common_vendor.f($data.bannerList, (item, index, i0) => {
  214. return {
  215. a: item.image,
  216. b: item.id || index
  217. };
  218. }),
  219. b: common_vendor.f($data.processes, (item, index, i0) => {
  220. return {
  221. a: item.icon,
  222. b: common_vendor.t(item.text),
  223. c: index
  224. };
  225. }),
  226. c: common_assets._imports_0,
  227. d: common_assets._imports_1,
  228. e: common_vendor.o((...args) => $options.getPickupto && $options.getPickupto(...args)),
  229. f: common_vendor.p({
  230. dashed: true
  231. }),
  232. g: common_vendor.p({
  233. type: "right",
  234. size: "16",
  235. color: "#999"
  236. }),
  237. h: common_vendor.t($options.cityListStr),
  238. i: common_vendor.o((...args) => $options.goCity && $options.goCity(...args)),
  239. j: $data.addressCion,
  240. k: common_assets._imports_2,
  241. l: common_vendor.o((...args) => $options.goService && $options.goService(...args)),
  242. m: $data.sbkCion,
  243. n: common_vendor.p({
  244. type: "right",
  245. size: "16",
  246. color: "#999"
  247. }),
  248. o: common_vendor.o((...args) => $options.goAbout && $options.goAbout(...args)),
  249. p: common_vendor.p({
  250. type: "right",
  251. size: "14",
  252. color: "#999"
  253. }),
  254. q: common_vendor.f($data.priceList, (item, index, i0) => {
  255. return common_vendor.e({
  256. a: item.icon
  257. }, item.icon ? {
  258. b: item.icon
  259. } : {}, {
  260. c: common_vendor.t(item.name),
  261. d: common_vendor.t(item.price),
  262. e: common_vendor.t(item.unit),
  263. f: item.id || index,
  264. g: common_vendor.o(($event) => $options.goToRecycleCategory(item.id), item.id || index)
  265. });
  266. }),
  267. r: common_vendor.f($data.records, (item, index, i0) => {
  268. return {
  269. a: item.image,
  270. b: common_vendor.t(item.name),
  271. c: common_vendor.t(item.phone ? item.phone.slice(-4) : ""),
  272. d: common_vendor.t(item.price),
  273. e: index,
  274. f: common_vendor.o(($event) => $options.goToInspectionReport(item), index)
  275. };
  276. }),
  277. s: common_vendor.f($data.destinations, (item, index, i0) => {
  278. return {
  279. a: item.icon,
  280. b: common_vendor.t(item.title),
  281. c: common_vendor.t(item.desc),
  282. d: common_vendor.n(`destination-item${index + 1}`),
  283. e: index
  284. };
  285. }),
  286. t: common_assets._imports_5,
  287. v: common_assets._imports_6,
  288. w: common_vendor.p({
  289. text: "首页"
  290. }),
  291. x: common_assets._imports_7,
  292. y: common_assets._imports_8,
  293. z: common_vendor.p({
  294. text: "回收"
  295. }),
  296. A: common_assets._imports_9,
  297. B: common_assets._imports_10,
  298. C: common_vendor.p({
  299. text: "我的"
  300. }),
  301. D: common_vendor.o($options.changeTo),
  302. E: common_vendor.p({
  303. value: $data.value,
  304. fixed: true
  305. })
  306. };
  307. }
  308. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-24407015"]]);
  309. wx.createPage(MiniProgramPage);
  310. //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/component/home.js.map