index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <view class="percon-area">
  3. <navbar />
  4. <view style="height:92rpx;"></view>
  5. <view class="head-card">
  6. <view class="head-box">
  7. <image :src="user_head_img"></image>
  8. </view>
  9. <text class="user-text">{{user_name}}</text>
  10. <button class="quit-btn" @click="signOut">退出登录</button>
  11. </view>
  12. <view class="head-card book-card">
  13. <uni-grid :column="3" :showBorder="false" :square="false">
  14. <uni-grid-item v-for="(item, index) in pageList" :key="index">
  15. <view class="book-box" @click="linkBook(item.book_id)">
  16. <image :src="item.book_picture_url"></image>
  17. </view>
  18. <text class="text" @click="linkBook(item.book_id)">{{item.book_name}}</text>
  19. </uni-grid-item>
  20. </uni-grid>
  21. </view>
  22. <view style="height:120rpx;"></view>
  23. </view>
  24. </template>
  25. <script>
  26. import {
  27. GetMyBookList_JoinCourse_Student,
  28. } from '@/api/exercise.js';
  29. import {
  30. GetMyUserInfo,
  31. } from '@/api/user.js';
  32. export default {
  33. data() {
  34. return {
  35. user_head_img: '', // 用户头像
  36. user_name: '用户名',
  37. pageList: [],
  38. }
  39. },
  40. onLoad() {
  41. this.getMyUserInfo();
  42. this.loadMoreData();
  43. },
  44. methods: {
  45. getMyUserInfo() {
  46. GetMyUserInfo().then((res) => {
  47. if (res.status) {
  48. this.user_name = res.real_name;
  49. this.user_head_img = res.image_url;
  50. }
  51. });
  52. },
  53. //加载数据
  54. loadMoreData() {
  55. GetMyBookList_JoinCourse_Student().then((res) => {
  56. if (res.status) {
  57. this.pageList = res.book_list;
  58. }
  59. })
  60. },
  61. //退出
  62. signOut() {
  63. this.$store.dispatch('user/signOut');
  64. window.location.href = '/';
  65. },
  66. linkBook(book_id) {
  67. let baseUrl = location.protocol + '//' + location.hostname + (location.port ? ':' + location.port : '');
  68. let url = baseUrl + '/GCLS-Book/#/courseview?showCourse=true&invok_module=GCLS-LC&bookId=' + book_id;
  69. window.open(url, 'target');
  70. },
  71. }
  72. }
  73. </script>
  74. <style lang="scss">
  75. .percon-area {
  76. .head-card {
  77. margin: 16rpx;
  78. background-color: #fff;
  79. border-radius: 16rpx;
  80. height: 400rpx;
  81. display: flex;
  82. flex-direction: column;
  83. align-items: center;
  84. justify-content: center;
  85. row-gap: 32rpx;
  86. font-weight: 500;
  87. font-size: 13pt;
  88. .head-box {
  89. width: 160rpx;
  90. height: 160rpx;
  91. background-color: #d9d9d9;
  92. margin: 0 auto;
  93. border-radius: 80rpx;
  94. uni-image {
  95. width: 100%;
  96. height: 100%;
  97. border-radius: 80rpx;
  98. }
  99. }
  100. .quit-btn {
  101. font-size: 16px;
  102. border: 1px solid #ed5c5c;
  103. color: #ed5c5c;
  104. background-color: #fff;
  105. padding: 0 40rpx;
  106. }
  107. }
  108. .book-card {
  109. padding: 16px 22px;
  110. height: auto;
  111. margin-bottom: 120px;
  112. .book-box {
  113. width: 85%;
  114. aspect-ratio: 3 / 4;
  115. background-color: #d9d9d9;
  116. uni-image {
  117. width: 100%;
  118. height: 100%;
  119. }
  120. }
  121. .book-box::before {
  122. display: inline-block;
  123. padding-bottom: 120%;
  124. content: '';
  125. }
  126. .text {
  127. margin: 16rpx 0 32rpx 0;
  128. width: 85%;
  129. font-size: 13pt;
  130. }
  131. /deep/ .uni-grid-item {
  132. width: 33% !important;
  133. .uni-grid-item__box {
  134. align-items: center;
  135. }
  136. }
  137. }
  138. }
  139. </style>