Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

old-user.vue 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <view class="box">
  3. <view class="title">公务车车牌号</view>
  4. <carNumerInput @numberInputResult="numberInputResult">
  5. </carNumerInput>
  6. </view>
  7. <!-- 车牌颜色 -->
  8. <view class="plate-color">
  9. <view class="title">选择车牌颜色</view>
  10. <numberplateColor :numberplate="state.numberplate?state.numberplate:state.vehiclePlateNumber"
  11. :numberplateCor="{ id: 0 }" @numberplateResult="checkNumberplateColor">
  12. </numberplateColor>
  13. </view>
  14. <view class="btn">
  15. <submit-button title="确定" @submit="submit"></submit-button>
  16. </view>
  17. <u-popup v-model="state.showPopup" mode="bottom">
  18. <view v-if="state.showPopup">
  19. <popup-numberplate-color :numberplateCor="state.curNumberplateColor" :numberplate="state.numberplate"
  20. @numberplateResult="numberplateResult">
  21. </popup-numberplate-color>
  22. </view>
  23. </u-popup>
  24. </template>
  25. <script setup lang="ts">
  26. import {
  27. reactive
  28. } from "vue";
  29. import {
  30. onLoad
  31. } from "@dcloudio/uni-app";
  32. import {
  33. msg,
  34. navTo
  35. } from '@/utils/utils';
  36. import {
  37. request
  38. } from "@/utils/network/request.js";
  39. import {
  40. gongWuChefindFormatVehicleInfo,
  41. gongWuCheDanWeiJinDu
  42. } from "@/utils/network/api.js";
  43. import {
  44. stringToJson
  45. } from "@/utils/network/encryption";
  46. import popupNumberplateColor from "./components/popup-choose-numberplate-color";
  47. import numberplateColor from "./components/layout-numberplate-color";
  48. import carNumerInput from "@/components/car-number-input/car-number-input";
  49. const tools = require("../../static/etcUtil/tools.js");
  50. onLoad((option) => {
  51. console.log(option);
  52. })
  53. const state = reactive({
  54. //显示车牌颜色选择popup
  55. showPopup: false,
  56. //当前选择的车牌颜色
  57. curNumberplateColor: {
  58. id: -1
  59. },
  60. vehiclePlateColor: 0,
  61. vehiclePlateColorStr: "请选择车牌颜色",
  62. numberplate: "",
  63. vehiclePlateNumber: "贵A12345",
  64. })
  65. /* 选择车牌颜色 */
  66. const checkNumberplateColor = (item : any) => {
  67. state.vehiclePlateColor = item.id;
  68. };
  69. //车牌颜色选择回调结果
  70. const numberplateResult = (colorItem : any) => {
  71. console.log(colorItem);
  72. state.vehiclePlateColor = colorItem.id;
  73. state.vehiclePlateColorStr = colorItem.title;
  74. state.showPopup = false;
  75. }
  76. const numberInputResult = (e : string) => {
  77. state.numberplate = e;
  78. }
  79. const chooseColor = () => {
  80. state.showPopup = true
  81. }
  82. //提交换货申请
  83. const submit = () => {
  84. if (state.numberplate.trim().length < 7) {
  85. msg('请输入正确车牌号');
  86. return
  87. }
  88. if (isVehicleNumber(state.numberplate.trim())) {
  89. msg('请输入车牌号格式不正确');
  90. }
  91. const options = {
  92. type: 2,
  93. data: {
  94. vehPlateNo: state.numberplate,
  95. vehPlateNoColor: state.vehiclePlateColor,
  96. },
  97. method: "POST",
  98. showLoading: true,
  99. };
  100. request(gongWuChefindFormatVehicleInfo, options).then((res : any) => {
  101. const result = stringToJson(res.bizContent)
  102. console.log(result);
  103. // deptName单位名称
  104. getGongWuCheDanWeiJinDu(result.fvehClass, result.fvehPlateColor, result.fvehPlateNo, result.deptName);
  105. })
  106. }
  107. const getGongWuCheDanWeiJinDu = (vehicleType : number, vehiclePlateColor : number, vehiclePlate : string, deptName :
  108. string) => {
  109. const options = {
  110. type: 2,
  111. data: {
  112. vehicleId: vehiclePlate + "_" + vehiclePlateColor,
  113. vehicleType: vehicleType,
  114. },
  115. method: "POST",
  116. showLoading: true,
  117. };
  118. request(gongWuCheDanWeiJinDu, options).then((res : any) => {
  119. const result = stringToJson(res.bizContent)
  120. console.log(result);
  121. console.log("deptName", deptName)
  122. if (result) {
  123. //成功调到查询界面
  124. tools.showModalAlert("历史用户信息检测成功,请您前往特制卡申请进行单位查询", function (res) {
  125. if (res.confirm) { //确定
  126. // tools.toUrl(route.scompnayQuery + '?deptShortName=' + deptShortName)
  127. navTo("/subpackage/personal-center/query-company-list?deptShortName=" + deptName)
  128. return;
  129. }
  130. });
  131. } else {
  132. tools.showModalAlert("未检测到历史用户信息,是否前往特制卡申请进行新增单位", function (res) {
  133. if (res.confirm) { //确定
  134. // tools.toUrl(route.scompnayQuery)
  135. navTo("/subpackage/personal-center/query-company-list")
  136. return;
  137. }
  138. }, null, "", true);
  139. }
  140. })
  141. }
  142. //车牌号验证方法
  143. function isVehicleNumber(vehicleNumber : string) {
  144. var xreg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([0-9]{5}[DF]$)|([DF][A-HJ-NP-Z0-9][0-9]{4}$))/;
  145. var creg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]{1}$/;
  146. if (vehicleNumber.length == 7) {
  147. return creg.test(vehicleNumber);
  148. } else if (vehicleNumber.length == 8) {
  149. return xreg.test(vehicleNumber);
  150. } else {
  151. return false;
  152. }
  153. }
  154. </script>
  155. <style>
  156. page {
  157. background-color: #EEF7F7;
  158. }
  159. </style>
  160. <style lang="scss" scoped>
  161. .title {
  162. font-size: 32rpx;
  163. font-weight: bold;
  164. padding-bottom: 20rpx;
  165. padding-left: 20rpx;
  166. }
  167. .plate-color {
  168. display: flex;
  169. flex-direction: column;
  170. margin: 30rpx 30rpx 60rpx 30rpx;
  171. padding: 20rpx 0;
  172. }
  173. .plate-color .tit {
  174. font-size: 32rpx;
  175. padding-right: 20rpx;
  176. color: #666;
  177. }
  178. .plate-color .value {
  179. flex: 1;
  180. font-size: 32rpx;
  181. }
  182. .plate-color image {
  183. width: 36rpx;
  184. height: 36rpx;
  185. }
  186. .box {
  187. margin: 30rpx 0rpx;
  188. padding: 0 30rpx;
  189. }
  190. .btn {
  191. padding: 0 30rpx;
  192. }
  193. </style>