index.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. const $app = (_b = common_vendor.getCurrentInstance()) == null ? void 0 : _b.appContext.config.globalProperties.$app;
  9. const $config = (_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. const aee = await $app("/wechat/api/login/app", "GET", {
  41. js_code: res.code,
  42. config: $config.wx_projectkey
  43. });
  44. if (aee.errcode == "0") {
  45. common_vendor.index.setStorage({
  46. key: "openid",
  47. data: aee.data.openid
  48. });
  49. common_vendor.index.reLaunch({
  50. url: `/pages/home/index`
  51. });
  52. } else {
  53. common_vendor.index.showToast({
  54. title: aee.errmsg,
  55. icon: "none"
  56. });
  57. }
  58. } else {
  59. common_vendor.index.showToast({
  60. title: res.errMsg,
  61. icon: "none"
  62. });
  63. }
  64. }
  65. });
  66. }
  67. });
  68. };
  69. return (_ctx, _cache) => {
  70. var _a2, _b2;
  71. return {
  72. a: ((_b2 = (_a2 = config.value) == null ? void 0 : _a2.logo[0]) == null ? void 0 : _b2.url) || "/static/logo.png"
  73. };
  74. };
  75. }
  76. });
  77. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-1cf27b2a"], ["__file", "D:/project/赋强公证/notarization_applet/pages/index/index.vue"]]);
  78. wx.createPage(MiniProgramPage);