setting.vue 3.3 KB

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