index.vue 7.2 KB

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