出现tokne自动切登录
This commit is contained in:
		
							parent
							
								
									5832f7a0bc
								
							
						
					
					
						commit
						b41672ce8b
					
				@ -7,6 +7,7 @@
 | 
			
		||||
</template>
 | 
			
		||||
<script lang="ts">
 | 
			
		||||
import { defineComponent } from 'vue';
 | 
			
		||||
import router from './router';
 | 
			
		||||
import store from './store';
 | 
			
		||||
import { getValue } from './utils/common';
 | 
			
		||||
 | 
			
		||||
@ -15,6 +16,8 @@ export default defineComponent({
 | 
			
		||||
    if(getValue('token')){
 | 
			
		||||
      store.commit("login", true)
 | 
			
		||||
      store.dispatch("setUserInfo");
 | 
			
		||||
    }else{
 | 
			
		||||
      router.push("/")
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
@ -3,6 +3,7 @@ import axios from '../config/axiosConfig'
 | 
			
		||||
import { AxiosRequestConfig, CustomSuccessData } from 'axios';
 | 
			
		||||
import { getValue } from '@/utils/common';
 | 
			
		||||
import { message } from 'ant-design-vue';
 | 
			
		||||
import router from '@/router';
 | 
			
		||||
 | 
			
		||||
// 泛型接口 
 | 
			
		||||
export interface Get {
 | 
			
		||||
@ -10,7 +11,9 @@ export interface Get {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
axios.interceptors.response.use((response)=>{
 | 
			
		||||
    
 | 
			
		||||
    if(response.data.code == 1001){
 | 
			
		||||
        router.push("/")
 | 
			
		||||
    }
 | 
			
		||||
    return response;
 | 
			
		||||
},(error)=>{
 | 
			
		||||
    message.error(error.response.data.message)
 | 
			
		||||
 | 
			
		||||
@ -235,3 +235,24 @@ export async function sendsms(phone: string, type: number): Promise<boolean>{
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 获取国家数据
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
interface Countries{
 | 
			
		||||
    id: number;
 | 
			
		||||
    name: string;
 | 
			
		||||
    country_code: string;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface Willsay{
 | 
			
		||||
    languageid: number;
 | 
			
		||||
    name: string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export async function getarchives(): Promise<[Countries[],Willsay[]]>{
 | 
			
		||||
    return [(await get<Countries[]>("countries")).data, (await get<Willsay[]>("willsay")).data];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -22,8 +22,8 @@
 | 
			
		||||
                            ref="select"
 | 
			
		||||
                            :getPopupContainer="triggerNode => triggerNode.parentNode"
 | 
			
		||||
                        >
 | 
			
		||||
                            <a-select-option v-for="(item, index) in ['美国', '英国']" :key="index" :value="item">
 | 
			
		||||
                                {{ item }}
 | 
			
		||||
                            <a-select-option v-for="(item, index) in chiveslist[0]" :key="index" :value="item.name">
 | 
			
		||||
                                {{ item.name }}
 | 
			
		||||
                            </a-select-option>
 | 
			
		||||
                        </a-select>
 | 
			
		||||
                    </div>
 | 
			
		||||
@ -57,8 +57,8 @@
 | 
			
		||||
                                        ref="select"
 | 
			
		||||
                                        :getPopupContainer="triggerNode => triggerNode.parentNode"
 | 
			
		||||
                                    >
 | 
			
		||||
                                        <a-select-option v-for="(item, index) in ['英语', '法语']" :key="index" :value="item">
 | 
			
		||||
                                            {{ item }}
 | 
			
		||||
                                        <a-select-option v-for="(item, index) in chiveslist[1]" :key="index" :value="item.name">
 | 
			
		||||
                                            {{ item.name }}
 | 
			
		||||
                                        </a-select-option>
 | 
			
		||||
                                    </a-select>
 | 
			
		||||
                                    <div class="proficiency">
 | 
			
		||||
@ -84,8 +84,8 @@
 | 
			
		||||
                            ref="select"
 | 
			
		||||
                            :getPopupContainer="triggerNode => triggerNode.parentNode"
 | 
			
		||||
                        >
 | 
			
		||||
                            <a-select-option v-for="(item, index) in ['英语', '法语']" :key="index" :value="item">
 | 
			
		||||
                                {{ item }}
 | 
			
		||||
                            <a-select-option v-for="(item, index) in chiveslist[1]" :key="index" :value="item.name">
 | 
			
		||||
                                {{ item.name }}
 | 
			
		||||
                            </a-select-option>
 | 
			
		||||
                        </a-select>
 | 
			
		||||
                    </div>
 | 
			
		||||
@ -259,13 +259,14 @@
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script lang="ts">
 | 
			
		||||
import { computed, defineComponent, reactive, Ref, ref } from "vue";
 | 
			
		||||
import { computed, defineComponent, onMounted, reactive, Ref, ref } from "vue";
 | 
			
		||||
import { UserOutlined, PlaySquareOutlined } from '@ant-design/icons-vue';
 | 
			
		||||
import NavBottom from '@/components/NavBottom.vue';
 | 
			
		||||
import { uploadflie } from "@/utils/vod"
 | 
			
		||||
import store from '@/store';
 | 
			
		||||
import smile from "@/static/images/smile.png"
 | 
			
		||||
import smilet from "@/static/images/smilet.png"
 | 
			
		||||
import { getarchives } from "@/api/index"
 | 
			
		||||
 | 
			
		||||
export default defineComponent({
 | 
			
		||||
    name: "Archives",
 | 
			
		||||
@ -285,9 +286,15 @@ export default defineComponent({
 | 
			
		||||
        }];
 | 
			
		||||
        const userinfo = computed(() => store.state.userinfo)
 | 
			
		||||
        // 表单数据
 | 
			
		||||
        const formData = reactive(store.state.userinfo);
 | 
			
		||||
        const formData = reactive(userinfo);
 | 
			
		||||
        
 | 
			
		||||
        const modalNode = () => document.getElementsByClassName('modal-container')[0]
 | 
			
		||||
 | 
			
		||||
        const chiveslist = ref<unknown>([[],[]]);
 | 
			
		||||
        onMounted(async ()=>{
 | 
			
		||||
            chiveslist.value = await getarchives()
 | 
			
		||||
        })
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * 修改用户名
 | 
			
		||||
         * @return { void }
 | 
			
		||||
@ -300,9 +307,9 @@ export default defineComponent({
 | 
			
		||||
         * @return { void }
 | 
			
		||||
         */
 | 
			
		||||
        function addSpeakLang (): void {
 | 
			
		||||
            store.state.userinfo.willsay.push({
 | 
			
		||||
            formData.value.willsay.push({
 | 
			
		||||
                name: '请选择',
 | 
			
		||||
                level: 4
 | 
			
		||||
                level: 0
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        // 验证码
 | 
			
		||||
@ -432,6 +439,8 @@ export default defineComponent({
 | 
			
		||||
        function setlevel(index: number, level: number){
 | 
			
		||||
            store.state.userinfo.willsay[index].level = level
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        
 | 
			
		||||
        return {
 | 
			
		||||
            modalNode,
 | 
			
		||||
            formData,
 | 
			
		||||
@ -453,11 +462,12 @@ export default defineComponent({
 | 
			
		||||
            passwordForm,
 | 
			
		||||
            updateUserPassword,
 | 
			
		||||
            submitInfo,
 | 
			
		||||
            userinfo,
 | 
			
		||||
            userinfo: formData,
 | 
			
		||||
            uploads,
 | 
			
		||||
            smile,
 | 
			
		||||
            smilet,
 | 
			
		||||
            setlevel
 | 
			
		||||
            setlevel,
 | 
			
		||||
            chiveslist
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user