index.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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. for (let val of searchList.value) {
  95. if (val.code == "displacement")
  96. info[val.code] = val.label;
  97. else
  98. info[val.code] = val.value;
  99. }
  100. const res = await $api("car", "GET", {
  101. ...info,
  102. ...searchInfo.value
  103. });
  104. if (res.errcode === 0) {
  105. total.value = res.total;
  106. } else {
  107. common_vendor.index.showToast({
  108. title: res.errmsg || "",
  109. icon: "error"
  110. });
  111. }
  112. };
  113. const search = async () => {
  114. const data = pagesHome_condition_common_classify.classifyData.map((item, index) => {
  115. if (item.type == "boxType") {
  116. boxTypeList.value.forEach((v) => {
  117. v["is_open"] = false;
  118. });
  119. item.foods = boxTypeList.value;
  120. } else if (item.type == "structure") {
  121. structureList.value.forEach((v) => {
  122. v["is_open"] = false;
  123. });
  124. item.foods = structureList.value;
  125. } else if (item.type == "emission") {
  126. emissionList.value.forEach((v) => {
  127. v["is_open"] = false;
  128. });
  129. item.foods = emissionList.value;
  130. } else if (item.type == "energy") {
  131. energyList.value.forEach((v) => {
  132. v["is_open"] = false;
  133. });
  134. item.foods = energyList.value;
  135. } else if (item.type == "displacement") {
  136. displacementList.value.forEach((v) => {
  137. v["is_open"] = false;
  138. });
  139. item.foods = displacementList.value;
  140. } else if (item.type == "set") {
  141. setList.value.forEach((v) => {
  142. v["is_open"] = false;
  143. });
  144. item.foods = setList.value;
  145. }
  146. return item;
  147. });
  148. tabbar.value = data;
  149. };
  150. const swichMenu = (index) => {
  151. if (index == current.value)
  152. return;
  153. current.value = index;
  154. itemId.value = `item${index}`;
  155. };
  156. const rightScroll = async (e) => {
  157. scrollTop.value = e.scrollTop;
  158. };
  159. const toCommon = (type) => {
  160. if (type == "0") {
  161. common_vendor.index.navigateTo({
  162. url: `/pagesHome/brand/index`
  163. });
  164. } else {
  165. common_vendor.index.navigateTo({
  166. url: `/pagesHome/city/index`
  167. });
  168. }
  169. };
  170. const changeSliderValue = async (e, data) => {
  171. tabbar.value = tabbar.value.map((item, index) => {
  172. if (item.name == data.name) {
  173. if (e.firstValue == 0)
  174. item.content = `${e.secondValue}${item.unit}以下`;
  175. else
  176. item.content = `${e.firstValue}-${e.secondValue}${item.unit}`;
  177. item.value = e.values;
  178. }
  179. return item;
  180. });
  181. if (data.name == "价格")
  182. searchInfo.value.money = data.content;
  183. else if (data.name == "车龄")
  184. searchInfo.value.year = data.content;
  185. else
  186. searchInfo.value.mileage = data.content;
  187. await searchCar();
  188. };
  189. const toSelect = async (arr, data) => {
  190. searchList.value.push(data);
  191. tabbar.value = tabbar.value.map((item, index) => {
  192. if (item.type == arr.type) {
  193. item.foods = item.foods.map((item1, index1) => {
  194. if (item1.value == data.value)
  195. item1.is_open = !item1.is_open;
  196. return item1;
  197. });
  198. }
  199. return item;
  200. });
  201. await searchCar();
  202. };
  203. const toSearch = () => {
  204. common_vendor.index.navigateTo({
  205. url: `/pagesHome/search/index`
  206. });
  207. };
  208. const toReset = async () => {
  209. searchInfo.value = {};
  210. searchList.value = [];
  211. await search();
  212. await searchCar();
  213. };
  214. return (_ctx, _cache) => {
  215. return {
  216. a: common_vendor.f(tabbar.value, (item, index, i0) => {
  217. return {
  218. a: common_vendor.t(item.name),
  219. b: index,
  220. c: "item" + index,
  221. d: common_vendor.n(current.value == index ? "u-tab-item-active" : ""),
  222. e: common_vendor.o(($event) => swichMenu(index), index)
  223. };
  224. }),
  225. b: scrollTop.value,
  226. c: common_vendor.f(tabbar.value, (item, index, i0) => {
  227. return common_vendor.e({
  228. a: item.type != "2"
  229. }, item.type != "2" ? {
  230. b: common_vendor.t(item.name)
  231. } : {
  232. c: common_vendor.t(item.name),
  233. d: common_vendor.t(item.unit),
  234. e: common_vendor.t(item.content || "不限")
  235. }, {
  236. f: item.type == "1"
  237. }, item.type == "1" ? {
  238. g: common_vendor.o(($event) => toCommon(item.value), index),
  239. h: "4b99813d-0-" + i0,
  240. i: common_vendor.p({
  241. text: item.text,
  242. size: "normal",
  243. type: "info"
  244. })
  245. } : item.type == "2" ? {
  246. k: common_vendor.o((event) => changeSliderValue(event, item), index),
  247. l: "4b99813d-1-" + i0,
  248. m: common_vendor.p({
  249. value: item.value,
  250. min: item.min,
  251. max: item.max,
  252. step: item.step,
  253. scale: {
  254. show: true
  255. }
  256. })
  257. } : {
  258. n: common_vendor.f(item.foods, (item1, index1, i1) => {
  259. return {
  260. a: common_vendor.t(item1.label),
  261. b: common_vendor.n((item1 == null ? void 0 : item1.is_open) == false ? "title_1" : "title_2"),
  262. c: index1,
  263. d: common_vendor.o(($event) => toSelect(item, item1), index1)
  264. };
  265. })
  266. }, {
  267. j: item.type == "2",
  268. o: "item" + index,
  269. p: index
  270. });
  271. }),
  272. d: scrollRightTop.value,
  273. e: itemId.value,
  274. f: common_vendor.o(rightScroll),
  275. g: common_vendor.o(toReset),
  276. h: common_vendor.t(total.value),
  277. i: common_vendor.o(toSearch)
  278. };
  279. };
  280. }
  281. });
  282. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-4b99813d"], ["__file", "D:/project/赋强公证/notarization_applet/pagesHome/condition/index.vue"]]);
  283. wx.createPage(MiniProgramPage);