index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <view class="video-pagesCons">
  3. <view class="tab-body">
  4. <scroll-view scroll-y style="height: 100%;width: 100%;overflow: auto;" @scrolltolower="onreachBottom">
  5. <view
  6. class="check-order-list"
  7. v-for="(item,index) in list"
  8. :key="item.id"
  9. @click="viewRow(item)"
  10. >
  11. <view class="video-item">
  12. <view>
  13. <u-image :src="item.imageUrl" height="140px" width="100%"></u-image>
  14. </view>
  15. <view class="ellipsis-two">{{item.promoName}}</view>
  16. </view>
  17. </view>
  18. <view style="padding: 20upx;">
  19. <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>
  20. <u-loadmore v-if="(total>=list.length&&list.length)||status=='loading'" :status="status" />
  21. </view>
  22. </scroll-view>
  23. </view>
  24. <u-tabbar :list="vuex_tabBarList" :mid-button-size="80" :before-switch="beforeSwitch" :midButton="vuex_tabBarList.length==5"></u-tabbar>
  25. </view>
  26. </template>
  27. <script>
  28. import {
  29. mapState,
  30. mapMutations,
  31. } from 'vuex'
  32. import { promoTerminalListByPage } from '@/api/video.js'
  33. import { clickTab } from "@/utils/index.js"
  34. export default {
  35. data() {
  36. return {
  37. status: 'loading',
  38. noDataText: '暂无活动',
  39. // 查询条件
  40. pageNo: 1,
  41. pageSize: 10,
  42. list: [],
  43. total: 0,
  44. }
  45. },
  46. computed: {
  47. ...mapState(['hasLogin','vuex_vinScanNums','vuex_scanMaxNums','vuex_tabBarList','vuex_videoTypeList']),
  48. userInfo(){
  49. return this.$store.state.vuex_userInfo
  50. },
  51. tabList(){
  52. return this.$store.state.vuex_videoTypeList
  53. }
  54. },
  55. onLoad() {
  56. this.pageInit()
  57. uni.$on("refashProm",()=>{
  58. this.pageInit()
  59. })
  60. },
  61. // 页面卸载
  62. onUnload() {
  63. uni.$off('refashProm')
  64. },
  65. methods: {
  66. pageInit(){
  67. this.total = 0
  68. this.pageNo = 1
  69. this.list = []
  70. this.getRow()
  71. },
  72. // scroll-view到底部加载更多
  73. onreachBottom() {
  74. if(this.list.length < this.total){
  75. this.pageNo += 1
  76. this.getRow()
  77. }else{
  78. this.status = "nomore"
  79. }
  80. },
  81. // 查询列表
  82. getRow (pageNo) {
  83. let _this = this
  84. if (pageNo) {
  85. this.pageNo = pageNo
  86. }
  87. let params = {
  88. pageNo: this.pageNo,
  89. pageSize: this.pageSize,
  90. queryWord: this.queryWord
  91. }
  92. this.status = "loading"
  93. promoTerminalListByPage(params).then(res => {
  94. if (res.code == 200 || res.status == 204 || res.status == 200) {
  95. const list = res.data.list
  96. if(_this.pageNo>1){
  97. _this.list = _this.list.concat(list)
  98. }else{
  99. _this.list = list
  100. }
  101. _this.total = res.data.count || 0
  102. } else {
  103. _this.list = []
  104. _this.total = 0
  105. _this.noDataText = res.message
  106. }
  107. _this.status = _this.total>=_this.list.length ? "nomore" : 'loadmore'
  108. })
  109. },
  110. // 促销活动产品列表页
  111. viewRow(item){
  112. uni.navigateTo({
  113. url: '/pagesB/promoProduct?promoSn='+item.promoSn+'&title='+item.promoName
  114. })
  115. },
  116. // tab单击
  117. beforeSwitch(index){
  118. const row = this.$store.state.vuex_tabBarList[index] // 当前tab
  119. const isNoAuth = this.userInfo ? this.userInfo.sysUserFlag == '0' : false // 是否认证门店
  120. return clickTab(row,this.hasLogin,isNoAuth,this.vuex_vinScanNums < this.vuex_scanMaxNums)
  121. },
  122. }
  123. }
  124. </script>
  125. <style lang="less">
  126. page{
  127. height: 100vh;
  128. }
  129. .video-pagesCons{
  130. height: 100%;
  131. display: flex;
  132. flex-direction: column;
  133. .tab-body{
  134. height: calc(100vh - 86px);
  135. .check-order-list{
  136. background: #ffffff;
  137. margin: 25upx;
  138. border-radius: 10upx;
  139. overflow: hidden;
  140. box-shadow: 1px 1px 3px #EEEEEE;
  141. .video-item{
  142. > view{
  143. &:first-child{
  144. position: relative;
  145. }
  146. &:last-child{
  147. text-align: center;
  148. font-size: 32rpx;
  149. padding: 20rpx 0;
  150. }
  151. }
  152. }
  153. }
  154. }
  155. }
  156. </style>