import { getProducts } from '~/api/global' Component({ /** * 组件的属性列表 */ properties: { }, /** * 组件的初始数据 */ data: { show: false, products: [], // 是否购买过vip isPreferential: false }, /** * 组件的方法列表 */ methods: { open() { this.getProducts() this.setData({ show: true, }) }, closeModal() { this.setData({ show: false }) }, async getProducts() { let { isPreferential, productList: products, } = await getProducts() this.setData({ products, isPreferential }) }, triggerPay({ currentTarget }) { console.log(currentTarget.dataset.goods); this.triggerEvent('toBuy', currentTarget.dataset.goods) } } })