set.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <template>
  2. <view class="content">
  3. <view class='flex bottom flex-between' style="padding: 20rpx;">
  4. <text>允许他人分享我的名片</text>
  5. <u-switch v-model="value1" activeColor="#112253" :activeValue='true' :inactiveValue='false' @change="change($event,1)"
  6. size="20"></u-switch>
  7. </view>
  8. <view class='flex bottom flex-between' style="padding: 20rpx;">
  9. <text>允许圈子成员查看我的主页</text>
  10. <u-switch v-model="value2" activeColor="#112253" @change="change($event,2)" size="20"></u-switch>
  11. </view>
  12. <view class="flex flex-between" style="padding: 20rpx;">
  13. <text>自动接受交换名片邀请</text>
  14. <u-switch v-model="value3" activeColor="#112253" @change="change($event,3)" size="20"></u-switch>
  15. </view>
  16. <u-toast ref="uToast"></u-toast>
  17. </view>
  18. </template>
  19. <script>
  20. export default {
  21. data() {
  22. return {
  23. value1: false,
  24. value2: false,
  25. value3: false
  26. };
  27. },
  28. onShow() {
  29. this.value1 = (uni.getStorageSync("userInfo").shareCard == 1 ? true : false)
  30. this.value2 = (uni.getStorageSync("userInfo").lookPage == 1 ? true : false)
  31. this.value3 = (uni.getStorageSync("userInfo").autoAccept == 1 ? true : false)
  32. },
  33. methods: {
  34. change(e, status) {
  35. console.log(e)
  36. let data = {
  37. id: uni.getStorageSync("userInfo").id
  38. }
  39. if (status == 1) {
  40. if (e) {
  41. data.shareCard = 1
  42. } else {
  43. data.shareCard = 0
  44. }
  45. } else if (status == 2) {
  46. if (e) {
  47. data.lookPage = 1
  48. } else {
  49. data.lookPage = 0
  50. }
  51. } else if (status == 3) {
  52. if (e) {
  53. data.autoAccept = 1
  54. } else {
  55. data.autoAccept = 0
  56. }
  57. }
  58. this.$request.baseRequest('admin.unimall.commonUserInfo', 'update', {
  59. commonUserInfo: JSON.stringify(data)
  60. }, failres => {
  61. console.log('res+++++', failres.errmsg)
  62. uni.showToast({
  63. icon:"none",
  64. title: failres.errmsg,
  65. duration: 3000
  66. });
  67. uni.hideLoading()
  68. }).then(res => {
  69. uni.showToast({
  70. icon:"success",
  71. title: '设置成功!',
  72. duration: 2000
  73. });
  74. let userInfo = uni.getStorageSync("userInfo")
  75. if (status == 1) {
  76. if (e) {
  77. userInfo.shareCard = 1
  78. } else {
  79. userInfo.shareCard = 0
  80. }
  81. } else if (status == 2) {
  82. if (e) {
  83. userInfo.lookPage = 1
  84. } else {
  85. userInfo.lookPage = 0
  86. }
  87. } else if (status == 3) {
  88. if (e) {
  89. userInfo.autoAccept = 1
  90. } else {
  91. userInfo.autoAccept = 0
  92. }
  93. }
  94. uni.setStorageSync("userInfo", userInfo)
  95. })
  96. }
  97. }
  98. }
  99. </script>
  100. <style lang="scss" scoped>
  101. .content {
  102. background: #fff;
  103. margin: 20rpx;
  104. padding: 0rpx 20rpx 0 20rpx;
  105. border-radius: 20rpx;
  106. .bottom {
  107. border-bottom: 1px solid #E6E6E6;
  108. }
  109. }
  110. </style>