From 2c056d0c4b960052da340922904fe39a82d98936 Mon Sep 17 00:00:00 2001
From: whycq <10027870+whycq@user.noreply.gitee.com>
Date: 星期五, 27 十月 2023 09:42:39 +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