<template>
<gracePage headerBG="#FFFFFF" :customHeader="false">
<view slot="gBody" class="grace-body">
<view class="grace-idcard-desc grace-margin-top">
描述示例文本 : graceUI 极速开发之旅 ! 基于 uni-app 的优秀前端框架,大幅度提高布局效率!
</view>
<view class="grace-title grace-margin-top">身份证照片 ( 个人信息面 )</view>
<view class="grace-idcard-items grace-img-in grace-rows grace-flex-center">
<image class="grace-idcard-items-image" :src="idCard1" @tap="selectImg1" mode="widthFix"></image>
</view>
<view class="grace-title grace-margin-top">身份证照片 ( 国徽图案面 )</view>
<view class="grace-idcard-items grace-img-in grace-rows grace-flex-center">
<image class="grace-idcard-items-image" :src="idCard2" @tap="selectImg2" mode="widthFix"></image>
</view>
<view style="margin-top:50rpx;">
<button type="primary" class="grace-button grace-border-radius" @tap="uploadCards">上传</button>
</view>
</view>
</gracePage>
</template>
<script>
import gracePage from "../../graceUI/components/gracePage.vue";
export default {
data() {
return {
idCard1 : 'https://lanhu.oss-cn-beijing.aliyuncs.com/ps2cd8e5feb924c1f4-b826-4dcd-a986-c338a92b57db',
idCard2 : 'https://lanhu.oss-cn-beijing.aliyuncs.com/ps8f524a9bcb0ab440-6a40-408d-86a1-64d365a2168a'
};
},
methods:{
selectImg1 : function() {
uni.chooseImage({
count:1,
success:(res) => {
this.idCard1 = res.tempFilePaths[0];
}
})
},
selectImg2 : function() {
uni.chooseImage({
count:1,
success:(res)=>{
this.idCard2 = res.tempFilePaths[0];
}
})
},
uploadCards : function(){
if(
this.idCard1 == 'https://lanhu.oss-cn-beijing.aliyuncs.com/ps2cd8e5feb924c1f4-b826-4dcd-a986-c338a92b57db' ||
this.idCard2 == 'https://lanhu.oss-cn-beijing.aliyuncs.com/ps8f524a9bcb0ab440-6a40-408d-86a1-64d365a2168a'
){
uni.showToast({title:"请选择身份证照片", icon:"none"});
return;
}
// 临时文件地址保存在 this.idCard1 和 this.idCard2
// 请调用 uni.uploadFile api 完成上传工作
}
},
components:{gracePage}
}
</script>
<style>
page{background:#F8F8F8;}
.grace-idcard-main{margin:25rpx;}
.grace-idcard-desc{background-color:#FFFFFF; color:#666666; line-height:56rpx; font-size:26rpx; padding:20rpx; border-radius:10rpx;}
.grace-idcard-text{line-height:1.8em; margin-top:30rpx; color:#666666;}
.grace-idcard-items{background-color:#FFFFFF; padding:50rpx; border-radius:10rpx; margin-top:15rpx;}
.grace-idcard-items-image{width:398rpx;}
</style>
<template>
<gracePage headerBG="#FFFFFF" :customHeader="false">
<view slot="gBody" class="grace-body">
<text class="grace-idcard-desc grace-margin-top">描述示例文本 : graceUI 极速开发之旅 ! 基于 uni-app 的优秀前端框架,大幅度提高布局效率! </text>
<text class="grace-title grace-margin-top">身份证照片 ( 个人信息面 )</text>
<view class="grace-idcard-items grace-img-in grace-rows grace-flex-center">
<image class="grace-idcard-items-image" :src="idCard1" @tap="selectImg1" mode="widthFix"></image>
</view>
<text class="grace-title grace-margin-top">身份证照片 ( 国徽图案面 )</text>
<view class="grace-idcard-items grace-img-in grace-rows grace-flex-center">
<image class="grace-idcard-items-image" :src="idCard2" @tap="selectImg2" mode="widthFix"></image>
</view>
<view style="margin-top:50rpx;">
<button type="primary" class="grace-button grace-border-radius" @tap="uploadCards">上传</button>
</view>
</view>
</gracePage>
</template>
<script>
import gracePage from "../../graceUI/weexComponents/gracePage.nvue";
export default {
data() {
return {
idCard1 : 'https://lanhu.oss-cn-beijing.aliyuncs.com/ps2cd8e5feb924c1f4-b826-4dcd-a986-c338a92b57db',
idCard2 : 'https://lanhu.oss-cn-beijing.aliyuncs.com/ps8f524a9bcb0ab440-6a40-408d-86a1-64d365a2168a'
};
},
methods:{
selectImg1 : function() {
uni.chooseImage({
count:1,
success:(res) => {
this.idCard1 = res.tempFilePaths[0];
}
})
},
selectImg2 : function() {
uni.chooseImage({
count:1,
success:(res)=>{
this.idCard2 = res.tempFilePaths[0];
}
})
},
uploadCards : function(){
if(
this.idCard1 == 'https://lanhu.oss-cn-beijing.aliyuncs.com/ps2cd8e5feb924c1f4-b826-4dcd-a986-c338a92b57db' ||
this.idCard2 == 'https://lanhu.oss-cn-beijing.aliyuncs.com/ps8f524a9bcb0ab440-6a40-408d-86a1-64d365a2168a'
){
uni.showToast({title:"请选择身份证照片", icon:"none"});
return;
}
// 临时文件地址保存在 this.idCard1 和 this.idCard2
// 请调用 uni.uploadFile api 完成上传工作
}
},
components:{gracePage}
}
</script>
<style>
.grace-idcard-main{margin:25rpx;}
.grace-idcard-desc{background-color:#F8F8F8; color:#666666; line-height:56rpx; font-size:26rpx; padding:20rpx; border-radius:10rpx;}
.grace-idcard-text{line-height:1.8em; margin-top:30rpx; color:#666666;}
.grace-idcard-items{background-color:#F8F8F8; padding:50rpx; border-radius:10rpx; margin-top:15rpx;}
.grace-idcard-items-image{width:398rpx; height:258rpx;}
</style>
.wxml
<gracePage headerBG="#FFFFFF" customHeader="{{false}}">
<view slot="gBody" class="grace-body">
<view class="grace-idcard-desc grace-margin-top">
描述示例文本 : graceUI 极速开发之旅 ! 基于 uni-app 的优秀前端框架,大幅度提高布局效率!
</view>
<view class="grace-title grace-margin-top">身份证照片 ( 个人信息面 )</view>
<view class="grace-idcard-items grace-img-in grace-rows grace-flex-center">
<image class="grace-idcard-items-image" src="{{idCard1}}" bindtap="selectImg1" mode="widthFix"></image>
</view>
<view class="grace-title grace-margin-top">身份证照片 ( 国徽图案面 )</view>
<view class="grace-idcard-items grace-img-in grace-rows grace-flex-center">
<image class="grace-idcard-items-image" src="{{idCard2}}" bindtap="selectImg2" mode="widthFix"></image>
</view>
<view style="margin-top:50rpx;">
<button type="primary" class="grace-button grace-border-radius" bindtap="uploadCards">上传</button>
</view>
</view>
</gracePage>.wxss
page{background:#F8F8F8;}
.grace-idcard-main{margin:25rpx;}
.grace-idcard-desc{background-color:#FFFFFF; color:#666666; line-height:56rpx; font-size:26rpx; padding:20rpx; border-radius:10rpx;}
.grace-idcard-text{line-height:1.8em; margin-top:30rpx; color:#666666;}
.grace-idcard-items{background-color:#FFFFFF; padding:50rpx; border-radius:10rpx; margin-top:15rpx;}
.grace-idcard-items-image{width:398rpx;}.js
Page({
data: {
idCard1: 'https://lanhu.oss-cn-beijing.aliyuncs.com/ps2cd8e5feb924c1f4-b826-4dcd-a986-c338a92b57db',
idCard2: 'https://lanhu.oss-cn-beijing.aliyuncs.com/ps8f524a9bcb0ab440-6a40-408d-86a1-64d365a2168a'
},
selectImg1: function () {
wx.chooseImage({
count: 1,
success: (res) => {
this.setData({ idCard1: res.tempFilePaths[0] });
}
})
},
selectImg2: function () {
wx.chooseImage({
count: 1,
success: (res) => {
this.setData({ idCard2: res.tempFilePaths[0] });
}
})
},
uploadCards: function () {
if (
this.data.idCard1 == 'https://lanhu.oss-cn-beijing.aliyuncs.com/ps2cd8e5feb924c1f4-b826-4dcd-a986-c338a92b57db' ||
this.data.idCard2 == 'https://lanhu.oss-cn-beijing.aliyuncs.com/ps8f524a9bcb0ab440-6a40-408d-86a1-64d365a2168a'
) {
wx.showToast({ title: "请选择身份证照片", icon: "none" });
return;
}
// 临时文件地址保存在 this.data.idCard1 和 this.data.idCard2
// 请调用 wx.uploadFile api 完成上传工作
}
}).json
{
"usingComponents": {
"gracePage": "../../graceUI/components/gracePage"
}
}