homeList.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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.removeStorageSync('fromHome');
  73. uni.reLaunch({
  74. url: '/subpkg/pages/login/index',
  75. success: () => {
  76. setTimeout(() => {
  77. this.$refs.alertDialog.open();
  78. }, 1000);
  79. }
  80. });
  81. },
  82. dialogClose() {
  83. console.log('点击关闭')
  84. },
  85. handleMenuClick() {
  86. // uni.navigateTo({
  87. // url: '/pages/home/home'
  88. // });
  89. }
  90. }
  91. }
  92. </script>
  93. <style lang="scss">
  94. .page {
  95. background: #f5f5f5;
  96. min-height: 100vh;
  97. .header {
  98. background: #90ffe4;
  99. height: 300rpx;
  100. .user {
  101. display: flex;
  102. flex-direction: column;
  103. align-items: center;
  104. image {
  105. width: 150rpx;
  106. height: 150rpx;
  107. border-radius: 50%;
  108. margin: 10rpx;
  109. background: #ccc;
  110. }
  111. text {
  112. color: #000;
  113. font-size: 25rpx;
  114. margin-top: 15rpx;
  115. }
  116. }
  117. }
  118. .menu {
  119. background: #fff;
  120. .item {
  121. border-bottom: 1px solid #f0f0f0;
  122. display: flex;
  123. height: 80rpx;
  124. align-items: center;
  125. padding: 0 20rpx;
  126. box-sizing: border-box;
  127. width: 750rpx;
  128. &:active {
  129. background: #f0f0f0;
  130. }
  131. image {
  132. height: 40rpx;
  133. width: 40rpx;
  134. }
  135. view {
  136. font-size: 14px;
  137. color: #444;
  138. padding-left: 10rpx;
  139. box-sizing: border-box;
  140. width: calc(100% - 70rpx);
  141. }
  142. .arrow {
  143. width: 30rpx;
  144. height: 36rpx;
  145. }
  146. }
  147. }
  148. }
  149. </style>