您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

LicensePlateColor.vue 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <template>
  2. <div style="padding-left: 30px;margin-top: 10px;">
  3. <div class="container">
  4. <div class="numberplate" v-for="(item,index) in handleItems(items)" :key="index"
  5. @click="checkNumberplateColor(item)">
  6. <image class="numberplate-bg" :src="`${fileURL}image/issueActivation/${item.src}.png`"></image>
  7. <view class="numberplate-name" :style="`color:${item.color}`">
  8. <text style="font-size:24rpx">{{numberplate ? numberplate : item.title }}</text>
  9. </view>
  10. <image :src="`${fileURL}image/issueActivation/${item.checkSrc}.png`" class="numberplate-icon-check"
  11. v-if="item.id === curCheckId"></image>
  12. </div>
  13. </div>
  14. </div>
  15. </template>
  16. <script setup lang='ts'>
  17. import {
  18. ref,
  19. watchEffect
  20. } from 'vue'
  21. import {
  22. fileURL
  23. } from '@/utils/network/api.js';
  24. const props = defineProps({
  25. defaultStr: {
  26. default: '',
  27. },
  28. vanType: {
  29. default: 'all'
  30. }
  31. })
  32. const handleItems = (item) => {
  33. let vanType = props.vanType
  34. if (vanType === 'all') {
  35. return item
  36. } else if (vanType === 'passengerCar') {
  37. // 客车
  38. return item.filter(item => !['黄绿双拼色', '黄色','蓝白渐变','红色'].includes(item.title))
  39. } else {
  40. return item.filter(item => ['黄绿双拼色', '黄色'].includes(item.title))
  41. }
  42. }
  43. const emit = defineEmits([
  44. "numberplateResult"
  45. ])
  46. /* 选择车牌颜色 */
  47. const checkNumberplateColor = (item) => {
  48. curCheckId.value = item.id;
  49. emit('numberplateResult', item)
  50. }
  51. const numberplate = ref('') //车牌号
  52. const curCheckId = ref(-1) //当前选择的车牌
  53. watchEffect(() => {
  54. if (parseInt(props.defaultStr) === 0 || props.defaultStr) {
  55. curCheckId.value = parseInt(props.defaultStr)
  56. }
  57. })
  58. const items = [ //车牌颜色
  59. {
  60. src: 'bg-blue',
  61. checkSrc: 'icon-select-blue',
  62. id: 0,
  63. color: '#ffffff',
  64. title: '蓝色'
  65. },
  66. {
  67. src: 'bg-green',
  68. checkSrc: 'icon-select-green',
  69. id: 4,
  70. color: '#ffffff',
  71. title: '渐变绿色'
  72. },
  73. {
  74. src: 'bg-orange',
  75. checkSrc: 'icon-select-orange',
  76. id: 1,
  77. color: '#ffffff',
  78. title: '黄色'
  79. },
  80. {
  81. src: 'bg-yellow_green',
  82. checkSrc: 'icon-select-yellow_green',
  83. id: 5,
  84. color: '#ffffff',
  85. title: '黄绿双拼色'
  86. },
  87. {
  88. src: 'bg-black',
  89. checkSrc: 'icon-select-black',
  90. id: 2,
  91. color: '#ffffff',
  92. title: '黑色'
  93. },
  94. {
  95. src: 'bg-white',
  96. checkSrc: 'icon-select-white',
  97. id: 3,
  98. color: '#000000',
  99. title: '白色'
  100. },
  101. {
  102. src: 'bg-white_blue',
  103. checkSrc: 'icon-select-blue',
  104. id: 6,
  105. color: '#ffffff',
  106. title: '蓝白渐变'
  107. },
  108. {
  109. src: 'green',
  110. checkSrc: 'icon-green',
  111. id: 11,
  112. color: '#ffffff',
  113. title: '绿色'
  114. },
  115. {
  116. src: 'rad',
  117. checkSrc: 'icon-select-red',
  118. id: 12,
  119. color: '#ffffff',
  120. title: '红色'
  121. }
  122. ]
  123. </script>
  124. <style lang='scss' scoped>
  125. .flex-bg {
  126. display: flex;
  127. flex-direction: row;
  128. flex-wrap: wrap;
  129. justify-content: space-between;
  130. align-content: flex-start;
  131. line-height: 10px;
  132. }
  133. .numberplate {
  134. width: 200rpx;
  135. height: 80rpx;
  136. }
  137. .item {
  138. background-color: $uni-bg-color-mask;
  139. }
  140. .container {
  141. display: flex;
  142. flex-wrap: wrap;
  143. justify-content: flex-start;
  144. align-items: center;
  145. gap: 10px;
  146. /* 根据实际情况调整间距大小 */
  147. }
  148. .numberplate {
  149. display: flex;
  150. justify-content: center;
  151. align-items: center;
  152. margin-bottom: 10rpx;
  153. position: relative;
  154. &:nth-child(even) {
  155. margin-right: 0rpx;
  156. }
  157. &-bg {
  158. width: 200rpx;
  159. height: 80rpx;
  160. }
  161. &-name {
  162. font-size: 30rpx;
  163. color: white;
  164. position: absolute;
  165. line-height: 80rpx;
  166. }
  167. &-icon-check {
  168. width: 40rpx;
  169. height: 40rpx;
  170. position: absolute;
  171. right: -12rpx;
  172. bottom: -12rpx;
  173. }
  174. }
  175. </style>