video.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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 {mapState} from 'vuex';
  22. import appVideo from "../../components/page-component/app-video/app-video.vue";
  23. import tabBar from './../../core/tabbar.js';
  24. let page = 1;
  25. let is_no_more = false;
  26. let is_loading = false;
  27. export default {
  28. name: "video",
  29. components: {
  30. 'app-video': appVideo,
  31. },
  32. data() {
  33. return {
  34. list: [],
  35. active: -1,
  36. navigationBarTitle: '',
  37. };
  38. },
  39. onLoad() { this.$commonLoad.onload();
  40. page = 1;
  41. is_no_more = false;
  42. is_loading = false;
  43. this.loadData();
  44. // #ifdef MP-WEIXIN
  45. wx.showShareMenu({
  46. menus: ['shareAppMessage', 'shareTimeline']
  47. });
  48. // #endif
  49. this.$nextTick(() => {
  50. let currentRoute = this.$platDiff.route();
  51. tabBar.setNavigationBarTitle(this.bar_title, currentRoute).then(res => {
  52. this.navigationBarTitle = res;
  53. });
  54. });
  55. },
  56. onPageScroll(e) {
  57. this.$store.dispatch('page/actionSetScrollTop', e.scrollTop);
  58. },
  59. onReachBottom() {
  60. if (is_no_more) return;
  61. this.loadData();
  62. },
  63. // #ifdef MP
  64. onShareAppMessage() {
  65. return this.$shareAppMessage({
  66. title: this.navigationBarTitle,
  67. path: '/pages/video/video'
  68. });
  69. },
  70. // #endif
  71. // #ifdef MP-WEIXIN
  72. onShareTimeline() {
  73. // 分享朋友圈beta
  74. return this.$shareTimeline({
  75. title: this.navigationBarTitle,
  76. });
  77. },
  78. // #endif
  79. computed: {
  80. ...mapState('mallConfig', {
  81. bar_title: state => state.bar_title,
  82. })
  83. },
  84. methods: {
  85. loadData() {
  86. if (is_loading) {
  87. return;
  88. }
  89. this.$showLoading();
  90. is_loading = true;
  91. this.$request({
  92. url: this.$api.video.index,
  93. data: {
  94. page: page
  95. }
  96. }).then(response => {
  97. this.$hideLoading();
  98. if (response.code === 0) {
  99. this.list = this.list.concat(response.data.list);
  100. if (response.data.list.length === 0) {
  101. is_no_more = true;
  102. }
  103. page++;
  104. }
  105. is_loading = false;
  106. }).catch(() => {
  107. this.$hideLoading();
  108. is_loading = false;
  109. })
  110. },
  111. click(index) {
  112. if (this.active === index) {
  113. this.active = -1;
  114. } else {
  115. this.active = index;
  116. }
  117. }
  118. },
  119. }
  120. </script>
  121. <style scoped lang="scss">
  122. .video {
  123. padding: #{24rpx};
  124. }
  125. .title {
  126. color: $uni-important-color-black;
  127. margin-top: #{24rpx};
  128. }
  129. .content {
  130. font-size: $uni-font-size-general-one;
  131. color: $uni-general-color-two;
  132. margin-top: #{40rpx};
  133. }
  134. .content.active {
  135. word-break: break-all;
  136. white-space: pre-wrap;
  137. text-overflow: ellipsis;
  138. display: -webkit-box;
  139. -webkit-box-orient: vertical;
  140. -webkit-line-clamp: 2;
  141. overflow: hidden;
  142. }
  143. .other {
  144. font-size: $uni-font-size-weak-one;
  145. color: $uni-general-color-two;
  146. margin-top: #{36rpx};
  147. margin-bottom: #{40rpx};
  148. }
  149. .img {
  150. height: #{22rpx};
  151. width: #{12rpx};
  152. margin-right: #{16rpx};
  153. transform: rotate(90deg);
  154. }
  155. .img.active {
  156. transform: rotate(-90deg);
  157. }
  158. </style>