homeList.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <view class="page">
  3. <view class="header">
  4. <view class="user">
  5. <image class="avatar" :src="headLogo || '../../static/head.png'" />
  6. <text> {{displayName}} </text>
  7. </view>
  8. </view>
  9. <view class="menu">
  10. <view class="item" @click="handleMenuClick">
  11. <img src="/static/appstore-add.png"></img>
  12. <view>编辑中心</view>
  13. </view>
  14. <view class="item" @click="dialogToggle('success')">
  15. <img src="/static/poweroff.png"></img>
  16. <view>退出登录</view>
  17. </view>
  18. <uni-popup ref="alertDialog" type="dialog">
  19. <uni-popup-dialog :type="msgType" cancelText="否" confirmText="是" title="提示" content="是否退出登录"
  20. @confirm="dialogConfirm" @close="dialogClose"></uni-popup-dialog>
  21. </uni-popup>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. data() {
  28. return {
  29. headLogo: '',
  30. nameList: ''
  31. }
  32. },
  33. created() {
  34. // this.wechatId = uni.getStorageSync('wechatId');
  35. this.headLogo = uni.getStorageSync('headLogo');
  36. // this.nameList = uni.getStorageSync('nameList');
  37. this.getData()
  38. },
  39. computed: {
  40. displayName: function() {
  41. if (this.nameList) {
  42. return this.nameList;
  43. } else {
  44. return '编号00001';
  45. }
  46. }
  47. },
  48. onLoad() {
  49. },
  50. methods: {
  51. onPullDownRefresh() {
  52. this.getData();
  53. setTimeout(function() {
  54. uni.stopPullDownRefresh(); //停止下拉刷新动画
  55. }, 1000);
  56. },
  57. getData() {
  58. this.$http('homePage.information', {}, '加载中').then((res) => {
  59. this.nameList = res.data.userName;
  60. })
  61. },
  62. //退出登录
  63. dialogToggle(type) {
  64. this.msgType = type
  65. this.$refs.alertDialog.open()
  66. },
  67. dialogConfirm() {
  68. uni.removeStorageSync('token'); // 清除缓存中的 token
  69. uni.removeStorageSync('headLogo');
  70. uni.removeStorageSync('wechatId');
  71. uni.removeStorageSync('nameList');
  72. uni.reLaunch({
  73. url: '/pages/login/index',
  74. success: () => {
  75. setTimeout(() => {
  76. this.$refs.alertDialog.open();
  77. }, 1000);
  78. }
  79. });
  80. },
  81. dialogClose() {
  82. console.log('点击关闭')
  83. },
  84. handleMenuClick() {
  85. uni.navigateTo({
  86. url: '/pages/home/home'
  87. });
  88. }
  89. }
  90. }
  91. </script>
  92. <style lang="scss">
  93. .page {
  94. background: #f5f5f5;
  95. min-height: 100vh;
  96. .header {
  97. background: #90ffe4;
  98. height: 300rpx;
  99. .user {
  100. display: flex;
  101. flex-direction: column;
  102. align-items: center;
  103. image {
  104. width: 150rpx;
  105. height: 150rpx;
  106. border-radius: 50%;
  107. margin: 10rpx;
  108. background: #ccc;
  109. }
  110. text {
  111. color: #000;
  112. font-size: 25rpx;
  113. margin-top: 15rpx;
  114. }
  115. }
  116. }
  117. .menu {
  118. background: #fff;
  119. .item {
  120. border-bottom: 1px solid #f0f0f0;
  121. display: flex;
  122. height: 80rpx;
  123. align-items: center;
  124. padding: 0 20rpx;
  125. box-sizing: border-box;
  126. width: 750rpx;
  127. &:active {
  128. background: #f0f0f0;
  129. }
  130. image {
  131. height: 40rpx;
  132. width: 40rpx;
  133. }
  134. view {
  135. font-size: 14px;
  136. color: #444;
  137. padding-left: 10rpx;
  138. box-sizing: border-box;
  139. width: calc(100% - 70rpx);
  140. }
  141. .arrow {
  142. width: 30rpx;
  143. height: 36rpx;
  144. }
  145. }
  146. }
  147. }
  148. </style>