index.uvue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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. import { getCurrentUserSync } from '@/utils/auth.uts'
  33. type ImageItem={
  34. image:string
  35. }
  36. type Item={
  37. colorClass:string,
  38. iconType:string,
  39. path:string,
  40. text:string
  41. }
  42. export default {
  43. data() {
  44. let basic = [
  45. ,{colorClass: 'green', iconType: "wallet-filled", text: "修改用户信息",path:"/pages/mine/pwd/index" }
  46. ] as Item[];
  47. let isAdmin = state.roles.includes('admin') ? true : false;
  48. let adminItem = [ {colorClass: 'blue', iconType: "personadd-filled", text: "注册用户",path:"/pages/register" },
  49. {colorClass: 'blue', iconType: "staff-filled", text: "用户列表",path:"/pages/mine/person/PersonList" }] as Item [];
  50. let items = isAdmin ? basic.concat(adminItem) : basic;
  51. return {
  52. items: items as Item[],
  53. currentName: getCurrentUserSync(),
  54. }
  55. },
  56. onBackPress() {
  57. // 覆盖系统默认的返回行为,返回到指定页面
  58. uni.reLaunch({
  59. url: `/pages/work/index`,
  60. })
  61. // 返回true表示拦截默认返回行为
  62. return true
  63. },
  64. methods: {
  65. enterItem(e:Item) {
  66. if (e.path != null && e.path != "") {
  67. uni.navigateTo({
  68. url: e.path as string
  69. });
  70. } else {
  71. uni.showToast({
  72. title: '模块建设中~',
  73. icon: 'none'
  74. });
  75. }
  76. }
  77. }
  78. }
  79. </script>
  80. <style lang="scss" scope>
  81. /* #ifndef APP-NVUE */
  82. .my-page {
  83. display: flex;
  84. flex-direction: column;
  85. box-sizing: border-box;
  86. background-color: #fff;
  87. /* #ifndef APP-ANDROID */
  88. min-height: 100%;
  89. /* #endif */
  90. height: 100%;
  91. }
  92. /* #ifndef APP-ANDROID */
  93. view {
  94. font-size: 14px;
  95. line-height: inherit;
  96. }
  97. /* #endif */
  98. /* #endif */
  99. .text {
  100. text-align: center;
  101. font-size: 26rpx;
  102. margin-top: 10rpx;
  103. }
  104. .swiper {
  105. height: 300rpx;
  106. }
  107. .swiper-box {
  108. height: 150px;
  109. }
  110. .swiper-item {
  111. /* #ifndef APP-NVUE */
  112. display: flex;
  113. /* #endif */
  114. flex-direction: column;
  115. justify-content: center;
  116. align-items: center;
  117. color: #fff;
  118. height: 300rpx;
  119. line-height: 300rpx;
  120. }
  121. @media screen and (min-width: 500px) {
  122. .my-image {
  123. width: 100%;
  124. }
  125. }
  126. .grid-body {
  127. /* #ifndef APP-NVUE */
  128. display: flex;
  129. /* #endif */
  130. flex-wrap: wrap;
  131. justify-content: space-between;
  132. margin-top: 40rpx;
  133. }
  134. .grid-item {
  135. width: 32%;
  136. padding: 18px 15px;
  137. margin-bottom: 40rpx;
  138. border-radius: 20rpx;
  139. box-shadow: 0 8rpx 20rpx rgba(24, 144, 255, 0.15);
  140. display: flex;
  141. flex-direction: column;
  142. .my-icon{
  143. text-align: center;
  144. border-radius: 20rpx;
  145. }
  146. }
  147. .purple {color:#6366f1;}
  148. .blue {color:#2563eb; }
  149. .orange {color:#d97706;}
  150. .green {color:#059669;}
  151. .yellow {color:yellow;}
  152. $uni-primary: #2979ff !default;
  153. .uni-section {
  154. background-color: #fff;
  155. .uni-section-header {
  156. position: relative;
  157. /* #ifndef APP-NVUE */
  158. display: flex;
  159. /* #endif */
  160. flex-direction: row;
  161. align-items: center;
  162. padding: 12px 10px;
  163. font-weight: normal;
  164. &__decoration{
  165. margin-right: 6px;
  166. background-color: $uni-primary;
  167. &.line {
  168. width: 4px;
  169. height: 12px;
  170. border-radius: 10px;
  171. }
  172. &.circle {
  173. width: 8px;
  174. height: 8px;
  175. border-top-right-radius: 50px;
  176. border-top-left-radius: 50px;
  177. border-bottom-left-radius: 50px;
  178. border-bottom-right-radius: 50px;
  179. }
  180. &.square {
  181. width: 8px;
  182. height: 8px;
  183. }
  184. }
  185. &__content {
  186. /* #ifndef APP-NVUE */
  187. display: flex;
  188. /* #endif */
  189. flex-direction: column;
  190. flex: 1;
  191. color: #333;
  192. .distraction {
  193. flex-direction: row;
  194. align-items: center;
  195. }
  196. &-sub {
  197. margin-top: 2px;
  198. }
  199. }
  200. }
  201. }
  202. .name-label {
  203. margin-right: 20rpx;
  204. margin-left: auto;
  205. }
  206. </style>