myCenter.vue 1.4 KB

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