index.js 9.1 KB

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