index.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const _sfc_main = {
  4. __name: "index",
  5. setup(__props) {
  6. const notifications = common_vendor.ref({
  7. system: true,
  8. crop: true,
  9. weather: true
  10. });
  11. const cacheSize = common_vendor.ref("0.00MB");
  12. const version = common_vendor.ref("1.0.0");
  13. const getCacheSize = () => {
  14. common_vendor.index.getStorageInfo({
  15. success: (res) => {
  16. const size = (res.currentSize / 1024).toFixed(2);
  17. cacheSize.value = size + "MB";
  18. }
  19. });
  20. };
  21. const handleClearCache = () => {
  22. common_vendor.index.showModal({
  23. title: "提示",
  24. content: "确定要清除缓存吗?",
  25. success: (res) => {
  26. if (res.confirm) {
  27. common_vendor.index.clearStorage({
  28. success: () => {
  29. common_vendor.index.showToast({
  30. title: "清除成功",
  31. icon: "success"
  32. });
  33. getCacheSize();
  34. }
  35. });
  36. }
  37. }
  38. });
  39. };
  40. const checkUpdate = () => {
  41. common_vendor.index.showLoading({ title: "检查更新中..." });
  42. setTimeout(() => {
  43. common_vendor.index.hideLoading();
  44. common_vendor.index.showToast({
  45. title: "已是最新版本",
  46. icon: "none"
  47. });
  48. }, 1500);
  49. };
  50. const handleSystemNotification = (e) => {
  51. notifications.value.system = e.detail.value;
  52. saveNotificationSettings();
  53. };
  54. const handleCropNotification = (e) => {
  55. notifications.value.crop = e.detail.value;
  56. saveNotificationSettings();
  57. };
  58. const handleWeatherNotification = (e) => {
  59. notifications.value.weather = e.detail.value;
  60. saveNotificationSettings();
  61. };
  62. const saveNotificationSettings = () => {
  63. common_vendor.index.setStorageSync("notifications", notifications.value);
  64. };
  65. const loadNotificationSettings = () => {
  66. const savedSettings = common_vendor.index.getStorageSync("notifications");
  67. if (savedSettings) {
  68. notifications.value = savedSettings;
  69. }
  70. };
  71. const navigateToAboutUs = () => {
  72. common_vendor.index.navigateTo({ url: "/pages/about/index" });
  73. };
  74. const navigateToPrivacy = () => {
  75. common_vendor.index.navigateTo({ url: "/pages/privacy/index" });
  76. };
  77. const handleContact = () => {
  78. common_vendor.index.makePhoneCall({
  79. phoneNumber: "400-xxx-xxxx"
  80. // 替换为实际的客服电话
  81. });
  82. };
  83. common_vendor.onShow(() => {
  84. getCacheSize();
  85. loadNotificationSettings();
  86. });
  87. return (_ctx, _cache) => {
  88. return {
  89. a: notifications.value.system,
  90. b: common_vendor.o(handleSystemNotification),
  91. c: notifications.value.crop,
  92. d: common_vendor.o(handleCropNotification),
  93. e: notifications.value.weather,
  94. f: common_vendor.o(handleWeatherNotification),
  95. g: common_vendor.t(cacheSize.value),
  96. h: common_vendor.o(handleClearCache),
  97. i: common_vendor.t(version.value),
  98. j: common_vendor.o(checkUpdate),
  99. k: common_vendor.o(navigateToAboutUs),
  100. l: common_vendor.o(handleContact),
  101. m: common_vendor.o(navigateToPrivacy)
  102. };
  103. };
  104. }
  105. };
  106. wx.createPage(_sfc_main);