From 6e1e2b85e0926175053746cfe19f82afc452c24a Mon Sep 17 00:00:00 2001 From: whycq <10027870+whycq@user.noreply.gitee.com> Date: 星期五, 20 十月 2023 08:29:08 +0800 Subject: [PATCH] # --- pages/user/user.vue | 42 ++++++++++++++++++------------------------ 1 files changed, 18 insertions(+), 24 deletions(-) diff --git a/pages/user/user.vue b/pages/user/user.vue index cb5bc04..f03cfc6 100644 --- a/pages/user/user.vue +++ b/pages/user/user.vue @@ -20,6 +20,7 @@ </template> <script> + import user from '@/pages/api/user/user.js' export default{ data() { return { @@ -30,35 +31,28 @@ this.getDetail() }, methods: { + async getDetail() { + let res = await user.getDetail() + if (res.code === 200) { + this.username = res.data.username + console.log(res); + } else if (res.code === 403) { + this.backLogin(res) + } + }, userDetail() { uni.navigateTo({ url:'/pages/user/user_detail/userDetail' }) }, - getDetail() { - let that = this - uni.request({ - url: that.baseUrl + '/user/detail/auth', - header: {'token' : uni.getStorageSync('token')}, - method: 'POST', - success(res) { - res = res.data - if (res.code === 200) { - that.username = res.data.username - } else if (res.code === 403) { - uni.showToast({title: res.msg, icon: "none", position: 'top'}) - setTimeout(() => { - uni.reLaunch({ - url: '../../login/login' - }); - }, 1000); - } else { - uni.showToast({title: res.msg, icon: "none",position: 'top'}) - } - console.log(res.data); - } - }) - }, + backLogin(res) { + uni.showToast({title: res.msg, icon: "none", position: 'top'}) + setTimeout(() => { + uni.reLaunch({ + url: '../login/login' + }); + }, 1000); + } } } </script> -- Gitblit v1.9.1