feat: 增加登录接口
This commit is contained in:
parent
15b63a143f
commit
af428323e1
|
@ -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 = ""; // 正式
|
||||
//统一请求
|
||||
axios.interceptors.request.use((config) => {
|
||||
|
|
39
index.html
39
index.html
|
@ -96,7 +96,7 @@
|
|||
<div class="skeleton-loader" style="width: 2.5rem; height: 0.2rem;"></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">
|
||||
{{ state.toastText }}
|
||||
</div>
|
||||
|
@ -113,22 +113,57 @@
|
|||
showPage: false,
|
||||
showPop: "",
|
||||
checkedGoods: "",
|
||||
toast: false,
|
||||
showToast: false,
|
||||
toastText: ""
|
||||
})
|
||||
|
||||
const openToast = (msg) => {
|
||||
if (state.showToast) return;
|
||||
state.toastText = msg;
|
||||
state.showToast = true;
|
||||
setTimeout(() => {
|
||||
state.showToast = false;
|
||||
}, 1500);
|
||||
};
|
||||
|
||||
|
||||
// 获取商品列表
|
||||
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(() => {
|
||||
const url = new URL(window.location.href);
|
||||
const searchParams = new URLSearchParams(url.search);
|
||||
const token = searchParams.get("token");
|
||||
if (token) {
|
||||
state.token = token;
|
||||
localStorage.setItem("yl_token", token);
|
||||
|
||||
state.showPage = true;
|
||||
return
|
||||
getUserInfo();
|
||||
} else {
|
||||
openToast("未登录");
|
||||
}
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue