index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <view class="content">
  3. <view class="one">
  4. <view class="left">
  5. <u-avatar text="车" fontSize="20" randomBgColor :colorIndex="0"></u-avatar>
  6. </view>
  7. <view class="right" @tap="toLogin">
  8. <text>点击登录</text>
  9. <u-icon :bold="true" color="#000" name="arrow-right" size="16"></u-icon>
  10. </view>
  11. </view>
  12. <view class="two">
  13. <view class="list" v-for="(item, index) in $config.menuList" :key="index" @click="toCommon(item.route)">
  14. <view class="left">
  15. <view class="icon">
  16. <u-icon :name="item.icon" size="22"></u-icon>
  17. </view>
  18. <text class="title">{{item.title||'暂无'}}</text>
  19. </view>
  20. <view class="right">
  21. <u-icon name="arrow-right" size="20"></u-icon>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script setup lang="ts">
  28. import { getCurrentInstance, ref } from 'vue';
  29. //该依赖已内置不需要单独安装
  30. import { onLoad } from "@dcloudio/uni-app";
  31. // 请求接口
  32. const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
  33. const $config = getCurrentInstance()?.appContext.config.globalProperties.$config;
  34. // 基本信息
  35. const config = ref({});
  36. // 用户信息
  37. const user = ref({});
  38. onLoad(async () => {
  39. await searchConfig();
  40. await search();
  41. })
  42. // config信息
  43. const searchConfig = async () => {
  44. config.value = uni.getStorageSync('config');
  45. };
  46. // 查询
  47. const search = async () => {
  48. };
  49. // 登录
  50. const toLogin = () => {
  51. uni.navigateTo({
  52. url: `/pagesHome/login/index`
  53. })
  54. };
  55. // 公共跳转
  56. const toCommon = (e) => {
  57. // if (user.value && user.value._id) {
  58. if (e) {
  59. uni.navigateTo({
  60. url: `/${e}`
  61. })
  62. } else {
  63. try {
  64. uni.clearStorage();
  65. uni.reLaunch({
  66. url: '/pages/index/index'
  67. })
  68. } catch (e) { }
  69. }
  70. // } else {
  71. // uni.navigateTo({
  72. // url: `/pagesHome/login/index`
  73. // })
  74. // }
  75. };
  76. </script>
  77. <style lang="scss" scoped>
  78. .content {
  79. display: flex;
  80. flex-direction: column;
  81. width: 100vw;
  82. height: 100vh;
  83. .one {
  84. display: flex;
  85. align-items: center;
  86. padding: 0 8vw;
  87. height: 25vh;
  88. background: linear-gradient(to bottom, #2979ff, #ffffff);
  89. .left {
  90. .image {
  91. width: 50px;
  92. height: 50px;
  93. border-radius: 50px;
  94. }
  95. }
  96. .right {
  97. display: flex;
  98. align-items: center;
  99. margin: 0 0 0 3vw;
  100. font-size: var(--font16Size);
  101. font-weight: bold;
  102. }
  103. }
  104. .two {
  105. display: flex;
  106. flex-direction: column;
  107. padding: 2vw;
  108. margin: 2vw;
  109. border-radius: 10px;
  110. background-color: var(--mainColor);
  111. .list {
  112. display: flex;
  113. justify-content: space-between;
  114. padding: 4vw;
  115. border-bottom: 1px solid var(--f9Color);
  116. .left {
  117. display: flex;
  118. align-items: center;
  119. .icon {
  120. padding: 0 1vw 0 0;
  121. }
  122. .title {
  123. display: inline-block;
  124. font-size: var(--font14Size);
  125. }
  126. }
  127. .right {
  128. font-size: var(--font12Size);
  129. color: var(--f99Color);
  130. }
  131. }
  132. }
  133. }
  134. </style>