setUp.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <view class="ref" style="background-color: #fff;height: 100%;">
  3. <u-navbar :back-text="i18n('Back')" :back-text-style="backStyle" back-icon-color="#fff" title-color="#fff"
  4. :background="background" title-width="300" :title="i18n('setUp')"></u-navbar>
  5. <!-- 订阅设置 -->
  6. <list-cell iconColor="#333" :title="$t('common.Subscription')"
  7. @eventClick="navTo('/pages/profile/profileSetUp/subscribe')"></list-cell>
  8. <!-- 账号安全 -->
  9. <list-cell iconColor="#333" :title="$t('common.AccountSecurity')"
  10. @eventClick="navTo('/pages/profile/profileSetUp/accountSecurity')"></list-cell>
  11. <!-- 注销服务 -->
  12. <list-cell iconColor="#333" :title="$t('common.Cancellation')"
  13. @eventClick="navTo('/pages/profile/profileSetUp/cancellationOfAccount')"></list-cell>
  14. <!-- 清除缓存 -->
  15. <!-- <list-cell iconColor="#333" :title="$t('common.ClearCache')"></list-cell> -->
  16. <!-- <view class="border"></view> -->
  17. <view class="backLogin">
  18. <!-- <button type="fff" style="">切换账户</button> -->
  19. <!-- <view class="border"></view> -->
  20. <u-button type='primary' @click="showModal">{{i18n('Logout')}}</u-button>
  21. </view>
  22. <u-modal v-model="show" :content="content" :cancel-text="$i18n.locale == 'zh'?'取消':'cancel'" :show-title="false"
  23. :confirm-text="$i18n.locale === 'zh'?'确认':'confirm'" @confirm="confirm" @cancel="cancel"
  24. :show-cancel-button="true"></u-modal>
  25. </view>
  26. </template>
  27. <script>
  28. import listCell from '@/components/JumpBox';
  29. export default {
  30. components: {
  31. listCell
  32. },
  33. data() {
  34. return {
  35. Storage_data: null,
  36. AuthToken: null,
  37. show: false,
  38. content: this.$i18n.locale === 'zh' ? '是否退出登录?' : 'Log out?',
  39. background: {
  40. backgroundImage: 'linear-gradient(270deg, #4BC0E2 0%, #538BE7 100%)',
  41. },
  42. backStyle: {
  43. color: '#FFFFFF',
  44. },
  45. };
  46. },
  47. onShow() {
  48. },
  49. onLoad() {
  50. try {
  51. this.Storage_data = JSON.parse(uni.getStorageSync('user'));
  52. this.AuthToken = uni.getStorageSync('Auth-Token');
  53. } catch (e) {
  54. };
  55. },
  56. methods: {
  57. showModal() {
  58. this.show = true;
  59. },
  60. confirm() {
  61. // setTimeout(() => {
  62. // 3秒后自动关闭
  63. this.show = false;
  64. // 如果不想关闭,而单是清除loading状态,需要通过ref手动调用方法
  65. // this.$refs.uModal.clearLoading();
  66. this.backLogin();
  67. // }, 3000)
  68. },
  69. cancel() {
  70. this.show = false;
  71. },
  72. backLogin() {
  73. try {
  74. uni.removeStorageSync('Auth-Token');
  75. uni.removeStorageSync('user');
  76. // uni.redirectTo({
  77. // url: '/pages/profile/profile'
  78. // });
  79. this.Storage_data = null;
  80. this.AuthToken = null;
  81. console.log(this.AuthToken, '========', uni.getStorageSync('Auth-Token'))
  82. uni.reLaunch({
  83. // url: '/pages/public/login'
  84. url: '/pages/index/index'
  85. });
  86. } catch (e) {
  87. };
  88. },
  89. i18n(data) {
  90. return this.$t('common.' + data);
  91. },
  92. navTo(route) {
  93. this.$mRouter.push({
  94. route
  95. });
  96. },
  97. }
  98. }
  99. </script>
  100. <style lang="scss" scoped>
  101. page {
  102. background-color: #fff;
  103. // height: 100%;
  104. }
  105. .border {
  106. background-color: #f3f4f6;
  107. height: 20upx;
  108. width: 100%;
  109. }
  110. .ref {
  111. position: relative;
  112. }
  113. .backLogin {
  114. // position: absolute;
  115. width: 90%;
  116. // top: 240upx;
  117. margin: 600upx 10upx 0upx 40upx;
  118. }
  119. </style>