index.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <view class="content">
  3. <view class="banner">
  4. <view class="avatar">
  5. <image :src="userAvatar" mode="widthFix" @error="userAvatar=defaultAvatar"></image>
  6. </view>
  7. <view class="bottom">
  8. <view class="name">
  9. <text>{{userName}}</text>
  10. </view>
  11. </view>
  12. </view>
  13. <view class="zhcx-table">
  14. <uni-list>
  15. <uni-list-item title="个人资料"
  16. link="navigateTo" to="/pages/myCenter/personalData/personalData"
  17. showArrow></uni-list-item>
  18. <uni-list-item title="修改密码"
  19. link="navigateTo" to="/pages/myCenter/updatePassword/updatePassword"
  20. showArrow></uni-list-item>
  21. <uni-list-item title="退出登录" @click="logout" clickable></uni-list-item>
  22. </uni-list>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. export default{
  28. data(){
  29. return{
  30. defaultAvatar:"/static/components/avatar.png",
  31. userAvatar:"",
  32. userName:""
  33. }
  34. },
  35. onShow() {
  36. this.init();
  37. },
  38. methods:{
  39. init(){
  40. let user=uni.getStorageSync('accountInfo');
  41. if(user){user=JSON.parse(user)}
  42. this.userAvatar=user.avatar||this.defaultAvatar;
  43. this.userName=user.name;
  44. },
  45. logout(){
  46. uni.showModal({
  47. title:'提示!',
  48. content:"是否要退出登录",
  49. success(res) {
  50. if (res.confirm) {
  51. uni.reLaunch({
  52. url:'/pages/login/index'
  53. })
  54. }
  55. }
  56. })
  57. }
  58. }
  59. }
  60. </script>
  61. <style lang="scss" scoped>
  62. .content{
  63. .banner{
  64. height: 327upx;
  65. background-color: var(--sysblue);
  66. padding-top:46upx;
  67. .avatar{
  68. width: 150upx;
  69. height: 150upx;
  70. border-radius: 50%;
  71. overflow: hidden;
  72. image{
  73. display: block;
  74. width: 150upx;
  75. height: 150upx;
  76. border-radius: 50%;
  77. }
  78. margin:0 auto;
  79. }
  80. .bottom{
  81. position: relative;
  82. .name{
  83. font-size: 40upx;
  84. text-align: center;
  85. color: #fff;
  86. padding-top: 15upx;
  87. }
  88. .edit{
  89. position: absolute;
  90. right:48upx;
  91. bottom: 0;
  92. .zhcx-iconfont{
  93. font-size: 50upx;
  94. color: #fff;
  95. }
  96. }
  97. }
  98. }
  99. }
  100. </style>