#
whycq
2023-10-20 6e1e2b85e0926175053746cfe19f82afc452c24a
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) {
         backLogin(res) {
                     uni.showToast({title: res.msg, icon: "none", position: 'top'})
                     setTimeout(() => {
                        uni.reLaunch({
                           url: '../../login/login'
                  url: '../login/login'
                        });
                     }, 1000);
                  } else {
                     uni.showToast({title: res.msg, icon: "none",position: 'top'})
                  }
                  console.log(res.data);
               }
            })
         },
      }
   }
</script>