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

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