index.js 888 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import {
  2. getProducts,
  3. } from '~/api/global'
  4. let polling
  5. Component({
  6. data: {
  7. products: [],
  8. },
  9. lifetimes: {
  10. attached() {
  11. // this.selectComponent("#popUp").showModal()
  12. this.getProducts()
  13. },
  14. },
  15. methods: {
  16. async getProducts() {
  17. let {
  18. productList: products,
  19. } = await getProducts()
  20. this.setData({
  21. products,
  22. })
  23. },
  24. openDonutBuy({
  25. currentTarget
  26. }) {
  27. let product = currentTarget.dataset.product
  28. this.triggerEvent('toBuy',product)
  29. this.close()
  30. },
  31. async open(product) {
  32. this.selectComponent("#popUp").showModal()
  33. },
  34. closeEvent() {},
  35. close() {
  36. this.selectComponent("#popUp").hideModal()
  37. }
  38. }
  39. })