feat: 增加登录接口

This commit is contained in:
zhangds 2024-05-30 18:30:23 +08:00
parent 15b63a143f
commit af428323e1
2 changed files with 39 additions and 3 deletions

View File

@ -1,4 +1,5 @@
const baseurl = "http://lottery.unipay.test.86698.cn/api"; // 测试 const baseurl = "http://192.168.110.39:8080"; // 本地
// const baseurl = "http://lottery.unipay.test.86698.cn/api"; // 测试
// const baseurl = ""; // 正式 // const baseurl = ""; // 正式
//统一请求 //统一请求
axios.interceptors.request.use((config) => { axios.interceptors.request.use((config) => {

View File

@ -96,7 +96,7 @@
<div class="skeleton-loader" style="width: 2.5rem; height: 0.2rem;"></div> <div class="skeleton-loader" style="width: 2.5rem; height: 0.2rem;"></div>
</div> </div>
<div class="am-toast text" v-show="state.toast"> <div class="am-toast text" v-show="state.showToast">
<div class="am-toast-text"> <div class="am-toast-text">
{{ state.toastText }} {{ state.toastText }}
</div> </div>
@ -113,22 +113,57 @@
showPage: false, showPage: false,
showPop: "", showPop: "",
checkedGoods: "", checkedGoods: "",
toast: false, showToast: false,
toastText: "" toastText: ""
}) })
const openToast = (msg) => {
if (state.showToast) return;
state.toastText = msg;
state.showToast = true;
setTimeout(() => {
state.showToast = false;
}, 1500);
};
// 获取商品列表 // 获取商品列表
const getGoodsList = () => { const getGoodsList = () => {
} }
// 获取用户信息
const getUserInfo = () => {
try {
req.axiosGet("/front/getAccountInfo", {
token: state.token
}).then(res => {
console.log("res =>", res);
if (res.code === 200) {
state.showPage = true;
} else {
openToast(res.message);
}
})
} catch (err) {
console.log("err =>", err);
}
}
onMounted(() => { onMounted(() => {
const url = new URL(window.location.href); const url = new URL(window.location.href);
const searchParams = new URLSearchParams(url.search); const searchParams = new URLSearchParams(url.search);
const token = searchParams.get("token"); const token = searchParams.get("token");
if (token) { if (token) {
state.token = token; state.token = token;
localStorage.setItem("yl_token", token);
state.showPage = true;
return
getUserInfo();
} else {
openToast("未登录");
} }
}) })