index.uvue 5.8 KB

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