threshold.js 861 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. Page({
  2. data: {
  3. countThreshold: 3, // 条数阈值
  4. percentageThreshold: 70 // 百分比阈值
  5. },
  6. // 修改条数阈值
  7. updateCountThreshold(e) {
  8. this.setData({
  9. countThreshold: Number(e.detail.value)
  10. });
  11. },
  12. // 修改百分比阈值
  13. updatePercentageThreshold(e) {
  14. this.setData({
  15. percentageThreshold: Number(e.detail.value)
  16. });
  17. },
  18. // 保存设置
  19. saveSettings() {
  20. const { countThreshold, percentageThreshold } = this.data;
  21. const app = getApp();
  22. // 更新全局变量
  23. app.globalData.triggerThreshold = {
  24. count: countThreshold,
  25. percentage: percentageThreshold
  26. };
  27. // 持久化存储
  28. wx.setStorageSync('triggerThreshold', app.globalData.triggerThreshold);
  29. wx.showToast({
  30. title: '设置已保存',
  31. icon: 'success',
  32. duration: 2000
  33. });
  34. }
  35. });