index.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  4. __name: "index",
  5. setup(__props) {
  6. var _a, _b, _c;
  7. const $api = (_a = common_vendor.getCurrentInstance()) == null ? void 0 : _a.appContext.config.globalProperties.$api;
  8. (_b = common_vendor.getCurrentInstance()) == null ? void 0 : _b.appContext.config.globalProperties.$app;
  9. (_c = common_vendor.getCurrentInstance()) == null ? void 0 : _c.appContext.config.globalProperties.$config;
  10. const config = common_vendor.ref({ logo: [] });
  11. common_vendor.onLoad(async () => {
  12. await searchConfig();
  13. await search();
  14. });
  15. const searchConfig = async () => {
  16. let res = await $api(`config`, "GET", {});
  17. if (res.errcode == 0) {
  18. config.value = res.data;
  19. common_vendor.index.setStorage({
  20. key: "config",
  21. data: res.data
  22. });
  23. }
  24. };
  25. const search = async () => {
  26. common_vendor.index.getStorage({
  27. key: "openid",
  28. success: function(res) {
  29. common_vendor.index.reLaunch({
  30. url: `/pages/home/index`
  31. });
  32. },
  33. fail: function(err) {
  34. common_vendor.index.login({
  35. success: async function(res) {
  36. if (res.code) {
  37. common_vendor.index.reLaunch({
  38. url: `/pages/home/index`
  39. });
  40. } else {
  41. common_vendor.index.showToast({
  42. title: res.errMsg,
  43. icon: "none"
  44. });
  45. }
  46. }
  47. });
  48. }
  49. });
  50. };
  51. return (_ctx, _cache) => {
  52. var _a2, _b2;
  53. return {
  54. a: ((_b2 = (_a2 = config.value) == null ? void 0 : _a2.logo[0]) == null ? void 0 : _b2.url) || "/static/logo.png"
  55. };
  56. };
  57. }
  58. });
  59. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-1cf27b2a"], ["__file", "D:/project/二手车/car_applet/pages/index/index.vue"]]);
  60. wx.createPage(MiniProgramPage);