video.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <app-layout>
  3. <view v-for="(item, index) in list" :key="index">
  4. <view>
  5. <app-video :pic-url="item.pic_url" :url="item.url"></app-video>
  6. </view>
  7. <view class="video">
  8. <view class="title">{{item.title}}</view>
  9. <view class="content" :class="active !== index ? 'active' : ''">{{item.content}}</view>
  10. <view class="other dir-left-nowrap cross-center">
  11. <view class="box-grow-1">{{item.time}}</view>
  12. <image src="../../static/image/icon/arrow-right.png" class="img" @click="click(index)"
  13. :class="active === index ? 'active' : ''"></image>
  14. <view class="box-grow-0" @click="click(index)">{{active === index ? '收起' : '展开'}}</view>
  15. </view>
  16. </view>
  17. </view>
  18. </app-layout>
  19. </template>
  20. <script>
  21. import appVideo from "../../components/page-component/app-video/app-video.vue";
  22. let page = 1;
  23. let is_no_more = false;
  24. let is_loading = false;
  25. export default {
  26. name: "video",
  27. components: {
  28. 'app-video': appVideo,
  29. },
  30. data() {
  31. return {
  32. list: [],
  33. active: -1,
  34. };
  35. },
  36. onLoad() {
  37. page = 1;
  38. is_no_more = false;
  39. is_loading = false;
  40. this.loadData();
  41. },
  42. onPageScroll(e) {
  43. this.$store.dispatch('page/actionSetScrollTop', e.scrollTop);
  44. },
  45. onReachBottom() {
  46. if (is_no_more) return;
  47. this.loadData();
  48. },
  49. methods: {
  50. loadData() {
  51. if (is_loading) {
  52. return;
  53. }
  54. this.$showLoading();
  55. is_loading = true;
  56. this.$request({
  57. url: this.$api.video.index,
  58. data: {
  59. page: page
  60. }
  61. }).then(response => {
  62. this.$hideLoading();
  63. if (response.code === 0) {
  64. this.list = this.list.concat(response.data.list);
  65. if (response.data.list.length === 0) {
  66. is_no_more = true;
  67. }
  68. page++;
  69. }
  70. is_loading = false;
  71. }).catch(() => {
  72. this.$hideLoading();
  73. is_loading = false;
  74. })
  75. },
  76. click(index) {
  77. if (this.active === index) {
  78. this.active = -1;
  79. } else {
  80. this.active = index;
  81. }
  82. }
  83. },
  84. }
  85. </script>
  86. <style scoped lang="scss">
  87. .video {
  88. padding: #{24rpx};
  89. }
  90. .title {
  91. color: $uni-important-color-black;
  92. margin-top: #{24rpx};
  93. }
  94. .content {
  95. font-size: $uni-font-size-general-one;
  96. color: $uni-general-color-two;
  97. margin-top: #{40rpx};
  98. }
  99. .content.active {
  100. word-break: break-all;
  101. white-space: pre-wrap;
  102. text-overflow: ellipsis;
  103. display: -webkit-box;
  104. -webkit-box-orient: vertical;
  105. -webkit-line-clamp: 2;
  106. overflow: hidden;
  107. }
  108. .other {
  109. font-size: $uni-font-size-weak-one;
  110. color: $uni-general-color-two;
  111. margin-top: #{36rpx};
  112. margin-bottom: #{40rpx};
  113. }
  114. .img {
  115. height: #{22rpx};
  116. width: #{12rpx};
  117. margin-right: #{16rpx};
  118. transform: rotate(90deg);
  119. }
  120. .img.active {
  121. transform: rotate(-90deg);
  122. }
  123. </style>