This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
// 引入一个模块,该模块导出了一个名为getBuy的函数
const { getBuy } = require("../../api/index.js")
// 定义一个页面对象,这是微信小程序页面的标准结构
Page({
data: {
goodsData:{}// 用于存储商品数据的对象,初始化为空对象
},
// 页面的初始数据
onLoad(options) {
// 调用getBuy函数,传入一个对象作为参数,该对象包含一个id属性,其值来自页面加载时的选项参数
getBuy({ id:options.id }).then(res =>{
// 在Promise的then回调中处理异步请求的响应
console.log(res.data);
// 使用setData方法更新页面数据
// 这里将响应数据中的第一个商品数据赋值给goodsData
this.setData({
goodsData:res.data.data[0]
})
// 页面上的提交按钮点击时触发的事件处理函数
onSubmit(){
wx.showToast({
// 显示一个提示框,告知用户购买完成
title: '购买完成',// 提示框的标题
icon:"success"// 提示框的图标,这里使用成功图标
}