giftZone.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <view class="common-page">
  3. <image :src="bgUrl" style="width: 100%; height: 380rpx" mode="aspectFill">
  4. </image>
  5. <view class="list-box">
  6. <CommercePartRow :data="data"></CommercePartRow>
  7. </view>
  8. </view>
  9. </template>
  10. <script>
  11. import CommercePartRow from "@/components/CommercePartRow.vue";
  12. import {
  13. getAdData
  14. } from '@/common/api/home.js'
  15. import {
  16. getGiftGoodsList
  17. } from '@/common/api/good.js'
  18. export default {
  19. components: {
  20. CommercePartRow
  21. },
  22. data() {
  23. return {
  24. pageOptions: {},
  25. bgUrl: '',
  26. data: [],
  27. page: 1,
  28. pageSize: 6,
  29. total: 0
  30. }
  31. },
  32. onLoad(options) {
  33. this.pageOptions = options
  34. this.getBanner()
  35. this.getData(true)
  36. },
  37. onReachBottom() {
  38. this.getData()
  39. },
  40. onShareAppMessage(res) {
  41. if (res.from === 'button') { // 来自页面内分享按钮
  42. console.log(res.target)
  43. }
  44. let userInfo = uni.getStorageSync('userInfo')
  45. userInfo = userInfo && JSON.parse(userInfo) || {}
  46. let params = {}
  47. if (userInfo.id) {
  48. params = {
  49. id: userInfo.id
  50. }
  51. }
  52. let configs = uni.getStorageSync('configs') || {}
  53. return {
  54. title: configs.shop_share_title,
  55. path: `/subPages/giftZone/giftZone${this.$stringPageOptions(params)}`
  56. }
  57. },
  58. onShareTimeline() {
  59. if (res.from === 'button') { // 来自页面内分享按钮
  60. console.log(res.target)
  61. }
  62. let userInfo = uni.getStorageSync('userInfo')
  63. userInfo = userInfo && JSON.parse(userInfo) || {}
  64. let params = {}
  65. if (userInfo.id) {
  66. params = {
  67. id: userInfo.id
  68. }
  69. }
  70. let configs = uni.getStorageSync('configs') || {}
  71. return {
  72. title: configs.shop_share_title,
  73. path: `/subPages/giftZone/giftZone${this.$stringPageOptions(params)}`
  74. }
  75. },
  76. methods: {
  77. getBanner() {
  78. getAdData({
  79. pstn_id: 5
  80. }).then(res => {
  81. this.bgUrl = res.data.length && res.data[0].pic
  82. })
  83. },
  84. getData(initFlag) {
  85. if (!initFlag) {
  86. if (this.page * this.pageSize < this.total) {
  87. this.page++
  88. } else {
  89. return
  90. }
  91. } else {
  92. this.page = 1
  93. this.total = 0
  94. this.data = []
  95. }
  96. const sendData = {
  97. pageSize: this.pageSize,
  98. page: this.page
  99. }
  100. getGiftGoodsList(sendData).then(res => {
  101. this.data = this.data.concat(res.data.list)
  102. this.total = res.data.page.total
  103. })
  104. },
  105. }
  106. }
  107. </script>
  108. <style lang="scss" scoped>
  109. .common-page {
  110. background-color: #F4D01A;
  111. height: 100vh;
  112. // overflow-y: auto;
  113. .list-box {
  114. padding: 20rpx 20rpx 30rpx;
  115. }
  116. }
  117. </style>