| 12345678910111213141516171819202122232425262728293031323334353637 |
- import Vue from 'vue'
- import Vuex from 'vuex'
- Vue.use(Vuex)
- import {getConfigByKey} from '@/api/course.js'
- const store = new Vuex.Store({
- state: {
- coureLogin: uni.getStorageSync('coureLogin') || 0,
- webviewUrl: ""
- },
- mutations: {
- setCoureLogin(state, payload) {
- uni.setStorageSync('coureLogin', payload);
- state.coureLogin = payload;
- },
- SET_WEBVIEWURL(state, payload) {
- state.webviewUrl = payload;
- },
- },
- getters: {
- coureLogin: (state) => state.coureLogin,
- webviewUrl: (state) => state.webviewUrl,
- },
- actions: {
- async getWebviewUrl({commit}) {
- const res = await getConfigByKey({
- key: 'course.config'
- })
- if (res.code === 200) {
- commit('SET_WEBVIEWURL', JSON.parse(res.data).userCourseAuthDomain)
- }
- }
- }
- })
- export default store
|