checkImageInfo.vue 12 KB

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