app.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. "use strict";
  2. const sheep_api_promotion_diy = require("../api/promotion/diy.js");
  3. const common_vendor = require("../../common/vendor.js");
  4. const sheep_platform_index = require("../platform/index.js");
  5. const sheep_router_index = require("../router/index.js");
  6. const sheep_store_user = require("./user.js");
  7. const sheep_store_sys = require("./sys.js");
  8. const app = common_vendor.defineStore({
  9. id: "app",
  10. state: () => ({
  11. info: {
  12. // 应用信息
  13. name: "",
  14. // 商城名称
  15. logo: "",
  16. // logo
  17. version: "",
  18. // 版本号
  19. copyright: "",
  20. // 版权信息 I
  21. copytime: "",
  22. // 版权信息 II
  23. cdnurl: "",
  24. // 云存储域名
  25. filesystem: ""
  26. // 云存储平台
  27. },
  28. platform: {
  29. share: {
  30. methods: [],
  31. // 支持的分享方式
  32. forwardInfo: {},
  33. // 默认转发信息
  34. posterInfo: {},
  35. // 海报信息
  36. linkAddress: ""
  37. // 复制链接地址
  38. },
  39. bind_mobile: 0
  40. // 登陆后绑定手机号提醒 (弱提醒,可手动关闭)
  41. },
  42. chat: {},
  43. template: {
  44. // 店铺装修模板
  45. basic: {},
  46. // 基本信息
  47. home: {
  48. // 首页模板
  49. style: {},
  50. data: []
  51. },
  52. user: {
  53. // 个人中心模板
  54. style: {},
  55. data: []
  56. }
  57. },
  58. shareInfo: {},
  59. // 全局分享信息
  60. has_wechat_trade_managed: 0
  61. // 小程序发货信息管理 0 没有 || 1 有
  62. }),
  63. actions: {
  64. // 获取Shopro应用配置和模板
  65. async init(templateId = null) {
  66. const networkStatus = await sheep_platform_index._platform.checkNetwork();
  67. if (!networkStatus) {
  68. sheep_router_index.$router.error("NetworkError");
  69. }
  70. await adaptTemplate(this.template, templateId);
  71. {
  72. this.info = {
  73. name: "常来此购",
  74. logo: "/static/zxlogo.png",
  75. version: "1.1.13",
  76. copyright: "全部开源,个人与企业可 100% 免费使用",
  77. copytime: "Copyright© 2018-2024",
  78. cdnurl: "https://file.sheepjs.com",
  79. // 云存储域名
  80. filesystem: "qcloud"
  81. // 云存储平台
  82. };
  83. this.platform = {
  84. share: {
  85. methods: ["poster", "link"],
  86. // linkAddress: "http://localhost/#/", //跳转链接
  87. linkAddress: "https://zxgz.newfeifan.cn/#/",
  88. //跳转链接
  89. posterInfo: {
  90. "user_bg": "/static/user-poster-bg.jpg",
  91. "goods_bg": "/static/user-poster-bg.jpg",
  92. "groupon_bg": "/static/img/shop/config/groupon-poster-bg.png"
  93. }
  94. },
  95. bind_mobile: 0
  96. };
  97. this.chat = {
  98. chat_domain: "https://api.shopro.sheepjs.com/chat",
  99. room_id: "admin"
  100. };
  101. this.has_wechat_trade_managed = 0;
  102. const sysStore = sheep_store_sys.sys();
  103. sysStore.setTheme();
  104. const userStore = sheep_store_user.user();
  105. if (userStore.isLogin) {
  106. userStore.loginAfter();
  107. }
  108. return Promise.resolve(true);
  109. }
  110. }
  111. },
  112. persist: {
  113. enabled: true,
  114. strategies: [{
  115. key: "app-store"
  116. }]
  117. }
  118. });
  119. const adaptTemplate = async (appTemplate, templateId) => {
  120. var _a;
  121. const {
  122. data: diyTemplate
  123. } = templateId ? await sheep_api_promotion_diy.DiyApi.getDiyTemplate(templateId) : await sheep_api_promotion_diy.DiyApi.getUsedDiyTemplate();
  124. if (!diyTemplate) {
  125. sheep_router_index.$router.error("TemplateError");
  126. return;
  127. }
  128. const tabBar = (_a = diyTemplate == null ? void 0 : diyTemplate.property) == null ? void 0 : _a.tabBar;
  129. if (tabBar) {
  130. appTemplate.basic.tabbar = tabBar;
  131. if (tabBar == null ? void 0 : tabBar.theme) {
  132. appTemplate.basic.theme = tabBar == null ? void 0 : tabBar.theme;
  133. }
  134. }
  135. appTemplate.home = diyTemplate == null ? void 0 : diyTemplate.home;
  136. appTemplate.user = diyTemplate == null ? void 0 : diyTemplate.user;
  137. };
  138. const __vite_glob_0_0 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  139. __proto__: null,
  140. default: app
  141. }, Symbol.toStringTag, { value: "Module" }));
  142. exports.__vite_glob_0_0 = __vite_glob_0_0;
  143. exports.app = app;