PointProd.vue 3.2 KB

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