index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <template>
  2. <view class="video-pagesCons">
  3. <view class="tab-body">
  4. <view>
  5. <u-tabs-swiper ref="uTabs" :list="tabList" :offset="[5,40]" bar-width='100' active-color="#1283d4" name="dispName" :current="current" @change="tabsChange" :is-scroll="false"
  6. swiperWidth="750"></u-tabs-swiper>
  7. </view>
  8. <swiper class="check-list" :current="swiperCurrent" @transition="transition" @change="swiperChange" @animationfinish="animationfinish">
  9. <swiper-item style="height: 100%;width: 100%;overflow: hidden;" v-for="(tabs, indexs) in tabList" :key="indexs">
  10. <scroll-view scroll-y style="height: 100%;width: 100%;overflow: auto;" @scrolltolower="onreachBottom" v-if="swiperCurrent==indexs">
  11. <view
  12. class="check-order-list"
  13. v-for="(item,index) in list"
  14. :key="item.id"
  15. @click="viewRow(item)"
  16. >
  17. <view class="video-item">
  18. <view>
  19. <view class="play-btn" v-if="!item.showVideo&&item.contentType == 'VIDEO'">
  20. <u-icon size="24" color="#fff" name="play-right-fill"></u-icon>
  21. </view>
  22. <view class="pnums" v-if="!item.showVideo&&item.contentType == 'VIDEO'">
  23. <u-icon size="30" color="#fff" name="eye-fill"></u-icon>
  24. {{item.viewNum}}
  25. </view>
  26. <u-image :src="item.images" height="200px" width="100%"></u-image>
  27. </view>
  28. <view class="ellipsis-two">{{item.titile}}</view>
  29. </view>
  30. </view>
  31. <view style="padding: 20upx;">
  32. <u-empty :src="`/static/nodata.png`" icon-size="180" :text="noDataText" img-width="120" v-if="list.length==0 && status!='loading'" mode="list"></u-empty>
  33. <u-loadmore v-if="(total>=list.length&&list.length)||status=='loading'" :status="status" />
  34. </view>
  35. </scroll-view>
  36. </swiper-item>
  37. </swiper>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. import {
  43. mapState,
  44. mapMutations,
  45. } from 'vuex'
  46. import { getVideoList, videoDetail } from "@/api/video.js"
  47. import { openWebView } from "@/utils/index.js"
  48. export default {
  49. data() {
  50. return {
  51. status: 'loading',
  52. noDataText: '暂无数据',
  53. current: 0,
  54. swiperCurrent: 0,
  55. // 查询条件
  56. pageNo: 1,
  57. pageSize: 5,
  58. list: [],
  59. total: 0,
  60. videoObj:null
  61. }
  62. },
  63. computed: {
  64. ...mapState(['hasLogin','vuex_videoTypeList']),
  65. userInfo(){
  66. return this.$store.state.vuex_userInfo
  67. },
  68. tabList(){
  69. return this.$store.state.vuex_videoTypeList
  70. }
  71. },
  72. onLoad() {
  73. this.pageInit()
  74. },
  75. // 页面卸载
  76. onUnload() {
  77. uni.$off('refashProm')
  78. },
  79. onHide() {
  80. this.list.map(item => {
  81. item.showVideo = false
  82. })
  83. },
  84. methods: {
  85. pageInit(){
  86. this.total = 0
  87. this.pageNo = 1
  88. this.list = []
  89. this.getRow()
  90. },
  91. // tabs通知swiper切换
  92. tabsChange(index) {
  93. this.list = []
  94. this.status = "loading"
  95. this.swiperCurrent = index;
  96. },
  97. swiperChange(event){
  98. this.list = []
  99. this.status = "loading"
  100. this.swiperCurrent = event.detail.current;
  101. },
  102. // swiper-item左右移动,通知tabs的滑块跟随移动
  103. transition(e) {
  104. let dx = e.detail.dx;
  105. this.$refs.uTabs.setDx(dx);
  106. },
  107. // 由于swiper的内部机制问题,快速切换swiper不会触发dx的连续变化,需要在结束时重置状态
  108. // swiper滑动结束,分别设置tabs和swiper的状态
  109. animationfinish(e) {
  110. let current = e.detail.current;
  111. if(current != this.current){
  112. this.$refs.uTabs.setFinishCurrent(current);
  113. this.swiperCurrent = current;
  114. this.current = current;
  115. this.pageInit()
  116. }
  117. },
  118. // scroll-view到底部加载更多
  119. onreachBottom() {
  120. if(this.list.length < this.total){
  121. this.pageNo += 1
  122. this.getRow()
  123. }else{
  124. this.status = "nomore"
  125. }
  126. },
  127. // 查询列表
  128. getRow (pageNo) {
  129. let _this = this
  130. if (pageNo) {
  131. this.pageNo = pageNo
  132. }
  133. let params = {
  134. pageNo: this.pageNo,
  135. pageSize: this.pageSize,
  136. }
  137. params.category = this.tabList ? this.tabList[this.swiperCurrent].code : ''
  138. this.status = "loading"
  139. getVideoList(params).then(res => {
  140. if (res.status == 200) {
  141. const list = res.data.list || []
  142. const ret = []
  143. list.map(item => {
  144. ret.push({
  145. id: item.id,
  146. showVideo: false,
  147. contentType: item.contentType,
  148. titile: item.titile,
  149. viewNum: item.viewNum,
  150. images: item.images,
  151. content: item.content
  152. })
  153. })
  154. _this.list = _this.list.concat(ret)
  155. _this.total = res.data.count || 0
  156. } else {
  157. _this.list = []
  158. _this.total = 0
  159. _this.noDataText = res.message
  160. }
  161. _this.status = _this.total>=_this.list.length ? "nomore" : 'loadmore'
  162. })
  163. },
  164. // 详细页
  165. viewRow(item){
  166. if(item.contentType == 'VIDEO' && !item.showVideo){
  167. // item.showVideo = true
  168. videoDetail({id: item.id}).then(res => {
  169. if(res.data){
  170. item.viewNum = res.data.viewNum
  171. this.list.splice()
  172. uni.navigateTo({
  173. url: "/pagesB/videos/detail?form=videoList&&title="+item.titile+"&&content="+item.content
  174. })
  175. }
  176. })
  177. }
  178. if(item.contentType == 'LINK'){
  179. openWebView({url:item.content})
  180. }
  181. },
  182. }
  183. }
  184. </script>
  185. <style lang="less">
  186. page{
  187. height: 100vh;
  188. }
  189. .video-pagesCons{
  190. height: 100%;
  191. display: flex;
  192. flex-direction: column;
  193. .tab-body{
  194. .check-list{
  195. height: calc(100vh - 42px);
  196. }
  197. .check-order-list{
  198. background: #ffffff;
  199. padding: 20upx;
  200. margin: 25upx;
  201. border-radius: 10upx;
  202. box-shadow: 1px 1px 3px #EEEEEE;
  203. .video-item{
  204. > view{
  205. &:first-child{
  206. position: relative;
  207. .play-btn{
  208. width: 40rpx;
  209. height: 40rpx;
  210. background: rgba(0,0,0,0.35);
  211. border-radius: 150rpx;
  212. position: absolute;
  213. top: 20rpx;
  214. right:30rpx;
  215. z-index: 100;
  216. display: flex;
  217. align-items: center;
  218. justify-content: center;
  219. }
  220. .pnums{
  221. position: absolute;
  222. left:20rpx;
  223. bottom: 20rpx;
  224. background: rgba(0,0,0,0.35);
  225. padding: 4rpx 10rpx;
  226. border-radius: 50rpx;
  227. display: flex;
  228. align-items: center;
  229. color:#fff;
  230. z-index: 110;
  231. font-size: 24rpx;
  232. }
  233. }
  234. &:last-child{
  235. text-align: center;
  236. font-size: 36rpx;
  237. margin: 20rpx 0 0;
  238. }
  239. }
  240. }
  241. }
  242. }
  243. }
  244. </style>