PointMallVoucher.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <home-base :show="true"><view style="position: absolute;top:0;right:0;left:0;bottom:0" class="scroll-view-wrapper div">
  3. <view class="div common-header-wrap">
  4. <view class="status-holder"></view>
  5. <view :style="'height:'+navHeight+'px'"></view>
  6. <view class="common-header-holder"></view>
  7. <view class="common-header-fixed">
  8. <title-header />
  9. <uni-nav-bar title="积分平台代金券" class="common-header" left-icon="back" @clickLeft="goBack()">
  10. </uni-nav-bar>
  11. </view>
  12. </view>
  13. <view class="div gc_list">
  14. <view class="ul">
  15. <view class="li" v-on:click='setgcid(0)' v-bind:class="{ active: gcid == 0 }">全部
  16. </view>
  17. <view class="li" v-bind:class="{ active: gcid == item.gc_id }" v-for="item in gc_list" :key="item.gc_id" v-on:click='setgcid(item.gc_id)'>{{item.gc_name}}</view>
  18. </view>
  19. </view>
  20. <view class="scroll-view div" style="position:relative">
  21. <scroll-view style="position: absolute;top:0;right:0;left:0;bottom:0" class="div list-wrap" @scrolltolower="loadMore" scroll-y="true">
  22. <index-mall-voucher-item class="list-wrap-item" v-for="item in mallvoucherlist" :key="item.mallvouchertemplate_id" :item="item">
  23. </index-mall-voucher-item>
  24. </scroll-view>
  25. <empty-record v-if="mallvoucherlist.length === 0"></empty-record>
  26. </view>
  27. </view></home-base>
  28. </template>
  29. <script>
  30. import {getFontSize} from '@/util/common'
  31. import TitleHeader from '../../TitleHeader'
  32. import HomeBase from '../HomeBase'
  33. import EmptyRecord from '../../EmptyRecord'
  34. import IndexMallVoucherItem from './IndexMallVoucherItem'
  35. import { getPointMallVoucherList } from '../../../api/homePointsgoods'
  36. export default {
  37. name: 'index',
  38. mounted(){
  39. // #ifdef MP-WEIXIN
  40. this.navHeight = uni.getMenuButtonBoundingClientRect().top
  41. // #endif
  42. },
  43. computed:{
  44. fontSize(){
  45. return getFontSize()
  46. },
  47. },
  48. data(){
  49. return {
  50. navHeight: 0,
  51. params: { 'page': 0, 'per_page': 10 },
  52. loading: false, // 是否加载更多
  53. isMore: true, // 是否有更多
  54. pageTotal: 1, // 总页数
  55. gcid: 0,
  56. mallvoucherlist: [], // 平台代金券列表
  57. gc_list:[],//分类列表
  58. }
  59. },
  60. components:{
  61. TitleHeader,
  62. HomeBase,
  63. EmptyRecord,
  64. IndexMallVoucherItem
  65. },
  66. created () {
  67. this.loadMore()
  68. },
  69. methods:{
  70. goBack(){uni.navigateBack({delta:1})},
  71. getPointMallVoucherList (ispush) {
  72. uni.showLoading({ title: '加载中' })
  73. let params = this.params
  74. getPointMallVoucherList(params).then(res => {
  75. uni.hideLoading()
  76. if (ispush) {
  77. this.mallvoucherlist = this.mallvoucherlist.concat(res.result.mallvoucherlist)
  78. } else {
  79. this.mallvoucherlist = res.result.mallvoucherlist
  80. }
  81. this.pageTotal = res.result.page_total
  82. this.gc_list = res.result.gc_list
  83. if (res.result.hasmore) {
  84. this.isMore = true
  85. } else {
  86. this.isMore = false
  87. }
  88. })
  89. },
  90. loadMore () {
  91. this.loading = true
  92. this.params.page = ++this.params.page
  93. if (this.isMore && this.params.page <= this.pageTotal) {
  94. this.loading = false
  95. this.getPointMallVoucherList(true)
  96. }
  97. },
  98. setgcid(gcid){
  99. this.params.gc_id = gcid
  100. this.gcid = gcid
  101. this.getPointMallVoucherList(false)
  102. }
  103. }
  104. }
  105. </script>
  106. <style scoped lang="scss">
  107. .gc_list{width: 100%;overflow: hidden;padding: 0 3%;box-sizing: border-box;background-color: #fff;}
  108. .gc_list .ul{overflow-x: overlay;display: flex;}
  109. .gc_list .ul::-webkit-scrollbar{width:0;}
  110. .gc_list .ul .li{margin-right: 1rem;white-space: nowrap;font-size: .7rem;line-height: 2.2rem; border-bottom: 0.1rem solid transparent;}
  111. .gc_list .ul .li.active{ color: #FB2630;border-bottom-color: #FB2630;}
  112. .scroll-view-wrapper{display: flex;flex-direction: column;}
  113. .scroll-view{flex:1}
  114. .list-wrap {padding:0 15px;box-sizing: border-box;}
  115. .list-wrap .list-wrap-item {display: inline-block;margin-top: 10px;width:50%;}
  116. .list-wrap .list-wrap-item:nth-child(2n+2) {text-align: right}
  117. </style>