index.vue 7.4 KB

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