index.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <view class="page_container">
  3. <custom-nav-bar title="消息通知" />
  4. <view class="info_wrap">
  5. <setting-item
  6. @switch="changeNotify"
  7. :loading="loadingState.message"
  8. :switchValue="newMessageNotify"
  9. title="新消息通知"
  10. :is_switch="true"
  11. />
  12. <setting-item
  13. v-show="newMessageNotify"
  14. @click="toNotificationDetails"
  15. title="消息通知设置"
  16. />
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. import CustomNavBar from "../../../components/CustomNavBar/index.vue";
  22. import MyAvatar from "../../../components/MyAvatar/index.vue";
  23. import SettingItem from "../../../components/SettingItem/index.vue";
  24. export default {
  25. components: {
  26. CustomNavBar,
  27. MyAvatar,
  28. SettingItem,
  29. },
  30. data() {
  31. return {
  32. newMessageNotify: true,
  33. loadingState: {
  34. message: false,
  35. },
  36. };
  37. },
  38. onLoad() {
  39. const disableNotify =
  40. uni.getStorageSync(
  41. `${this.$store.getters.storeCurrentUserID}_DisableNotify`,
  42. ) ?? false;
  43. this.newMessageNotify = !disableNotify;
  44. },
  45. methods: {
  46. toNotificationDetails() {
  47. uni.navigateTo({
  48. url: "/pages_im/pages/profile/notificationDetails/index",
  49. });
  50. },
  51. changeNotify(value) {
  52. this.loadingState.message = true;
  53. uni.setStorageSync(
  54. `${this.$store.getters.storeCurrentUserID}_DisableNotify`,
  55. !value,
  56. );
  57. this.newMessageNotify = value;
  58. this.loadingState.message = false;
  59. },
  60. },
  61. };
  62. </script>
  63. <style lang="scss" scoped>
  64. .page_container {
  65. background-color: #f8f8f8;
  66. .info_wrap {
  67. background-color: #fff;
  68. margin-top: 24rpx;
  69. }
  70. }
  71. </style>