index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. default_head_img: '../../../static/head.png', // 默认头像
  37. user_name: '用户名',
  38. pageList: [],
  39. }
  40. },
  41. onLoad() {
  42. this.getMyUserInfo();
  43. this.loadMoreData();
  44. },
  45. methods: {
  46. getMyUserInfo() {
  47. GetMyUserInfo().then((res) => {
  48. if (res.status) {
  49. this.user_name = res.real_name;
  50. this.user_head_img = res.image_url ? res.image_url : this.default_head_img;
  51. }
  52. });
  53. },
  54. //加载数据
  55. loadMoreData() {
  56. GetMyBookList_JoinCourse_Student().then((res) => {
  57. if (res.status) {
  58. this.pageList = res.book_list;
  59. }
  60. })
  61. },
  62. //退出
  63. signOut() {
  64. this.$store.dispatch('user/signOut');
  65. window.location.href = '/';
  66. },
  67. linkBook(book_id) {
  68. let baseUrl = location.protocol + '//' + location.hostname + (location.port ? ':' + location.port : '');
  69. let url = baseUrl + '/GCLS-Book/#/courseview?showCourse=true&invok_module=GCLS-LC&bookId=' + book_id +
  70. "&enterPage=mobilePerson";
  71. //window.open(url, 'target');
  72. window.location.href = url;
  73. },
  74. }
  75. }
  76. </script>
  77. <style lang="scss">
  78. .percon-area {
  79. .head-card {
  80. margin: 16rpx;
  81. background-color: #fff;
  82. border-radius: 16rpx;
  83. //height: 400rpx;
  84. padding: 17px;
  85. display: flex;
  86. flex-direction: column;
  87. align-items: center;
  88. justify-content: center;
  89. row-gap: 32rpx;
  90. font-weight: 500;
  91. font-size: 13pt;
  92. .head-box {
  93. width: 160rpx;
  94. height: 160rpx;
  95. background-color: #d9d9d9;
  96. margin: 0 auto;
  97. border-radius: 80rpx;
  98. uni-image {
  99. width: 100%;
  100. height: 100%;
  101. border-radius: 80rpx;
  102. }
  103. }
  104. .quit-btn {
  105. font-size: 16px;
  106. border: 1px solid #ed5c5c;
  107. color: #ed5c5c;
  108. background-color: #fff;
  109. padding: 0 40rpx;
  110. }
  111. }
  112. .book-card {
  113. padding: 16px 22px;
  114. height: auto;
  115. margin-bottom: 120px;
  116. .book-box {
  117. width: 85%;
  118. aspect-ratio: 3 / 4;
  119. background-color: #d9d9d9;
  120. uni-image {
  121. width: 100%;
  122. height: 100%;
  123. }
  124. }
  125. .book-box::before {
  126. display: inline-block;
  127. padding-bottom: 120%;
  128. content: '';
  129. }
  130. .text {
  131. margin: 16rpx 0 32rpx 0;
  132. width: 85%;
  133. font-size: 13pt;
  134. }
  135. /deep/ .uni-grid-item {
  136. width: 33% !important;
  137. .uni-grid-item__box {
  138. align-items: center;
  139. }
  140. }
  141. }
  142. }
  143. </style>