kidArtExpo/src/store/auth/index.js

30 lines
747 B
JavaScript
Raw Normal View History

2024-08-07 12:00:54 +00:00
import {ref} from 'vue'
import {createGlobalState,useStorage} from '@vueuse/core'
import {sendCode} from '@/api/auth/index.js'
import {message} from "@/utils/message.js"
export const useAuth=createGlobalState(()=>{
const token = useStorage('token', '', localStorage)
const telNum =ref('')
const code=ref('')
const clickSendCode=async ()=>{
if (!telNum.value){
message.warning('请输入手机号')
return
}
const data={
telNum:telNum.value
}
const res=await sendCode(data)
if (res.status===0){
message.success('发送成功')
}
}
return {
code,
clickSendCode,
telNum,
token
}
})