index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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.id)">
  17. <image :src="item.picture_url"></image>
  18. </view>
  19. <text class="text" @click="linkBook(item.id)">{{item.name}}</text>
  20. </uni-grid-item>
  21. </uni-grid>
  22. </view>
  23. <uni-load-more :status="status" :icon-size="14" :content-text="contentText" v-if="pageList.length > 0" />
  24. </view>
  25. <view style="height:120rpx;"></view>
  26. </view>
  27. </template>
  28. <script>
  29. import {
  30. PageQueryBookList,
  31. } from '@/api/exercise.js';
  32. import {
  33. GetMyUserInfo,
  34. } from '@/api/user.js';
  35. export default {
  36. data() {
  37. return {
  38. user_head_img: '', // 用户头像
  39. default_head_img: '../../../static/head.png', // 默认头像
  40. user_name: '用户名',
  41. contentText: {
  42. contentdown: '下拉加载更多',
  43. contentrefresh: '加载中',
  44. contentnomore: '加载完毕'
  45. },
  46. pageQueryData: {
  47. page_capacity: 20, // 每页容量,最大不能超过 50
  48. cur_page: 1, // 当前查询第几页,页码序号从 1 开始
  49. publish_status: 1,
  50. sys_version_type: -1,
  51. is_control_publish_scope: "true",
  52. is_enable_book_org_free_license_query: "true",
  53. order_column_list: ["name"]
  54. },
  55. total: 0, //数据总条数
  56. pageList: [],
  57. }
  58. },
  59. onLoad() {
  60. this.getMyUserInfo();
  61. this.loadMoreData();
  62. },
  63. // 监听触底
  64. onReachBottom() {
  65. let that = this;
  66. if (that.total <= that.pageList.length) {
  67. uni.showToast({
  68. title: '已加载全部数据',
  69. icon: "none"
  70. });
  71. that.status = 'noMore';
  72. } else {
  73. that.status = 'loading';
  74. that.pageQueryData.cur_page++;
  75. that.loadMoreData();
  76. }
  77. },
  78. methods: {
  79. getMyUserInfo() {
  80. GetMyUserInfo().then((res) => {
  81. if (res.status) {
  82. this.user_name = res.real_name;
  83. this.user_head_img = res.image_url ? res.image_url : this.default_head_img;
  84. }
  85. });
  86. },
  87. //加载数据
  88. loadMoreData() {
  89. PageQueryBookList(this.pageQueryData).then((res) => {
  90. if (res.status) {
  91. this.total = res.total_count;
  92. if (res.total_count > 0) {
  93. const dataMap = res.book_list;
  94. this.pageList = this.reload ? dataMap : this.pageList.concat(dataMap);
  95. this.reload = false;
  96. }
  97. if (this.total === this.pageList.length) {
  98. this.reload = false;
  99. this.status = 'noMore'
  100. }
  101. }
  102. })
  103. },
  104. //退出
  105. signOut() {
  106. this.$store.dispatch('user/signOut');
  107. window.location.href = '/';
  108. },
  109. linkBook(book_id) {
  110. let baseUrl = location.protocol + '//' + location.hostname + (location.port ? ':' + location.port : '');
  111. let url = baseUrl + '/GCLS-Book/#/courseview?showCourse=true&invok_module=GCLS-LC&bookId=' + book_id +
  112. "&enterPage=mobilePerson";
  113. //window.open(url, 'target');
  114. window.location.href = url;
  115. },
  116. }
  117. }
  118. </script>
  119. <style lang="scss">
  120. /*竖屏样式*/
  121. .percon-area {
  122. .head-card {
  123. margin: 16rpx;
  124. background-color: #fff;
  125. border-radius: 16rpx;
  126. padding: 17px;
  127. display: flex;
  128. flex-direction: column;
  129. align-items: center;
  130. justify-content: center;
  131. row-gap: 32rpx;
  132. font-weight: 500;
  133. font-size: 13pt;
  134. @media (orientation: landscape) {
  135. row-gap: 18rpx;
  136. justify-content: start;
  137. height: 260px;
  138. min-width: 120px;
  139. }
  140. .head-box {
  141. width: 160rpx;
  142. height: 160rpx;
  143. background-color: #d9d9d9;
  144. margin: 0 auto;
  145. border-radius: 80rpx;
  146. @media (orientation: landscape) {
  147. width: 100rpx;
  148. height: 100rpx;
  149. }
  150. uni-image {
  151. width: 100%;
  152. height: 100%;
  153. border-radius: 80rpx;
  154. }
  155. }
  156. .quit-btn {
  157. font-size: 16px;
  158. border: 1px solid #ed5c5c;
  159. color: #ed5c5c;
  160. background-color: #fff;
  161. padding: 0 40rpx;
  162. @media (orientation: landscape) {
  163. padding: 0 20rpx;
  164. }
  165. }
  166. }
  167. .book-card {
  168. margin: 16rpx;
  169. background-color: #fff;
  170. padding: 16px 22px;
  171. height: auto;
  172. margin-bottom: 120px;
  173. border-radius: 16rpx;
  174. @media (orientation: landscape) {
  175. margin-bottom: 20px;
  176. }
  177. .book-box {
  178. width: 85%;
  179. @media (orientation: landscape) {
  180. width: 65%;
  181. }
  182. aspect-ratio: 3 / 4;
  183. background-color: #d9d9d9;
  184. uni-image {
  185. width: 100%;
  186. height: 100%;
  187. }
  188. }
  189. .book-box::before {
  190. display: inline-block;
  191. padding-bottom: 120%;
  192. content: '';
  193. }
  194. .text {
  195. margin: 16rpx 0 32rpx 0;
  196. width: 85%;
  197. font-size: 13pt;
  198. }
  199. /deep/ .uni-grid-item {
  200. width: 33% !important;
  201. .uni-grid-item__box {
  202. align-items: center;
  203. }
  204. }
  205. }
  206. }
  207. /* 横屏样式 */
  208. @media (orientation: landscape) {
  209. /deep/ .content-area {
  210. display: flex;
  211. flex-direction: row;
  212. }
  213. }
  214. </style>