|
|
<template> <view class="lf-w-100 lf-h-100"> <view class="lf-row-between lf-p-t-30 lf-p-b-30 lf-p-l-32 lf-p-r-32 title-border"> <view class="input-title"> <text style="color: #E21196;">*</text> <text class="lf-m-l-10" style="color: #131315;">真实姓名</text> </view> <view> <input type="text" placeholder="请填写真实姓名" style="text-align: right;" /> </view> </view> <view class="lf-row-between lf-p-t-30 lf-p-b-30 lf-p-l-32 lf-p-r-32"> <view class="input-title"> <text style="color: #E21196;">*</text> <text class="lf-m-l-10" style="color: #131315;">身份证号</text> </view> <view> <input type="text" placeholder="请填写身份证号" style="text-align: right;" /> </view> </view> <view class="flr"></view> <view> <view class="lf-color-777 lf-font-32 lf-p-t-30 lf-p-b-30 lf-p-l-32"> 请根据示例图上传清晰照片 </view> <view class="authen-pic"> <view> <image src="../../static/logo.png" mode="aspectFill" style="width: 200rpx;height: 135rpx;"></image> </view> <view @tap="ChooseImage"> <view> <u-icon name="camera-fill" style="font-size: 80rpx;"></u-icon> </view> <view class="lf-color-999 lf-font-24">点击上传照片</view> </view> </view> </view> <view class="lf-row-center lf-font-28 lf-m-t-20"> <text style="color: #E21196;">*</text><text class="lf-m-l-10 lf-color-222">上传身份证正面</text> </view> <view class="authen-pic" style="margin-top: 60rpx;"> <view> <image src="../../static/logo.png" mode="aspectFill" style="width: 200rpx;height: 135rpx;"></image> </view> <view @tap="ChooseImage"> <view> <u-icon name="camera-fill" style="font-size: 80rpx;"></u-icon> </view> <view class="lf-color-999 lf-font-24">点击上传照片</view> </view> </view> <view class="lf-row-center lf-font-28 lf-m-t-20"> <text style="color: #E21196;">*</text><text class="lf-m-l-10 lf-color-222">上传身份证反面</text> </view> <view class="apply-btn"> 申请认证 </view> </view> </template>
<script> export default { data() { return { hostImg: '', frontPic: '', backPic: '' } }, methods: { checkImgInfo(tempFilePath, suc){ uni.getImageInfo({ src: tempFilePath, success (res) { let type = res.type; console.log('checkImgInfo...', type); if(type == 'png' || type == 'jpeg' || type == 'jpg'){ suc && suc(true); } else { suc && suc(false); } }, fail(err) { suc && suc(false); } }) }, // 选择图片
ChooseImage(e) { let that = this; uni.chooseImage({ count: 1, sizeType: ['original'], // 可以指定是原图original还是压缩图compressed ,默认二者都有
sourceType: ['album', 'camera'], // album 从相册选图,camera 使用相机,默认二者都有
success: res => { that.hostImg = res.tempFilePaths[0]; let tempFile = res.tempFiles.shift(); let tempFilePath = res.tempFilePaths.shift(); console.log('临时路径',res) that.checkImgInfo(tempFilePath, (res) => { // 过滤不是图片不是png、jpeg 格式
if(res){ if(tempFile.size > 10000000){ uni.showModal({ title: '', content: '您选择的图片过大:'+ (tempFile.size / 1024000).toFixed(2) +"M,请点击确定重新上传", success: res2 => { if(res2.confirm){ uni.chooseImage({ count: 1, sizeType: ['compressed'], sourceType: ['album', 'camera'], success: (res3) => { console.log(res3) let tempFilePath = res3.tempFilePaths.shift(); that.frontPic = res3.tempFilePaths that.is_wx_reduce = true; } }) } } }) } else{ that.frontPic = res3.tempFilePaths } } else { uni.showModal({ title: '', content: '选择的图片须为jpg、jpeg或png格式', showCancel: false, confirmColor: '#1697EE' }) } }); } }); }, // 上传图片到服务器
upload(url){ let that = this; let uploads = []; // 商品banner图上传
if (that.img_list.length > 0) { for (let i = 0; i < that.img_list.length; i++) { let upload_img = new Promise((resolve, reject) => { that.uploadFile(that.img_list[i], (res) => { resolve(res); }, (err) => { reject(err); }); }) uploads.push(upload_img); } } if(uploads.length == 0) { that.realSubmitInfo([]); return } Promise.all(uploads).then((result) => { let img_url_list = []; if(result.length > 0){ img_url_list = result; } if(img_url_list) { that.realSubmitInfo(img_url_list); } }).catch(err => { that.is_publish = false; // 恢复提交按钮
uni.showModal({ title: '', content: '图片上传失败,请重新提交', confirmColor: '#1697EE' }) }) }, } }</script>
<style> .apply-btn { width: 686rpx; height: 100rpx; background: #E21196; border-radius: 60rpx; margin: 0 auto; font-size: 36rpx; color: white; display: flex; justify-content: center; align-items: center; margin-top: 60rpx; } .flr{ width: 100%; height: 20rpx; background: #F5F5F5; } .title-border { border-bottom: 1rpx solid rgba(0,0,0,0.1); border-top: 1rpx solid rgba(0,0,0,0.1) ; } .input-title { font-size: 32rpx; color: #131315; display: flex; justify-content: center; align-items: center; } .authen-pic { width: 686rpx; height: 349rpx; background: #F5F5F5; border-radius: 10rpx; margin: 0 auto; display: flex; flex-direction: column; justify-content: space-around; align-items: center; text-align: center; }</style>
|