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.

addCar.vue 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <view class="bg">
  3. <!-- 车牌输入 -->
  4. <view class="car-input">
  5. <view class="title" style="margin-top: 10rpx;">车牌号</view>
  6. <car-number-input @numberInputResult="carNumber" inputColor='#ECF1F4'></car-number-input>
  7. </view>
  8. <!-- 车牌颜色 -->
  9. <view class="chepai-lane">
  10. <view class="title">车牌颜色</view>
  11. <numberplate-color :numberplate="state.vehiclePlate"
  12. :numberplateCor='state.vehiclePlateColor' @numberplateResult="checkNumberplateColor">
  13. </numberplate-color>
  14. </view>
  15. <view class="chepai-lane" v-if="state.isBand">
  16. <view class="title">选择卡号</view>
  17. <picker mode="selector" :value="state.index" :range="state.array" @change="choiceCard" class="picker">
  18. <view>{{state.index<0?'请选择':state.array[state.index]}} </view>
  19. </picker>
  20. </view>
  21. </view>
  22. <view class="action">
  23. <button type="default" class="ui-btn" @click="add()" v-if="state.isBand">
  24. 绑定
  25. </button>
  26. <button type="default" class="ui-btn" @click="search()" v-else>
  27. 查询
  28. </button>
  29. </view>
  30. </template>
  31. <script setup lang="ts">
  32. import { reactive } from "vue";
  33. import { onLoad } from "@dcloudio/uni-app";
  34. import {vehicleBind,queryCardInfo } from "@/utils/network/api.js";
  35. import {requestNew } from "@/utils/network/request.js";
  36. import {getItem,StorageKeys } from "@/utils/storage";
  37. import carNumberInput from "../components/car-number-input.vue";
  38. import numberplateColor from "../components/layout-numberplate-color";
  39. import {msg} from "@/utils/utils";
  40. const state = reactive({
  41. vehiclePlate: "",
  42. vehiclePlateColor: "",
  43. index:-1,
  44. array:[],
  45. arrayAll:[],
  46. isBand:false
  47. });
  48. onLoad((option : any) => {
  49. })
  50. const carNumber = (val : any) => {
  51. state.vehiclePlate = val.trim();
  52. };
  53. /* 选择车牌颜色 */
  54. const checkNumberplateColor = (item : any) => {
  55. state.vehiclePlateColor = item;
  56. };
  57. const search=()=>{
  58. cardList()
  59. }
  60. const add = () => {
  61. if(state.index<0){
  62. msg('请选择卡号');
  63. return;
  64. }
  65. const options = {
  66. type: 2,
  67. data: {
  68. "vehiclePlate": state.vehiclePlate,
  69. "vehiclePlateColor": state.vehiclePlateColor,
  70. "operaterId":getItem(StorageKeys.OpenId),
  71. "cardId": state.arrayAll[state.index]['cardId'],
  72. "cardStatus": state.arrayAll[state.index]['cardStatus'],
  73. "cardType": state.arrayAll[state.index]['cardType'],
  74. },
  75. method: 'POST',
  76. showLoading: true,
  77. }
  78. requestNew(vehicleBind, options).then((res) => {
  79. console.log("res==",res)
  80. msg("新增成功")
  81. setTimeout(()=>{
  82. uni.navigateBack()
  83. },1500)
  84. })
  85. }
  86. const cardList = () => {
  87. if(!state.vehiclePlate){
  88. msg('请输入车牌号');
  89. return;
  90. }
  91. const options = {
  92. type: 2,
  93. data: {
  94. "vehiclePlate": state.vehiclePlate,
  95. "vehiclePlateColor": state.vehiclePlateColor,
  96. },
  97. method: 'POST',
  98. showLoading: true,
  99. }
  100. requestNew(queryCardInfo, options).then((res) => {
  101. console.log("卡信息",res)
  102. if(res.length>0){
  103. state.isBand=true
  104. state.arrayAll=res
  105. for(var i=0;i<res.length;i++){
  106. state.array.push(res[i]['cardId'])
  107. }
  108. }
  109. })
  110. }
  111. const choiceCard=(e)=>{
  112. console.log("e",e.detail.value)
  113. state.index=e.detail.value
  114. }
  115. </script>
  116. <style scoped lang="scss">
  117. .bg {
  118. background-color: white;
  119. width: 88%;
  120. margin: 0 auto;
  121. margin-top: 20rpx;
  122. border-radius: 12px;
  123. border: 1px solid #FFFFFF;
  124. padding: 20rpx;
  125. overflow: hidden;
  126. .title{
  127. font-weight: 400;
  128. font-size: 30rpx;
  129. color: #01243A;
  130. margin: 30rpx 0;
  131. }
  132. }
  133. .action {
  134. position: fixed;
  135. left: 0;
  136. bottom: 0;
  137. height: 160rpx;
  138. background-color: #fff;
  139. border-radius: 30rpx 30rpx 0 0;
  140. width: 100vw;
  141. display: flex;
  142. align-items: center;
  143. justify-content: space-evenly;
  144. flex-direction: column;
  145. margin-top: 20rpx;
  146. }
  147. .picker{
  148. border: 1rpx solid #E9EDF0;
  149. padding:10rpx;
  150. }
  151. </style>