選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

base-change-people.vue 8.2KB

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