| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- // index.js
- const { API } = require('../../service/api.js');
- const App = getApp();
- Page({
- data: {
- brandList: [
- {
- name: "全部IP",
- },
- {
- name: "火影忍者",
- },
- {
- name: "原神",
- },
- {
- name: "柯南",
- },
- {
- name: "非人哉",
- },
- {
- name: "海贼王",
- },
- {
- name: "初音",
- },
- {
- name: "千与千寻",
- },
- {
- name: "樱木花道",
- },
- {
- name: "原神",
- },
- ],
- categoryList: [
- {
- name: "立绘",
- },
- {
- name: "立绘",
- },
- {
- name: "立绘",
- },
- {
- name: "立绘",
- },
- {
- name: "立绘",
- },
- {
- name: "立绘",
- },
- {
- name: "立绘",
- },
- {
- name: "立绘",
- },
- ],
- showAddCartModal: false,
- currentProduct: null
- },
- // 显示商品属性模态框
- showAddCartModal(e) {
- const product = e.detail;
- this.setData({
- showAddCartModal: true,
- currentProduct:product
- });
- },
- // 关闭商品属性模态框
- handleCloseAddCartModal() {
- this.setData({ showAddCartModal: false });
- },
- // 添加购物车
- handleAddToCart(e) {
- const cartItem = e.detail.item;
- // 这里实现添加到购物车的逻辑
- console.log('添加到购物车:', cartItem);
-
- // 可以显示添加成功的提示
- wx.showToast({
- title: '已加入购物车',
- icon: 'success'
- });
-
- // 关闭弹框
- this.setData({ showAddCartModal: false });
- },
- methods: {
- onLoad: async function (options) {
- // 生命周期函数--监听页面加载
- console.log("onLoad");
- console.log('App.globalData', App.globalData);
- const res = await API.getBanners({});
- console.log('res', res);
- },
- },
- })
|