index.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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. return (_ctx, _cache) => {
  147. var _a2, _b, _c, _d, _e, _f, _g;
  148. return {
  149. a: common_vendor.t(currentNum.value + 1),
  150. b: common_vendor.t((_a2 = info.value.file) == null ? void 0 : _a2.length),
  151. c: common_vendor.o((e) => currentNum.value = e.current),
  152. d: common_vendor.p({
  153. list: info.value.file,
  154. height: "300px",
  155. keyName: "url",
  156. autoplay: false,
  157. indicatorStyle: "right: 20px",
  158. radius: "0"
  159. }),
  160. e: common_vendor.t(info.value.real_pay || "0"),
  161. f: common_vendor.t(info.value.price || "0"),
  162. g: common_vendor.o(PhoneNumber),
  163. h: common_vendor.t(info.value.series || "暂无"),
  164. i: common_vendor.t(info.value.year || "暂无"),
  165. j: common_vendor.t(info.value.style || "暂无"),
  166. k: common_vendor.t(info.value.series),
  167. l: common_vendor.p({
  168. name: "arrow-right",
  169. size: "12"
  170. }),
  171. m: common_vendor.t(info.value.first_pay),
  172. n: common_vendor.p({
  173. name: "arrow-right",
  174. size: "16"
  175. }),
  176. o: common_vendor.o(toChat),
  177. p: common_vendor.t(common_vendor.unref(common_vendor.hooks)(info.value.f_time).format("YYYY-MM") || "暂无日期"),
  178. q: common_vendor.t(info.value.mileage || "暂无"),
  179. r: common_vendor.t(getDict(info.value.emission, "emission")),
  180. s: common_vendor.t(info.value.place || "暂无"),
  181. t: common_vendor.o(toRecord),
  182. v: common_vendor.p({
  183. name: "arrow-right",
  184. size: "16"
  185. }),
  186. w: common_vendor.t(info.value.hundred_time || "0"),
  187. x: common_vendor.t(info.value.displacement || "暂无"),
  188. y: common_vendor.t(info.value.wheelbase || "暂无"),
  189. z: common_vendor.t(getDict(info.value.type, "type")),
  190. A: common_vendor.t(info.value.oil || "0"),
  191. B: common_vendor.t(info.value.premium || "0"),
  192. C: common_vendor.t(info.value.maintenance || "0"),
  193. 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",
  194. E: common_vendor.t(shop.value.name || "暂无"),
  195. F: common_vendor.p({
  196. bold: true,
  197. color: "#000",
  198. name: "arrow-right",
  199. size: "16"
  200. }),
  201. G: common_vendor.o(toShop),
  202. H: common_vendor.t(shop.value.num || 0),
  203. I: common_vendor.o(toChat),
  204. J: common_vendor.p({
  205. icon: "phone",
  206. text: "咨询卖家车况",
  207. size: "normal",
  208. type: "info"
  209. }),
  210. 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",
  211. 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",
  212. 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",
  213. 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",
  214. 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",
  215. P: common_vendor.o(toMore),
  216. Q: common_vendor.p({
  217. text: "查看更多图片",
  218. size: "normal",
  219. type: "info"
  220. }),
  221. R: common_vendor.f(list.value, (item, index, i0) => {
  222. return common_vendor.e({
  223. a: item.file && item.file.length > 0 ? item.file[0].url : "",
  224. b: common_vendor.t(item.series || "暂无"),
  225. c: common_vendor.t(item.year || "暂无"),
  226. d: common_vendor.t(item.style || "暂无"),
  227. e: item.year
  228. }, item.year ? {
  229. f: common_vendor.t(item.year || "暂无")
  230. } : {}, {
  231. g: item.mileage
  232. }, item.mileage ? {
  233. h: common_vendor.t(item.mileage || "暂无")
  234. } : {}, {
  235. i: item.place
  236. }, item.place ? {
  237. j: common_vendor.t(item.place || "暂无")
  238. } : {}, {
  239. k: common_vendor.t(item.total_money || "0"),
  240. l: index,
  241. m: common_vendor.o(($event) => toView(item), index)
  242. });
  243. }),
  244. S: common_vendor.p({
  245. color: "#000",
  246. name: "red-packet",
  247. size: "20"
  248. }),
  249. T: common_vendor.o(toChat),
  250. U: common_vendor.o(toChat),
  251. V: common_vendor.o(toChat)
  252. };
  253. };
  254. }
  255. });
  256. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-6b665083"], ["__file", "D:/project/二手车/car_applet/pagesHome/car/index.vue"]]);
  257. wx.createPage(MiniProgramPage);