index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <view class="page">
  3. <navBar title="设置" :back="true" color="black" background="white" />
  4. <view class="content">
  5. <view class="item" style="border-radius: 0rpx 0rpx 0rpx 24rpx;;">
  6. <view class="line">
  7. <view class="left">
  8. 显示售价
  9. </view>
  10. <view class="right">
  11. <u-switch v-model="value1" @change="asyncChange1" :disabled="disAbled1" activeColor="#F7790C"
  12. inactiveColor="#E6E6E6"></u-switch>
  13. </view>
  14. </view>
  15. <view class="line" v-if="role!='svip'&&role!='gvip'">
  16. <view class="left">
  17. 显示会员价
  18. </view>
  19. <view class="right">
  20. <u-switch v-model="value2" @change="asyncChange2" :disabled="disAbled2" activeColor="#F7790C"
  21. inactiveColor="#E6E6E6"></u-switch>
  22. </view>
  23. </view>
  24. <view class="line" v-if="role!='cydg'">
  25. <view class="left">
  26. 显示VIP价
  27. </view>
  28. <view class="right">
  29. <u-switch v-model="value3" @change="asyncChange3" :disabled="disAbled3" activeColor="#F7790C"
  30. inactiveColor="#E6E6E6"></u-switch>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. export default {
  39. components: {
  40. },
  41. data() {
  42. return {
  43. role: '',
  44. role: '',
  45. value1: true,
  46. value2: false,
  47. value3: false,
  48. // switchs: uni.getStorageSync('switchs')
  49. }
  50. },
  51. onLoad(o) {
  52. this.role = o.role
  53. console.log(this.disAbled1, this.disAbled2, this.disAbled3);
  54. },
  55. onShow() {
  56. this.value1 = Boolean(this.switchs[0])
  57. this.value2 = Boolean(this.switchs[1])
  58. this.value3 = Boolean(this.switchs[2])
  59. console.log(this.switchs);
  60. },
  61. computed: {
  62. switchs() {
  63. return uni.getStorageSync('switchs')
  64. },
  65. disAbled1() {
  66. if (!this.value2 && !this.value3 && this.value1) {
  67. return true
  68. } else {
  69. return false
  70. }
  71. },
  72. disAbled2() {
  73. if (!this.value1 && !this.value3 && this.value2) {
  74. return true
  75. } else {
  76. return false
  77. }
  78. },
  79. disAbled3() {
  80. if (!this.value2 && !this.value1 && this.value3) {
  81. return true
  82. } else {
  83. return false
  84. }
  85. },
  86. },
  87. methods: {
  88. asyncChange1(e) {
  89. if (e) {
  90. this.switchs[0] = 1
  91. if (this.value2) {
  92. this.value2 = false
  93. this.switchs[1] = 0
  94. }
  95. if (this.value3) {
  96. this.value3 = false
  97. this.switchs[2] = 0
  98. }
  99. } else {
  100. this.switchs[0] = 0
  101. }
  102. uni.setStorageSync('switchs', this.switchs)
  103. console.log(this.switchs);
  104. },
  105. asyncChange2(e) {
  106. if (e) {
  107. this.switchs[1] = 1
  108. if (this.value1) {
  109. this.value1 = false
  110. this.switchs[0] = 0
  111. }
  112. if (this.value3) {
  113. this.value3 = false
  114. this.switchs[2] = 0
  115. }
  116. } else {
  117. this.switchs[1] = 0
  118. }
  119. uni.setStorageSync('switchs', this.switchs)
  120. console.log(this.switchs);
  121. },
  122. asyncChange3(e) {
  123. if (e) {
  124. this.switchs[2] = 1
  125. if (this.value1) {
  126. this.value1 = false
  127. this.switchs[0] = 0
  128. }
  129. if (this.value2) {
  130. this.value2 = false
  131. this.switchs[1] = 0
  132. }
  133. } else {
  134. this.switchs[2] = 0
  135. }
  136. uni.setStorageSync('switchs', this.switchs)
  137. console.log(this.switchs);
  138. },
  139. }
  140. }
  141. </script>
  142. <style lang="scss" scoped>
  143. .u-switch--disabled {
  144. opacity: 1 !important;
  145. }
  146. @import "./index.scss";
  147. </style>