msgSetting.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <view class="content">
  3. <view class="es-pt-20 es-pb-20 es-pl-20 es-fs-26 es-c-99 es-bc-f7">你希望收到</view>
  4. <view class="set-box" >
  5. <view class="item">
  6. <view class="left">
  7. <view class="title">消息通知</view>
  8. <view class="text">关闭后,可能会错过点赞、评论、关注等消息通知</view>
  9. </view>
  10. <switch :checked="user.isPush" color="#2583EB" @change="switch1Change" style="transform:scale(0.7)"/>
  11. </view>
  12. <!-- <view class="line"></view> -->
  13. <view class="item">
  14. <view class="left">
  15. <view class="title">个性化推送</view>
  16. <view class="text">依据您的喜好和习惯向您推荐相关信息</view>
  17. </view>
  18. <switch :checked="user.isIndividuationPush" color="#2583EB" @change="switch2Change" style="transform:scale(0.7)"/>
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. import { editUserPushSetting,getUserPushSetting} from '@/api/user'
  25. export default {
  26. data() {
  27. return {
  28. user:{
  29. "isPush": 0,
  30. "isIndividuationPush": 0
  31. }
  32. }
  33. },
  34. onLoad() {
  35. this.getUserPushSetting();
  36. },
  37. onNavigationBarButtonTap(e) {
  38. this.editUserPushSetting();
  39. },
  40. methods: {
  41. getUserPushSetting(){
  42. let that=this;
  43. getUserPushSetting().then(res => {
  44. if(res.code==200){
  45. if(res.data!=null){
  46. this.user = res.data;
  47. }
  48. else{
  49. uni.showToast({
  50. icon:'none',
  51. title: res.msg,
  52. });
  53. }
  54. }
  55. },
  56. rej => {}
  57. );
  58. },
  59. editUserPushSetting(){
  60. let that=this;
  61. uni.showLoading({title:""});
  62. let data={"isPush":this.user.isPush?1:0,"isIndividuationPush":this.user.isIndividuationPush?1:0};
  63. editUserPushSetting(data).then(res => {
  64. uni.hideLoading();
  65. if(res.code==200){
  66. uni.showToast({icon:'none',title: "操作成功"});
  67. }
  68. else{
  69. uni.showToast({
  70. icon:'none',
  71. title: res.msg
  72. });
  73. }
  74. },
  75. rej => {}
  76. );
  77. },
  78. loginNavTo(url){
  79. if(!this.$isLogin()){
  80. this.$showLoginPage();
  81. return;
  82. }
  83. uni.navigateTo({
  84. url: url
  85. });
  86. },
  87. switch1Change(e){
  88. this.user.isPush=e.detail.value;
  89. this.editUserPushSetting();
  90. },
  91. switch2Change(e){
  92. this.user.isIndividuationPush=e.detail.value;
  93. this.editUserPushSetting();
  94. },
  95. }
  96. }
  97. </script>
  98. <style scoped lang="scss">
  99. page{
  100. height: 100%;
  101. }
  102. .content{
  103. height: 100%;
  104. background-color: #ffffff;
  105. }
  106. .line{
  107. height: 1px;background-color: #F7F7F7;
  108. }
  109. .logo{
  110. padding-top: 15%;
  111. text-align: center;
  112. image{
  113. width: 120rpx;
  114. height: 120rpx;
  115. border-radius: 10rpx;
  116. box-shadow:0px 0px 20rpx rgba(0,0,0,0.2);
  117. }
  118. p{
  119. margin: 10px 0px;
  120. font-size: 14px;
  121. }
  122. }
  123. .set-box{
  124. margin-top: 20upx;
  125. background: #fff;
  126. padding: 0 30upx;
  127. .item{
  128. position: relative;
  129. display: flex;
  130. align-items: center;
  131. justify-content: space-between;
  132. padding: 25upx 0;
  133. .left{
  134. display: flex;
  135. flex-direction: column;
  136. .title{
  137. font-size: 32upx;
  138. font-weight: bold;
  139. color: #333;
  140. margin-bottom: 10rpx;
  141. }
  142. .text{
  143. font-size: 22upx;
  144. color: #999;
  145. }
  146. }
  147. .right{
  148. width: 10upx;
  149. height: 20upx;
  150. }
  151. .right-text{
  152. }
  153. }
  154. }
  155. .contact-btn {
  156. position: absolute;
  157. width: 100%;
  158. display: flex;
  159. opacity: 0;
  160. }
  161. </style>