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.

user-card.vue 11KB

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