thres.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. Page({
  2. data: {
  3. countOptions: ['25', '40', '60'], // 条数阈值选项
  4. percentageOptions: ['25', '40', '60'], // 百分比阈值选项
  5. selectedCountIndex: 0, // 条数默认选择
  6. selectedPercentageIndex: 0, // 百分比默认选择
  7. countThresh: 25, // 当前条数阈值
  8. percentageThresh: 25, // 当前百分比阈值
  9. },
  10. // 条数选择框变化
  11. onCountPickerChange(e) {
  12. const selectedValue = this.data.countOptions[e.detail.value];
  13. this.setData({
  14. selectedCountIndex: e.detail.value,
  15. countThresh: selectedValue, // 更新到输入框
  16. });
  17. },
  18. // 百分比选择框变化
  19. onPercentagePickerChange(e) {
  20. const selectedValue = this.data.percentageOptions[e.detail.value];
  21. this.setData({
  22. selectedPercentageIndex: e.detail.value,
  23. percentageThresh: selectedValue, // 更新到输入框
  24. });
  25. },
  26. // 更新条数阈值输入框
  27. updateCountThreshold(e) {
  28. this.setData({
  29. countThresh: e.detail.value, // 允许手动输入
  30. });
  31. },
  32. // 更新百分比阈值输入框
  33. updatePercentageThreshold(e) {
  34. this.setData({
  35. percentageThresh: e.detail.value, // 允许手动输入
  36. });
  37. },
  38. // 保存设置
  39. saveSettings() {
  40. wx.showToast({
  41. title: '保存成功',
  42. icon: 'success',
  43. });
  44. console.log('条数阈值:', this.data.countThresh);
  45. console.log('百分比阈值:', this.data.percentageThresh);
  46. },
  47. });