index.js 920 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import {
  2. getProducts
  3. } from '~/api/global'
  4. const app = getApp()
  5. Component({
  6. properties: {
  7. },
  8. data: {
  9. show: false,
  10. products: [],
  11. // 是否购买过vip
  12. isIos: app.globalData.isIOS,
  13. isPreferential: false
  14. },
  15. methods: {
  16. open() {
  17. this.getProducts()
  18. this.setData({
  19. show: true,
  20. })
  21. },
  22. closeModal() {
  23. this.setData({
  24. show: false
  25. })
  26. },
  27. async getProducts() {
  28. let {
  29. isPreferential,
  30. productList: products,
  31. } = await getProducts()
  32. this.setData({
  33. products,
  34. isPreferential
  35. })
  36. },
  37. toBuy({
  38. currentTarget
  39. }) {
  40. this.triggerEvent('toBuy', currentTarget.dataset.goods)
  41. }
  42. }
  43. })