index.js 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const pagesHome_condition_common_classify = require("./common/classify.js");
  4. if (!Array) {
  5. const _easycom_u_button2 = common_vendor.resolveComponent("u-button");
  6. _easycom_u_button2();
  7. }
  8. const _easycom_u_button = () => "../../node-modules/uview-plus/components/u-button/u-button.js";
  9. if (!Math) {
  10. (_easycom_u_button + SliderRange)();
  11. }
  12. const SliderRange = () => "../../components/slider-range/index.js";
  13. const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  14. __name: "index",
  15. setup(__props) {
  16. var _a;
  17. const $api = (_a = common_vendor.getCurrentInstance()) == null ? void 0 : _a.appContext.config.globalProperties.$api;
  18. common_vendor.computed(() => {
  19. return common_vendor.index.getStorageSync("openid");
  20. });
  21. const config = common_vendor.ref({});
  22. const id = common_vendor.ref("");
  23. const total = common_vendor.ref(0);
  24. const scrollTop = common_vendor.ref(0);
  25. const current = common_vendor.ref(0);
  26. const itemId = common_vendor.ref("");
  27. const tabbar = common_vendor.ref([]);
  28. const scrollRightTop = common_vendor.ref(0);
  29. const brandInfo = common_vendor.ref({});
  30. const cityInfo = common_vendor.ref({});
  31. const searchList = common_vendor.ref([]);
  32. const searchInfo = common_vendor.ref({});
  33. const boxTypeList = common_vendor.ref([]);
  34. const structureList = common_vendor.ref([]);
  35. const emissionList = common_vendor.ref([]);
  36. const energyList = common_vendor.ref([]);
  37. const displacementList = common_vendor.ref([]);
  38. const setList = common_vendor.ref([]);
  39. common_vendor.onLoad(async (options) => {
  40. id.value = options && options.id;
  41. await searchOther();
  42. await searchConfig();
  43. await search();
  44. });
  45. common_vendor.onShow(async () => {
  46. common_vendor.index.$on("toRoute", function(data) {
  47. brandInfo.value = data;
  48. tabbar.value = tabbar.value.map((item, index) => {
  49. if (item.type == "1" && item.value == "0")
  50. item.text = data.title;
  51. return item;
  52. });
  53. });
  54. common_vendor.index.$on("toCity", function(data) {
  55. cityInfo.value = data;
  56. tabbar.value = tabbar.value.map((item, index) => {
  57. if (item.type == "1" && item.value == "1")
  58. item.text = data.name;
  59. return item;
  60. });
  61. });
  62. });
  63. const searchOther = async () => {
  64. let res;
  65. res = await $api(`dictData`, "GET", { code: "boxType", is_use: "0" });
  66. if (res.errcode === 0)
  67. boxTypeList.value = res.data;
  68. res = await $api(`dictData`, "GET", { code: "structure", is_use: "0" });
  69. if (res.errcode === 0)
  70. structureList.value = res.data;
  71. res = await $api(`dictData`, "GET", { code: "emission", is_use: "0" });
  72. if (res.errcode === 0)
  73. emissionList.value = res.data;
  74. res = await $api(`dictData`, "GET", { code: "energy", is_use: "0" });
  75. if (res.errcode === 0)
  76. energyList.value = res.data;
  77. res = await $api(`dictData`, "GET", { code: "displacement", is_use: "0" });
  78. if (res.errcode === 0)
  79. displacementList.value = res.data;
  80. res = await $api(`dictData`, "GET", { code: "set", is_use: "0" });
  81. if (res.errcode === 0)
  82. setList.value = res.data;
  83. };
  84. const searchConfig = async () => {
  85. config.value = common_vendor.index.getStorageSync("config");
  86. };
  87. const search = async () => {
  88. const data = pagesHome_condition_common_classify.classifyData.map((item, index) => {
  89. if (item.type == "boxType") {
  90. boxTypeList.value.forEach((v) => {
  91. v["is_open"] = false;
  92. });
  93. item.foods = boxTypeList.value;
  94. } else if (item.type == "structure") {
  95. structureList.value.forEach((v) => {
  96. v["is_open"] = false;
  97. });
  98. item.foods = structureList.value;
  99. } else if (item.type == "emission") {
  100. emissionList.value.forEach((v) => {
  101. v["is_open"] = false;
  102. });
  103. item.foods = emissionList.value;
  104. } else if (item.type == "energy") {
  105. energyList.value.forEach((v) => {
  106. v["is_open"] = false;
  107. });
  108. item.foods = energyList.value;
  109. } else if (item.type == "displacement") {
  110. displacementList.value.forEach((v) => {
  111. v["is_open"] = false;
  112. });
  113. item.foods = displacementList.value;
  114. } else if (item.type == "set") {
  115. setList.value.forEach((v) => {
  116. v["is_open"] = false;
  117. });
  118. item.foods = setList.value;
  119. }
  120. return item;
  121. });
  122. tabbar.value = data;
  123. const info = {
  124. skip: 0,
  125. limit: 1,
  126. status: "0"
  127. };
  128. const res = await $api("car", "GET", {
  129. ...info,
  130. ...searchInfo.value
  131. });
  132. if (res.errcode === 0) {
  133. total.value = res.total;
  134. } else {
  135. common_vendor.index.showToast({
  136. title: res.errmsg || "",
  137. icon: "error"
  138. });
  139. }
  140. };
  141. const swichMenu = (index) => {
  142. if (index == current.value)
  143. return;
  144. current.value = index;
  145. itemId.value = `item${index}`;
  146. };
  147. const rightScroll = async (e) => {
  148. scrollTop.value = e.scrollTop;
  149. };
  150. const toCommon = (type) => {
  151. if (type == "0") {
  152. common_vendor.index.navigateTo({
  153. url: `/pagesHome/brand/index`
  154. });
  155. } else {
  156. common_vendor.index.navigateTo({
  157. url: `/pagesHome/city/index`
  158. });
  159. }
  160. };
  161. const changeSliderValue = (e, data) => {
  162. tabbar.value = tabbar.value.map((item, index) => {
  163. if (item.name == data.name) {
  164. if (e.firstValue == 0)
  165. item.content = `${e.secondValue}${item.unit}以下`;
  166. else
  167. item.content = `${e.firstValue}-${e.secondValue}${item.unit}`;
  168. item.value = e.values;
  169. }
  170. return item;
  171. });
  172. };
  173. const toSelect = async (arr, data) => {
  174. searchList.value.push(data);
  175. tabbar.value = tabbar.value.map((item, index) => {
  176. if (item.type == arr.type) {
  177. item.foods = item.foods.map((item1, index1) => {
  178. if (item1.value == data.value)
  179. item1.is_open = !item1.is_open;
  180. return item1;
  181. });
  182. }
  183. return item;
  184. });
  185. };
  186. const toSearch = () => {
  187. common_vendor.index.navigateTo({
  188. url: `/pagesHome/search/index`
  189. });
  190. };
  191. const toReset = () => {
  192. searchInfo.value = {};
  193. search();
  194. };
  195. return (_ctx, _cache) => {
  196. return {
  197. a: common_vendor.f(tabbar.value, (item, index, i0) => {
  198. return {
  199. a: common_vendor.t(item.name),
  200. b: index,
  201. c: "item" + index,
  202. d: common_vendor.n(current.value == index ? "u-tab-item-active" : ""),
  203. e: common_vendor.o(($event) => swichMenu(index), index)
  204. };
  205. }),
  206. b: scrollTop.value,
  207. c: common_vendor.f(tabbar.value, (item, index, i0) => {
  208. return common_vendor.e({
  209. a: item.type != "2"
  210. }, item.type != "2" ? {
  211. b: common_vendor.t(item.name)
  212. } : {
  213. c: common_vendor.t(item.name),
  214. d: common_vendor.t(item.unit),
  215. e: common_vendor.t(item.content || "不限")
  216. }, {
  217. f: item.type == "1"
  218. }, item.type == "1" ? {
  219. g: common_vendor.o(($event) => toCommon(item.value), index),
  220. h: "4b99813d-0-" + i0,
  221. i: common_vendor.p({
  222. text: item.text,
  223. size: "normal",
  224. type: "info"
  225. })
  226. } : item.type == "2" ? {
  227. k: common_vendor.o((event) => changeSliderValue(event, item), index),
  228. l: "4b99813d-1-" + i0,
  229. m: common_vendor.p({
  230. value: item.value,
  231. min: item.min,
  232. max: item.max,
  233. step: item.step,
  234. scale: {
  235. show: true
  236. }
  237. })
  238. } : {
  239. n: common_vendor.f(item.foods, (item1, index1, i1) => {
  240. return {
  241. a: common_vendor.t(item1.label),
  242. b: common_vendor.n((item1 == null ? void 0 : item1.is_open) == false ? "title_1" : "title_2"),
  243. c: index1,
  244. d: common_vendor.o(($event) => toSelect(item, item1), index1)
  245. };
  246. })
  247. }, {
  248. j: item.type == "2",
  249. o: "item" + index,
  250. p: index
  251. });
  252. }),
  253. d: scrollRightTop.value,
  254. e: itemId.value,
  255. f: common_vendor.o(rightScroll),
  256. g: common_vendor.o(toReset),
  257. h: common_vendor.t(total.value),
  258. i: common_vendor.o(toSearch)
  259. };
  260. };
  261. }
  262. });
  263. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-4b99813d"], ["__file", "D:/project/二手车/car_applet/pagesHome/condition/index.vue"]]);
  264. wx.createPage(MiniProgramPage);