activity_detail.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <mescroll-body ref="mescrollRef" @init="mescrollInit" @up="upCallback" :up="upOption" @down="downCallback">
  3. <view class="activity-detail">
  4. <view class="header" v-if="goodsList.length">
  5. <image class="header-bg" src="/bundle/static/activity_detail_bg.png"></image>
  6. <view class="header-con flex-col col-center">
  7. <view class="title white">{{name}}</view>
  8. <view class="desc white sm br60">{{title}}</view>
  9. </view>
  10. </view>
  11. <view class="content">
  12. <view class="goods-container">
  13. <goods-list :list="goodsList" type="activity"></goods-list>
  14. </view>
  15. </view>
  16. </view>
  17. </mescroll-body>
  18. </template>
  19. <script>
  20. import {
  21. getActivityGoodsLists
  22. } from "@/api/activity";
  23. import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
  24. export default {
  25. mixins: [MescrollMixin], // 使用mixin
  26. data() {
  27. return {
  28. upOption: {
  29. empty: {
  30. icon: '/static/images/goods_null.png',
  31. tip: '暂无商品', // 提示
  32. }
  33. },
  34. goodsList: [],
  35. name: '',
  36. title: ''
  37. };
  38. },
  39. onLoad: function(options) {
  40. const {
  41. id,
  42. title,
  43. name
  44. } = this.$Route.query
  45. this.id = id;
  46. this.title = title
  47. this.name = name
  48. uni.setNavigationBarTitle({
  49. title: name
  50. });
  51. },
  52. methods: {
  53. upCallback(page) {
  54. const pageNum = page.num; // 页码, 默认从1开始
  55. const pageSize = page.size; // 页长, 默认每页10条
  56. getActivityGoodsLists({
  57. page_size: pageSize,
  58. page_no: pageNum,
  59. id: this.id
  60. }).then(({
  61. data
  62. }) => {
  63. if (page.num == 1) this.goodsList = [];
  64. const curPageData = data.list;
  65. const curPageLen = curPageData.length;
  66. const hasNext = !!data.more;
  67. this.goodsList = this.goodsList.concat(curPageData);
  68. this.mescroll.endSuccess(curPageLen, hasNext);
  69. }).catch(() => {
  70. this.mescroll.endErr()
  71. })
  72. },
  73. }
  74. };
  75. </script>
  76. <style lang="scss">
  77. .activity-detail {
  78. overflow: hidden;
  79. .header {
  80. height: 410rpx;
  81. width: 100%;
  82. position: relative;
  83. .header-bg {
  84. position: absolute;
  85. width: 100%;
  86. height: 100%;
  87. }
  88. .header-con {
  89. position: relative;
  90. padding-top: 50rpx;
  91. .title {
  92. font-size: 60rpx;
  93. }
  94. .desc {
  95. margin-top: 30rpx;
  96. background-color: rgba(256, 203, 203, 0.5);
  97. padding: 4rpx 40rpx;
  98. }
  99. }
  100. }
  101. .content {
  102. position: relative;
  103. margin-top: -140rpx;
  104. padding: 0 20rpx;
  105. }
  106. }
  107. </style>