#
whycq
2023-11-24 9a3837ce2d128a9f03264f2ce99b8d3584e5520e
pages/user/user.vue
@@ -1,8 +1,102 @@
<template>
   <view>
      <view class="user" @click="userDetail">
         <!-- 头像 -->
         <view class="user-avatar">
            <image src="../../static/image/user__easyico.png" mode="aspectFit"></image>
         </view>
         <!-- 信息 -->
         <view class="user-info">
            <view class="user-name">{{username}}</view>
            <view class="user-company">中扬立库技术有限公司</view>
         </view>
         <!-- 更多 -->
         <view class="user-icons">
            <uni-icons type="right"></uni-icons>
         </view>
      </view>
   </view>
</template>
<script>
   import user from '@/pages/api/user/user.js'
   export default{
      data() {
         return {
            username: ''
         }
      },
      onShow() {
         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'
            })
         },
         backLogin(res) {
            uni.showToast({title: res.msg, icon: "none", position: 'top'})
            setTimeout(() => {
               uni.reLaunch({
                  url: '../login/login'
               });
            }, 1000);
         }
      }
   }
</script>
<style>
   .user {
      width: 100%;
      height: 200rpx;
      background-color: #fff;
      display: grid;
      grid-template-columns: 1fr 4fr 1fr;
   }
   .user-avatar {
      height: 100rpx;
      width: 100rpx;
      padding: 50rpx;
      /* background-color: aquamarine; */
      display: flex;
      justify-content: center;
      align-items: center;
   }
   .user-avatar img {
      height: 100rpx;
      border-radius: 20rpx;
   }
   .user-info {
      height: 200rpx;
      display: grid;
      grid-template-rows: 2fr 2fr;
      /* background-color: aqua; */
   }
   .user-name {
      height: 100rpx;
      width: 100%;
      display: flex;
      align-items: flex-end;
      font-size: 30rpx;
      font-weight: 700;
   }
   .user-company {
      height: 100rpx;
   }
   .user-icons {
      display: flex;
      align-items: center;
      justify-content: center;
   }
</style>