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.

layout-numberplate-color.vue 3.7KB

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