鸿宇研学生前端代码
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.

127 lines
2.4 KiB

  1. <template>
  2. <view class="flex card">
  3. <view>
  4. <uv-checkbox-group
  5. v-model="selectCheckboxValue"
  6. @change="onSelectChange"
  7. >
  8. <uv-checkbox
  9. size="36rpx"
  10. icon-size="36rpx"
  11. activeColor="#00A9FF"
  12. :name="1"
  13. ></uv-checkbox>
  14. </uv-checkbox-group>
  15. </view>
  16. <view class="info">
  17. <view class="flex name">
  18. <view>{{ data.name }}</view>
  19. <view :class="['tag', `tag-${data.type}`]">{{ typeDesc }}</view>
  20. </view>
  21. <view class="id">{{ data.idNo }}</view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. const MEMBER_TYPE_AND_DESC_MAPPING = {
  27. 0: '成人',
  28. 1: '青少年',
  29. 2: '儿童',
  30. }
  31. export default {
  32. props: {
  33. data: {
  34. type: Object,
  35. default() {
  36. return {}
  37. }
  38. },
  39. },
  40. data() {
  41. return {
  42. selectCheckboxValue: [],
  43. }
  44. },
  45. computed: {
  46. isSelected: {
  47. set(val) {
  48. this.selectCheckboxValue = val ? [1]: []
  49. if (this.data.isSelected == val) {
  50. return
  51. }
  52. this.$emit('selectChange', val)
  53. },
  54. get() {
  55. return this.selectCheckboxValue.length ? true : false
  56. }
  57. },
  58. typeDesc() {
  59. return MEMBER_TYPE_AND_DESC_MAPPING[this.data.type]
  60. },
  61. },
  62. watch: {
  63. data: {
  64. handler(val) {
  65. this.isSelected = val.isSelected
  66. },
  67. immediate: true,
  68. deep: true,
  69. }
  70. },
  71. methods: {
  72. onSelectChange(val) {
  73. this.isSelected = val.length ? true : false
  74. },
  75. }
  76. }
  77. </script>
  78. <style scoped lang="scss">
  79. .card {
  80. justify-content: flex-start;
  81. column-gap: 24rpx;
  82. padding: 24rpx;
  83. background: #F9F9F9;
  84. }
  85. .info {
  86. .name {
  87. justify-content: flex-start;
  88. column-gap: 24rpx;
  89. font-size: 32rpx;
  90. color: #181818;
  91. .tag {
  92. padding: 2rpx 14rpx;
  93. font-size: 24rpx;
  94. color: #00A9FF;
  95. background: #E9F8FF;
  96. border: 2rpx solid #00A9FF;
  97. border-radius: 8rpx;
  98. &-1 {
  99. color: #03C25C;
  100. background: #E9FFF5;
  101. border-color: #03C25C;
  102. }
  103. &-2 {
  104. color: #EE6E05;
  105. background: #FFEFE9;
  106. border-color: #EE6E05;
  107. }
  108. }
  109. }
  110. .id {
  111. margin-top: 8rpx;
  112. font-size: 28rpx;
  113. color: #9B9B9B;
  114. }
  115. }
  116. </style>