index.js 8.4 KB

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