index.js 862 B

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