index.uvue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <template>
  2. <!-- #ifdef APP -->
  3. <scroll-view style="flex:1">
  4. <!-- #endif -->
  5. <view class="my-page">
  6. <!-- 轮播图 -->
  7. <swiper class="swiper-box my-swiper" :current="swiperDotIndex" :indicator-dots="true"
  8. @change="changeSwiper">
  9. <swiper-item v-for="item in data">
  10. <view class="swiper-item" @click="clickBannerItem(item)">
  11. <image class="my-image" :src="item.image" mode="aspectFill" />
  12. </view>
  13. </swiper-item>
  14. </swiper>
  15. <!-- 标题栏 -->
  16. <view class=" uni-section">
  17. <view class=" uni-section-header">
  18. <view class=" uni-section-header__decoration line" />
  19. <view class=" uni-section-header__content">
  20. <text style="font-size:18px;color:#333" class="distraction">工作台</text>
  21. </view>
  22. <view class="name-label">
  23. <text>您好:{{currentName}}</text>
  24. </view>
  25. <view class="name-label">
  26. <text class="logout-text" @click="logout">[退出登录]</text>
  27. </view>
  28. </view>
  29. </view>
  30. <!-- 宫格 -->
  31. <view class="grid-body">
  32. <view class="grid uni-row">
  33. <view class="grid-item" v-for="(item: Item, index: number) in items" :key="index"
  34. @click="enterItem(item)">
  35. <!-- 您的网格项内容 -->
  36. <uni-icons class="my-icon" :type="item.iconType" size="40" :color="item.colorClass"></uni-icons>
  37. <text class="text">{{ item.text }}</text>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. <!-- #ifdef APP -->
  43. </scroll-view>
  44. <!-- #endif -->
  45. </template>
  46. <script lang="uts">
  47. import { state } from '@/store';
  48. import { getCurrentUserSync } from '@/utils/auth.uts'
  49. import { logout } from '@/api/login';
  50. type ImageItem = {
  51. image : string
  52. }
  53. type Item = {
  54. colorClass : string,
  55. iconType : string,
  56. path : string,
  57. text : string
  58. }
  59. export default {
  60. data() {
  61. let basic = [
  62. { colorClass: 'blue', iconType: "person-filled", text: "用户管理", path: "/pages/mine/index" },
  63. // {colorClass: 'blue', iconType: "list", text: "任务管理",path:"/pages/work/task/TaskList" },
  64. { colorClass: 'orange', iconType: "camera", text: "声像记录", path: "/pages/work/record/InfoList" },
  65. { colorClass: 'orange', iconType: "list", text: "检验任务", path: "/pages/work/download/DownloadList" },
  66. // {colorClass: 'orange', iconType: "calendar", text: "检验记录",path:"/pages/work/report/InspectionList" },
  67. // {colorClass: 'orange', iconType: "gear-filled", text: "关键工序",path:"/pages/work/process/ProcessList" },
  68. // {colorClass: 'green', iconType: "folder-add-filled", text: "文档查阅",path:"" },
  69. // {colorClass: 'green', iconType: "cloud-upload", text: "数据上传",path:"" },
  70. //{colorClass: 'green', iconType: "wallet-filled", text: "日志管理",path:"/pages/work/log/logList" }
  71. ] as Item[];
  72. let isAdmin = state.roles.includes('admin') ? true : false;
  73. let adminItem = { colorClass: 'green', iconType: "wallet-filled", text: "日志管理", path: "/pages/work/log/logList" } as Item;
  74. let items = isAdmin ? basic.concat(adminItem) : basic;
  75. return {
  76. items: items as Item[],
  77. current: 0 as number,
  78. swiperDotIndex: 0 as number,
  79. data: [{
  80. image: '/static/images/banner/banner01.png'
  81. },
  82. ] as ImageItem[],
  83. currentName: getCurrentUserSync(),
  84. }
  85. },
  86. methods: {
  87. clickBannerItem(item : ImageItem) {
  88. console.info(item)
  89. },
  90. changeSwiper(e : UniSwiperChangeEvent) {
  91. this.current = e.detail.current
  92. },
  93. enterItem(e : Item) {
  94. if (e.path != null && e.path != "") {
  95. uni.navigateTo({
  96. url: e.path as string
  97. });
  98. } else {
  99. uni.showToast({
  100. title: '模块建设中~',
  101. icon: 'none'
  102. });
  103. }
  104. },
  105. logout() {
  106. console.log("退出")
  107. logout();
  108. uni.showToast({
  109. title: '退出成功',
  110. icon: 'success',
  111. mask: true
  112. });
  113. // 延迟1500毫秒后再跳转到登录页面,确保用户能看到完整的提示信息
  114. setTimeout(() => {
  115. uni.navigateTo({
  116. url: '/pages/login'
  117. });
  118. }, 1500);
  119. }
  120. }
  121. }
  122. </script>
  123. <style lang="scss">
  124. /* #ifndef APP-NVUE */
  125. .my-page {
  126. display: flex;
  127. flex-direction: column;
  128. box-sizing: border-box;
  129. background-color: #fff;
  130. /* #ifndef APP-ANDROID */
  131. min-height: 100%;
  132. /* #endif */
  133. height: 100%;
  134. }
  135. /* #ifndef APP-ANDROID */
  136. view {
  137. font-size: 14px;
  138. line-height: inherit;
  139. }
  140. /* #endif */
  141. /* #endif */
  142. .text {
  143. text-align: center;
  144. font-size: 26rpx;
  145. margin-top: 10rpx;
  146. }
  147. .swiper {
  148. height: 300rpx;
  149. }
  150. .swiper-box {
  151. height: 150px;
  152. }
  153. .swiper-item {
  154. /* #ifndef APP-NVUE */
  155. display: flex;
  156. /* #endif */
  157. flex-direction: column;
  158. justify-content: center;
  159. align-items: center;
  160. color: #fff;
  161. height: 300rpx;
  162. line-height: 300rpx;
  163. }
  164. @media screen and (min-width: 500px) {
  165. .my-image {
  166. width: 100%;
  167. }
  168. }
  169. .grid-body {
  170. /* #ifndef APP-NVUE */
  171. display: flex;
  172. /* #endif */
  173. flex-wrap: wrap;
  174. justify-content: space-between;
  175. margin-top: 40rpx;
  176. }
  177. .grid-item {
  178. width: 32%;
  179. padding: 18px 15px;
  180. margin-bottom: 40rpx;
  181. border-radius: 20rpx;
  182. box-shadow: 0 8rpx 20rpx rgba(24, 144, 255, 0.15);
  183. display: flex;
  184. flex-direction: column;
  185. .my-icon {
  186. text-align: center;
  187. border-radius: 20rpx;
  188. }
  189. }
  190. .purple {
  191. color: #6366f1;
  192. }
  193. .blue {
  194. color: #2563eb;
  195. }
  196. .orange {
  197. color: #d97706;
  198. }
  199. .green {
  200. color: #059669;
  201. }
  202. .yellow {
  203. color: yellow;
  204. }
  205. $uni-primary: #2979ff !default;
  206. .uni-section {
  207. background-color: #fff;
  208. .uni-section-header {
  209. position: relative;
  210. /* #ifndef APP-NVUE */
  211. display: flex;
  212. /* #endif */
  213. flex-direction: row;
  214. align-items: center;
  215. padding: 12px 10px;
  216. font-weight: normal;
  217. &__decoration {
  218. margin-right: 6px;
  219. background-color: $uni-primary;
  220. &.line {
  221. width: 4px;
  222. height: 12px;
  223. border-radius: 10px;
  224. }
  225. &.circle {
  226. width: 8px;
  227. height: 8px;
  228. border-top-right-radius: 50px;
  229. border-top-left-radius: 50px;
  230. border-bottom-left-radius: 50px;
  231. border-bottom-right-radius: 50px;
  232. }
  233. &.square {
  234. width: 8px;
  235. height: 8px;
  236. }
  237. }
  238. &__content {
  239. /* #ifndef APP-NVUE */
  240. display: flex;
  241. /* #endif */
  242. flex-direction: column;
  243. flex: 1;
  244. color: #333;
  245. .distraction {
  246. flex-direction: row;
  247. align-items: center;
  248. }
  249. &-sub {
  250. margin-top: 2px;
  251. }
  252. }
  253. }
  254. }
  255. .name-label {
  256. margin-right: 20rpx;
  257. margin-left: auto;
  258. }
  259. .logout-text {
  260. color: #2563eb;
  261. }
  262. </style>