index.js 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. if (!Array) {
  4. const _easycom_u_swiper2 = common_vendor.resolveComponent("u-swiper");
  5. const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon");
  6. const _easycom_u_button2 = common_vendor.resolveComponent("u-button");
  7. (_easycom_u_swiper2 + _easycom_u_icon2 + _easycom_u_button2)();
  8. }
  9. const _easycom_u_swiper = () => "../../node-modules/uview-plus/components/u-swiper/u-swiper.js";
  10. const _easycom_u_icon = () => "../../node-modules/uview-plus/components/u-icon/u-icon.js";
  11. const _easycom_u_button = () => "../../node-modules/uview-plus/components/u-button/u-button.js";
  12. if (!Math) {
  13. (_easycom_u_swiper + _easycom_u_icon + _easycom_u_button)();
  14. }
  15. const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  16. __name: "index",
  17. setup(__props) {
  18. var _a;
  19. const $api = (_a = common_vendor.getCurrentInstance()) == null ? void 0 : _a.appContext.config.globalProperties.$api;
  20. common_vendor.computed(() => {
  21. return common_vendor.index.getStorageSync("openid");
  22. });
  23. const config = common_vendor.ref({});
  24. const id = common_vendor.ref("");
  25. const currentNum = common_vendor.ref(1);
  26. const info = common_vendor.ref({});
  27. const shop = common_vendor.ref({});
  28. const list = common_vendor.ref([]);
  29. const emissionList = common_vendor.ref([]);
  30. const boxTypeList = common_vendor.ref([]);
  31. const displacementList = common_vendor.ref([]);
  32. common_vendor.onLoad(async (options) => {
  33. id.value = options && options.id;
  34. await searchConfig();
  35. await search();
  36. });
  37. const searchConfig = async () => {
  38. config.value = common_vendor.index.getStorageSync("config");
  39. };
  40. const search = async () => {
  41. var _a2;
  42. if (id.value) {
  43. const res = await $api(`car/${id.value}`, "GET", {});
  44. if (res.errcode === 0) {
  45. info.value = res.data;
  46. await searchShop((_a2 = res.data) == null ? void 0 : _a2.shop);
  47. await searchOther();
  48. } else {
  49. common_vendor.index.showToast({
  50. title: res.errmsg || "",
  51. icon: "error"
  52. });
  53. }
  54. }
  55. };
  56. const searchShop = async (e) => {
  57. if (!e)
  58. return;
  59. const res = await $api(`shop/${e}`, "GET", {});
  60. if (res.errcode === 0) {
  61. shop.value = res.data;
  62. } else {
  63. common_vendor.index.showToast({
  64. title: res.errmsg || "",
  65. icon: "error"
  66. });
  67. }
  68. };
  69. const searchOther = async () => {
  70. const info2 = {
  71. skip: 0,
  72. limit: 20,
  73. status: "0",
  74. shop: shop.value._id
  75. };
  76. const arr = await $api("car", "GET", {
  77. ...info2
  78. });
  79. if (arr.errcode === 0) {
  80. list.value = arr.data;
  81. shop.value.num = arr.total;
  82. } else {
  83. common_vendor.index.showToast({
  84. title: arr.errmsg || "",
  85. icon: "error"
  86. });
  87. }
  88. let res;
  89. res = await $api(`dictData`, "GET", { code: "boxType", is_use: "0" });
  90. if (res.errcode === 0)
  91. boxTypeList.value = res.data;
  92. res = await $api(`dictData`, "GET", { code: "emission", is_use: "0" });
  93. if (res.errcode === 0)
  94. emissionList.value = res.data;
  95. res = await $api(`dictData`, "GET", { code: "displacement", is_use: "0" });
  96. if (res.errcode === 0)
  97. displacementList.value = res.data;
  98. };
  99. const getDict = (data, model) => {
  100. let list2;
  101. switch (model) {
  102. case "type":
  103. list2 = boxTypeList.value;
  104. break;
  105. case "emission":
  106. list2 = emissionList.value;
  107. break;
  108. case "displacement":
  109. list2 = displacementList.value;
  110. break;
  111. }
  112. if (!list2)
  113. return;
  114. const res = list2.find((f) => f.value == data);
  115. return (res == null ? void 0 : res.label) || "暂无";
  116. };
  117. const PhoneNumber = (e) => {
  118. console.log(e);
  119. };
  120. const toRecord = () => {
  121. common_vendor.index.navigateTo({
  122. url: `/pagesHome/record/index?id=${info.value.id || info.value._id}`
  123. });
  124. };
  125. const toView = (item) => {
  126. common_vendor.index.navigateTo({
  127. url: `/pagesHome/car/index?id=${item.id || item._id}`
  128. });
  129. };
  130. const toChat = (item) => {
  131. var _a2;
  132. common_vendor.index.makePhoneCall({
  133. phoneNumber: (_a2 = shop.value) == null ? void 0 : _a2.tel,
  134. success: function() {
  135. console.log("拨打电话成功");
  136. },
  137. fail: function() {
  138. console.log("拨打电话失败");
  139. }
  140. });
  141. };
  142. const toShop = () => {
  143. common_vendor.index.navigateTo({
  144. url: `/pagesHome/shop/index?id=${shop.value.id || shop.value._id}&name=${shop.value.name}`
  145. });
  146. };
  147. const toMore = () => {
  148. common_vendor.index.navigateTo({
  149. url: `/pagesHome/picture/index?id=${info.value.id || info.value._id}`
  150. });
  151. };
  152. const toCollect = () => {
  153. console.log("收藏");
  154. };
  155. return (_ctx, _cache) => {
  156. var _a2, _b, _c, _d, _e, _f, _g;
  157. return {
  158. a: common_vendor.t(currentNum.value + 1),
  159. b: common_vendor.t((_a2 = info.value.file) == null ? void 0 : _a2.length),
  160. c: common_vendor.o((e) => currentNum.value = e.current),
  161. d: common_vendor.p({
  162. list: info.value.file,
  163. height: "300px",
  164. keyName: "url",
  165. autoplay: false,
  166. indicatorStyle: "right: 20px",
  167. radius: "0"
  168. }),
  169. e: common_vendor.t(info.value.real_pay || "0"),
  170. f: common_vendor.t(info.value.price || "0"),
  171. g: common_vendor.o(PhoneNumber),
  172. h: common_vendor.t(info.value.series || "暂无"),
  173. i: common_vendor.t(info.value.year || "暂无"),
  174. j: common_vendor.t(info.value.style || "暂无"),
  175. k: common_vendor.t(info.value.series),
  176. l: common_vendor.p({
  177. name: "arrow-right",
  178. size: "12"
  179. }),
  180. m: common_vendor.t(info.value.rank),
  181. n: common_vendor.t(info.value.rankNum),
  182. o: common_vendor.p({
  183. name: "arrow-right",
  184. size: "12"
  185. }),
  186. p: common_vendor.t(info.value.first_pay),
  187. q: common_vendor.p({
  188. name: "arrow-right",
  189. size: "16"
  190. }),
  191. r: common_vendor.t(common_vendor.unref(common_vendor.hooks)(info.value.f_time).format("YYYY-MM") || "暂无日期"),
  192. s: common_vendor.t(info.value.mileage || "暂无"),
  193. t: common_vendor.t(getDict(info.value.emission, "emission")),
  194. v: common_vendor.t(info.value.place || "暂无"),
  195. w: common_vendor.o(toRecord),
  196. x: common_vendor.p({
  197. name: "arrow-right",
  198. size: "16"
  199. }),
  200. y: common_vendor.t(getDict(info.value.displacement, "displacement")),
  201. z: common_vendor.t(info.value.wheelbase),
  202. A: common_vendor.t(getDict(info.value.type, "type")),
  203. B: common_vendor.t(info.value.oil),
  204. C: shop.value.logo && ((_b = shop.value.logo) == null ? void 0 : _b.length) > 0 ? shop.value.logo[0].url : "https://cdn.uviewui.com/uview/album/1.jpg",
  205. D: common_vendor.t(shop.value.name || "暂无"),
  206. E: common_vendor.p({
  207. bold: true,
  208. color: "#000",
  209. name: "arrow-right",
  210. size: "16"
  211. }),
  212. F: common_vendor.o(toShop),
  213. G: common_vendor.t(shop.value.num || 0),
  214. H: common_vendor.o(toChat),
  215. I: common_vendor.p({
  216. icon: "phone",
  217. text: "咨询卖家车况",
  218. size: "normal",
  219. type: "info"
  220. }),
  221. J: info.value.file && ((_c = info.value.file) == null ? void 0 : _c.length) > 0 ? info.value.file[0].url : "https://cdn.uviewui.com/uview/album/1.jpg",
  222. K: info.value.file && ((_d = info.value.file) == null ? void 0 : _d.length) > 1 ? info.value.file[1].url : "https://cdn.uviewui.com/uview/album/5.jpg",
  223. L: info.value.file && ((_e = info.value.file) == null ? void 0 : _e.length) > 2 ? info.value.file[2].url : "https://cdn.uviewui.com/uview/album/2.jpg",
  224. M: info.value.file && ((_f = info.value.file) == null ? void 0 : _f.length) > 3 ? info.value.file[3].url : "https://cdn.uviewui.com/uview/album/3.jpg",
  225. N: info.value.file && ((_g = info.value.file) == null ? void 0 : _g.length) > 4 ? info.value.file[4].url : "https://cdn.uviewui.com/uview/album/4.jpg",
  226. O: common_vendor.o(toMore),
  227. P: common_vendor.p({
  228. text: "查看更多图片",
  229. size: "normal",
  230. type: "info"
  231. }),
  232. Q: common_vendor.f(list.value, (item, index, i0) => {
  233. return common_vendor.e({
  234. a: item.file && item.file.length > 0 ? item.file[0].url : "",
  235. b: common_vendor.t(item.series || "暂无"),
  236. c: common_vendor.t(item.year || "暂无"),
  237. d: common_vendor.t(item.style || "暂无"),
  238. e: item.year
  239. }, item.year ? {
  240. f: common_vendor.t(item.year || "暂无")
  241. } : {}, {
  242. g: item.mileage
  243. }, item.mileage ? {
  244. h: common_vendor.t(item.mileage || "暂无")
  245. } : {}, {
  246. i: item.place
  247. }, item.place ? {
  248. j: common_vendor.t(item.place || "暂无")
  249. } : {}, {
  250. k: common_vendor.t(item.total_money || "0"),
  251. l: index,
  252. m: common_vendor.o(($event) => toView(item), index)
  253. });
  254. }),
  255. R: common_vendor.p({
  256. color: "#000",
  257. name: "red-packet",
  258. size: "20"
  259. }),
  260. S: common_vendor.o(toChat),
  261. T: common_vendor.p({
  262. color: "#000",
  263. name: "heart",
  264. size: "20"
  265. }),
  266. U: common_vendor.o(toCollect),
  267. V: common_vendor.o(toChat),
  268. W: common_vendor.o(toChat)
  269. };
  270. };
  271. }
  272. });
  273. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-6b665083"], ["__file", "D:/project/二手车/car_applet/pagesHome/car/index.vue"]]);
  274. wx.createPage(MiniProgramPage);