init.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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: uni.getStorageSync('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. var params = 'system.config';
  29. const result = await http('conf.getGroupConf', {
  30. group: params
  31. }).then(res => {
  32. // uni.hideTabBar()
  33. if (res.code === 0) {
  34. // uni.setNavigationBarTitle({
  35. // title: res.data.site_name
  36. // });
  37. commit('appInfo', res.data);
  38. uni.setStorageSync('appInfo', res.data);
  39. if (!options?.query?.token) {
  40. dispatch('autoLogin');
  41. }
  42. // ws.init();
  43. // #ifdef MP-WEIXIN
  44. if (res.data.examine_mode == 1) {
  45. uni.reLaunch({
  46. url: '/pages/wx/wx'
  47. });
  48. return false;
  49. }
  50. // #endif
  51. // if(res.data.bottom_menu_status == 1){
  52. // dispatch('getbottom_menu',res.data)
  53. // }else{
  54. // uni.setTabBarItem({
  55. // index: 0,
  56. // text: '找好活',
  57. // })
  58. // uni.setTabBarItem({
  59. // index: 1,
  60. // text: '找师傅',
  61. // })
  62. // uni.setTabBarItem({
  63. // index: 2,
  64. // text: '消息',
  65. // })
  66. // uni.setTabBarItem({
  67. // index: 3,
  68. // text: '我的',
  69. // })
  70. // // uni.showTabBar({animation:true})
  71. // }
  72. return res.data;
  73. }
  74. return false;
  75. });
  76. },
  77. // 获取模板数据
  78. async getTemplate({
  79. commit
  80. }, options) {
  81. const result = await http('common.template');
  82. if (result.code === 0) {
  83. commit('TEMPLATE', result.data);
  84. uni.setStorageSync('homeTemplate', result.data);
  85. // console.log('模版数据-----------', result.data);
  86. return result.data;
  87. } else {
  88. return false;
  89. }
  90. },
  91. }
  92. const mutations = {
  93. appInfo(state, data) {
  94. state.appInfo = data;
  95. },
  96. shareInfo(state, shareInfo) {
  97. state.shareInfo = shareInfo;
  98. },
  99. TEMPLATE(state, data) {
  100. state.template = data;
  101. state.homeTemplate = data
  102. }
  103. }
  104. export default {
  105. state,
  106. mutations,
  107. actions,
  108. getters
  109. }