|  |  |  | 
|---|
|  |  |  | <view class="user" @click="userDetail"> | 
|---|
|  |  |  | <!-- 头像 --> | 
|---|
|  |  |  | <view class="user-avatar"> | 
|---|
|  |  |  | <img src="" alt=""> | 
|---|
|  |  |  | <!-- <image src="" mode="aspectFit"></image> --> | 
|---|
|  |  |  | <image src="../../static/image/user__easyico.png" mode="aspectFit"></image> | 
|---|
|  |  |  | </view> | 
|---|
|  |  |  | <!-- 信息 --> | 
|---|
|  |  |  | <view class="user-info"> | 
|---|
|  |  |  | 
|---|
|  |  |  | </template> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <script> | 
|---|
|  |  |  | import user from '@/pages/api/user/user.js' | 
|---|
|  |  |  | export default{ | 
|---|
|  |  |  | data() { | 
|---|
|  |  |  | return { | 
|---|
|  |  |  | 
|---|
|  |  |  | this.getDetail() | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | methods: { | 
|---|
|  |  |  | async getDetail() { | 
|---|
|  |  |  | let res = await user.getDetail() | 
|---|
|  |  |  | if (res.code === 200) { | 
|---|
|  |  |  | this.username = res.data.username | 
|---|
|  |  |  | console.log(res.data); | 
|---|
|  |  |  | } 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> | 
|---|
|  |  |  | 
|---|
|  |  |  | grid-template-columns: 1fr 4fr 1fr; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | .user-avatar { | 
|---|
|  |  |  | height: 200rpx; | 
|---|
|  |  |  | width: 200rpx; | 
|---|
|  |  |  | height: 100rpx; | 
|---|
|  |  |  | width: 100rpx; | 
|---|
|  |  |  | padding: 50rpx; | 
|---|
|  |  |  | /* background-color: aquamarine; */ | 
|---|
|  |  |  | display: flex; | 
|---|
|  |  |  | justify-content: center; | 
|---|