選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

layout-numberplate-color.vue 3.4KB

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