mine.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <view class="mine">
  3. <view class="top">
  4. <image :src="currentUser.avatar"></image>
  5. <view class="name">{{ currentUser.name }}</view>
  6. </view>
  7. <view class="bottom">
  8. <text>欢迎体验GoEasyIM</text>
  9. <view class="logout" @click="logout">注销</view>
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. const GoEasy = uni.$GoEasy;
  15. export default {
  16. data() {
  17. return {
  18. currentUser: null
  19. }
  20. },
  21. onShow() {
  22. this.currentUser = uni.$currentUser;
  23. },
  24. methods: {
  25. logout() {
  26. if(GoEasy.getConnectionStatus() === 'disconnected') {
  27. return
  28. }
  29. uni.showLoading({
  30. title: '注销中',
  31. mask: true,
  32. });
  33. GoEasy.disconnect({
  34. onSuccess: function () {
  35. uni.hideLoading();
  36. console.log('注销成功')
  37. uni.$currentUser = null;
  38. uni.removeStorageSync('currentUser');
  39. uni.navigateTo({
  40. url: './login'
  41. })
  42. },
  43. onFailed: function (error) {
  44. uni.hideLoading();
  45. uni.showToast({
  46. icon: 'none',
  47. title: '注销超时,请检查网络!(务必确保注销成功才允许客户退出应用,否则有可能会收到上个用户的消息。)',
  48. duration: 6000
  49. });
  50. console.log('注销失败', error);
  51. }
  52. });
  53. }
  54. }
  55. }
  56. </script>
  57. <style>
  58. .mine {
  59. width: 100%;
  60. height: 100%;
  61. display: flex;
  62. flex-direction: column;
  63. }
  64. .top {
  65. height: 400rpx;
  66. background: #F3F4F7;
  67. display: flex;
  68. flex-direction: column;
  69. justify-content: center;
  70. align-items: center;
  71. }
  72. .top image {
  73. width: 156rpx;
  74. height: 156rpx;
  75. border-radius: 156rpx;
  76. }
  77. .top .name {
  78. line-height: 80rpx;
  79. }
  80. .bottom {
  81. text-align: center;
  82. line-height: 200rpx;
  83. }
  84. .logout {
  85. width: 266rpx;
  86. height: 76rpx;
  87. line-height: 76rpx;
  88. margin: 0 auto;
  89. background-color: #d02129;
  90. border-radius: 10rpx;
  91. color: #FFFFFF;
  92. font-size: 34rpx;
  93. }
  94. </style>