index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <view class="main">
  3. <view class="one">
  4. <view class="name">{{user.name||'暂无昵称'}}</view>
  5. <view class="account">账号:<text>{{user.account||'暂无账号'}}</text></view>
  6. </view>
  7. <view class="two">
  8. <view class="list" :class="[index==0?'color0':index==1?'color1':index==2?'color2':'color3']"
  9. v-for="(item, index) in list" :key="index" @tap='toInfo(item)'>
  10. {{item.name}}
  11. </view>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. data() {
  18. return {
  19. user: {},
  20. list: [{
  21. name: '基础研究平台',
  22. route: 'pagesBasic/home/index'
  23. },
  24. // {
  25. // name: '项目管理',
  26. // route: 'pagesProject/home/index'
  27. // },
  28. // {
  29. // name: '科学家工作室',
  30. // route: 'pagesStudio/home/index'
  31. // },
  32. {
  33. name: '退出登录',
  34. type: '0'
  35. }
  36. ]
  37. }
  38. },
  39. onShow: function(e) {
  40. const that = this;
  41. that.searchToken();
  42. },
  43. methods: {
  44. searchToken() {
  45. const that = this;
  46. try {
  47. const res = uni.getStorageSync('token');
  48. if (res) {
  49. const user = that.$jwt(res);
  50. that.$set(that, `user`, user);
  51. } else {
  52. uni.navigateTo({
  53. url: `/pages/login/index`
  54. })
  55. }
  56. } catch (e) {
  57. uni.showToast({
  58. title: err.errmsg,
  59. icon: 'error',
  60. duration: 2000
  61. });
  62. }
  63. },
  64. // 跳转
  65. toInfo(item) {
  66. const that = this;
  67. if (that.user && that.user._id) {
  68. if (item.type == '0') {
  69. uni.showModal({
  70. title: '提示',
  71. content: '确定退出登录吗?',
  72. success: async function(res) {
  73. if (res.confirm) {
  74. uni.removeStorage({
  75. key: 'token',
  76. success: function(res) {
  77. let url = `/pages/login/index`;
  78. uni.reLaunch({
  79. url
  80. })
  81. }
  82. });
  83. }
  84. }
  85. });
  86. } else {
  87. uni.navigateTo({
  88. url: `/${item.route}`
  89. })
  90. }
  91. } else {
  92. uni.navigateTo({
  93. url: `/pagesIndex/login/index`
  94. })
  95. }
  96. }
  97. }
  98. }
  99. </script>
  100. <style lang="scss" scoped>
  101. .main {
  102. margin: 0 2vw;
  103. .one {
  104. border: 2px solid var(--f07CColor);
  105. border-radius: 10px;
  106. margin: 2vw 0;
  107. padding: 5vw;
  108. .name {
  109. font-size: var(--font18Size);
  110. font-weight: bold;
  111. }
  112. .account {
  113. margin: 2vw 0 0 0;
  114. font-size: var(--font14Size);
  115. text {
  116. color: var(--f85Color);
  117. }
  118. }
  119. }
  120. .two {
  121. display: flex;
  122. justify-content: center;
  123. align-items: center;
  124. flex-wrap: wrap;
  125. .color0 {
  126. border: 2px solid var(--fF0Color);
  127. background: radial-gradient(circle at 7.2% 13.6%, rgb(255, 160, 122) 0%, rgb(255, 0, 0) 90%);
  128. }
  129. .color1 {
  130. border: 2px solid var(--f3CColor);
  131. background: radial-gradient(circle at 7.2% 13.6%, rgb(37, 249, 245) 0%, rgb(0, 122, 255) 90%);
  132. }
  133. .color2 {
  134. border: 2px solid var(--f08Color);
  135. background: radial-gradient(circle at 7.2% 13.6%, rgb(144, 238, 144) 0%, rgb(0, 128, 0) 90%);
  136. }
  137. .color3 {
  138. border: 2px solid var(--f07CColor);
  139. background: radial-gradient(circle at 7.2% 13.6%, rgb(175, 238, 238) 0%, rgb(7, 196, 175) 90%);
  140. }
  141. .list {
  142. display: flex;
  143. align-items: center;
  144. justify-content: center;
  145. width: 40vw;
  146. height: 40vw;
  147. border-radius: 30px;
  148. margin: 2vw 2.5vw 0 0;
  149. padding: 2vw;
  150. font-size: var(--font16Size);
  151. font-weight: bold;
  152. color: var(--mainColor);
  153. }
  154. .list:nth-child(2n) {
  155. margin: 2vw 0 0 0;
  156. }
  157. }
  158. }
  159. </style>