init.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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: {autologin:true}, // 微信配置
  7. share: {}, // 分享配置
  8. payment: {}, // 支付配置
  9. recharge: uni.getStorageSync("recharge") || {}, //充值配置
  10. shareInfo: {} ,// 默认分享数据
  11. homeTemplate: [], // 首页模板数据
  12. }
  13. const getters = {
  14. appInfo: state => state.appInfo,
  15. initWechat: state => state.wechat,
  16. initShare: state => state.share,
  17. shareInfo: state => state.shareInfo,
  18. homeTemplate: state => state.homeTemplate,
  19. }
  20. const actions = {
  21. // 初始化数据
  22. async appInit({
  23. commit,
  24. dispatch
  25. }, options) {
  26. var params = 'system.config';
  27. const result = await http('conf.getGroupConf', {
  28. group: params
  29. }).then(res => {
  30. // uni.hideTabBar()
  31. if (res.code === 0) {
  32. // uni.setNavigationBarTitle({
  33. // title: res.data.site_name
  34. // });
  35. commit('appInfo', res.data);
  36. uni.setStorageSync('appInfo', res.data);
  37. if (!options?.query?.token) {
  38. dispatch('autoLogin');
  39. }
  40. // ws.init();
  41. // #ifdef MP-WEIXIN
  42. if(res.data.examine_mode == 1){
  43. uni.reLaunch({
  44. url:'/pages/wx/wx'
  45. });
  46. return false;
  47. }
  48. // #endif
  49. // if(res.data.bottom_menu_status == 1){
  50. // dispatch('getbottom_menu',res.data)
  51. // }else{
  52. // uni.setTabBarItem({
  53. // index: 0,
  54. // text: '找好活',
  55. // })
  56. // uni.setTabBarItem({
  57. // index: 1,
  58. // text: '找师傅',
  59. // })
  60. // uni.setTabBarItem({
  61. // index: 2,
  62. // text: '消息',
  63. // })
  64. // uni.setTabBarItem({
  65. // index: 3,
  66. // text: '我的',
  67. // })
  68. // // uni.showTabBar({animation:true})
  69. // }
  70. return res.data;
  71. }
  72. return false;
  73. });
  74. },
  75. // 获取模板数据
  76. async getTemplate({
  77. commit
  78. }, options) {
  79. const result = await http('common.template');
  80. if (result.code === 0) {
  81. commit('TEMPLATE', result.data);
  82. uni.setStorageSync('homeTemplate', result.data);
  83. return result.data;
  84. } else {
  85. return false;
  86. }
  87. },
  88. }
  89. const mutations = {
  90. appInfo(state, data) {
  91. state.appInfo = data;
  92. },
  93. shareInfo(state, shareInfo) {
  94. state.shareInfo = shareInfo;
  95. },
  96. TEMPLATE(state, data) {
  97. state.template = data;
  98. state.homeTemplate = data
  99. }
  100. }
  101. export default {
  102. state,
  103. mutations,
  104. actions,
  105. getters
  106. }