286 lines
		
	
	
		
			6.2 KiB
		
	
	
	
		
			Vue
		
	
	
	
			
		
		
	
	
			286 lines
		
	
	
		
			6.2 KiB
		
	
	
	
		
			Vue
		
	
	
	
| <template>
 | |
|   <div class="my-page">
 | |
|     <PageHeader
 | |
|       title="我的"
 | |
|       :is-back="false"
 | |
|       :border-bottom="false"
 | |
|       :background="headerBackground"
 | |
|     />
 | |
| 
 | |
|     <div class="content-wrapper">
 | |
|       <div class="user-info">
 | |
|         <div class="avatar">
 | |
|           <!-- <img src="" alt="用户头像" /> -->
 | |
|         </div>
 | |
|         <div class="info">
 | |
|           <div class="name">{{ teacherInfo.name }}</div>
 | |
|           <div class="tag">
 | |
|             <image
 | |
|               class="tag-icon"
 | |
|               src="@/static/notes/collage-icon.png"
 | |
|             ></image>
 | |
|             {{ teacherInfo.collegeName }}
 | |
|           </div>
 | |
|           <div class="tag">
 | |
|             <image class="tag-icon" src="@/static/notes/major-icon.png"></image>
 | |
|             {{ teacherInfo.professionalName }}
 | |
|           </div>
 | |
|         </div>
 | |
|       </div>
 | |
| 
 | |
|       <div class="statistics">
 | |
|         <div class="stat-item">
 | |
|           <div class="stat-num">36</div>
 | |
|           <div class="stat-label">总答题</div>
 | |
|         </div>
 | |
|         <div class="stat-item">
 | |
|           <div class="stat-num">10</div>
 | |
|           <div class="stat-label">已完成</div>
 | |
|         </div>
 | |
|         <div class="stat-item">
 | |
|           <div class="stat-num">26</div>
 | |
|           <div class="stat-label">未回复</div>
 | |
|         </div>
 | |
|       </div>
 | |
| 
 | |
|       <div class="banner">
 | |
|         <img src="@/static/notes/banner.png" alt="banner" />
 | |
|       </div>
 | |
| 
 | |
|       <div class="menu-list">
 | |
|         <div class="menu-item" @click="navigateTo('personal-info')">
 | |
|           <div class="menu-icon">
 | |
|             <image src="@/static/notes/menu1.png" class="menu-icon-img"></image>
 | |
|           </div>
 | |
|           <div class="menu-text">个人信息</div>
 | |
|           <view class="arrow-icon">
 | |
|             <u-icon name="arrow-right" color="#999" size="24"></u-icon>
 | |
|           </view>
 | |
|         </div>
 | |
|         <div class="menu-item" @click="navigateTo('change-password')">
 | |
|           <div class="menu-icon">
 | |
|             <image src="@/static/notes/menu2.png" class="menu-icon-img"></image>
 | |
|           </div>
 | |
|           <div class="menu-text">修改密码</div>
 | |
|           <view class="arrow-icon">
 | |
|             <u-icon name="arrow-right" color="#999" size="24"></u-icon>
 | |
|           </view>
 | |
|         </div>
 | |
|         <div class="menu-item" @click="navigateTo('logout-records')">
 | |
|           <div class="menu-icon">
 | |
|             <image src="@/static/notes/menu3.png" class="menu-icon-img"></image>
 | |
|           </div>
 | |
|           <div class="menu-text">退出登录</div>
 | |
|           <view class="arrow-icon">
 | |
|             <u-icon name="arrow-right" color="#999" size="24"></u-icon>
 | |
|           </view>
 | |
|         </div>
 | |
|       </div>
 | |
|     </div>
 | |
| 
 | |
|     <TabBar :currentPath="'/pages/my/index'" @change="handleTabChange" />
 | |
|   </div>
 | |
| </template>
 | |
| 
 | |
| <script>
 | |
| import TabBar from "@/components/TabBar.vue";
 | |
| import PageHeader from "@/components/PageHeader.vue";
 | |
| 
 | |
| export default {
 | |
|   name: "MyPage",
 | |
|   components: {
 | |
|     TabBar,
 | |
|     PageHeader,
 | |
|   },
 | |
|   data() {
 | |
|     return {
 | |
|       headerBackground: {
 | |
|         background: "transparent",
 | |
|       },
 | |
|       teacherInfo: {},
 | |
|     };
 | |
|   },
 | |
|   onLoad() {
 | |
|     this.getTeacherInfo();
 | |
|   },
 | |
|   methods: {
 | |
|     navigateTo(route) {
 | |
|       // 导航到指定路由
 | |
|       if (route === 'personal-info') {
 | |
|         uni.navigateTo({
 | |
|           url: '/pages/my/personalInfo'
 | |
|         });
 | |
|       } else if (route === 'change-password') {
 | |
|         uni.showToast({
 | |
|           title: '功能开发中',
 | |
|           icon: 'none'
 | |
|         });
 | |
|       } else if (route === 'logout-records') {
 | |
|         uni.showModal({
 | |
|           title: '提示',
 | |
|           content: '确定要退出登录吗?',
 | |
|           success: (res) => {
 | |
|             if (res.confirm) {
 | |
|               // 清除用户信息
 | |
|               this.$u.vuex('vuex_teacherInfo', {});
 | |
|               this.$u.vuex('vuex_token', '');
 | |
|               // 跳转到登录页
 | |
|               uni.reLaunch({
 | |
|                 url: '/pages/login/login/login'
 | |
|               });
 | |
|             }
 | |
|           }
 | |
|         });
 | |
|       }
 | |
|     },
 | |
|     handleTabChange(path, index) {
 | |
|       console.log("切换到标签页:", path, index);
 | |
|     },
 | |
|     getTeacherInfo() {
 | |
|       this.$u.api
 | |
|         .getTeacherInfo({ Id: "b5269ed1-5bc8-11f0-9a89-00163e2d2dd3" })
 | |
|         .then((res) => {
 | |
|           this.teacherInfo = res.data[0];
 | |
|           this.$u.vuex("vuex_teacherInfo", this.teacherInfo);
 | |
|         });
 | |
|     }
 | |
|   },
 | |
| };
 | |
| </script>
 | |
| 
 | |
| <style scoped>
 | |
| .my-page {
 | |
|   height: 100vh;
 | |
|   /* background-color: #f5f6fa; */
 | |
|   background-image: url("@/static/notes/bg.png");
 | |
|   background-position: center top;
 | |
|   background-repeat: no-repeat;
 | |
|   background-size: 100% auto; /* 以宽度为基准等比例缩放 */
 | |
|   display: flex;
 | |
|   flex-direction: column;
 | |
|   position: relative;
 | |
| }
 | |
| 
 | |
| .content-wrapper {
 | |
|   flex: 1;
 | |
|   display: flex;
 | |
|   flex-direction: column;
 | |
|   padding-bottom: 60px; /* 为底部导航栏预留空间 */
 | |
|   overflow: hidden; /* 防止滚动条出现 */
 | |
| }
 | |
| 
 | |
| .user-info {
 | |
|   display: flex;
 | |
|   padding: 30rpx;
 | |
| }
 | |
| 
 | |
| .avatar {
 | |
|   width: 148rpx;
 | |
|   height: 148rpx;
 | |
|   border-radius: 16rpx;
 | |
|   overflow: hidden;
 | |
|   margin-right: 30rpx;
 | |
|   background-color: #ddd;
 | |
| }
 | |
| 
 | |
| .avatar img {
 | |
|   width: 100%;
 | |
|   height: 100%;
 | |
|   object-fit: cover;
 | |
| }
 | |
| 
 | |
| .info .name {
 | |
|   font-size: 16px;
 | |
|   font-weight: bold;
 | |
|   margin-bottom: 24rpx;
 | |
| }
 | |
| 
 | |
| .tag-icon {
 | |
|   width: 20rpx;
 | |
|   height: 20rpx;
 | |
|   margin-right: 16rpx;
 | |
| }
 | |
| 
 | |
| .tag {
 | |
|   font-size: 10px;
 | |
|   font-weight: 500;
 | |
|   color: #666;
 | |
|   margin-bottom: 26rpx;
 | |
|   display: flex;
 | |
|   align-items: center;
 | |
| }
 | |
| 
 | |
| .statistics {
 | |
|   display: flex;
 | |
|   justify-content: space-around;
 | |
|   /* margin-top: 5px;
 | |
|   padding: 15px 0; */
 | |
| }
 | |
| 
 | |
| .stat-item {
 | |
|   display: flex;
 | |
|   flex-direction: column;
 | |
|   align-items: center;
 | |
|   padding: 20rpx 0 26rpx 0;
 | |
| }
 | |
| 
 | |
| .stat-num {
 | |
|   font-size: 20px;
 | |
|   font-weight: bold;
 | |
|   line-height: 40rpx;
 | |
|   color: #333;
 | |
| }
 | |
| 
 | |
| .stat-label {
 | |
|   font-size: 10px;
 | |
|   color: #666;
 | |
|   margin-top: 16rpx;
 | |
| }
 | |
| 
 | |
| .banner {
 | |
|   padding: 0 26rpx 0 26rpx;
 | |
| }
 | |
| 
 | |
| .banner img {
 | |
|   width: 100%;
 | |
|   border-radius: 8px;
 | |
|   height: 100%;
 | |
|   object-fit: cover;
 | |
| }
 | |
| 
 | |
| .menu-list {
 | |
|   background-color: #fff;
 | |
|   border-radius: 8px;
 | |
|   margin: 54rpx 30rpx 0 30rpx;
 | |
| }
 | |
| 
 | |
| .menu-item {
 | |
|   display: flex;
 | |
|   align-items: center;
 | |
|   padding: 15px;
 | |
| }
 | |
| 
 | |
| .menu-icon {
 | |
|   margin-right: 10px;
 | |
|   font-size: 20px;
 | |
| }
 | |
| 
 | |
| .menu-text {
 | |
|   flex: 1;
 | |
|   font-size: 16px;
 | |
| }
 | |
| 
 | |
| .arrow-icon {
 | |
|   display: flex;
 | |
|   align-items: center;
 | |
|   justify-content: center;
 | |
|   width: 30px;
 | |
|   height: 30px;
 | |
| }
 | |
| 
 | |
| .menu-icon-img {
 | |
|   width: 28rpx;
 | |
|   height: 28rpx;
 | |
| }
 | |
| </style>
 |