爱简收旧衣按件回收前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

336 lines
7.3 KiB

1 week ago
  1. <template>
  2. <view class="container">
  3. <!-- 顶部banner -->
  4. <view class="banner">
  5. <view class="banner-content">
  6. <text class="title">账号角色管理</text>
  7. <text class="subtitle">让管理更高效</text>
  8. </view>
  9. <image class="banner-image" src="/static/images/role-management.png" mode="aspectFit"></image>
  10. </view>
  11. <!-- 搜索栏 -->
  12. <view class="search-bar">
  13. <view class="tabs">
  14. <view class="tab active">员工</view>
  15. <view class="tab">用户</view>
  16. </view>
  17. <view class="search-input">
  18. <uni-icons type="search" size="20" color="#999"></uni-icons>
  19. <input type="text" placeholder="请输入要查询的内容" placeholder-class="placeholder" />
  20. </view>
  21. </view>
  22. <!-- 用户列表 -->
  23. <view class="user-list">
  24. <view class="user-item" v-for="(item, index) in userList" :key="index">
  25. <view class="user-info">
  26. <text class="user-id">ID: {{item.id}}</text>
  27. <view class="edit-btn" @tap="handleEdit(item)">
  28. <text>去编辑</text>
  29. <uni-icons type="right" size="14" color="#666"></uni-icons>
  30. </view>
  31. </view>
  32. <view class="user-detail">
  33. <image class="avatar" :src="item.avatar" mode="aspectFill"></image>
  34. <view class="detail-info">
  35. <view class="info-row">
  36. <text class="label">昵称</text>
  37. <text class="value">{{item.nickname}}</text>
  38. </view>
  39. <view class="info-row">
  40. <text class="label">密码</text>
  41. <text class="value">************</text>
  42. </view>
  43. <view class="info-row">
  44. <text class="label">角色</text>
  45. <view v-if="item.role" class="role-tag">{{item.role}}</view>
  46. <text v-else>-</text>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="delete-btn" @tap="handleDelete(item)">
  51. <uni-icons type="trash" size="20" color="#666"></uni-icons>
  52. <text>删除</text>
  53. </view>
  54. </view>
  55. </view>
  56. <uv-tabbar
  57. :value="value"
  58. :fixed="true"
  59. @change="changeTo"
  60. >
  61. <uv-tabbar-item text="首页" icon="home"></uv-tabbar-item>
  62. <uv-tabbar-item text="角色管理" icon="photo"></uv-tabbar-item>
  63. <uv-tabbar-item text="个人中心" icon="account"></uv-tabbar-item>
  64. </uv-tabbar>
  65. </view>
  66. </template>
  67. <script>
  68. // import tabBarMixin from '../mixins/tabBarMixin.js'
  69. export default {
  70. // mixins: [tabBarMixin],
  71. data() {
  72. return {
  73. value:1,
  74. userList: [
  75. {
  76. id: 'YG250428000001',
  77. nickname: '吴彦谋',
  78. avatar: '/static/images/avatar1.png',
  79. role: '推广官'
  80. },
  81. {
  82. id: 'YG250428000002',
  83. nickname: '冯思钧',
  84. avatar: '/static/images/avatar2.png',
  85. role: ''
  86. },
  87. {
  88. id: 'YG250428000003',
  89. nickname: '何炜',
  90. avatar: '/static/images/avatar3.png',
  91. role: ''
  92. },
  93. {
  94. id: 'YG250428000004',
  95. nickname: '郑文锦',
  96. avatar: '/static/images/avatar4.png',
  97. role: '推广官'
  98. }
  99. ]
  100. }
  101. },
  102. methods: {
  103. changeTo(e){
  104. this.value = e
  105. console.log(e,'111')
  106. if(e==0){
  107. uni.reLaunch({
  108. url: '/pages/component/admin_home'
  109. });
  110. }else if(e == 2){
  111. uni.reLaunch({
  112. url: '/pages/component/admin_my'
  113. });
  114. }
  115. },
  116. handleEdit(user) {
  117. if (this.userRole !== 'admin') {
  118. uni.showToast({
  119. title: '无权限操作',
  120. icon: 'none'
  121. })
  122. return
  123. }
  124. uni.navigateTo({
  125. url: `/pages/user-edit/user-edit?id=${user.id}`
  126. })
  127. },
  128. handleDelete(user) {
  129. if (this.userRole !== 'admin') {
  130. uni.showToast({
  131. title: '无权限操作',
  132. icon: 'none'
  133. })
  134. return
  135. }
  136. uni.showModal({
  137. title: '提示',
  138. content: '确定要删除该用户吗?',
  139. success: (res) => {
  140. if (res.confirm) {
  141. console.log('删除用户:', user.id)
  142. }
  143. }
  144. })
  145. }
  146. },
  147. // onShow() {
  148. // this.checkUserRole()
  149. // // 如果不是管理员,跳转到首页
  150. // if (this.userRole !== 'admin') {
  151. // uni.showToast({
  152. // title: '无权限访问',
  153. // icon: 'none'
  154. // })
  155. // uni.reLaunch({
  156. // url: '/pages/index/index'
  157. // })
  158. // }
  159. // }
  160. }
  161. </script>
  162. <style lang="scss" scoped>
  163. .container {
  164. min-height: 100vh;
  165. background: #f5f5f5;
  166. padding-bottom: 120rpx;
  167. }
  168. .banner {
  169. background: #2196F3;
  170. padding: 40rpx 30rpx;
  171. display: flex;
  172. justify-content: space-between;
  173. align-items: center;
  174. .banner-content {
  175. .title {
  176. font-size: 40rpx;
  177. color: #fff;
  178. font-weight: bold;
  179. margin-bottom: 10rpx;
  180. display: block;
  181. }
  182. .subtitle {
  183. font-size: 28rpx;
  184. color: rgba(255,255,255,0.8);
  185. }
  186. }
  187. .banner-image {
  188. width: 200rpx;
  189. height: 120rpx;
  190. }
  191. }
  192. .search-bar {
  193. background: #fff;
  194. padding: 20rpx 30rpx;
  195. .tabs {
  196. display: flex;
  197. margin-bottom: 20rpx;
  198. .tab {
  199. padding: 10rpx 30rpx;
  200. font-size: 28rpx;
  201. color: #666;
  202. position: relative;
  203. &.active {
  204. color: #333;
  205. font-weight: 500;
  206. &::after {
  207. content: '';
  208. position: absolute;
  209. left: 30rpx;
  210. right: 30rpx;
  211. bottom: -4rpx;
  212. height: 4rpx;
  213. background: #00C853;
  214. border-radius: 2rpx;
  215. }
  216. }
  217. }
  218. }
  219. .search-input {
  220. display: flex;
  221. align-items: center;
  222. background: #f5f5f5;
  223. border-radius: 35rpx;
  224. padding: 15rpx 30rpx;
  225. input {
  226. flex: 1;
  227. font-size: 28rpx;
  228. margin-left: 20rpx;
  229. }
  230. }
  231. }
  232. .user-list {
  233. padding: 20rpx;
  234. .user-item {
  235. background: #fff;
  236. border-radius: 20rpx;
  237. padding: 30rpx;
  238. margin-bottom: 20rpx;
  239. .user-info {
  240. display: flex;
  241. justify-content: space-between;
  242. align-items: center;
  243. margin-bottom: 20rpx;
  244. .user-id {
  245. font-size: 28rpx;
  246. color: #333;
  247. }
  248. .edit-btn {
  249. display: flex;
  250. align-items: center;
  251. color: #666;
  252. font-size: 28rpx;
  253. }
  254. }
  255. .user-detail {
  256. display: flex;
  257. margin-bottom: 20rpx;
  258. .avatar {
  259. width: 100rpx;
  260. height: 100rpx;
  261. border-radius: 50%;
  262. margin-right: 20rpx;
  263. }
  264. .detail-info {
  265. flex: 1;
  266. .info-row {
  267. display: flex;
  268. align-items: center;
  269. margin-bottom: 10rpx;
  270. .label {
  271. font-size: 28rpx;
  272. color: #666;
  273. width: 100rpx;
  274. }
  275. .value {
  276. font-size: 28rpx;
  277. color: #333;
  278. }
  279. .role-tag {
  280. background: #fff5e6;
  281. color: #ff9800;
  282. font-size: 24rpx;
  283. padding: 4rpx 16rpx;
  284. border-radius: 20rpx;
  285. }
  286. }
  287. }
  288. }
  289. .delete-btn {
  290. display: flex;
  291. align-items: center;
  292. justify-content: center;
  293. gap: 10rpx;
  294. color: #666;
  295. font-size: 28rpx;
  296. padding-top: 20rpx;
  297. border-top: 1px solid #f5f5f5;
  298. }
  299. }
  300. }
  301. .placeholder {
  302. color: #999;
  303. font-size: 28rpx;
  304. }
  305. </style>