You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
1.2 KiB

This file contains ambiguous Unicode characters!

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"// 提示框的图标,这里使用成功图标
})
}
})