index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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 class="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">
  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.imageSet[0]" 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. <u-tabbar :list="vuex_tabBarList" :before-switch="beforeSwitch" :mid-button="true"></u-tabbar>
  40. </view>
  41. </template>
  42. <script>
  43. import {
  44. mapState,
  45. mapMutations,
  46. } from 'vuex'
  47. import { getVideoList, videoDetail } from "@/api/video.js"
  48. import { openWebView } from "@/utils/index.js"
  49. export default {
  50. data() {
  51. return {
  52. status: 'loading',
  53. noDataText: '暂无数据',
  54. current: 0,
  55. swiperCurrent: 0,
  56. // 查询条件
  57. pageNo: 1,
  58. pageSize: 10,
  59. list: [],
  60. total: 0,
  61. videoObj:null
  62. }
  63. },
  64. computed: {
  65. ...mapState(['hasLogin','vuex_vinScanNums','vuex_scanMaxNums','vuex_tabBarList','vuex_videoTypeList']),
  66. userInfo(){
  67. return this.$store.state.vuex_userInfo
  68. },
  69. tabList(){
  70. return this.$store.state.vuex_videoTypeList
  71. }
  72. },
  73. onLoad() {
  74. this.pageInit()
  75. },
  76. onHide() {
  77. this.list.map(item => {
  78. item.showVideo = false
  79. })
  80. },
  81. methods: {
  82. pageInit(){
  83. this.total = 0
  84. this.pageNo = 1
  85. this.getRow()
  86. },
  87. // tabs通知swiper切换
  88. tabsChange(index) {
  89. this.swiperCurrent = index;
  90. },
  91. swiperChange(event){
  92. console.log(event.detail)
  93. this.list = []
  94. this.status = "loading"
  95. },
  96. // swiper-item左右移动,通知tabs的滑块跟随移动
  97. transition(e) {
  98. let dx = e.detail.dx;
  99. this.$refs.uTabs.setDx(dx);
  100. },
  101. // 由于swiper的内部机制问题,快速切换swiper不会触发dx的连续变化,需要在结束时重置状态
  102. // swiper滑动结束,分别设置tabs和swiper的状态
  103. animationfinish(e) {
  104. let current = e.detail.current;
  105. if(current != this.current){
  106. this.$refs.uTabs.setFinishCurrent(current);
  107. this.swiperCurrent = current;
  108. this.current = current;
  109. this.pageInit()
  110. }
  111. },
  112. // scroll-view到底部加载更多
  113. onreachBottom() {
  114. console.log(this.list.length, this.total)
  115. if(this.list.length < this.total){
  116. this.pageNo += 1
  117. this.getRow()
  118. }else{
  119. this.status = "nomore"
  120. }
  121. },
  122. // 查询列表
  123. getRow (pageNo) {
  124. let _this = this
  125. if (pageNo) {
  126. this.pageNo = pageNo
  127. }
  128. let params = {
  129. pageNo: this.pageNo,
  130. pageSize: this.pageSize,
  131. }
  132. params.category = this.tabList ? this.tabList[this.swiperCurrent].code : ''
  133. this.status = "loading"
  134. getVideoList(params).then(res => {
  135. if (res.code == 200 || res.status == 204 || res.status == 200) {
  136. const list = res.data.list || []
  137. list.map(item => {
  138. item.showVideo = false
  139. })
  140. if(_this.pageNo>1){
  141. _this.list = _this.list.concat(list)
  142. }else{
  143. _this.list = list
  144. }
  145. _this.total = res.data.count || 0
  146. } else {
  147. _this.list = []
  148. _this.total = 0
  149. _this.noDataText = res.message
  150. }
  151. _this.status = _this.total>=_this.list.length ? "nomore" : 'loadmore'
  152. })
  153. },
  154. // 详细页
  155. viewRow(item){
  156. if(item.contentType == 'VIDEO' && !item.showVideo){
  157. // item.showVideo = true
  158. videoDetail({id: item.id}).then(res => {
  159. if(res.data){
  160. item.viewNum = res.data.viewNum
  161. this.list.splice()
  162. uni.navigateTo({
  163. url: "/pages/videos/detail?form=videoList&&title="+item.titile+"&&content="+item.content
  164. })
  165. }
  166. })
  167. }
  168. if(item.contentType == 'LINK'){
  169. openWebView({url:item.content})
  170. }
  171. },
  172. // 扫描vin
  173. beforeSwitch(index){
  174. console.log(index)
  175. if(index==2){
  176. this.openCamera()
  177. }else{
  178. return true
  179. }
  180. },
  181. // 去扫描
  182. openCamera(){
  183. if(this.hasLogin){
  184. if(this.userInfo.sysUserFlag == '0'){
  185. if(this.vuex_vinScanNums < this.vuex_scanMaxNums){
  186. uni.navigateTo({
  187. url: "/pages/scan-frame/scan-frame"
  188. })
  189. }else{
  190. uni.showModal({
  191. title: '提示',
  192. content: '个人用户扫描VIN仅限10次,您的次数已用完!',
  193. confirmText: '好的',
  194. showCancel: false,
  195. success(res) {}
  196. })
  197. }
  198. }else{
  199. uni.navigateTo({
  200. url: "/pages/scan-frame/scan-frame"
  201. })
  202. }
  203. }else{
  204. uni.navigateTo({
  205. url: '/pages/login/login'
  206. })
  207. }
  208. },
  209. }
  210. }
  211. </script>
  212. <style lang="less">
  213. page{
  214. height: 100vh;
  215. }
  216. .video-pagesCons{
  217. height: 100%;
  218. display: flex;
  219. flex-direction: column;
  220. .tab-body{
  221. .check-list{
  222. height: calc(100vh - 126px);
  223. }
  224. .check-order-list{
  225. background: #ffffff;
  226. padding: 20upx;
  227. margin: 25upx;
  228. border-radius: 10upx;
  229. box-shadow: 1px 1px 3px #EEEEEE;
  230. .video-item{
  231. > view{
  232. &:first-child{
  233. position: relative;
  234. .play-btn{
  235. width: 40rpx;
  236. height: 40rpx;
  237. background: rgba(0,0,0,0.35);
  238. border-radius: 150rpx;
  239. position: absolute;
  240. top: 20rpx;
  241. right:30rpx;
  242. z-index: 100;
  243. display: flex;
  244. align-items: center;
  245. justify-content: center;
  246. }
  247. .pnums{
  248. position: absolute;
  249. left:20rpx;
  250. bottom: 20rpx;
  251. background: rgba(0,0,0,0.35);
  252. padding: 4rpx 10rpx;
  253. border-radius: 50rpx;
  254. display: flex;
  255. align-items: center;
  256. color:#fff;
  257. z-index: 110;
  258. font-size: 24rpx;
  259. }
  260. }
  261. &:last-child{
  262. text-align: center;
  263. font-size: 36rpx;
  264. margin: 20rpx 0 0;
  265. }
  266. }
  267. }
  268. }
  269. }
  270. }
  271. </style>