index.js 9.7 KB

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