Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

user-card.vue 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. <template>
  2. <view class="main" :style="{height: height+'px'}">
  3. <view class="content">
  4. <view class="item-tips">
  5. <view class="title"> 上传后请核对识别信息 </view>
  6. <view class="tip"> 如有错误请及时手动修改 </view>
  7. </view>
  8. <view class="picture-wrapper" @click="takePhotoMode('1')">
  9. <view class="bg">
  10. <view class="">
  11. <view class="name"> 人像面 </view>
  12. <view class="value"> 上传身份证的人像面 </view>
  13. <view class="tip">
  14. <view class="tip-value"> 拍摄规范 </view>
  15. </view>
  16. </view>
  17. <image v-if="!state.form.userPosImgUrl" class="icon" :src="`${$imgUrl}applyCard/renxiang.png`">
  18. </image>
  19. <image v-else class="icon" :src="strReplace(state.form.userPosImgUrl)"></image>
  20. </view>
  21. </view>
  22. <view class="picture-wrapper" @click="takePhotoMode('2')">
  23. <view class="bg">
  24. <view class="">
  25. <view class="name"> 国徽面 </view>
  26. <view class="value"> 上传身份证的国徽面 </view>
  27. <view class="tip">
  28. <view class="tip-value"> 拍摄规范 </view>
  29. </view>
  30. </view>
  31. <image v-if="!state.form.userNegImgUrl" class="icon" :src="`${$imgUrl}applyCard/guohui.png`">
  32. </image>
  33. <image v-else class="icon" :src="strReplace(state.form.userNegImgUrl)"></image>
  34. </view>
  35. </view>
  36. <view class="shibie-wrapper">
  37. <view class="title"> 识别内容如下 </view>
  38. <u-form label-width="200" :model="state.form" ref="uForm">
  39. <u-form-item label="姓名">
  40. <u-input v-model="state.form.customerName" placeholder='请输入姓名' />
  41. </u-form-item>
  42. <u-form-item label="地址">
  43. <u-input placeholder='请输入地址' height='38' type='textarea' :autoHeight='true'
  44. v-model="state.form.address" />
  45. </u-form-item>
  46. <u-form-item label="手机号" class="phoneBox">
  47. <u-input placeholder='手机号' type="number" v-model="state.form.tel" maxlength="11" />
  48. <u-button type="success" size="mini" @click="getCode" v-if="waitTime==0">获取验证码</u-button>
  49. <text class="btn" v-else>{{waitTime}}后重试</text>
  50. </u-form-item>
  51. <u-form-item label="验证码">
  52. <u-input placeholder='请输入验证码' type="number" v-model="state.form.newMobileCode" />
  53. </u-form-item>
  54. </u-form>
  55. </view>
  56. <view class="green-tip">
  57. 如识别信息有误,请手动修改,确认无误后,点击下一步!
  58. </view>
  59. <view class="action">
  60. <button type="default" class="button" @click="savaHandle()">
  61. 下一步
  62. </button>
  63. </view>
  64. </view>
  65. </view>
  66. <view class="choice-takePhoto-wrap" v-if="state.isTakePhotoModeShow" @click="cancle">
  67. <view class="choice-takePhoto">
  68. <view @click.stop="takePhoto(state.choiceIndex)" style="border-radius: 20rpx 20rpx 0 0;">拍照</view>
  69. <view @click.stop="xiangce(state.choiceIndex)">从手机相册选择</view>
  70. <view @click.stop="cancle">取消</view>
  71. </view>
  72. </view>
  73. <viewfinder v-if="state.phoneType" :phoneType="state.phoneType" :images="state.images"
  74. :showStartPhoto="state.showImg" @confirmReturn="confirmReturn" @camera="camera"></viewfinder>
  75. </template>
  76. <script lang="ts" setup>
  77. import {
  78. getItem
  79. } from "@/utils/storage.ts"
  80. import {
  81. reactive,
  82. ref
  83. } from "vue";
  84. import {
  85. msg,
  86. checkStr,
  87. strReplace,
  88. uploadFile
  89. } from "@/utils/utils";
  90. import {
  91. onLoad,
  92. onShow
  93. } from "@dcloudio/uni-app";
  94. import {
  95. etcOcrCard,
  96. userInfoChange,
  97. sendCode,
  98. envs,
  99. } from "@/utils/network/api.js";
  100. import {
  101. request
  102. } from "@/utils/network/request.js";
  103. import {
  104. stringToJson
  105. } from "@/utils/network/encryption.js";
  106. import {
  107. fileURL
  108. } from "@/datas/fileURL.js";
  109. import viewfinder from "../../../../components/viewfinder.vue"
  110. const height = uni.getSystemInfoSync().windowHeight
  111. const defHeadstockImg = `${fileURL}image/applyCard/renxiang.png`;
  112. const defInstallImg = `${fileURL}image/applyCard/guohui.png`;
  113. const state = reactive({
  114. phoneType: 0, // 1 身份证正面 2 身份证反面 3行驶证正面 4行驶证反面
  115. choiceIndex: 1, // 1 身份证正面 2 身份证反面
  116. isTakePhotoModeShow: false, //选择拍照方式是否出来
  117. showImg: true,
  118. images: "",
  119. genderList: [{
  120. value: '男',
  121. label: '男'
  122. },
  123. {
  124. value: '女',
  125. label: '女'
  126. }
  127. ],
  128. codeTips: "获取验证码",
  129. form: {
  130. customerId: '', //用户编号
  131. customerName: "", //开户人姓名
  132. openId: getItem('openId'),
  133. userPosImgUrl: "", //身份证正面
  134. userNegImgUrl: "", //身份证反面
  135. tel: "", //开户人手机号
  136. address: "", //开户人地址
  137. newMobileCode: "" //手机号验证码
  138. }
  139. })
  140. const getCode = () => {
  141. console.log(123);
  142. if (checkStr(state.form.tel, "mobile")) {
  143. sendCodeApi()
  144. codeInterval()
  145. } else {
  146. uni.showToast({
  147. title: '请输入正确的手机号',
  148. icon: 'none'
  149. });
  150. }
  151. }
  152. let waitTime = ref(0)
  153. //倒计时函数
  154. const codeInterval = () => {
  155. waitTime.value = 60
  156. let timer = setInterval(() => {
  157. if (waitTime.value == 1) {
  158. clearInterval(timer)
  159. }
  160. waitTime.value -= 1
  161. }, 1000)
  162. }
  163. // 发送验证码
  164. const sendCodeApi = (type) => {
  165. //参数说明
  166. let options = {
  167. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  168. data: {
  169. mobile: state.form.tel
  170. }, //请求参数
  171. method: "POST", //提交方式(默认POST)
  172. showLoading: true, //是否显示加载中(默认显示)
  173. };
  174. //调用方式
  175. request(sendCode, options)
  176. .then((res) => {
  177. let data = stringToJson(res.bizContent)
  178. console.log(data, "#################");
  179. if (data.info == "成功.") {
  180. console.log('######################CCCCCCCCCCCCCCCCC');
  181. }
  182. })
  183. .catch((err) => {
  184. console.log(err);
  185. });
  186. }
  187. //下一步
  188. const savaHandle = () => {
  189. console.log(state.form);
  190. if (!state.form.userPosImgUrl) {
  191. msg("请上传身份证正面")
  192. return;
  193. }
  194. if (!state.form.userNegImgUrl) {
  195. msg("请上传身份证反面")
  196. return;
  197. }
  198. if (!state.form.customerName) {
  199. msg("请输入姓名")
  200. return;
  201. }
  202. if (!state.form.address) {
  203. msg("请输入地址")
  204. return;
  205. }
  206. if (!checkStr(state.form.tel, "mobile")) {
  207. msg("请输入正确的手机号")
  208. return;
  209. }
  210. if (!state.form.newMobileCode) {
  211. msg("请输入验证码")
  212. return;
  213. }
  214. const options = {
  215. type: 2,
  216. data: state.form,
  217. method: "POST",
  218. showLoading: true,
  219. };
  220. request(userInfoChange, options).then((res) => {
  221. const data = JSON.parse(res.bizContent)
  222. msg('个人信息变更成功')
  223. setTimeout(() => {
  224. uni.navigateBack({
  225. delta: 1
  226. });
  227. }, 1500)
  228. console.log(data);
  229. });
  230. }
  231. onLoad((options) => {
  232. console.log(options.customerId);
  233. state.form.customerId = options.customerId
  234. })
  235. const takePhotoMode = (index) => {
  236. console.log("index", index)
  237. state.isTakePhotoModeShow = true
  238. state.choiceIndex = index
  239. }
  240. const camera = () => {
  241. state.phoneType = 0
  242. }
  243. const xiangce = (val) => {
  244. console.log("val", val)
  245. var imageType = val;
  246. uni.chooseImage({
  247. count: 1, //只能选取一张照片
  248. sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
  249. sourceType: ["album"], //从相册选择
  250. success: function (res) {
  251. state.showImg = false
  252. state.images = res.tempFilePaths[0]
  253. state.phoneType = state.choiceIndex
  254. state.isTakePhotoModeShow = false
  255. },
  256. })
  257. }
  258. const takePhoto = (val) => {
  259. console.log("拍照", val)
  260. state.phoneType = val;
  261. state.showImg = true;
  262. }
  263. const confirmReturn = (val) => {
  264. state.phoneType = 0
  265. state.isTakePhotoModeShow = false
  266. var imageType = state.choiceIndex;
  267. console.log("图片地址val", val.tempImagePath)
  268. uploadFile(val.tempImagePath, imageType, etcOcrCard).then((data) => {
  269. if (state.choiceIndex === "1") {
  270. state.form.customerName = data.name;
  271. state.form.userPosImgUrl = data.imageUrl;
  272. state.form.address = data.address;
  273. } else {
  274. state.form.customerIdVld = data.enddate;
  275. state.form.userNegImgUrl = data.imageUrl;
  276. }
  277. state.isTakePhotoModeShow = false
  278. })
  279. }
  280. const cancle = () => {
  281. state.isTakePhotoModeShow = false
  282. }
  283. </script>
  284. <style>
  285. page {
  286. background: #eef7f7;
  287. }
  288. </style>
  289. <style lang="scss" scoped>
  290. ::v-deep .u-size-mini {
  291. white-space: nowrap;
  292. }
  293. .main {
  294. .content {
  295. padding: 50rpx 30rpx 50rpx 30rpx;
  296. .action {
  297. padding-left: 20rpx;
  298. padding-right: 20rpx;
  299. padding-bottom: 30rpx;
  300. .button {
  301. height: 80rpx;
  302. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  303. border-radius: 40rpx;
  304. font-size: 32rpx;
  305. font-weight: 400;
  306. color: #ffffff;
  307. line-height: 80rpx;
  308. }
  309. }
  310. .item-tips {
  311. .title {
  312. font-size: 30rpx;
  313. font-family: Microsoft YaHei;
  314. font-weight: 400;
  315. color: #000000;
  316. line-height: 24rpx;
  317. }
  318. .tip {
  319. margin-top: 16rpx;
  320. font-size: 24rpx;
  321. font-family: Microsoft YaHei;
  322. font-weight: 400;
  323. color: #999999;
  324. line-height: 24rpx;
  325. }
  326. }
  327. .picture-wrapper {
  328. margin-top: 40rpx;
  329. .bg {
  330. background: #ffffff;
  331. box-shadow: 0rpx 4rpx 13rpx 3rpx rgba(223, 223, 223, 0.8);
  332. border-radius: 20rpx;
  333. padding: 40rpx;
  334. display: flex;
  335. justify-content: space-between;
  336. .name {
  337. font-size: 34rpx;
  338. font-family: Microsoft YaHei;
  339. font-weight: 400;
  340. color: #000000;
  341. line-height: 34rpx;
  342. }
  343. .value {
  344. margin-top: 20rpx;
  345. font-size: 24rpx;
  346. font-family: Microsoft YaHei;
  347. font-weight: 400;
  348. color: #999999;
  349. line-height: 24rpx;
  350. }
  351. .tip {
  352. margin-top: 20rpx;
  353. text-align: center;
  354. width: 110rpx;
  355. height: 40rpx;
  356. background: rgba(33, 190, 177, 0.2);
  357. border-radius: 6rpx;
  358. .tip-value {
  359. font-size: 20rpx;
  360. font-family: Microsoft YaHei;
  361. font-weight: 400;
  362. color: #0a8f8a;
  363. line-height: 40rpx;
  364. opacity: 1;
  365. }
  366. }
  367. }
  368. .icon {
  369. width: 294rpx;
  370. height: 188rpx;
  371. }
  372. }
  373. .shibie-wrapper {
  374. margin-top: 40rpx;
  375. background: #fff;
  376. padding: 40rpx 30rpx;
  377. border-radius: 20rpx;
  378. box-shadow: 0 4rpx 13rpx 3rpx rgba(223, 223, 223, .8);
  379. .title {
  380. font-size: 30rpx;
  381. font-family: Microsoft YaHei;
  382. font-weight: 400;
  383. color: #000000;
  384. line-height: 30rpx;
  385. }
  386. .phoneBox {
  387. ::v-deep .u-form-item--right__content__slot {
  388. display: flex;
  389. .btn {
  390. flex: 1;
  391. background: transparent;
  392. font-size: 30rpx;
  393. color: #15E5C1;
  394. z-index: 999;
  395. }
  396. }
  397. }
  398. }
  399. .buchong-wrapper {
  400. margin-top: 60rpx;
  401. .title {
  402. font-size: 30rpx;
  403. font-family: Microsoft YaHei;
  404. font-weight: 400;
  405. color: #000000;
  406. line-height: 30rpx;
  407. }
  408. }
  409. .green-tip {
  410. margin-top: 50rpx;
  411. font-size: 24rpx;
  412. font-family: Microsoft YaHei;
  413. font-weight: 400;
  414. color: #00b38b;
  415. line-height: 24rpx;
  416. margin-bottom: 60rpx;
  417. }
  418. }
  419. }
  420. .choice-takePhoto {
  421. position: absolute;
  422. bottom: 0;
  423. background-color: white;
  424. width: 100%;
  425. border-radius: 20rpx 20rpx 0 0;
  426. }
  427. .choice-takePhoto>view:first-child {
  428. text-align: center;
  429. height: 80rpx;
  430. line-height: 80rpx;
  431. border-bottom: 1rpx solid rgba(127, 127, 127, 0.3);
  432. background-color: white;
  433. }
  434. .choice-takePhoto>view:last-child {
  435. text-align: center;
  436. height: 80rpx;
  437. line-height: 80rpx;
  438. border-top: 6rpx solid rgba(127, 127, 127, 0.1);
  439. background-color: white;
  440. }
  441. .choice-takePhoto>view {
  442. text-align: center;
  443. height: 80rpx;
  444. line-height: 80rpx;
  445. background-color: white;
  446. }
  447. .choice-takePhoto-wrap {
  448. width: 100%;
  449. height: 100vh;
  450. background-color: rgba(127, 127, 127, 0.2);
  451. position: fixed;
  452. left: 0;
  453. top: 0;
  454. z-index: 11111;
  455. }
  456. </style>