1.点击上传并识别
组件样式<van-field border="{{ false }}" placeholder="请输入银行卡卡号" model:value="{{bankNo}}" label="卡号"><van-icon bindtap="handleChooseImg" slot="right-icon" name="scan" class="custom-icon" /></van-field>view .van-field__control {text-align: right;
}
方法handleChooseImg(){wx.chooseImage({count: 1,sourceType: ['album'],success: (res) => {let temp_path = res.tempFilePaths[0];console.log(temp_path);const _this = thiswx.uploadFile({filePath: temp_path, 文件路径 按后端接口参数修改name: 'file', 传过去的文件名url: 后端接口,success: (res) => {let data = JSON.parse(res.data)if (data.code === 200) {_this.getBankCardOcr(data.data.fullFilePath)} else {wx.showToast({title: '上传失败',icon: 'none',duration: 2000});}wx.hideLoading()},fail: () => {console.log("失败...");}})}})},OCR识别getBankCardOcr(imageUrl) {wx.showLoading()util.request(commonLoan.bankCardOcr, {imageUrl}, 'GET').then((res) => {wx.hideLoading() }).catch(err => {})},
2.一个方法监听多个checkbox打开pdf
场景:多个checkbox,我觉得要一个一个写bindchange事件太杂糅
样式代码<view style=" display: flex;text-align: left; margin: 10rpx 0 10rpx 40rpx; font-size: 26rpx;line-height: 44rpx"><van-checkbox style="position: relative; top: 6rpx;" icon-size="25rpx" shape="square" value="{{check1}}" data-index='1' bindchange="changeCheck2"></van-checkbox><view style="color: #999;font-size: 13px"> 阅读并同意签署<text style="color:rgb(98, 78, 255);font-size: 13px;" bindtap="openUrl" data-num='h5012'>《个人授权书》</text>(适用于零售信贷线上业务个人征信授权)</view>
</view>
change事件changeCheck2(e) {this.setData({['check' + e.currentTarget.dataset.index]: e.detail})if (this.data.check1 && this.data.check2 && this.data.check3 && this.data.check4 && this.data.check5) {this.setData({checkAll: true})} else {this.setData({checkAll: false})}},