import http from '@/common/request/index' import share from '@/common/share'; import ws from "@/store/ws.js"; const state = { appInfo: {}, wechat: { autologin: true }, // 微信配置 share: {}, // 分享配置 payment: {}, // 支付配置 recharge: uni.getStorageSync("recharge") || {}, //充值配置 shareInfo: {}, // 默认分享数据 homeTemplate: [], // 首页模板数据 } const getters = { appInfo: state => state.appInfo, initWechat: state => state.wechat, initShare: state => state.share, shareInfo: state => state.shareInfo, homeTemplate: state => state.homeTemplate, } const actions = { // 初始化数据 async appInit({ commit, dispatch }, options) { // 暂时中断获取系统配置 return var params = 'system.config'; const result = await http('conf.getGroupConf', { group: params }).then(res => { if (res.code === 0) { commit('appInfo', res.data); uni.setStorageSync('appInfo', res.data); if (!options?.query?.token) { dispatch('autoLogin'); } // #ifdef MP-WEIXIN if (res.data.examine_mode == 1) { uni.reLaunch({ url: '/pages/wx/wx' }); return false; } // #endif return res.data; } return false; }); }, // 获取模板数据 async getTemplate({ commit }, options) { // 暂时中断获取模板 return const result = await http('common.template'); if (result.code === 0) { commit('TEMPLATE', result.data); uni.setStorageSync('homeTemplate', result.data); return result.data; } else { return false; } }, } const mutations = { appInfo(state, data) { state.appInfo = data; }, shareInfo(state, shareInfo) { state.shareInfo = shareInfo; }, TEMPLATE(state, data) { state.template = data; state.homeTemplate = data } } export default { state, mutations, actions, getters }