msgSetting.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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="#FF5C03" @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="#FF5C03" @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. console.log("qxj isPush:"+this.user.isPush);
  63. let data={"isPush":this.user.isPush?1:0,"isIndividuationPush":this.user.isIndividuationPush?1:0};
  64. editUserPushSetting(data).then(res => {
  65. uni.hideLoading();
  66. if(res.code==200){
  67. uni.showToast({icon:'none',title: "操作成功"});
  68. }
  69. else{
  70. uni.showToast({
  71. icon:'none',
  72. title: res.msg
  73. });
  74. }
  75. },
  76. rej => {}
  77. );
  78. },
  79. loginNavTo(url){
  80. if(!this.$isLogin()){
  81. this.$showLoginPage();
  82. return;
  83. }
  84. uni.navigateTo({
  85. url: url
  86. });
  87. },
  88. switch1Change(e){
  89. console.log('switch1 发生 change 事件,携带值为', e.detail.value);
  90. this.user.isPush=e.detail.value;
  91. },
  92. switch2Change(e){
  93. console.log('switch2 发生 change 事件,携带值为', e.detail.value);
  94. this.user.isIndividuationPush=e.detail.value;
  95. },
  96. }
  97. }
  98. </script>
  99. <style scoped lang="scss">
  100. page{
  101. height: 100%;
  102. }
  103. .content{
  104. height: 100%;
  105. background-color: #ffffff;
  106. }
  107. .line{
  108. height: 1px;background-color: #F7F7F7;
  109. }
  110. .logo{
  111. padding-top: 15%;
  112. text-align: center;
  113. image{
  114. width: 120rpx;
  115. height: 120rpx;
  116. border-radius: 10rpx;
  117. box-shadow:0px 0px 20rpx rgba(0,0,0,0.2);
  118. }
  119. p{
  120. margin: 10px 0px;
  121. font-size: 14px;
  122. }
  123. }
  124. .set-box{
  125. margin-top: 20upx;
  126. background: #fff;
  127. padding: 0 30upx;
  128. .item{
  129. position: relative;
  130. display: flex;
  131. align-items: center;
  132. justify-content: space-between;
  133. padding: 25upx 0;
  134. .left{
  135. display: flex;
  136. flex-direction: column;
  137. .title{
  138. font-size: 32upx;
  139. font-weight: bold;
  140. color: #333;
  141. margin-bottom: 10rpx;
  142. }
  143. .text{
  144. font-size: 22upx;
  145. color: #999;
  146. }
  147. }
  148. .right{
  149. width: 10upx;
  150. height: 20upx;
  151. }
  152. .right-text{
  153. }
  154. }
  155. }
  156. .contact-btn {
  157. position: absolute;
  158. width: 100%;
  159. display: flex;
  160. opacity: 0;
  161. }
  162. </style>