index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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" :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. 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 == '购物车'){
  123. if(!this.hasLogin){
  124. uni.navigateTo({
  125. url: '/pages/login/login'
  126. })
  127. return true
  128. }
  129. if(this.userInfo.sysUserFlag == '0'){
  130. uni.navigateTo({
  131. url: '/pages/storeManage/storeAuth'
  132. })
  133. return true
  134. }
  135. uni.navigateTo({
  136. url:'/pagesB/cart/index',
  137. target: 'page'
  138. })
  139. }
  140. if(row.text == '扫描VIN'){
  141. this.openCamera()
  142. }else{
  143. return true
  144. }
  145. },
  146. // 去扫描
  147. openCamera(){
  148. if(this.hasLogin){
  149. if(this.userInfo.sysUserFlag == '0'){
  150. if(this.vuex_vinScanNums < this.vuex_scanMaxNums){
  151. uni.navigateTo({
  152. url: "/pages/scan-frame/scan-frame"
  153. })
  154. }else{
  155. uni.showModal({
  156. title: '提示',
  157. content: '个人用户扫描VIN仅限10次,您的次数已用完!',
  158. confirmText: '好的',
  159. showCancel: false,
  160. success(res) {}
  161. })
  162. }
  163. }else{
  164. uni.navigateTo({
  165. url: "/pages/scan-frame/scan-frame"
  166. })
  167. }
  168. }else{
  169. uni.navigateTo({
  170. url: '/pages/login/login'
  171. })
  172. }
  173. },
  174. }
  175. }
  176. </script>
  177. <style lang="less">
  178. page{
  179. height: 100vh;
  180. }
  181. .video-pagesCons{
  182. height: 100%;
  183. display: flex;
  184. flex-direction: column;
  185. .tab-body{
  186. height: 100vh;
  187. .check-order-list{
  188. background: #ffffff;
  189. padding: 20upx;
  190. margin: 25upx;
  191. border-radius: 10upx;
  192. box-shadow: 1px 1px 3px #EEEEEE;
  193. .video-item{
  194. > view{
  195. &:first-child{
  196. position: relative;
  197. }
  198. &:last-child{
  199. text-align: center;
  200. font-size: 36rpx;
  201. margin: 20rpx 0 0;
  202. }
  203. }
  204. }
  205. }
  206. }
  207. }
  208. </style>