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

layout-numberplate-color.vue 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <!-- 车牌颜色选择组件 -->
  2. <template>
  3. <view class="numberplates">
  4. <view class="numberplate" v-for="(item,index) in state.numberplateColorList" @click="checkNumberplateColor(item)" :key="index">
  5. <image :src="`${fileURL}/image/issueActivation/${item.src}.png`" class="numberplate-bg"></image>
  6. <view class="numberplate-name" :style="`color:${item.color}`">{{numberplate}}</view>
  7. <image :src="`${fileURL}image/issueActivation/${item.checkSrc}.png`" class="numberplate-icon-check"
  8. v-if="item.id === state.curCheckId"></image>
  9. </view>
  10. </view>
  11. </template>
  12. <script setup lang="ts">
  13. import { onMounted, reactive } from "vue";
  14. import{fileURL} from '@/datas/fileURL.js';
  15. import { getItem} from "@/utils/storage";
  16. import { getGlobalParam } from "@/utils/network/api.js";
  17. import {getCodeName} from "@/datas/queryKey.js";
  18. const emit = defineEmits(['numberplateResult'])
  19. const props = defineProps({
  20. //显示的车牌
  21. numberplate:{
  22. type:String,
  23. default:'贵A1234'
  24. },
  25. //当前选择的车牌
  26. numberplateCor:{
  27. type:Object,
  28. default:()=>{return {id:-1}}
  29. },
  30. //客车1 货车2
  31. type:{
  32. type:String,
  33. default:'1'
  34. },
  35. })
  36. const state = reactive({
  37. curCheckId:-1, //当前选择的车牌
  38. numberplateColorList:[],
  39. allColorList:[//车牌颜色
  40. {src:'bg-blue',checkSrc:'icon-select-blue',id:0,color:'#ffffff',title:'蓝色'},
  41. {src:'bg-green',checkSrc:'icon-select-green',id:4,color:'#000000',title:'渐变绿色'},
  42. {src:'bg-orange',checkSrc:'icon-select-orange',id:1,color:'#000000',title:'黄色'},
  43. {src:'bg-yellow_green',checkSrc:'icon-select-yellow_green',id:5,color:'#000000',title:'黄绿双拼'},
  44. {src:'bg-black',checkSrc:'icon-select-black',id:2,color:'#ffffff',title:'黑色'},
  45. {src:'bg-white',checkSrc:'icon-select-white',id:3,color:'#000000',title:'白色'},
  46. {src:'bg-white_blue',checkSrc:'icon-select-blue',id:6,color:'#000000',title:'蓝白渐变'},
  47. {src:'bg-green',checkSrc:'icon-select-green',id:11,color:'rgb(0,255,0)',title:'绿色'},
  48. {src:'bg-white_white',checkSrc:'icon-select-white',id:12,color:'rgb(255,0,0)',title:'红色'},
  49. ]
  50. })
  51. /* 选择车牌颜色 */
  52. const checkNumberplateColor = (item) => {
  53. state.curCheckId = item.id;
  54. emit('numberplateResult',item)
  55. }
  56. const getCarColor = () => {
  57. const data=getItem('globalParam')
  58. if(props.type==1){
  59. for(var i=0;i<data.carPlateColorType.length;i++){
  60. for(var j=0;j<state.allColorList.length;j++){
  61. if(state.allColorList[j].title==getCodeName('VEHICLE_COLOR_TYPE',data.carPlateColorType[i])){
  62. state.numberplateColorList.push(state.allColorList[j])
  63. }
  64. }
  65. }
  66. }else{
  67. for(var i=0;i<data.trucksPlateColorType.length;i++){
  68. for(var j=0;j<state.allColorList.length;j++){
  69. if(state.allColorList[j].title==getCodeName('VEHICLE_COLOR_TYPE',data.trucksPlateColorType[i])){
  70. state.numberplateColorList.push(state.allColorList[j])
  71. }
  72. }
  73. }
  74. }
  75. }
  76. onMounted(()=>{
  77. state.curCheckId = props.numberplateCor.id;
  78. getCarColor()
  79. console.log("type",props.type)
  80. })
  81. </script>
  82. <style lang="scss" scoped>
  83. .numberplates{
  84. display: flex;
  85. flex-direction: row;
  86. flex-wrap: wrap;
  87. .numberplate{
  88. display: flex;
  89. justify-content: center;
  90. align-items: center;
  91. margin-right: 60rpx;
  92. margin-bottom: 40rpx;
  93. position: relative;
  94. &:nth-child(even){
  95. margin-right: 0rpx;
  96. }
  97. &-bg{
  98. width: 230rpx;
  99. height: 80rpx;
  100. }
  101. &-name{
  102. font-size: 30rpx;
  103. color: white;
  104. position: absolute;
  105. line-height: 80rpx;
  106. }
  107. &-icon-check{
  108. width: 40rpx;
  109. height: 40rpx;
  110. position: absolute;
  111. right: -12rpx;
  112. bottom: -12rpx;
  113. }
  114. }
  115. }
  116. </style>