switch.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <view class="container">
  3. <!-- 背景图片区域 -->
  4. <img class="img_bg" src="../../static/images/center-bg.png" />
  5. <!-- 身份列表区域 -->
  6. <view class="list">
  7. <!-- 每一个身份区域 -->
  8. <view class="list_item" v-for="item in listData" :key="item.id" @click="handleChange(item)">
  9. <!-- 头像 -->
  10. <img
  11. class="item_img"
  12. mode="aspectFill"
  13. :src="item.headImage || 'https://wanzai-1306339220.cos.ap-shanghai.myqcloud.com/excelModel/nupp7VVnHWpVa413437dba82ce85374b2a4ee1a6b973.png'"
  14. />
  15. <!-- 姓名 -->
  16. <view class="item_name">{{ item.name }}</view>
  17. <!-- 身份类别 -->
  18. <view v-if="item.identityId === 1" class="item_type parents">家长</view>
  19. <view v-if="item.identityId === 2" class="item_type student">学生</view>
  20. <view v-if="item.identityId === 3" class="item_type teacher">老师</view>
  21. <view v-if="item.identityId === 14" class="item_type else">其他</view>
  22. <view v-if="item.identityId === 18" class="item_type teacher">年级主任</view>
  23. <view v-if="item.identityId === 19" class="item_type manage">超级管理员</view>
  24. <view v-if="item.identityId === 20" class="item_type teacher">班主任</view>
  25. <!-- 是否设置成默认身份 -->
  26. <!-- <view class="item_default" @click="handleClick(item)">
  27. <radio style="transform: scale(0.5)" :checked="item.isCheck"></radio>
  28. 设置默认身份
  29. </view> -->
  30. <!-- 是否选中 -->
  31. <!-- <uni-icons v-if="item.id === currentId" class="item_check" type="checkmarkempty" size="30" color="#00BAAD"></uni-icons> -->
  32. <div v-if="item.id === currentId" class="item_check">当前身份</div>
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <script setup>
  38. import { onLoad } from '@dcloudio/uni-app'
  39. import { ref } from 'vue'
  40. onLoad((options) => {
  41. let info = JSON.parse(decodeURIComponent(options.info))
  42. // console.log(info)
  43. uni.setStorageSync('token', info.token)
  44. currentId.value = uni.getStorageSync('userInfo').id || ''
  45. listData.value = info.user
  46. })
  47. // 用户身份列表
  48. const listData = ref([])
  49. // 当前展示身份id
  50. const currentId = ref()
  51. // 点击是否设置默认身份按钮回调
  52. // const handleClick = (item) => {
  53. // listData.value.forEach((ele) => {
  54. // ele.isCheck = false
  55. // })
  56. // item.isCheck = true
  57. // }
  58. // 点击每一个身份时的回调
  59. const handleChange = (item) => {
  60. // console.log(item)
  61. uni.setStorageSync('userhead', item.userhead)
  62. uni.setStorageSync('userInfo', item)
  63. uni.reLaunch({
  64. url: '/pages/home/home'
  65. })
  66. }
  67. </script>
  68. <style lang="scss" scoped>
  69. .container {
  70. min-height: 100vh;
  71. background-color: #f1f6fe;
  72. .img_bg {
  73. position: absolute;
  74. top: -70rpx;
  75. right: 0;
  76. width: 589rpx;
  77. height: 320rpx;
  78. pointer-events: none;
  79. }
  80. .list {
  81. z-index: 1;
  82. position: relative;
  83. padding: 58rpx 20rpx;
  84. .list_item {
  85. position: relative;
  86. display: flex;
  87. box-sizing: border-box;
  88. padding: 30rpx 22rpx;
  89. margin-bottom: 30rpx;
  90. width: 710rpx;
  91. height: 177rpx;
  92. border-radius: 8rpx;
  93. background-color: #fff;
  94. .item_img {
  95. width: 60rpx;
  96. height: 60rpx;
  97. border-radius: 50%;
  98. object-fit: cover;
  99. }
  100. .item_name {
  101. margin: 10rpx 16rpx 0 23rpx;
  102. height: 30rpx;
  103. font-size: 28rpx;
  104. }
  105. .item_type {
  106. margin-top: 15rpx;
  107. padding: 0 20rpx;
  108. height: 30rpx;
  109. font-size: 20rpx;
  110. color: #fff;
  111. border-radius: 28rpx;
  112. }
  113. .teacher {
  114. background-color: #00baad;
  115. }
  116. .parents {
  117. background-color: #0061ff;
  118. }
  119. .student {
  120. background-color: orange;
  121. }
  122. .else {
  123. background-color: #d43030;
  124. }
  125. .manage {
  126. background-color: #d43030;
  127. }
  128. .item_default {
  129. position: absolute;
  130. top: 118rpx;
  131. left: 22rpx;
  132. font-size: 16rpx;
  133. color: #a6a6a6;
  134. }
  135. .item_check {
  136. position: absolute;
  137. top: 50%;
  138. right: 48rpx;
  139. transform: translateY(-50%);
  140. color: #00baad;
  141. }
  142. }
  143. }
  144. }
  145. </style>