Page({
  data: {
    countOptions: ['25', '40', '60'], // 条数阈值选项
    percentageOptions: ['25', '40', '60'], // 百分比阈值选项

    selectedCountIndex: 0, // 条数默认选择
    selectedPercentageIndex: 0, // 百分比默认选择

    countThresh: 25, // 当前条数阈值
    percentageThresh: 25, // 当前百分比阈值
  },

  // 条数选择框变化
  onCountPickerChange(e) {
    const selectedValue = this.data.countOptions[e.detail.value];
    this.setData({
      selectedCountIndex: e.detail.value,
      countThresh: selectedValue, // 更新到输入框
    });
  },

  // 百分比选择框变化
  onPercentagePickerChange(e) {
    const selectedValue = this.data.percentageOptions[e.detail.value];
    this.setData({
      selectedPercentageIndex: e.detail.value,
      percentageThresh: selectedValue, // 更新到输入框
    });
  },

  // 更新条数阈值输入框
  updateCountThreshold(e) {
    this.setData({
      countThresh: e.detail.value, // 允许手动输入
    });
  },

  // 更新百分比阈值输入框
  updatePercentageThreshold(e) {
    this.setData({
      percentageThresh: e.detail.value, // 允许手动输入
    });
  },

  // 保存设置
  saveSettings() {
    wx.showToast({
      title: '保存成功',
      icon: 'success',
    });

    console.log('条数阈值:', this.data.countThresh);
    console.log('百分比阈值:', this.data.percentageThresh);
  },
});
