index.js 9.7 KB

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