init.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import http from '@/common/request/index'
  2. import share from '@/common/share';
  3. import ws from "@/store/ws.js";
  4. const state = {
  5. appInfo: {},
  6. wechat: {
  7. autologin: true
  8. }, // 微信配置
  9. share: {}, // 分享配置
  10. payment: {}, // 支付配置
  11. recharge: uni.getStorageSync("recharge") || {}, //充值配置
  12. shareInfo: {}, // 默认分享数据
  13. homeTemplate: [], // 首页模板数据
  14. }
  15. const getters = {
  16. appInfo: state => state.appInfo,
  17. initWechat: state => state.wechat,
  18. initShare: state => state.share,
  19. shareInfo: state => state.shareInfo,
  20. homeTemplate: state => state.homeTemplate,
  21. }
  22. const actions = {
  23. // 初始化数据
  24. async appInit({
  25. commit,
  26. dispatch
  27. }, options) {
  28. // 暂时中断获取系统配置
  29. return
  30. var params = 'system.config';
  31. const result = await http('conf.getGroupConf', {
  32. group: params
  33. }).then(res => {
  34. if (res.code === 0) {
  35. commit('appInfo', res.data);
  36. uni.setStorageSync('appInfo', res.data);
  37. if (!options?.query?.token) {
  38. dispatch('autoLogin');
  39. }
  40. // #ifdef MP-WEIXIN
  41. if (res.data.examine_mode == 1) {
  42. uni.reLaunch({
  43. url: '/pages/wx/wx'
  44. });
  45. return false;
  46. }
  47. // #endif
  48. return res.data;
  49. }
  50. return false;
  51. });
  52. },
  53. // 获取模板数据
  54. async getTemplate({
  55. commit
  56. }, options) {
  57. // 暂时中断获取模板
  58. return
  59. const result = await http('common.template');
  60. if (result.code === 0) {
  61. commit('TEMPLATE', result.data);
  62. uni.setStorageSync('homeTemplate', result.data);
  63. return result.data;
  64. } else {
  65. return false;
  66. }
  67. },
  68. }
  69. const mutations = {
  70. appInfo(state, data) {
  71. state.appInfo = data;
  72. },
  73. shareInfo(state, shareInfo) {
  74. state.shareInfo = shareInfo;
  75. },
  76. TEMPLATE(state, data) {
  77. state.template = data;
  78. state.homeTemplate = data
  79. }
  80. }
  81. export default {
  82. state,
  83. mutations,
  84. actions,
  85. getters
  86. }