index.vue 3.9 KB

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