index.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const _sfc_main = {
  4. data() {
  5. return {
  6. // 通知设置状态
  7. notifications: {
  8. system: true,
  9. crop: true,
  10. weather: true
  11. },
  12. // 缓存大小
  13. cacheSize: "0.00MB",
  14. // 版本号
  15. version: "1.0.0"
  16. };
  17. },
  18. methods: {
  19. // 获取缓存大小
  20. getCacheSize() {
  21. common_vendor.index.getStorageInfo({
  22. success: (res) => {
  23. const size = (res.currentSize / 1024).toFixed(2);
  24. this.cacheSize = size + "MB";
  25. }
  26. });
  27. },
  28. // 清除缓存
  29. handleClearCache() {
  30. common_vendor.index.showModal({
  31. title: "提示",
  32. content: "确定要清除缓存吗?",
  33. success: (res) => {
  34. if (res.confirm) {
  35. common_vendor.index.clearStorage({
  36. success: () => {
  37. common_vendor.index.showToast({
  38. title: "清除成功",
  39. icon: "success"
  40. });
  41. this.getCacheSize();
  42. }
  43. });
  44. }
  45. }
  46. });
  47. },
  48. // 检查更新
  49. checkUpdate() {
  50. common_vendor.index.showLoading({ title: "检查更新中..." });
  51. setTimeout(() => {
  52. common_vendor.index.hideLoading();
  53. common_vendor.index.showToast({
  54. title: "已是最新版本",
  55. icon: "none"
  56. });
  57. }, 1500);
  58. },
  59. // 通知设置处理函数
  60. handleSystemNotification(e) {
  61. this.notifications.system = e.detail.value;
  62. this.saveNotificationSettings();
  63. },
  64. handleCropNotification(e) {
  65. this.notifications.crop = e.detail.value;
  66. this.saveNotificationSettings();
  67. },
  68. handleWeatherNotification(e) {
  69. this.notifications.weather = e.detail.value;
  70. this.saveNotificationSettings();
  71. },
  72. // 保存通知设置
  73. saveNotificationSettings() {
  74. common_vendor.index.setStorageSync("notifications", this.notifications);
  75. },
  76. // 加载通知设置
  77. loadNotificationSettings() {
  78. const savedSettings = common_vendor.index.getStorageSync("notifications");
  79. if (savedSettings) {
  80. this.notifications = savedSettings;
  81. }
  82. },
  83. // 页面跳转
  84. navigateToAboutUs() {
  85. common_vendor.index.navigateTo({ url: "/pages/about/index" });
  86. },
  87. navigateToPrivacy() {
  88. common_vendor.index.navigateTo({ url: "/pages/privacy/index" });
  89. },
  90. handleContact() {
  91. common_vendor.index.makePhoneCall({
  92. phoneNumber: "400-xxx-xxxx"
  93. // 替换为实际的客服电话
  94. });
  95. }
  96. },
  97. // 页面显示时加载数据
  98. onShow() {
  99. this.getCacheSize();
  100. this.loadNotificationSettings();
  101. }
  102. };
  103. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  104. return {
  105. a: $data.notifications.system,
  106. b: common_vendor.o((...args) => $options.handleSystemNotification && $options.handleSystemNotification(...args)),
  107. c: $data.notifications.crop,
  108. d: common_vendor.o((...args) => $options.handleCropNotification && $options.handleCropNotification(...args)),
  109. e: $data.notifications.weather,
  110. f: common_vendor.o((...args) => $options.handleWeatherNotification && $options.handleWeatherNotification(...args)),
  111. g: common_vendor.t($data.cacheSize),
  112. h: common_vendor.o((...args) => $options.handleClearCache && $options.handleClearCache(...args)),
  113. i: common_vendor.t($data.version),
  114. j: common_vendor.o((...args) => $options.checkUpdate && $options.checkUpdate(...args)),
  115. k: common_vendor.o((...args) => $options.navigateToAboutUs && $options.navigateToAboutUs(...args)),
  116. l: common_vendor.o((...args) => $options.handleContact && $options.handleContact(...args)),
  117. m: common_vendor.o((...args) => $options.navigateToPrivacy && $options.navigateToPrivacy(...args))
  118. };
  119. }
  120. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
  121. wx.createPage(MiniProgramPage);
  122. //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/settings/index.js.map