setting.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <view>
  3. <u-navbar title="设置"></u-navbar>
  4. <u-cell-group>
  5. <u-cell-item title="修改手机号" :title-style="checked ? titleStyle : {}" v-model="userPhone" @click="gotoUrl('pages/user/phone')"
  6. :value-style="checked ? {fontSize:'16px'} : {}">
  7. </u-cell-item>
  8. <u-cell-item title="注销账号" :title-style="checked ? titleStyle : {}" value="注销后无法恢复,请谨慎操作"
  9. :value-style="checked ? {color:'#ff3300',fontSize:'16px'} : valueStyle" @click="gotoUrl('pages/user/logout')">
  10. </u-cell-item>
  11. </u-cell-group>
  12. <view class="switcher-mode">
  13. <view class="oldTextjp2" oldstyle="font-weight:bold;font-size:18px">
  14. 长辈模式
  15. <text class="oldTextjp2" oldstyle="font-weight:normal;font-size:16px;">字体更大更清晰</text>
  16. </view>
  17. <view class="switch-box" >
  18. <u-switch v-model="checked" class="switch" active-color="#00E266" @change="checkedChange"></u-switch>
  19. </view>
  20. </view>
  21. <view class="logout-btn oldTextjp" oldstyle="font-size:18px" @click="signOut">
  22. 退出帐号
  23. </view>
  24. <view>
  25. <u-modal v-model="show" @confirm="confirm":show-cancel-button="true" ref="uModal" :asyncClose="true" :title="title" :content="content"></u-modal>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. import * as userApi from '@/apis/user.js'
  31. export default {
  32. data() {
  33. return {
  34. show: false,
  35. title: '退出账号',
  36. content: '是否退出当前账号?',
  37. userId: '',
  38. userPhone: '',
  39. checked:false,
  40. valueStyle: {
  41. color:'#ff3300',
  42. },
  43. titleStyle: {
  44. fontWeight: 'bold',
  45. fontSize: '18px',
  46. }
  47. }
  48. },
  49. onReady() {
  50. if(this.carhelp.getPersonInfo()) {
  51. this.userId = this.carhelp.getPersonInfo().id;
  52. var phone = this.carhelp.getPersonInfo().phone;
  53. var phone1 = phone.slice(0,3);
  54. var phone2 = phone.slice(-4);
  55. this.userPhone = phone1 + '****' + phone2;
  56. if(this.carhelp.get("getElderModeClass") == "长辈模式") {
  57. this.checked = true;
  58. } else {
  59. this.checked = false;
  60. }
  61. }
  62. },
  63. methods: {
  64. checkedChange() {
  65. if(this.checked) {
  66. this.carhelp.set("getElderModeClass", "长辈模式");
  67. } else {
  68. this.carhelp.set("getElderModeClass", "标准模式");
  69. }
  70. },
  71. signOut() {
  72. this.show = true;
  73. },
  74. confirm() {
  75. uni.showLoading({
  76. title: "加载中",
  77. mask: true,
  78. })
  79. userApi.logout().then((res) => {
  80. uni.hideLoading();
  81. this.show = false;
  82. this.carhelp.logoff()
  83. uni.redirectTo({
  84. url: '/pages/login/login'
  85. })
  86. }).catch(error => {
  87. uni.showToast({
  88. title: error,
  89. icon: "none"
  90. })
  91. })
  92. }
  93. }
  94. }
  95. </script>
  96. <style lang="scss" scoped>
  97. .logout-btn{
  98. background-color: #fff;
  99. padding: 12px 0;
  100. text-align: center;
  101. margin-top: 12px;
  102. }
  103. .switcher-mode{
  104. background-color: #fff;
  105. height: 44px;
  106. line-height: 44px;
  107. display: flex;
  108. justify-content: space-between;
  109. padding: 0 14px;
  110. text{
  111. font-size: 12px;
  112. color: rgba(119, 119, 119, 100);
  113. margin-left: 8px;
  114. }
  115. .switch-box{
  116. padding-top: 8px;
  117. }
  118. .switch{
  119. width: 40px;
  120. height: 22px;
  121. }
  122. /deep/.u-switch__node{
  123. width: 20px !important;
  124. height: 20px !important;
  125. }
  126. }
  127. </style>