#
whycq
2022-12-28 729878405989b26424c84ddf916aa2a1cd8fe3b0
pages/user/user.vue
@@ -8,7 +8,7 @@
         </view>
         <!-- 信息 -->
         <view class="user-info">
            <view class="user-name">陈鹏</view>
            <view class="user-name">{{username}}</view>
            <view class="user-company">中扬立库技术有限公司</view>
         </view>
         <!-- 更多 -->
@@ -23,15 +23,42 @@
   export default{
      data() {
         return {
            username: ''
         }
      },
      onShow() {
         this.getDetail()
      },
      methods: {
         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);
               }
            })
         },
      }
   }
</script>