修改了api集中化 搞定了vuex
This commit is contained in:
@@ -149,11 +149,8 @@
|
||||
import { defineComponent, reactive, ref } from "vue";
|
||||
import LoginTab from "@/components/login/LoginTab.vue";
|
||||
import NavTop from "@/components/NavTop.vue"
|
||||
import { loginpass, sendsms } from '@/api';
|
||||
import { message } from 'ant-design-vue';
|
||||
import { ResData } from '@/types';
|
||||
import { saveValue } from '@/utils/common';
|
||||
import router from '@/router';
|
||||
import { loginpass } from '@/api';
|
||||
import store from '@/store';
|
||||
|
||||
export default defineComponent({
|
||||
name: "Login",
|
||||
@@ -188,9 +185,6 @@ export default defineComponent({
|
||||
*/
|
||||
const getcode: () => void = () => {
|
||||
console.log(phone.value);
|
||||
sendsms("86" + phone.value, 0).then((res)=>{
|
||||
console.log(res)
|
||||
})
|
||||
const timestep = setInterval(() => {
|
||||
console.log(11112);
|
||||
time.value = time.value - 1;
|
||||
@@ -202,23 +196,12 @@ export default defineComponent({
|
||||
}
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
function login(): void {
|
||||
console.log(userinfo.phone,userinfo.password)
|
||||
|
||||
loginpass(userinfo.phone,userinfo.password).then((res: ResData) =>{
|
||||
console.log(res.code)
|
||||
if(res.code == 1){
|
||||
message.error(res.msg)
|
||||
}else{
|
||||
console.log(res.data)
|
||||
if(!saveValue("token", res.data.api_token)){
|
||||
message.error("存储错误, 请允许网页使用本地存储!")
|
||||
}else{
|
||||
router.push("/mine/archives")
|
||||
}
|
||||
}
|
||||
loginpass(userinfo.phone,userinfo.password).then(()=>{
|
||||
store.dispatch("setUserInfo");
|
||||
})
|
||||
|
||||
}
|
||||
return {
|
||||
formLayout,
|
||||
|
||||
Reference in New Issue
Block a user