index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <view class="mine-page">
  3. <view class="topContent"></view>
  4. <view class="avatar-box">
  5. <u-avatar :src="userInfo.avatar?httpsImg + userInfo.avatar:require('@/static/head.png')" size="80"></u-avatar>
  6. </view>
  7. <view class="info-box">
  8. <view class="info-item">姓名:<view class="text">{{userInfo.userName}}</view>
  9. </view>
  10. <view class="info-item">手机号:<view class="text">{{userInfo.phonenumber}}</view>
  11. </view>
  12. <view class="info-item">邮箱:<view class="text">{{userInfo.email}}</view>
  13. </view>
  14. </view>
  15. <view class="btn-box">
  16. <u-button type="primary" text="退出登录" @click="logout"></u-button>
  17. </view>
  18. <uni-popup ref="alertDialog" type="dialog">
  19. <uni-popup-dialog :type="msgType" cancelText="取消" confirmText="确定" title="提示" content="确认退出吗?"
  20. @confirm="dialogConfirm"></uni-popup-dialog>
  21. </uni-popup>
  22. </view>
  23. </template>
  24. <script>
  25. import https from '@/https/index.js'
  26. export default {
  27. data() {
  28. return {
  29. msgType: 'warn',
  30. userInfo: {},
  31. httpsImg:'',
  32. }
  33. },
  34. onLoad() {
  35. this.httpsImg = https.url
  36. },
  37. onShow() {
  38. this.userProfilefun()
  39. },
  40. methods: {
  41. // 获取个人信息
  42. userProfilefun(){
  43. this.$api.userProfile().then(res=>{
  44. this.userInfo = res.data
  45. })
  46. },
  47. logout() {
  48. this.$refs.alertDialog.open()
  49. },
  50. dialogConfirm() {
  51. this.$api.logout().then(res => {
  52. uni.removeStorageSync('token');
  53. uni.showLoading({
  54. title: '正在退出...'
  55. });
  56. setTimeout(function() {
  57. uni.hideLoading();
  58. uni.reLaunch({
  59. url: '/pages/login/index'
  60. })
  61. }, 2000);
  62. }).catch(err => {})
  63. }
  64. },
  65. }
  66. </script>
  67. <style lang="scss" scoped>
  68. .mine-page {
  69. .topContent {
  70. height: 340rpx;
  71. background: url("@/static/mine.png");
  72. background-repeat: no-repeat;
  73. background-size: 100% 100%;
  74. }
  75. .avatar-box {
  76. display: flex;
  77. justify-content: center;
  78. margin-top: -100rpx;
  79. }
  80. .info-box {
  81. background-color: $uni-bg-color;
  82. border-radius: 24rpx;
  83. margin: 24rpx;
  84. padding: 12rpx 25rpx;
  85. color: #333;
  86. .info-item {
  87. display: flex;
  88. align-items: center;
  89. border-bottom: 1px solid #eee;
  90. padding: 20rpx 0;
  91. }
  92. .info-item:last-child {
  93. border-bottom: none;
  94. }
  95. .text {
  96. font-size: 26rpx;
  97. color: #000;
  98. }
  99. }
  100. .btn-box {
  101. margin: 24rpx;
  102. }
  103. }
  104. </style>