natasha 1 سال پیش
والد
کامیت
26d4704347

+ 44 - 0
src/App.vue

@@ -5,6 +5,8 @@
 </template>
 
 <script>
+import { getLogin } from "@/api/ajax";
+import { getToken } from '@/utils/auth'
 export default {
   name: "App",
   data() {
@@ -12,8 +14,50 @@ export default {
     };
   },
   created() {
+    this.fn()
   },
   methods:{
+    async fn() {
+        let userInfor = getToken();
+        if (userInfor) {
+            let MethodName = "/OrgServer/DictManager/GetStudyPhaseList";
+            let typeListAll = [{
+                study_phase: -1,
+                study_phase_name: '全部'
+            }]
+            let typeList = []
+            await getLogin(MethodName, {})
+                .then((res) => {
+                    if (res.status === 1) {
+                        typeListAll = typeListAll.concat(res.study_phase_list)
+                        typeList = res.study_phase_list
+                    }
+                })
+                .catch(() => {
+
+                });
+            this.$store.commit('setStudyTypeAll',typeListAll)   
+            this.$store.commit('setStudyType',typeList)
+            let MethodNames = "/OrgServer/DictManager/GetOrgTypeList";
+            let typeListAlls = [{
+                type: -1,
+                type_name: '全部'
+            }]
+            let typeLists = []
+            await getLogin(MethodNames, {})
+                .then((res) => {
+                    if (res.status === 1) {
+                        typeListAlls = typeListAlls.concat(res.type_list)
+                        typeLists = res.type_list
+                    }
+                })
+                .catch(() => {
+
+                });
+            this.$store.commit('setOrgTypeAll',typeListAlls)   
+            this.$store.commit('setOrgType',typeLists)
+        }
+    }         
   },
   mounted(){
   },

+ 0 - 81
src/store/global.js

@@ -1,86 +1,5 @@
 import Vue from 'vue'
 import { getLogin } from "@/api/ajax";
 export default {
-    async install() {
-        let MethodName = "/OrgServer/DictManager/GetStudyPhaseList";
-        let typeListAll = [{
-            study_phase: -1,
-            study_phase_name: '全部'
-        }]
-        let typeList = []
-        await getLogin(MethodName, {})
-            .then((res) => {
-                if (res.status === 1) {
-                    typeListAll = typeListAll.concat(res.study_phase_list)
-                    typeList = res.study_phase_list
-                }
-            })
-            .catch(() => {
 
-            });
-        Vue.prototype.$studyTypeAll = typeListAll
-        Vue.prototype.$studyType = typeList
-        let MethodNames = "/OrgServer/DictManager/GetOrgTypeList";
-        let typeListAlls = [{
-            type: -1,
-            type_name: '全部'
-        }]
-        let typeLists = []
-        await getLogin(MethodNames, {})
-            .then((res) => {
-                if (res.status === 1) {
-                    typeListAlls = typeListAlls.concat(res.type_list)
-                    typeLists = res.type_list
-                }
-            })
-            .catch(() => {
-
-            });
-        Vue.prototype.$orgTypeAll = typeListAlls
-        Vue.prototype.$orgType = typeLists
-
-        Vue.prototype.$checkStatusList = [{
-                value: -1,
-                label: '全部'
-            },
-            {
-                value: 0,
-                label: '待审核'
-            },
-            {
-                value: 3,
-                label: '被驳回'
-            },
-            {
-                value: 1,
-                label: '未上架'
-            },
-            {
-                value: 2,
-                label: '已上架'
-            }
-        ]
-        Vue.prototype.$checkStatusColorList = {
-            0: {
-                text: '待审核',
-                bg: '#C9CDD4',
-                color: ''
-            },
-            3: {
-                text: '被驳回',
-                bg: '#F53F3F',
-                color: '#F53F3F'
-            },
-            1: {
-                text: '未上架',
-                bg: '#165DFF',
-                color: ''
-            },
-            2: {
-                text: '已上架',
-                bg: '#00B42A',
-                color: ''
-            }
-        }
-    }
 }

+ 71 - 8
src/store/index.js

@@ -9,13 +9,76 @@ import lang from './modules/lang'
 Vue.use(Vuex)
 
 const store = new Vuex.Store({
-  modules: {
-    app,
-    settings,
-    user,
-    lang
-  },
-  getters
+    state: {
+        $studyTypeAll: null,
+        $studyType: null,
+        $orgTypeAll: null,
+        $orgType: null,
+        $checkStatusList: [{
+                value: -1,
+                label: '全部'
+            },
+            {
+                value: 0,
+                label: '待审核'
+            },
+            {
+                value: 3,
+                label: '被驳回'
+            },
+            {
+                value: 1,
+                label: '未上架'
+            },
+            {
+                value: 2,
+                label: '已上架'
+            }
+        ],
+        $checkStatusColorList: {
+            0: {
+                text: '待审核',
+                bg: '#C9CDD4',
+                color: ''
+            },
+            3: {
+                text: '被驳回',
+                bg: '#F53F3F',
+                color: '#F53F3F'
+            },
+            1: {
+                text: '未上架',
+                bg: '#165DFF',
+                color: ''
+            },
+            2: {
+                text: '已上架',
+                bg: '#00B42A',
+                color: ''
+            }
+        }
+    },
+    mutations: {
+        setStudyTypeAll(state, data) {
+            state.$studyTypeAll = data
+        },
+        setStudyType(state, data) {
+            state.$studyType = data
+        },
+        setOrgTypeAll(state, data) {
+            state.$orgTypeAll = data
+        },
+        setOrgType(state, data) {
+            state.$orgType = data
+        },
+    },
+    modules: {
+        app,
+        settings,
+        user,
+        lang
+    },
+    getters
 })
 
-export default store
+export default store

+ 1 - 1
src/utils/auth.js

@@ -1,6 +1,6 @@
 import Cookies from 'js-cookie'
 
-const TokenKey = 'GCLS_Token'
+const TokenKey = 'HM21St_Token'
 
 export function getToken() {
     return Cookies.get(TokenKey)

+ 3 - 1
src/views/content_manage/course_manage/CreateRecorded.vue

@@ -215,6 +215,8 @@ import "tinymce/plugins/textcolor";
 import "tinymce/plugins/colorpicker";
 import { getLogin } from "@/api/ajax";
 const Base64 = require("js-base64").Base64;
+import { mapState } from 'vuex';
+
 
 export default {
   //import引入的组件需要注入到对象中才能使用
@@ -362,7 +364,7 @@ export default {
   },
   //计算属性 类似于data概念
   computed: {
-    
+    ...mapState(['$studyType']),
   },
   //监控data中数据变化
   watch: {

+ 2 - 1
src/views/content_manage/course_manage/LiveCourse.vue

@@ -164,6 +164,7 @@ import NavMenu from "../../../components/NavMenu.vue"
 import Breadcrumb from '../../../components/Breadcrumb.vue';
 import { cutMoneyFiter } from '@/utils/defined';
 import { getLogin } from "@/api/ajax";
+import { mapState } from 'vuex';
 
 export default {
   //import引入的组件需要注入到对象中才能使用
@@ -212,7 +213,7 @@ export default {
   },
   //计算属性 类似于data概念
   computed: {
-    
+    ...mapState(['$checkStatusList', '$checkStatusColorList']),
   },
   //监控data中数据变化
   watch: {},

+ 2 - 1
src/views/content_manage/course_manage/RecordedCourse.vue

@@ -203,6 +203,7 @@ import NavMenu from "../../../components/NavMenu.vue"
 import Breadcrumb from '../../../components/Breadcrumb.vue';
 import { cutMoneyFiter } from '@/utils/defined';
 import { getLogin } from "@/api/ajax";
+import { mapState } from 'vuex'; 
 
 export default {
   //import引入的组件需要注入到对象中才能使用
@@ -267,7 +268,7 @@ export default {
   },
   //计算属性 类似于data概念
   computed: {
-    
+    ...mapState(['$studyTypeAll', '$checkStatusList', '$checkStatusColorList']),
   },
   //监控data中数据变化
   watch: {},

+ 2 - 1
src/views/content_manage/newspaper_manage/ChannelList.vue

@@ -214,6 +214,7 @@
 //例如:import 《组件名称》from ‘《组件路径》';
 import Header from "../../../components/Header.vue";
 import { getLogin } from "@/api/ajax";
+import { mapState } from 'vuex'; 
 
 export default {
   //import引入的组件需要注入到对象中才能使用
@@ -283,7 +284,7 @@ export default {
   },
   //计算属性 类似于data概念
   computed: {
-    
+    ...mapState(['$studyTypeAll','$studyType']),
   },
   //监控data中数据变化
   watch: {},

+ 2 - 1
src/views/content_manage/newspaper_manage/index.vue

@@ -196,6 +196,7 @@
 import Header from "../../../components/Header.vue";
 import NavMenu from "../../../components/NavMenu.vue"
 import Breadcrumb from '../../../components/Breadcrumb.vue';
+import { mapState } from 'vuex'; 
 import {
   provinceAndCityData
 } from "element-china-area-data";
@@ -291,7 +292,7 @@ export default {
   },
   //计算属性 类似于data概念
   computed: {
-    
+    ...mapState(['$studyTypeAll','$checkStatusList', '$checkStatusColorList']),
   },
   //监控data中数据变化
   watch: {},

+ 1 - 0
src/views/login.vue

@@ -161,6 +161,7 @@ export default {
                 this.loading = false
                 setToken(res);
                 this.$router.push({ path: "/EnterSys" });
+                window.location.reload()
             })
             .catch(() => {
                 this.loading = false

+ 2 - 1
src/views/organize_manage/CreateOrganize.vue

@@ -130,6 +130,7 @@ import { getLogin } from "@/api/ajax";
 import {
   provinceAndCityData
 } from "element-china-area-data";
+import { mapState } from 'vuex';
 
 export default {
   //import引入的组件需要注入到对象中才能使用
@@ -301,7 +302,7 @@ export default {
   },
   //计算属性 类似于data概念
   computed: {
-    
+    ...mapState(['$orgType']),
   },
   //监控data中数据变化
   watch: {

+ 2 - 1
src/views/organize_manage/index.vue

@@ -193,6 +193,7 @@ import { getLogin } from "@/api/ajax";
 import {
   provinceAndCityData
 } from "element-china-area-data";
+import { mapState } from 'vuex';
 
 export default {
   //import引入的组件需要注入到对象中才能使用
@@ -270,7 +271,7 @@ export default {
   },
   //计算属性 类似于data概念
   computed: {
-    
+    ...mapState(['$orgTypeAll']),
   },
   //监控data中数据变化
   watch: {},