// store/index.js import Vue from 'vue'; import Vuex from 'vuex'; Vue.use(Vuex); import { getConfigByKey } from '@/api/index.js' export default new Vuex.Store({ state: { coureLogin: uni.getStorageSync('coureLogin') || 0, webviewUrl: '', wsDanmuUrl: 'wss://userapp.cqsft.vip', // 弹幕评论接口地址 //红包领取规则: answerType: 1, //红包领取规则 0:完课且最后一分钟(第二次无需最后一分钟), 1:按完课百分比答题领红包 isSpare:1, // 0,主要小程序,1:备选 uploadFile: 'https://userapp.cqsft.vip', imgpath: 'https://kuanyitang-1317640934.cos.ap-shanghai.myqcloud.com',//宽 益堂图片请求地址 // https://kuanyitang-1317640934.cos.ap-shanghai.myqcloud.com/shop 宽 益堂图片链接 logoname:'宽益堂九', appid:'wx6f821705fbe9fc95',//宽益 堂 // appid:'wxe9169275655fa961',//宽益 堂-1 // appid:'wxcb2a284f84947808',//宽益 堂-1 // appid:'wx76121b6e19a9031d',//宽益 堂-2 // appid:'wxcb2a284f84947808',//世维会员管理 // appid:'wxe7e617fb6da83dd0',//宽益 堂博博 // appid:'wx9289087a1b32e857',//宽益 堂琦琦 // appid:'wx27188d0c214227cf',//宽益 堂堂堂 }, getters: { coureLogin: (state) => state.coureLogin, }, mutations: { setUserInfo(state, info) { state.userInfo = info; }, setWebviewUrl(state, value) { state.webviewUrl = value; }, setCoureLogin(state, payload) { uni.setStorageSync('coureLogin', payload); state.coureLogin = payload; } }, actions: { fetchUser({ commit }) { // const res = await uni.request({ url: '/api/user' }); commit('setUserInfo', 'noe'); }, getWebviewUrl({commit}) { var that = this; var data = { key: 'course.config' } return new Promise((resolve, reject) => { getConfigByKey(data).then(res => { if (res.code == 200) { console.log("getConfigByKey====", JSON.parse(res.data)) let data = JSON.parse(res.data) commit('setWebviewUrl', data.userCourseAuthDomain); resolve() } }).catch(error => { reject(error) }); }) } } });