index.vue 5.8 KB

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