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

效果图:

相关推荐
ZC跨境爬虫13 分钟前
跟着 MDN 学CSS day_35:浮动布局完全指南
前端·css·ui·html·tensorflow
double_eggm28 分钟前
微信小程序8
微信小程序·小程序
宏笋33 分钟前
qss/css 样式中margin和padding的作用和区别
css·qt
MageGojo38 分钟前
小程序每日一谜怎么做:riddle 接口接入示例
windows·小程序·apache·谜语
kyh100338112011 小时前
Cocos Creator 《打螺丝消除游戏》源码+实现
游戏·微信小程序·小程序·打螺丝小游戏源码·微笑小游戏源码
ZC跨境爬虫12 小时前
跟着 MDN 学CSS day_29:(掌握文本与字体样式的核心艺术)
前端·css·ui·html·tensorflow
哆来A梦没有口袋14 小时前
干货精讲 | 初级CSS面试高频考题
前端·css·面试
烂不烂问厨房18 小时前
支付宝小程序camera录制视频并上传注意事项
小程序·音视频
PeanutSplsh18 小时前
wx.setStorage 存的数据,没你以为的那么安全
微信小程序
我是伪码农21 小时前
小程序125-150
小程序