pointsZone.vue 2.7 KB

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