index.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. success: function(arr) {
  23. },
  24. fail: function(err) {
  25. console.log(err);
  26. }
  27. });
  28. }
  29. };
  30. const search = async () => {
  31. common_vendor.index.getStorage({
  32. key: "openid",
  33. success: function(res) {
  34. common_vendor.index.reLaunch({
  35. url: `/pages/home/index`
  36. });
  37. },
  38. fail: function(err) {
  39. common_vendor.index.login({
  40. success: async function(res) {
  41. if (res.code) {
  42. common_vendor.index.reLaunch({
  43. url: `/pages/home/index`
  44. });
  45. } else {
  46. common_vendor.index.showToast({
  47. title: res.errMsg,
  48. icon: "none"
  49. });
  50. }
  51. }
  52. });
  53. }
  54. });
  55. };
  56. return (_ctx, _cache) => {
  57. return {
  58. a: config.value.logo[0].url || "/static/logo.png"
  59. };
  60. };
  61. }
  62. });
  63. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-1cf27b2a"], ["__file", "D:/project/二手车/car_applet/pages/index/index.vue"]]);
  64. wx.createPage(MiniProgramPage);