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.

base-change-people.vue 9.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. <template>
  2. <view class="content">
  3. <view class="item-tips">
  4. <view class="picture-wrapper" @click="takePhotoMode('1')">
  5. <view class="bg">
  6. <view class="">
  7. <view class="name">
  8. 人像面
  9. </view>
  10. <view class="value">
  11. 上传身份证的人像面
  12. </view>
  13. <view class="tip">
  14. <view class="tip-value">
  15. 拍摄规范
  16. </view>
  17. </view>
  18. </view>
  19. <image class="icon" :src="`${$imgUrl}applyCard/renxiang.png`" v-if="!state.imageUrl"></image>
  20. <image class="icon" :src="state.imageUrl" v-else></image>
  21. </view>
  22. </view>
  23. <view class="picture-wrapper" @click="takePhotoMode('2')">
  24. <view class="bg">
  25. <view class="">
  26. <view class="name">
  27. 国徽面
  28. </view>
  29. <view class="value">
  30. 上传身份证的国徽面
  31. </view>
  32. <view class="tip">
  33. <view class="tip-value">
  34. 拍摄规范
  35. </view>
  36. </view>
  37. </view>
  38. <image class="icon" :src="`${$imgUrl}applyCard/guohui.png`" v-if="!state.imageUrl2"></image>
  39. <image class="icon" :src="state.imageUrl2" v-else></image>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="shibie-wrapper">
  44. <view class="title">
  45. 个人信息
  46. </view>
  47. <view class="">
  48. <u-field required labelWidth="200" v-model="state.ocrData.name" input-align='right' label="姓名" disabled>
  49. </u-field>
  50. <u-field required labelWidth="200" v-model="state.ocrData.gender" input-align='right' label="性别"
  51. disabled>
  52. </u-field>
  53. <u-field required labelWidth="200" v-model="state.ocrData.idno" input-align='right' label="证件号"
  54. disabled>
  55. </u-field>
  56. <u-field required labelWidth="200" v-model="state.ocrData.address" input-align='right' label="地址"
  57. disabled>
  58. </u-field>
  59. <u-field required labelWidth="200" v-model="state.ocrData.termValidity" input-align='right'
  60. label="证件有效期" disabled>
  61. </u-field>
  62. <u-field required labelWidth="200" v-model="state.ocrData.phone" input-align='right' label="联系方式"
  63. disabled>
  64. </u-field>
  65. </view>
  66. </view>
  67. <view class="action">
  68. <button type="default" class="button" @click="savaHandle()">确认下一步</button>
  69. </view>
  70. </view>
  71. <view class="choice-takePhoto-wrap" v-if="state.isTakePhotoModeShow" @click="cancle">
  72. <view class="choice-takePhoto">
  73. <view @click.stop="takePhoto(state.choiceIndex)" style="border-radius: 20rpx 20rpx 0 0;">拍照</view>
  74. <view @click.stop="xiangce(state.choiceIndex)">从手机相册选择</view>
  75. <view @click.stop="cancle">取消</view>
  76. </view>
  77. </view>
  78. <viewfinder v-if="state.phoneType" :phoneType="state.phoneType" :images="state.images"
  79. :showStartPhoto="state.showImg" @confirmReturn="confirmReturn" @camera="camera"></viewfinder>
  80. </template>
  81. <script setup lang="ts">
  82. import {
  83. ref,
  84. reactive
  85. } from "vue";
  86. import {
  87. navTo, uploadFile
  88. } from "@/utils/utils";
  89. import {
  90. etcOcrCard
  91. } from "@/utils/network/api.js";
  92. import {
  93. stringToJson
  94. } from "@/utils/network/encryption";
  95. import viewfinder from "@/components/viewfinder.vue"
  96. const savaHandle = () => {
  97. console.log("执行点击事件");
  98. if (state.imageUrl && state.imageUrl2) {
  99. navTo("/subpackage/after-sale/additional-equipment/car-change");
  100. } else {
  101. uni.showToast({
  102. title: "请上传图片",
  103. icon: "none",
  104. });
  105. }
  106. };
  107. const state = reactive({
  108. phoneType: 0, // 1 身份证正面 2 身份证反面 3行驶证正面 4行驶证反面
  109. choiceIndex: 1, // 1 身份证正面 2 身份证反面
  110. isTakePhotoModeShow: false, //选择拍照方式是否出来
  111. images: '',
  112. showImg: true,
  113. ocrData: {
  114. name: "",
  115. gender: "",
  116. idno: "",
  117. address: "",
  118. phone: "18225525252",
  119. termValidity: "",
  120. },
  121. isMyPeopple: true,
  122. imageUrl: "",
  123. imageUrl2: "",
  124. });
  125. const form_ref = ref()
  126. // 验证规则
  127. const rules = {
  128. name: {
  129. rules: [{
  130. required: true,
  131. errorMessage: '请输入',
  132. }]
  133. },
  134. bankID: {
  135. rules: [{
  136. required: true,
  137. errorMessage: '请输入',
  138. }]
  139. },
  140. phone: {
  141. rules: [{
  142. required: true,
  143. errorMessage: '请输入',
  144. }]
  145. },
  146. }
  147. const takePhotoMode = (index, isMy) => {
  148. console.log("index", index, isMy)
  149. state.isTakePhotoModeShow = true
  150. state.choiceIndex = index
  151. state.isMy = isMy
  152. }
  153. const xiangce = (val) => {
  154. console.log("val", val)
  155. var imageType = val;
  156. uni.chooseImage({
  157. count: 1, //只能选取一张照片
  158. sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
  159. sourceType: ["album"], //从相册选择
  160. success: function (res) {
  161. state.showImg = false
  162. state.images = res.tempFilePaths[0]
  163. state.phoneType = state.choiceIndex
  164. state.isTakePhotoModeShow = false
  165. console.log("tempFilePaths[0].startsWith('file://')", res.tempFilePaths[0], res.tempFilePaths[0].startsWith('file://'))
  166. },
  167. })
  168. }
  169. const takePhoto = (val) => {
  170. state.showImg = true
  171. console.log("拍照", val)
  172. state.phoneType = val;
  173. }
  174. const confirmReturn = (val) => {
  175. state.phoneType = 0
  176. state.isTakePhotoModeShow = false
  177. var imageType = state.choiceIndex;
  178. console.log("图片地址val", val.tempImagePath)
  179. uploadFile(val.tempImagePath, imageType, etcOcrCard).then((data) => {
  180. console.log("身份证上传", data)
  181. if (state.choiceIndex == 1) {
  182. state.imageUrl = data.imageUrl;
  183. state.ocrData.name = data.name;
  184. state.ocrData.gender = data.gender;
  185. state.ocrData.idno = data.idno;
  186. state.ocrData.address = data.address;
  187. } else {
  188. state.ocrData.termValidity = data.begindate + "-" + data
  189. .enddate;
  190. state.imageUrl2 = data.imageUrl;
  191. }
  192. state.isTakePhotoModeShow = false
  193. })
  194. }
  195. const cancle = () => {
  196. state.isTakePhotoModeShow = false
  197. }
  198. </script>
  199. <style lang="scss" scoped>
  200. .content {
  201. padding: 50rpx 30rpx 50rpx 30rpx;
  202. .action {
  203. margin-top: 60rpx;
  204. padding-left: 20rpx;
  205. padding-right: 20rpx;
  206. padding-bottom: 30rpx;
  207. .button {
  208. height: 80rpx;
  209. background: linear-gradient(-90deg, #43A1E0 0%, #13E7C1 100%);
  210. border-radius: 40rpx;
  211. font-size: 32rpx;
  212. font-weight: 400;
  213. color: #FFFFFF;
  214. line-height: 80rpx;
  215. }
  216. }
  217. .item-tips {
  218. .title {
  219. font-size: 30rpx;
  220. font-family: Microsoft YaHei;
  221. font-weight: 400;
  222. color: #000000;
  223. line-height: 24rpx;
  224. }
  225. .tip {
  226. margin-top: 16rpx;
  227. font-size: 24rpx;
  228. font-family: Microsoft YaHei;
  229. font-weight: 400;
  230. color: #999999;
  231. line-height: 24rpx;
  232. }
  233. }
  234. .picture-wrapper {
  235. margin-top: 40rpx;
  236. .bg {
  237. background: #FFFFFF;
  238. box-shadow: 0rpx 4rpx 13rpx 3rpx rgba(223, 223, 223, 0.8);
  239. border-radius: 20rpx;
  240. padding: 40rpx;
  241. display: flex;
  242. justify-content: space-between;
  243. .name {
  244. font-size: 34rpx;
  245. font-family: Microsoft YaHei;
  246. font-weight: 400;
  247. color: #000000;
  248. line-height: 34rpx
  249. }
  250. .value {
  251. margin-top: 20rpx;
  252. font-size: 24rpx;
  253. font-family: Microsoft YaHei;
  254. font-weight: 400;
  255. color: #999999;
  256. line-height: 24rpx;
  257. }
  258. .tip {
  259. margin-top: 20rpx;
  260. text-align: center;
  261. width: 110rpx;
  262. height: 40rpx;
  263. background: rgba(33, 190, 177, 0.2);
  264. border-radius: 6rpx;
  265. .tip-value {
  266. font-size: 20rpx;
  267. font-family: Microsoft YaHei;
  268. font-weight: 400;
  269. color: #0A8F8A;
  270. line-height: 40rpx;
  271. opacity: 1;
  272. }
  273. }
  274. }
  275. .icon {
  276. width: 294rpx;
  277. height: 188rpx;
  278. }
  279. }
  280. .shibie-wrapper {
  281. margin-top: 60rpx;
  282. .title {
  283. font-size: 30rpx;
  284. font-family: Microsoft YaHei;
  285. font-weight: 400;
  286. color: #000000;
  287. line-height: 30rpx;
  288. }
  289. ::v-deep .u-flex {
  290. width: 100%;
  291. }
  292. ::v-deep .u-field {
  293. border-bottom: 1rpx solid #DCDCDC;
  294. }
  295. .from1 {
  296. background-color: #fff;
  297. margin-top: 30rpx;
  298. ::v-deep .uni-forms-item {
  299. border-bottom: 1rpx solid #ccc;
  300. padding: 15rpx 0;
  301. margin-bottom: 0;
  302. .uni-forms-item__label {
  303. font-size: 28rpx;
  304. height: 50rpx;
  305. }
  306. .uni-forms-item__content {
  307. display: flex;
  308. }
  309. .uni-easyinput__content-input {
  310. font-size: 28rpx;
  311. height: 50rpx;
  312. }
  313. }
  314. .btn {
  315. line-height: 38rpx;
  316. font-size: 24rpx;
  317. font-family: Microsoft YaHei;
  318. font-weight: 400;
  319. color: #FFFFFF;
  320. background: #00B38B;
  321. border-radius: 10rpx;
  322. padding: 10rpx 15rpx
  323. }
  324. }
  325. }
  326. .buchong-wrapper {
  327. margin-top: 60rpx;
  328. .title {
  329. font-size: 30rpx;
  330. font-family: Microsoft YaHei;
  331. font-weight: 400;
  332. color: #000000;
  333. line-height: 30rpx;
  334. }
  335. }
  336. .green-tip {
  337. margin-top: 50rpx;
  338. font-size: 24rpx;
  339. font-family: Microsoft YaHei;
  340. font-weight: 400;
  341. color: #00B38B;
  342. line-height: 24rpx;
  343. margin-bottom: 60rpx;
  344. }
  345. }
  346. .choice-takePhoto {
  347. position: absolute;
  348. bottom: 0;
  349. background-color: white;
  350. width: 100%;
  351. border-radius: 20rpx 20rpx 0 0;
  352. }
  353. .choice-takePhoto>view:first-child {
  354. text-align: center;
  355. height: 80rpx;
  356. line-height: 80rpx;
  357. border-bottom: 1rpx solid rgba(127, 127, 127, 0.3);
  358. background-color: white;
  359. }
  360. .choice-takePhoto>view:last-child {
  361. text-align: center;
  362. height: 80rpx;
  363. line-height: 80rpx;
  364. border-top: 6rpx solid rgba(127, 127, 127, 0.1);
  365. background-color: white;
  366. }
  367. .choice-takePhoto>view {
  368. text-align: center;
  369. height: 80rpx;
  370. line-height: 80rpx;
  371. background-color: white;
  372. }
  373. .choice-takePhoto-wrap {
  374. width: 100%;
  375. height: 100vh;
  376. background-color: rgba(127, 127, 127, 0.2);
  377. position: fixed;
  378. left: 0;
  379. top: 0;
  380. z-index: 11111;
  381. }
  382. </style>