使用微信小程序版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;
}

效果图:

相关推荐
千寻技术帮17 小时前
基于微信小程序的家政服务系统(源码+脚本+文档)_50039
mysql·微信小程序·小程序·毕业设计·家政服务
GuWenyue18 小时前
z-index 写到 9999 还是被盖住:把层叠上下文的 6 个反例全复现了一遍
前端·css·浏览器
cooldream200918 小时前
计算机专业本科毕业设计系列05——类型②:移动应用与小程序
小程序·毕业设计·课程设计
愚公搬代码19 小时前
【愚公系列】《微信小程序项目实战(AI编程+视频图解)》045-项目实战:使用 AI 编程工具辅助实现我的订单页面
人工智能·微信小程序·ai编程
qinqinzqq21 小时前
CSS Grid 命名区域布局:组件 Header / Content / Sider 两栏布局实践
前端·css
源码手记21 小时前
基于微信小程序的购物商城系统-毕设源码
微信小程序·小程序·课程设计
SXkehuirongsheng21 小时前
太原做小程序定制的服务商是否支持源码交付?
小程序
Mh1 天前
基于踩过的坑,浅聊一下vh、svh、lvh、dvh
前端·css·设计模式
社会渣渣2 天前
开发者工具正常、真机白屏:一次渲染差异排查
微信小程序
daguanren2 天前
一个页面外壳,多页复用:weapp-vite / Wevu 布局的编译与动态切换
微信小程序