index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <view class="main">
  3. <view class="one">
  4. <view class="list" :class="[index==0?'color0':index==1?'color1':index==2?'color2':'color3']"
  5. v-for="(item, index) in list" :key="index" @tap='toInfo(item)'>
  6. <text>{{item.name}}</text>
  7. <uni-icons type="right" color="#ffffff" size="20"></uni-icons>
  8. </view>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. export default {
  14. data() {
  15. return {
  16. user: {},
  17. list: [{
  18. name: '实验室信息列表',
  19. route: 'pagesBasic/basic/index'
  20. },
  21. {
  22. name: '政策文件',
  23. route: 'pagesBasic/policyfile/index'
  24. }
  25. ]
  26. }
  27. },
  28. onShow: function(e) {
  29. const that = this;
  30. that.searchToken();
  31. },
  32. methods: {
  33. searchToken() {
  34. const that = this;
  35. try {
  36. const res = uni.getStorageSync('token');
  37. if (res) {
  38. const user = that.$jwt(res);
  39. that.$set(that, `user`, user);
  40. } else {
  41. uni.navigateTo({
  42. url: `/pages/login/index`
  43. })
  44. }
  45. } catch (e) {
  46. uni.showToast({
  47. title: err.errmsg,
  48. icon: 'error',
  49. duration: 2000
  50. });
  51. }
  52. },
  53. // 跳转
  54. toInfo(item) {
  55. const that = this;
  56. if (that.user && that.user._id) {
  57. if (item.type == '0') {
  58. uni.showModal({
  59. title: '提示',
  60. content: '确定退出登录吗?',
  61. success: async function(res) {
  62. if (res.confirm) {
  63. uni.removeStorage({
  64. key: 'token',
  65. success: function(res) {
  66. let url = `/pages/login/index`;
  67. uni.reLaunch({
  68. url
  69. })
  70. }
  71. });
  72. }
  73. }
  74. });
  75. } else {
  76. uni.navigateTo({
  77. url: `/${item.route}`
  78. })
  79. }
  80. } else {
  81. uni.navigateTo({
  82. url: `/pagesIndex/login/index`
  83. })
  84. }
  85. }
  86. }
  87. }
  88. </script>
  89. <style lang="scss" scoped>
  90. .main {
  91. .one {
  92. .color0 {
  93. border: 2px solid var(--fF0Color);
  94. background: radial-gradient(circle at 7.2% 13.6%, rgb(255, 160, 122) 0%, rgb(255, 0, 0) 90%);
  95. }
  96. .color1 {
  97. border: 2px solid var(--f3CColor);
  98. background: radial-gradient(circle at 7.2% 13.6%, rgb(37, 249, 245) 0%, rgb(0, 122, 255) 90%);
  99. }
  100. .color2 {
  101. border: 2px solid var(--f08Color);
  102. background: radial-gradient(circle at 7.2% 13.6%, rgb(144, 238, 144) 0%, rgb(0, 128, 0) 90%);
  103. }
  104. .color3 {
  105. border: 2px solid var(--f07CColor);
  106. background: radial-gradient(circle at 7.2% 13.6%, rgb(175, 238, 238) 0%, rgb(7, 196, 175) 90%);
  107. }
  108. .list {
  109. display: flex;
  110. align-items: center;
  111. justify-content: space-between;
  112. border-radius: 10px;
  113. margin: 2vw;
  114. padding: 4vw;
  115. font-size: var(--font16Size);
  116. font-weight: bold;
  117. color: var(--mainColor);
  118. }
  119. }
  120. }
  121. </style>