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 8.5KB

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