Page({
  data: {
    typeList: ['primary'],
    lie: [
      { id: 1, name: '推荐款式', showLine: true },
      { id: 2, name: '中长款', showLine: false },
      { id: 3, name: '本甲款', showLine: false },
      { id: 4, name: '长款', showLine: false },
      { id: 5, name: '短款', showLine: false },
    ],
    filteredShopping:[
      { id:1,commoditiesName:'亮面美甲贴片',commoditiesPrice:'78'},
      { id:2,commoditiesName:'亮面美甲贴片',commoditiesPrice:'78'},
      { id:3,commoditiesName:'亮面美甲贴片',commoditiesPrice:'78'},
      { id:4,commoditiesName:'亮面美甲贴片',commoditiesPrice:'78'},
      { id:5,commoditiesName:'亮面美甲贴片',commoditiesPrice:'78'},
      { id:6,commoditiesName:'亮面美甲贴片',commoditiesPrice:'78'},
    ]
  },
  onLoad() {},
  handleTapLink() {
    this.showToast('联系方式：15214547473');
},
showToast(content) {
  my.showToast({
      content: content,
      duration: 3000,
  });
},
selectItem(e) {
  const id = e.currentTarget.dataset.id;
  console.log(id);
  // 更新对应的 showLine 状态，控制是否显示线条
  const updatedLie = this.data.lie.map(item => {
    if (item.id === id) {
      item.showLine = !item.showLine;  // 切换显示状态
    } else {
      item.showLine = false; // 其他项隐藏
    }
    return item;
  });

  // 根据点击的类别 id 筛选对应的商品
  const filteredShopping = this.data.tuijian.filter(item => String(item.commoditiesGroupId) === String(id));

  // 更新数据
  this.setData({
    lie: updatedLie,
    filteredShopping,  // 更新右侧商品列表
    showShoppingCart: true,  // 显示购物车部分
    showComments: false,     // 隐藏评论部分
    showBusinessInfo: false, // 隐藏商家信息部分
  });
  console.log(this.data.filteredShopping,'hhhhhhhhhhhhhh');
},
shangpinjiemian(item){
  const id = item.target.dataset.num
  console.log('传递的数据:', id); 
    const ids = id.id
    const commoditiesPrice = id.commoditiesPrice
    const commoditiesName = id.commoditiesName
    const commoditiesImage = id.commoditiesImage
    const businessId = id.businessId
    const dianpuid = this.data.id
    const businessName =this.data.businessName
    console.log('Address being passed: ',id,commoditiesPrice,commoditiesName,commoditiesImage,businessId); 
  my.navigateTo({
    url:`/pages/shangpinjiemian/shangpinjiemian?commoditiesPrice=${commoditiesPrice}&&commoditiesName=${commoditiesName}&&commoditiesImage=${commoditiesImage}&&ids=${ids}&&businessId=${businessId}&&dianpuid=${dianpuid}&&businessName=${businessName}`
  })
  console.log(ids,businessId,commoditiesImage,commoditiesName,commoditiesPrice+'这是商品的',dianpuid+'这是店铺的')
},
});
