myCenter.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <view class="profile">
  3. <view class="banner">
  4. <image src="/static/avatar.png" class="avatar"></image>
  5. <view class="user-info">
  6. <view>{{user.userName}}</view>
  7. <view>{{user.phone}}</view>
  8. </view>
  9. </view>
  10. <button type="primary" @click="logoutSubmit" class="submit-BT">退出登录</button>
  11. </view>
  12. </template>
  13. <script>
  14. import {logout} from '@/api/system/user.js'
  15. export default {
  16. data() {
  17. return {
  18. user:{
  19. userAvatar:"",
  20. userName:"",
  21. userIntro:"",
  22. userPhone:""
  23. },
  24. phone:""
  25. }
  26. },
  27. onLoad() {
  28. this.init()
  29. },
  30. methods: {
  31. init(){
  32. this.initUser()
  33. },
  34. initUser(){
  35. let userInfo=uni.getStorageSync('accountInfo')
  36. if(userInfo){this.user=userInfo}
  37. let phone=uni.getStorageSync('phone-info')
  38. if(phone){this.phone=phone}
  39. },
  40. logoutSubmit(){
  41. uni.clearStorageSync();
  42. logout().then(()=>{
  43. uni.navigateTo({
  44. url:'/pages/login/index'
  45. })
  46. })
  47. }
  48. }
  49. }
  50. </script>
  51. <style lang="scss" scoped>
  52. .profile{
  53. .banner{
  54. padding: 20rpx;
  55. .avatar{
  56. display: block;
  57. width: 100rpx;
  58. height: 100rpx;
  59. border-radius: 50%;
  60. }
  61. }
  62. .submit-BT {
  63. width: 600rpx;
  64. height: 72rpx;
  65. line-height: 72rpx;
  66. box-sizing: border-box;
  67. border-radius: 16upx;
  68. margin-top: 50upx;
  69. background-color:#3384FF;
  70. font-size: 32rpx;
  71. }
  72. }
  73. </style>