index.uvue 4.6 KB

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