newsSet.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <view>
  3. <navbar :config="config" backColor="#999999"></navbar>
  4. <view class="box">
  5. <view>消息免打扰</view>
  6. <view><u-switch active-color="rgb(60,189,209)" size="32" v-model="messageConfig" @change="updateMessageConfig"></u-switch></view>
  7. </view>
  8. <view class="tig">*开启后,所有应用消息将不再提醒,仅可通过消息中心查看</view>
  9. </view>
  10. </template>
  11. <script>
  12. import {
  13. myUserInfo
  14. } from "@/api/government.js"
  15. export default {
  16. data() {
  17. return {
  18. config: {
  19. back: true, //false是tolbar页面 是则不写
  20. title: '消息设置',
  21. color: '#000',
  22. //背景颜色;参数一:透明度(0-1);参数二:背景颜色(array则为线性渐变,string为单色背景)
  23. // backgroundColor: [0, '#2cba28'],
  24. },
  25. messageConfig: false
  26. }
  27. },
  28. onLoad(options) {
  29. this.getUserData()
  30. },
  31. methods:{
  32. getUserData() {
  33. myUserInfo().then(res => {
  34. this.messageConfig = res.data.messageConfig
  35. })
  36. },
  37. // 修改消息免打扰配置
  38. updateMessageConfig(){
  39. uni.showLoading({
  40. title: '修改中',
  41. mask: true
  42. });
  43. this.$yghttp.post('/user/updateMessageConfig',{messageConfig:this.messageConfig}).then(res=>{
  44. uni.showToast({
  45. title: '修改成功!',
  46. icon: 'success',
  47. duration: 1000
  48. })
  49. this.getUserData()
  50. })
  51. }
  52. }
  53. }
  54. </script>
  55. <style>
  56. page {
  57. background-color: #F8F8F8;
  58. }
  59. </style>
  60. <style lang="scss" scoped>
  61. .box {
  62. padding: 40rpx 30rpx;
  63. background: #fff;
  64. border-radius: 20rpx;
  65. display: flex;
  66. justify-content: space-between;
  67. margin: 20rpx 30rpx;
  68. >view {
  69. font-size: 30rpx;
  70. }
  71. }
  72. .tig{
  73. font-size: 24rpx;
  74. color: #999999;
  75. margin: 20rpx 30rpx;
  76. }
  77. </style>