setting.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <view>
  3. <u-navbar title="设置"></u-navbar>
  4. <u-cell-group>
  5. <u-cell-item title="修改手机号" v-model="userPhone" @click="gotoUrl('pages/user/phone')"></u-cell-item>
  6. <u-cell-item title="注销账号" value="注销后无法恢复,请谨慎操作" :value-style="valueStyle" @click="gotoUrl('pages/user/logout')"></u-cell-item>
  7. </u-cell-group>
  8. <view class="logout-btn oldTextjp" oldstyle="font-size: 18px;" @click="signOut">
  9. 退出帐号
  10. </view>
  11. <view>
  12. <u-modal v-model="show" @confirm="confirm":show-cancel-button="true" ref="uModal" :asyncClose="true" :title="title" :content="content"></u-modal>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. import * as userApi from '@/apis/user.js'
  18. export default {
  19. data() {
  20. return {
  21. show: false,
  22. title: '退出账号',
  23. content: '是否退出当前账号?',
  24. userId: '',
  25. userPhone: '',
  26. valueStyle: {
  27. color:'#ff3300',
  28. }
  29. }
  30. },
  31. onReady() {
  32. if(this.carhelp.getPersonInfo()) {
  33. this.userId = this.carhelp.getPersonInfo().id;
  34. var phone = this.carhelp.getPersonInfo().phone;
  35. var phone1 = phone.slice(0,3);
  36. var phone2 = phone.slice(-4);
  37. this.userPhone = phone1 + '****' + phone2;
  38. }
  39. },
  40. methods: {
  41. signOut() {
  42. this.show = true;
  43. },
  44. confirm() {
  45. uni.showLoading({
  46. title: "加载中",
  47. mask: true,
  48. })
  49. userApi.logout().then((res) => {
  50. uni.hideLoading();
  51. this.show = false;
  52. this.carhelp.logoff()
  53. uni.redirectTo({
  54. url: '/pages/login/login'
  55. })
  56. }).catch(error => {
  57. uni.showToast({
  58. title: error,
  59. icon: "none"
  60. })
  61. })
  62. }
  63. }
  64. }
  65. </script>
  66. <style lang="scss" scoped>
  67. .logout-btn{
  68. background-color: #fff;
  69. padding: 12px 0;
  70. text-align: center;
  71. margin-top: 12px;
  72. }
  73. </style>