index.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. if (!Array) {
  4. const _easycom_u_album2 = common_vendor.resolveComponent("u-album");
  5. const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon");
  6. (_easycom_u_album2 + _easycom_u_icon2)();
  7. }
  8. const _easycom_u_album = () => "../../node-modules/uview-plus/components/u-album/u-album.js";
  9. const _easycom_u_icon = () => "../../node-modules/uview-plus/components/u-icon/u-icon.js";
  10. if (!Math) {
  11. (_easycom_u_album + _easycom_u_icon)();
  12. }
  13. const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  14. __name: "index",
  15. setup(__props) {
  16. var _a;
  17. const $api = (_a = common_vendor.getCurrentInstance()) == null ? void 0 : _a.appContext.config.globalProperties.$api;
  18. common_vendor.computed(() => {
  19. return common_vendor.index.getStorageSync("openid");
  20. });
  21. const config = common_vendor.ref({});
  22. const id = common_vendor.ref("");
  23. const current = common_vendor.ref(0);
  24. const itemId = common_vendor.ref("");
  25. const imageList = common_vendor.ref([{ name: "外观", url: [] }, { name: "内饰", url: [] }, { name: "空间", url: [] }]);
  26. common_vendor.onLoad(async (options) => {
  27. id.value = options && options.id;
  28. await searchConfig();
  29. await searchOther();
  30. await search();
  31. });
  32. const searchOther = async () => {
  33. };
  34. const searchConfig = async () => {
  35. config.value = common_vendor.index.getStorageSync("config");
  36. };
  37. const search = async () => {
  38. var _a2, _b;
  39. if (id.value) {
  40. const res = await $api(`car/${id.value}`, "GET", {});
  41. if (res.errcode === 0) {
  42. if (((_b = (_a2 = res.data) == null ? void 0 : _a2.file) == null ? void 0 : _b.length) > 0) {
  43. res.data.file = res.data.file.map((item, index) => {
  44. return item.url;
  45. });
  46. var one = res.data.file.slice(0, 9);
  47. var two = res.data.file.slice(9, 18);
  48. var thr = res.data.file.slice(18, 21);
  49. imageList.value = imageList.value.map((item, index) => {
  50. if (index == 0)
  51. item.url = one;
  52. else if (index == 1)
  53. item.url = two;
  54. else if (index == 2)
  55. item.url = thr;
  56. return item;
  57. });
  58. }
  59. } else {
  60. common_vendor.index.showToast({
  61. title: res.errmsg || "",
  62. icon: "error"
  63. });
  64. }
  65. }
  66. };
  67. const toChat = (item) => {
  68. common_vendor.index.makePhoneCall({
  69. phoneNumber: item.shop || "110",
  70. success: function() {
  71. console.log("拨打电话成功");
  72. },
  73. fail: function() {
  74. console.log("拨打电话失败");
  75. }
  76. });
  77. };
  78. const swichMenu = (index) => {
  79. if (index == current.value)
  80. return;
  81. current.value = index;
  82. itemId.value = `item${index}`;
  83. };
  84. return (_ctx, _cache) => {
  85. return {
  86. a: common_vendor.f(imageList.value, (item, index, i0) => {
  87. var _a2;
  88. return {
  89. a: common_vendor.t(item.name),
  90. b: common_vendor.t(((_a2 = item == null ? void 0 : item.url) == null ? void 0 : _a2.length) || 0),
  91. c: common_vendor.n(current.value == index ? "border" : ""),
  92. d: index,
  93. e: common_vendor.o(($event) => swichMenu(index), index)
  94. };
  95. }),
  96. b: common_vendor.f(imageList.value, (item, index, i0) => {
  97. var _a2;
  98. return {
  99. a: common_vendor.t(item.name),
  100. b: common_vendor.t(((_a2 = item == null ? void 0 : item.url) == null ? void 0 : _a2.length) || 0),
  101. c: "item" + index,
  102. d: common_vendor.o((width) => _ctx.albumWidth = width, index),
  103. e: "0d1a9630-0-" + i0,
  104. f: common_vendor.p({
  105. urls: item.url,
  106. multipleSize: "110"
  107. }),
  108. g: index
  109. };
  110. }),
  111. c: common_vendor.o(
  112. //@ts-ignore
  113. (...args) => _ctx.toPage && _ctx.toPage(...args)
  114. ),
  115. d: itemId.value,
  116. e: common_vendor.p({
  117. color: "#ffffff",
  118. name: "red-packet",
  119. size: "20"
  120. }),
  121. f: common_vendor.o(toChat),
  122. g: common_vendor.o(toChat),
  123. h: common_vendor.o(toChat)
  124. };
  125. };
  126. }
  127. });
  128. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-0d1a9630"], ["__file", "D:/project/二手车/car_applet/pagesHome/picture/index.vue"]]);
  129. wx.createPage(MiniProgramPage);