使用微信小程序版Vant的upload组件上传身份证的样式自定义方案(Css魔改版)

使用微信小程序版Vant的upload组件上传身份证的样式自定义方案(Css魔改版)

wxml文件:

xml 复制代码
 <van-cell-group>
     <van-cell required title="身份证人像面" label="反面|B面,不能把两面合成一张图片一起上传" title-width="6.5em" class="idcard-uploader">
         <van-uploader name="file_list_b" file-list="{{ file_list_b }}" bind:after-read="afterReadFile" bind:delete="deleteFile" image-fit="aspectFit" accept="image" max-count="1" upload-text="上传人像面" upload-icon="https://www.xxxx.com/test/idcardB.jpg" />
     </van-cell>
     <van-cell required title="身份证国徽面" label="正面|A面,不能把两面合成一张图片一起上传" title-width="6.5em" class="idcard-uploader" border="{{ !1 }}">
         <van-uploader name="file_list_a" file-list="{{ file_list_a }}" bind:after-read="afterReadFile" bind:delete="deleteFile" image-fit="aspectFit" accept="image" max-count="1" upload-text="上传国徽面" upload-icon="https://www.xxxx.com/test/idcardA.jpg" />
     </van-cell>
     <van-cell title-width="6.5em" border="{{ !1 }}">
         <van-button type="default" icon="certificate" bind:click="ocrIdcard" disabled="{{ocr_certificate_disabled}}" block>识别身份证并自动填入信息</van-button>
     </van-cell>
</van-cell-group>

wxss文件:

css 复制代码
.idcard-uploader .van-uploader__upload,
.idcard-uploader .van-image,
.idcard-uploader .van-uploader__preview-image {
    width: 44vw !important;
    height: 110px !important;
}

.idcard-uploader .van-uploader__upload-text {
    margin-top: 8px;
    color: #969799;
    font-size: 12px;
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 30px;
    line-height: 30px;
    background: #FF8C00;
    color: #fff;
    text-align: center;
}

.idcard-uploader .van-uploader__upload,
.idcard-uploader .van-image {
    background: #FDF5E6;
    border-radius: 10px;
    overflow: hidden;
}

.idcard-uploader .van-icon--image,
.idcard-uploader .van-icon__image {
    width: 4em;
    height: 3em;
    -o-object-fit: contain;
    object-fit: contain;
    margin-bottom: 23px;
}

效果图:

相关推荐
焦糖玛奇朵婷3 分钟前
盲盒小程序开发|解锁开箱新体验[特殊字符]
大数据·开发语言·程序人生·小程序·软件需求
左师佑图24 分钟前
微信小程序组件事件冒泡问题排查与解决方案
微信小程序·小程序
Greg_Zhong1 小时前
Css知识之伪类和伪元素
前端·css
树下水月1 小时前
微信小程序接口,必须使用https的443端口吗?
微信小程序·小程序·https
毕设源码-邱学长2 小时前
【开题答辩全过程】以 灵山水牛奶配送小程序的设计与实现为例,包含答辩的问题和答案
小程序
2501_915918412 小时前
基于Mach-O文件的动态库与静态库归属方案及API扫描实践
android·ios·小程序·https·uni-app·iphone·webview
2501_915106322 小时前
iOS 证书无法跨电脑使用?签名迁移方法一文讲透
android·ios·小程序·https·uni-app·iphone·webview
余瑜鱼鱼鱼2 小时前
css常用功能总结(三)(Chrome 调试工具 -- 查看 CSS 属性)
前端·css·chrome
毕设源码-赖学姐2 小时前
【开题答辩全过程】以 基于springboot的酒店预订小程序自动化订制系统为例,包含答辩的问题和答案
运维·小程序·自动化
Dxy12393102162 小时前
HTML常用CSS样式推荐:打造高效、美观的网页设计
前端·css·html