PointVoucher.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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="scroll-view div" style="position:relative">
  14. <scroll-view style="position: absolute;top:0;right:0;left:0;bottom:0" class="div list-wrap" @scrolltolower="loadMore" scroll-y="true">
  15. <index-voucher-item class="list-wrap-item" v-for="item in voucherList" :key="item.vouchertemplate_id" :item="item">
  16. </index-voucher-item>
  17. </scroll-view>
  18. <empty-record v-if="voucherList.length === 0"></empty-record>
  19. </view>
  20. </view></home-base>
  21. </template>
  22. <script>
  23. import {getFontSize} from '@/util/common'
  24. import TitleHeader from '../../TitleHeader'
  25. import HomeBase from '../HomeBase'
  26. import EmptyRecord from '../../EmptyRecord'
  27. import IndexVoucherItem from './IndexVoucherItem'
  28. import { getPointVoucherList } from '../../../api/homePointsgoods'
  29. export default {
  30. name: 'index',
  31. mounted(){
  32. // #ifdef MP-WEIXIN
  33. this.navHeight = uni.getMenuButtonBoundingClientRect().top
  34. // #endif
  35. },
  36. computed:{
  37. fontSize(){
  38. return getFontSize()
  39. },
  40. },
  41. data(){
  42. return {
  43. navHeight: 0,
  44. params: { 'page': 0, 'per_page': 10 },
  45. loading: false, // 是否加载更多
  46. isMore: true, // 是否有更多
  47. pageTotal: 1, // 总页数
  48. voucherList: [] // 商品列表
  49. }
  50. },
  51. components:{
  52. TitleHeader,
  53. HomeBase,
  54. EmptyRecord,
  55. IndexVoucherItem
  56. },
  57. created () {
  58. this.loadMore()
  59. },
  60. methods:{
  61. goBack(){uni.navigateBack({delta:1})},
  62. getPointVoucherList (ispush) {
  63. uni.showLoading({ title: '加载中' })
  64. let params = this.params
  65. getPointVoucherList(params).then(res => {
  66. uni.hideLoading()
  67. if (ispush) {
  68. this.voucherList = this.voucherList.concat(res.result.voucherlist)
  69. } else {
  70. this.voucherList = res.result.voucherlist
  71. }
  72. this.pageTotal = res.result.page_total
  73. if (res.result.hasmore) {
  74. this.isMore = true
  75. } else {
  76. this.isMore = false
  77. }
  78. })
  79. },
  80. loadMore () {
  81. this.loading = true
  82. this.params.page = ++this.params.page
  83. if (this.isMore && this.params.page <= this.pageTotal) {
  84. this.loading = false
  85. this.getPointVoucherList(true)
  86. }
  87. },
  88. }
  89. }
  90. </script>
  91. <style scoped lang="scss">
  92. .scroll-view-wrapper{display: flex;flex-direction: column;}
  93. .scroll-view{flex:1}
  94. .list-wrap {padding:0 15px;box-sizing: border-box;}
  95. .list-wrap .list-wrap-item {display: inline-block;margin-top: 10px;width:50%;}
  96. .list-wrap .list-wrap-item:nth-child(2n+2) {text-align: right}
  97. </style>