index.js 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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 files = common_vendor.ref([{ name: "上牌时间", content: "2013-10" }, { name: "表显里程", content: "8.0万公里" }, { name: "排放标准", content: "国六" }, { name: "车源地", content: "长春" }]);
  27. const parameter = common_vendor.ref([{ name: "发动机", content: "1.8L" }, { name: "轴距", content: "2700mm" }, { name: "变速箱", content: "自动" }, { name: "最大功率", content: "103kW" }]);
  28. const info = common_vendor.ref({ url: [{ url: "https://cdn.uviewui.com/uview/album/1.jpg" }, { url: "https://cdn.uviewui.com/uview/album/2.jpg" }, { url: "https://cdn.uviewui.com/uview/album/3.jpg" }, { url: "https://cdn.uviewui.com/uview/album/4.jpg" }, { url: "https://cdn.uviewui.com/uview/album/5.jpg" }], payment: "2.7", rankNum: "11", rank: "全国紧凑型SUV销售榜", type: "夏朗", name: "夏朗 2013款 1.8TSI 标配型 欧IV", money: "7.80", price: "29.06" });
  29. const shop = common_vendor.ref({});
  30. const list = 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 res = await $api("car", "GET", {
  76. ...info2
  77. });
  78. if (res.errcode === 0) {
  79. list.value = res.data;
  80. shop.value.num = res.total;
  81. } else {
  82. common_vendor.index.showToast({
  83. title: res.errmsg || "",
  84. icon: "error"
  85. });
  86. }
  87. };
  88. const PhoneNumber = (e) => {
  89. console.log(e);
  90. };
  91. const toRecord = () => {
  92. common_vendor.index.navigateTo({
  93. url: `/pagesHome/record/index?id=${info.value.id || info.value._id}`
  94. });
  95. };
  96. const toView = (item) => {
  97. common_vendor.index.navigateTo({
  98. url: `/pagesHome/car/index?id=${item.id || item._id}`
  99. });
  100. };
  101. const toChat = (item) => {
  102. common_vendor.index.makePhoneCall({
  103. phoneNumber: (item == null ? void 0 : item.shop) || "110",
  104. success: function() {
  105. console.log("拨打电话成功");
  106. },
  107. fail: function() {
  108. console.log("拨打电话失败");
  109. }
  110. });
  111. };
  112. const toShop = () => {
  113. common_vendor.index.navigateTo({
  114. url: `/pagesHome/shop/index?id=${shop.value.id || shop.value._id}&name=${shop.value.name}`
  115. });
  116. };
  117. const toMore = () => {
  118. common_vendor.index.navigateTo({
  119. url: `/pagesHome/picture/index?id=${info.value.id || info.value._id}`
  120. });
  121. };
  122. const toCollect = () => {
  123. console.log("收藏");
  124. };
  125. return (_ctx, _cache) => {
  126. var _a2, _b, _c, _d, _e, _f, _g;
  127. return {
  128. a: common_vendor.t(currentNum.value + 1),
  129. b: common_vendor.t((_a2 = info.value.file) == null ? void 0 : _a2.length),
  130. c: common_vendor.o((e) => currentNum.value = e.current),
  131. d: common_vendor.p({
  132. list: info.value.file,
  133. height: "300px",
  134. keyName: "url",
  135. autoplay: false,
  136. indicatorStyle: "right: 20px",
  137. radius: "0"
  138. }),
  139. e: common_vendor.t(info.value.real_pay || "0"),
  140. f: common_vendor.t(info.value.price || "0"),
  141. g: common_vendor.o(PhoneNumber),
  142. h: common_vendor.t(info.value.series || "暂无"),
  143. i: common_vendor.t(info.value.year || "暂无"),
  144. j: common_vendor.t(info.value.style || "暂无"),
  145. k: common_vendor.t(info.value.series),
  146. l: common_vendor.p({
  147. name: "arrow-right",
  148. size: "12"
  149. }),
  150. m: common_vendor.t(info.value.rank),
  151. n: common_vendor.t(info.value.rankNum),
  152. o: common_vendor.p({
  153. name: "arrow-right",
  154. size: "12"
  155. }),
  156. p: common_vendor.t(info.value.first_pay),
  157. q: common_vendor.p({
  158. name: "arrow-right",
  159. size: "16"
  160. }),
  161. r: common_vendor.f(files.value, (item, index, i0) => {
  162. return {
  163. a: common_vendor.t(item.content),
  164. b: common_vendor.t(item.name),
  165. c: index,
  166. d: common_vendor.o(($event) => _ctx.toCommon(item), index)
  167. };
  168. }),
  169. s: common_vendor.o(toRecord),
  170. t: common_vendor.p({
  171. name: "arrow-right",
  172. size: "16"
  173. }),
  174. v: common_vendor.f(parameter.value, (item, index, i0) => {
  175. return {
  176. a: common_vendor.t(item.content),
  177. b: common_vendor.t(item.name),
  178. c: index,
  179. d: common_vendor.o(($event) => _ctx.toCommon(item), index)
  180. };
  181. }),
  182. w: 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",
  183. x: common_vendor.t(shop.value.name || "暂无"),
  184. y: common_vendor.p({
  185. bold: true,
  186. color: "#000",
  187. name: "arrow-right",
  188. size: "16"
  189. }),
  190. z: common_vendor.o(toShop),
  191. A: common_vendor.t(shop.value.num || 0),
  192. B: common_vendor.o(toChat),
  193. C: common_vendor.p({
  194. icon: "phone",
  195. text: "咨询卖家车况",
  196. size: "normal",
  197. type: "info"
  198. }),
  199. D: 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",
  200. E: 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",
  201. F: 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",
  202. G: 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",
  203. H: 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",
  204. I: common_vendor.o(toMore),
  205. J: common_vendor.p({
  206. text: "查看更多图片",
  207. size: "normal",
  208. type: "info"
  209. }),
  210. K: common_vendor.f(list.value, (item, index, i0) => {
  211. return common_vendor.e({
  212. a: item.file && item.file.length > 0 ? item.file[0].url : "",
  213. b: common_vendor.t(item.series || "暂无"),
  214. c: common_vendor.t(item.year || "暂无"),
  215. d: common_vendor.t(item.style || "暂无"),
  216. e: item.year
  217. }, item.year ? {
  218. f: common_vendor.t(item.year || "暂无")
  219. } : {}, {
  220. g: item.mileage
  221. }, item.mileage ? {
  222. h: common_vendor.t(item.mileage || "暂无")
  223. } : {}, {
  224. i: item.place
  225. }, item.place ? {
  226. j: common_vendor.t(item.place || "暂无")
  227. } : {}, {
  228. k: common_vendor.t(item.total_money || "0"),
  229. l: index,
  230. m: common_vendor.o(($event) => toView(item), index)
  231. });
  232. }),
  233. L: common_vendor.p({
  234. color: "#000",
  235. name: "red-packet",
  236. size: "20"
  237. }),
  238. M: common_vendor.o(toChat),
  239. N: common_vendor.p({
  240. color: "#000",
  241. name: "heart",
  242. size: "20"
  243. }),
  244. O: common_vendor.o(toCollect),
  245. P: common_vendor.o(toChat),
  246. Q: common_vendor.o(toChat)
  247. };
  248. };
  249. }
  250. });
  251. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-6b665083"], ["__file", "D:/project/二手车/car_applet/pagesHome/car/index.vue"]]);
  252. wx.createPage(MiniProgramPage);