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.3KB

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