checkImageInfo.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. <template>
  2. <view class="z-index center" v-if="show" @tap.stop.prevent @touchmove.stop.prevent @click.stop.prevent>
  3. <view class="popContent " @tap.stop.prevent @touchmove.stop.prevent @click.stop.prevent>
  4. <view class="popHeader center">信息校验</view>
  5. <view class="popBody">
  6. <view class="icon iconfont icon-fanzhuanshunshizhen lRotate center" @click.stop.prevent="rotate">
  7. </view>
  8. <movable-area class="marea" scale-area v-for="(imgitem,imgindex) in img" :key="imgindex">
  9. <movable-view class="mview center" direction="all" :out-of-bounds="false" :inertia="true"
  10. damping="90" friction="2" scale="true" scale-min="1" scale-max="4" :scale-value="scale"
  11. @scale="onScale" @change="movableChange">
  12. <image class="image" :src="imgitem" :style="{ transform: 'rotateZ(' + deg + 'deg)' }" />
  13. </movable-view>
  14. </movable-area>
  15. <template v-if="checkType == '2'">
  16. <view class="line d-flex a-center">
  17. <view class="line_title">车牌号</view>
  18. <view class="line_info d-flex flex-1">
  19. <input class="input" type="text" placeholder-style="font-size:28upx; color:#999"
  20. placeholder="请输入车牌号" @input="upperCaseType('licenseNo')" v-model="checkInfo.licenseNo"
  21. maxlength="8" />
  22. </view>
  23. </view>
  24. <view class="line d-flex a-center">
  25. <view class="line_title">发动机号</view>
  26. <view class="line_info d-flex flex-1">
  27. <input class="input" type="text" placeholder-style="font-size:28upx; color:#999"
  28. @input="upperCaseType('engineNo')" placeholder="请输入发动机号" v-model="checkInfo.engineNo" />
  29. </view>
  30. </view>
  31. <view class="line d-flex a-center">
  32. <view class="line_title">车架号</view>
  33. <view class="line_info d-flex flex-1">
  34. <input class="input" type="text" placeholder-style="font-size:28upx; color:#999"
  35. placeholder="请输入车架号" @input="upperCaseType('vinNo')" v-model="checkInfo.vinNo"
  36. maxlength="17" />
  37. </view>
  38. </view>
  39. <view class="line d-flex a-center">
  40. <view class="line_title">注册日期</view>
  41. <view class="line_info d-flex flex-1">
  42. <picker mode="date" :value="checkInfo.registerDate" :start="startDate" :end="endDate"
  43. @change="bindDateChange($event,'registerDate')">
  44. <view :class="!checkInfo.registerDate?'':'active'" class="registerDate d-flex a-center">
  45. {{!checkInfo.registerDate?"请选择日期":checkInfo.registerDate}}
  46. </view>
  47. </picker>
  48. </view>
  49. </view>
  50. <view class="line d-flex a-center">
  51. <view class="line_title">发证日期</view>
  52. <view class="line_info d-flex flex-1">
  53. <picker mode="date" :value="checkInfo.issueDate" :start="checkInfo.registerDate"
  54. :end="endDate" @change="bindDateChange($event,'issueDate')">
  55. <view :class="!checkInfo.issueDate?'':'active'" class="registerDate d-flex a-center">
  56. {{!checkInfo.issueDate?"请选择日期":checkInfo.issueDate}}
  57. </view>
  58. </picker>
  59. </view>
  60. </view>
  61. </template>
  62. <template v-if="checkType == '1'">
  63. <view class="line d-flex a-center">
  64. <view class="line_title">姓名</view>
  65. <view class="line_info d-flex flex-1">
  66. <input type="text" placeholder-style="font-size:28upx; color:#999" placeholder="请输入姓名"
  67. v-model="checkInfo.name" />
  68. </view>
  69. </view>
  70. <view class="line d-flex a-center">
  71. <view class="line_title">证件号</view>
  72. <view class="line_info d-flex flex-1">
  73. <input type="text" placeholder-style="font-size:28upx; color:#999" placeholder="请输入证件号"
  74. v-model="checkInfo.identifyNumber" />
  75. </view>
  76. </view>
  77. <view class="line d-flex a-center" style="height: 100upx;">
  78. <view class="line_title">地址</view>
  79. <view class="line_info d-flex d-flex flex-1">
  80. <textarea class="d-flex flex-1"
  81. style="font-size: 28upx;width: 330upx;height: 60upx;min-height: 80upx;"
  82. v-model="checkInfo.addr" placeholder-style="font-size:28upx; color:#999"
  83. placeholder="请输入地址" />
  84. </view>
  85. </view>
  86. <view class="line d-flex a-center">
  87. <view class="line_title">有效期起期</view>
  88. <view class="line_info d-flex flex-1">
  89. <input type="text" placeholder-style="font-size:28upx; color:#999" placeholder="请输入证件号"
  90. v-model="checkInfo.identifyValidDate" />
  91. </view>
  92. </view>
  93. <view class="line d-flex a-center">
  94. <view class="line_title">有效期止期</view>
  95. <view class="line_info d-flex flex-1">
  96. <input type="text" placeholder-style="font-size:28upx; color:#999" placeholder="请输入证件号"
  97. v-model="checkInfo.identifyValidEndDate" />
  98. </view>
  99. </view>
  100. </template>
  101. </view>
  102. <view class="popBottom center d-flex">
  103. <view class="d-flex a-center j-center flex-1" style="border-right: 5upx solid #FAFAFA;"
  104. @tap="checkInfoCancel">取消</view>
  105. <view class="d-flex a-center j-center flex-1" @tap="checkInfoSubmit">确定</view>
  106. </view>
  107. </view>
  108. </view>
  109. </template>
  110. <script>
  111. export default {
  112. name: 'checkImageInfo', //插件名称
  113. props: {
  114. show: {
  115. type: Boolean,
  116. required: true,
  117. default: false
  118. },
  119. img: Array,
  120. checkType: {
  121. type: Number,
  122. required: true,
  123. default: 1,
  124. },
  125. checkInfo: {
  126. type: Object,
  127. required: true,
  128. default: () => {
  129. return {};
  130. }
  131. },
  132. items: ['选项卡1', '选项卡2', '选项卡3'],
  133. current: 0,
  134. colorIndex: 0,
  135. activeColor: '#007aff',
  136. styleType: 'button'
  137. },
  138. computed: {
  139. startDate() {
  140. return this.getDate('start');
  141. },
  142. endDate() {
  143. return this.getDate('end');
  144. }
  145. },
  146. data() {
  147. return {
  148. deg: 0, //旋转角度
  149. scale: 1 //缩放比例
  150. };
  151. },
  152. methods: {
  153. //转变大写(车型/车架号/发动机号)
  154. upperCaseType(type) {
  155. this.checkInfo[type] = this.checkInfo[type].toUpperCase();
  156. },
  157. checkInfoCancel() {
  158. this.deg = 0; //旋转角度
  159. this.scale = 1; //缩放比例
  160. this.$emit('cancel')
  161. },
  162. //日期(可以选择20年以内的时间)
  163. getDate(type) {
  164. const date = new Date();
  165. let year = date.getFullYear();
  166. let month = date.getMonth() + 1;
  167. let day = date.getDate();
  168. if (type === 'start') {
  169. year = year - 20;
  170. } else if (type === 'end') {}
  171. month = month > 9 ? month : '0' + month;;
  172. day = day > 9 ? day : '0' + day;
  173. return `${year}-${month}-${day}`;
  174. },
  175. bindDateChange(e, type) { //日期赋值
  176. if ((type == 'issueDate') && (!this.checkInfo.registerDate)) {
  177. return uni.showToast({
  178. title: '请先输入注册日期',
  179. icon: "none"
  180. });
  181. }
  182. this.checkInfo[type] = e.detail.value;
  183. },
  184. //比例变化
  185. onScale(e) {
  186. },
  187. //移动变化
  188. movableChange(e) {
  189. //console.log(e);
  190. /* if(this.old.scale <= 1){
  191. this.swiper=false;
  192. }else if(e.detail.x===0){
  193. this.swiper=false;
  194. } */
  195. },
  196. //旋转
  197. rotate(e) {
  198. this.deg = this.deg == 270 ? 0 : this.deg + 90;
  199. },
  200. //关闭
  201. checkInfoSubmit() {
  202. if ((this.checkType == 2) && !this.checkCarInfo()) {
  203. return false;
  204. }
  205. if ((this.checkType == 1) && !this.checkPersonInfo()) {
  206. return false;
  207. }
  208. this.deg = 0; //旋转角度
  209. this.scale = 1; //缩放比例
  210. var params = {
  211. checkType: this.checkType,
  212. checkInfo: this.checkInfo
  213. }
  214. this.$emit('close', params)
  215. },
  216. //验证车架号
  217. isFrameno(str) {
  218. let mPattern = /^([0-9A-Z]){17}$/;
  219. return mPattern.test(str);
  220. },
  221. isLicense(str) {
  222. let mPattern =
  223. /^(([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z](([0-9]{5}[DF])|([DF]([A-HJ-NP-Z0-9])[0-9]{4})))|([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z][A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳使领]))$/;
  224. return mPattern.test(str);
  225. },
  226. //校验车辆信息
  227. checkCarInfo() {
  228. if (!this.isLicense(this.checkInfo.licenseNo.trim())) {
  229. uni.showToast({
  230. title: '车牌号有误',
  231. icon: "none"
  232. });
  233. return false;
  234. }
  235. if (!this.checkInfo.engineNo.trim()) {
  236. uni.showToast({
  237. title: '发动机号有误',
  238. icon: "none"
  239. });
  240. return false;
  241. }
  242. if (!this.isFrameno(this.checkInfo.vinNo.trim())) {
  243. uni.showToast({
  244. title: '车架号有误',
  245. icon: "none"
  246. });
  247. return false;
  248. }
  249. if (!this.checkInfo.registerDate.trim()) {
  250. uni.showToast({
  251. title: '注册日期有误',
  252. icon: "none"
  253. });
  254. return false;
  255. }
  256. if (!this.checkInfo.issueDate.trim()) {
  257. uni.showToast({
  258. title: '发证日期有误',
  259. icon: "none"
  260. });
  261. return false;
  262. }
  263. return true;
  264. },
  265. // 身份证验证
  266. isIdCard(str) {
  267. return /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
  268. },
  269. //校验人员信息
  270. checkPersonInfo() {
  271. if (!this.checkInfo.name.trim()) {
  272. uni.showToast({
  273. title: '姓名不能为空',
  274. icon: "none"
  275. });
  276. return false;
  277. }
  278. if (!this.isIdCard(this.checkInfo.identifyNumber.trim())) {
  279. uni.showToast({
  280. title: '身份证号有误',
  281. icon: "none"
  282. });
  283. return false;
  284. }
  285. if (!this.checkInfo.addr.trim()) {
  286. uni.showToast({
  287. title: '地址不能为空',
  288. icon: "none"
  289. });
  290. return false;
  291. }
  292. return true;
  293. }
  294. }
  295. };
  296. </script>
  297. <!--使用scss,只在本组件生效-->
  298. <style lang="scss" scoped>
  299. /* 弹出框样式Start */
  300. .z-index {
  301. position: fixed;
  302. left: 0;
  303. top: 0;
  304. right: 0;
  305. bottom: 0;
  306. background-color: #000;
  307. background: rgba(0, 0, 0, 0.3);
  308. z-index: 999;
  309. .popContent {
  310. position: relative;
  311. z-index: 1000;
  312. width: 670upx;
  313. background: #FFFFFF;
  314. border-radius: 10upx;
  315. height: auto;
  316. padding-bottom: 50px;
  317. .popHeader {
  318. font-weight: bold;
  319. font-size: 32upx;
  320. height: 80upx;
  321. }
  322. .popBody {
  323. position: relative;
  324. width: 100%;
  325. background-color: #FAFAFA;
  326. padding: 10upx 20upx;
  327. box-sizing: border-box;
  328. .lRotate {
  329. color: #FFFFFF;
  330. font-size: 36upx;
  331. font-weight: bold;
  332. position: absolute;
  333. right: 20upx;
  334. top: 280upx;
  335. z-index: 1001;
  336. height: 60upx;
  337. width: 60upx;
  338. background-color: #000;
  339. }
  340. .marea {
  341. height: 330upx;
  342. width: 100%;
  343. margin-bottom: 10upx;
  344. overflow: hidden;
  345. .mview {
  346. width: 100%;
  347. height: auto;
  348. .image {
  349. width: 100%;
  350. height: 176px;
  351. }
  352. }
  353. }
  354. .line {
  355. height: 70upx;
  356. width: 100%;
  357. background: #FFF;
  358. border-top: 5upx solid #FAFAFA;
  359. .line_title {
  360. width: 80px;
  361. flex-shrink: 0;
  362. padding: 0upx 10upx;
  363. font-weight: bold;
  364. }
  365. .line_info {
  366. padding: 0upx 20upx;
  367. .registerDate {
  368. color: #999;
  369. min-width: 300upx;
  370. height: 70upx;
  371. }
  372. .registerDate.active {
  373. font-size: 28upx;
  374. color: #000;
  375. min-width: 300upx;
  376. height: 70upx;
  377. }
  378. .input {
  379. font-size: 28upx;
  380. }
  381. }
  382. }
  383. }
  384. .popBottom {
  385. position: absolute;
  386. box-sizing: border-box;
  387. bottom: 0;
  388. width: 100%;
  389. height: 100upx;
  390. color: #3e5cd7;
  391. border-top: 1px solid #f6f6f6;
  392. font-weight: 700;
  393. view {
  394. font-size: 32upx;
  395. }
  396. }
  397. }
  398. }
  399. /* 盒子内容居中 */
  400. .center {
  401. display: flex;
  402. justify-content: center;
  403. align-items: center;
  404. }
  405. .uni-common-mt {
  406. margin-top: 30px;
  407. }
  408. .uni-padding-wrap {
  409. // width: 750rpx;
  410. padding: 0px 30px;
  411. }
  412. /* 弹出框样式End */
  413. </style>