index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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.imageSet[0]" height="160px" width="100%"></u-image>
  14. </view>
  15. <view class="ellipsis-two">{{item.title}}</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" :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. export default {
  34. data() {
  35. return {
  36. status: 'loading',
  37. noDataText: '暂无活动',
  38. // 查询条件
  39. pageNo: 1,
  40. pageSize: 10,
  41. list: [],
  42. total: 0,
  43. }
  44. },
  45. computed: {
  46. ...mapState(['hasLogin','vuex_vinScanNums','vuex_scanMaxNums','vuex_tabBarList','vuex_videoTypeList']),
  47. userInfo(){
  48. return this.$store.state.vuex_userInfo
  49. },
  50. tabList(){
  51. return this.$store.state.vuex_videoTypeList
  52. }
  53. },
  54. onLoad() {
  55. this.pageInit()
  56. uni.$on("refashProm",()=>{
  57. this.pageInit()
  58. })
  59. },
  60. // 页面卸载
  61. onUnload() {
  62. uni.$off('refashProm')
  63. },
  64. methods: {
  65. pageInit(){
  66. this.total = 0
  67. this.pageNo = 1
  68. this.list = []
  69. this.getRow()
  70. },
  71. // scroll-view到底部加载更多
  72. onreachBottom() {
  73. if(this.list.length < this.total){
  74. this.pageNo += 1
  75. this.getRow()
  76. }else{
  77. this.status = "nomore"
  78. }
  79. },
  80. // 查询列表
  81. getRow (pageNo) {
  82. let _this = this
  83. if (pageNo) {
  84. this.pageNo = pageNo
  85. }
  86. let params = {
  87. pageNo: this.pageNo,
  88. pageSize: this.pageSize,
  89. queryWord: this.queryWord
  90. }
  91. const storeShelf = this.$store.state.vuex_storeShelf
  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.filter(item => item.content.indexOf("pagesB/promoDetail") >= 0)
  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?promoActiveSn='+item.promoActiveSn+'&title='+item.title
  114. })
  115. },
  116. // 扫描vin
  117. beforeSwitch(index){
  118. const row = this.$store.state.vuex_tabBarList[index]
  119. if(row.text == '促销'){
  120. uni.$emit('refashProm')
  121. }
  122. if(row.text == '扫描VIN'){
  123. this.openCamera()
  124. }else{
  125. return true
  126. }
  127. },
  128. // 去扫描
  129. openCamera(){
  130. if(this.hasLogin){
  131. if(this.userInfo.sysUserFlag == '0'){
  132. if(this.vuex_vinScanNums < this.vuex_scanMaxNums){
  133. uni.navigateTo({
  134. url: "/pages/scan-frame/scan-frame"
  135. })
  136. }else{
  137. uni.showModal({
  138. title: '提示',
  139. content: '个人用户扫描VIN仅限10次,您的次数已用完!',
  140. confirmText: '好的',
  141. showCancel: false,
  142. success(res) {}
  143. })
  144. }
  145. }else{
  146. uni.navigateTo({
  147. url: "/pages/scan-frame/scan-frame"
  148. })
  149. }
  150. }else{
  151. uni.navigateTo({
  152. url: '/pages/login/login'
  153. })
  154. }
  155. },
  156. }
  157. }
  158. </script>
  159. <style lang="less">
  160. page{
  161. height: 100vh;
  162. }
  163. .video-pagesCons{
  164. height: 100%;
  165. display: flex;
  166. flex-direction: column;
  167. .tab-body{
  168. height: 100vh;
  169. .check-order-list{
  170. background: #ffffff;
  171. padding: 20upx;
  172. margin: 25upx;
  173. border-radius: 10upx;
  174. box-shadow: 1px 1px 3px #EEEEEE;
  175. .video-item{
  176. > view{
  177. &:first-child{
  178. position: relative;
  179. }
  180. &:last-child{
  181. text-align: center;
  182. font-size: 36rpx;
  183. margin: 20rpx 0 0;
  184. }
  185. }
  186. }
  187. }
  188. }
  189. }
  190. </style>