index.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import {
  2. getProducts
  3. } from '~/api/global'
  4. import {
  5. getWxQrcode,
  6. } from '~/api/user'
  7. const app = getApp()
  8. Component({
  9. properties: {
  10. },
  11. data: {
  12. show: false,
  13. products: [],
  14. // 是否购买过vip
  15. isIos: app.globalData.isIOS,
  16. qrCode: '',
  17. isPreferential: false
  18. },
  19. methods: {
  20. async open() {
  21. if (!this.data.isIos) {
  22. this.getProducts()
  23. } else {
  24. let qrCode = await getWxQrcode()
  25. console.log(qrCode);
  26. this.setData({
  27. qrCode: qrCode.ticketUrl
  28. })
  29. }
  30. this.setData({
  31. show: true,
  32. })
  33. },
  34. closeModal() {
  35. this.setData({
  36. show: false
  37. })
  38. },
  39. async getProducts() {
  40. let {
  41. isPreferential,
  42. productList: products,
  43. } = await getProducts()
  44. this.setData({
  45. products,
  46. isPreferential
  47. })
  48. },
  49. toBuy({
  50. currentTarget
  51. }) {
  52. this.triggerEvent('toBuy', currentTarget.dataset.goods)
  53. }
  54. }
  55. })