index.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import {
  2. getProducts
  3. } from '~/api/global'
  4. Component({
  5. /**
  6. * 组件的属性列表
  7. */
  8. properties: {
  9. },
  10. /**
  11. * 组件的初始数据
  12. */
  13. data: {
  14. show: false,
  15. products: [],
  16. // 是否购买过vip
  17. isPreferential: false
  18. },
  19. /**
  20. * 组件的方法列表
  21. */
  22. methods: {
  23. open() {
  24. this.getProducts()
  25. this.setData({
  26. show: true,
  27. })
  28. },
  29. closeModal() {
  30. this.setData({
  31. show: false
  32. })
  33. },
  34. async getProducts() {
  35. let {
  36. isPreferential,
  37. productList: products,
  38. } = await getProducts()
  39. this.setData({
  40. products,
  41. isPreferential
  42. })
  43. },
  44. triggerPay({
  45. currentTarget
  46. }) {
  47. console.log(currentTarget.dataset.goods);
  48. this.triggerEvent('toBuy', currentTarget.dataset.goods)
  49. }
  50. }
  51. })