Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

layout-numberplate-color.vue 3.7KB

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:'#ffffff',title:'渐变绿色'},
  42. {src:'bg-orange',checkSrc:'icon-select-orange',id:1,color:'#ffffff',title:'黄色'},
  43. {src:'bg-yellow_green',checkSrc:'icon-select-yellow_green',id:5,color:'#ffffff',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:'#ffffff',title:'蓝白渐变'},
  47. {src:'bg-green',checkSrc:'icon-select-green',id:11,color:'#ffffff',title:'绿色'},
  48. {src:'bg-green',checkSrc:'icon-select-green',id:12,color:'#ffffff',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. console.log("23",getCodeName('VEHICLE_COLOR_TYPE',data.trucksPlateColorType[i]))
  70. if(state.allColorList[j].title==getCodeName('VEHICLE_COLOR_TYPE',data.trucksPlateColorType[i])){
  71. state.numberplateColorList.push(state.allColorList[j])
  72. }
  73. }
  74. }
  75. }
  76. }
  77. onMounted(()=>{
  78. state.curCheckId = props.numberplateCor.id;
  79. getCarColor()
  80. console.log("type",props.type)
  81. })
  82. </script>
  83. <style lang="scss" scoped>
  84. .numberplates{
  85. display: flex;
  86. flex-direction: row;
  87. flex-wrap: wrap;
  88. .numberplate{
  89. display: flex;
  90. justify-content: center;
  91. align-items: center;
  92. margin-right: 60rpx;
  93. margin-bottom: 40rpx;
  94. position: relative;
  95. &:nth-child(even){
  96. margin-right: 0rpx;
  97. }
  98. &-bg{
  99. width: 230rpx;
  100. height: 80rpx;
  101. }
  102. &-name{
  103. font-size: 30rpx;
  104. color: white;
  105. position: absolute;
  106. line-height: 80rpx;
  107. }
  108. &-icon-check{
  109. width: 40rpx;
  110. height: 40rpx;
  111. position: absolute;
  112. right: -12rpx;
  113. bottom: -12rpx;
  114. }
  115. }
  116. }
  117. </style>