|
|
@@ -6,23 +6,29 @@ import {
|
|
|
uploadImg
|
|
|
} from '../../services/uploadFile.js'
|
|
|
import {
|
|
|
+ apiUrl
|
|
|
+} from '../../config/config.js'
|
|
|
+import { url } from '../../api/api'
|
|
|
+import {
|
|
|
imgServerUrl,
|
|
|
imgServerUrl_new
|
|
|
} from '../../config/config.js'
|
|
|
import { isIDNum } from '../../utils/base'
|
|
|
var app = getApp()
|
|
|
const ocrSdk = require("../../ocrsdk/index");
|
|
|
-
|
|
|
+const fs = wx.getFileSystemManager()
|
|
|
Page({
|
|
|
data: {
|
|
|
imgServerUrl: imgServerUrl,
|
|
|
imgServerUrl_new: imgServerUrl_new,
|
|
|
realName: '',
|
|
|
idNum: '',
|
|
|
+ nation: '',
|
|
|
idFrontPic: '',
|
|
|
idBackPic: '',
|
|
|
idPersonPic: '',
|
|
|
showMessage: false,
|
|
|
+ showPass: false,
|
|
|
message: '',
|
|
|
canUpdate: false,
|
|
|
from: '',
|
|
|
@@ -51,6 +57,11 @@ Page({
|
|
|
showMessage: !this.data.showMessage
|
|
|
})
|
|
|
},
|
|
|
+ changeShowPass() {
|
|
|
+ this.setData({
|
|
|
+ showPass: !this.data.showPass
|
|
|
+ })
|
|
|
+ },
|
|
|
testCanUpdate() {
|
|
|
let {
|
|
|
realName,
|
|
|
@@ -97,22 +108,65 @@ Page({
|
|
|
case 1:
|
|
|
up_type = '1';
|
|
|
this.setData({
|
|
|
- realName: data.Name,
|
|
|
- idNum: data.IdNum,
|
|
|
- idFrontPic: 'data:image/jpeg;base64,' + JSON.parse(data.AdvancedInfo).IdCard
|
|
|
+ idFrontPic: false
|
|
|
+ }, _ => {
|
|
|
+ fs.unlink({
|
|
|
+ filePath: this.data.idFrontPic,
|
|
|
+ complete: () => {
|
|
|
+ const filePath = `${wx.env.USER_DATA_PATH}/identificationIdFrontPic${new Date().getTime()}.png`
|
|
|
+ fs.writeFile({
|
|
|
+ filePath,
|
|
|
+ data: JSON.parse(data.AdvancedInfo).IdCard,
|
|
|
+ encoding: 'base64',
|
|
|
+ success: res => {
|
|
|
+ this.setData({
|
|
|
+ realName: data.Name,
|
|
|
+ idNum: data.IdNum,
|
|
|
+ nation: data.Nation,
|
|
|
+ idFrontPic: filePath
|
|
|
+ })
|
|
|
+ this.testCanUpdate()
|
|
|
+ },
|
|
|
+ fail: (res) => {
|
|
|
+ console.log(res)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
})
|
|
|
break;
|
|
|
case 2:
|
|
|
up_type = '2';
|
|
|
this.setData({
|
|
|
- idBackPic: 'data:image/jpeg;base64,' + JSON.parse(data.AdvancedInfo).IdCard
|
|
|
+ idBackPic: false
|
|
|
+ }, _ => {
|
|
|
+ fs.unlink({
|
|
|
+ filePath: `${wx.env.USER_DATA_PATH}/identificationIdBackPic.png`,
|
|
|
+ complete: () => {
|
|
|
+ const filePath = `${wx.env.USER_DATA_PATH}/identificationIdBackPic${new Date().getTime()}.png`
|
|
|
+ fs.writeFile({
|
|
|
+ filePath,
|
|
|
+ data: JSON.parse(data.AdvancedInfo).IdCard,
|
|
|
+ encoding: 'base64',
|
|
|
+ success: res => {
|
|
|
+ this.setData({
|
|
|
+ idBackPic: filePath
|
|
|
+ })
|
|
|
+ this.testCanUpdate()
|
|
|
+ },
|
|
|
+ fail: (res) => {
|
|
|
+ console.log(res)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
})
|
|
|
break;
|
|
|
case 3:
|
|
|
up_type = '3';
|
|
|
break;
|
|
|
}
|
|
|
- this.testCanUpdate()
|
|
|
+
|
|
|
// uploadImg(up_type).then(res => {
|
|
|
// let image = res.data.imgUrl
|
|
|
// if (index == 1) {
|
|
|
@@ -150,13 +204,14 @@ Page({
|
|
|
this.testCanUpdate()
|
|
|
})
|
|
|
},
|
|
|
- submit(e) {
|
|
|
+ async submit(e) {
|
|
|
this.testCanUpdate();
|
|
|
let {
|
|
|
realName,
|
|
|
idNum,
|
|
|
idFrontPic,
|
|
|
idBackPic,
|
|
|
+ nation,
|
|
|
// idPersonPic
|
|
|
} = this.data;
|
|
|
if (realName == "") {
|
|
|
@@ -208,13 +263,22 @@ Page({
|
|
|
idCardNumber: idNum,
|
|
|
idFrontPic: idFrontPic,
|
|
|
idBackPic: idBackPic,
|
|
|
+ nation: nation,
|
|
|
// idPersonPic: idPersonPic,
|
|
|
minaType: 1, //1:代表小程序
|
|
|
user_id: app.globalData.userId,
|
|
|
user_token: app.globalData.userToken,
|
|
|
member_id: app.globalData.memberId
|
|
|
}
|
|
|
- Object.assign(paramsObj);
|
|
|
+ const idFrontPicPath = paramsObj.idFrontPic
|
|
|
+ paramsObj.idFrontPic = await this.uploadFile(1, idFrontPicPath)
|
|
|
+
|
|
|
+ fs.unlinkSync(idFrontPicPath)
|
|
|
+ const idBackPicPath = paramsObj.idFrontPic
|
|
|
+ paramsObj.idBackPic = await this.uploadFile(2, idBackPicPath)
|
|
|
+
|
|
|
+ fs.unlinkSync(idBackPicPath)
|
|
|
+
|
|
|
postApprove(paramsObj).then(data => {
|
|
|
wx.hideLoading()
|
|
|
wx.showToast({
|
|
|
@@ -224,12 +288,17 @@ Page({
|
|
|
wx.redirectTo({
|
|
|
url: '../result/index?type=auth&status=2&from=clock',
|
|
|
})
|
|
|
+ // this.setData({
|
|
|
+ // showPass: true,
|
|
|
+ // message: '您的实名认证已通过'
|
|
|
+ // })
|
|
|
return
|
|
|
}
|
|
|
wx.redirectTo({
|
|
|
url: '../result/index?type=auth&status=2',
|
|
|
})
|
|
|
}).catch(data => {
|
|
|
+ wx.hideLoading()
|
|
|
if (data.errcode === 2100) {
|
|
|
this.setData({
|
|
|
showMessage: true,
|
|
|
@@ -240,7 +309,7 @@ Page({
|
|
|
if (data.errcode === 2101) {
|
|
|
this.setData({
|
|
|
showMessage: true,
|
|
|
- message: '您的身份证已实名认证,无需重复认证'
|
|
|
+ message: '您已实名认证,无需重复认证'
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
@@ -250,6 +319,29 @@ Page({
|
|
|
eventId: '5ea25ae37739104342928e96'
|
|
|
});
|
|
|
},
|
|
|
+ uploadFile(up_type, filePath) {
|
|
|
+ return new Promise((reslove, reject) => {
|
|
|
+ wx.uploadFile({
|
|
|
+ url: apiUrl + url.imgUp,
|
|
|
+ filePath,
|
|
|
+ name: 'file',
|
|
|
+ header: {},
|
|
|
+ formData: {
|
|
|
+ up_type,
|
|
|
+ user_id: wx.getStorageSync("user_id"),
|
|
|
+ user_token: wx.getStorageSync("user_token"),
|
|
|
+ member_id: wx.getStorageSync("member_id")
|
|
|
+ },
|
|
|
+ success: (res) => {
|
|
|
+ let data = JSON.parse(res.data)
|
|
|
+ reslove(data.data.imgUrl)
|
|
|
+ },
|
|
|
+ fail: () => {
|
|
|
+ reject()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
ocrSdkStart(type) {
|
|
|
return new Promise((reslove, reject) => {
|
|
|
ocrSdk.start({
|
|
|
@@ -269,7 +361,7 @@ Page({
|
|
|
}
|
|
|
},
|
|
|
cameraConfig: {
|
|
|
- autoMode: true,
|
|
|
+ autoMode: false,
|
|
|
maxTry: 3,
|
|
|
disableAlbum: false
|
|
|
},
|
|
|
@@ -286,12 +378,6 @@ Page({
|
|
|
}
|
|
|
wx.navigateBack({
|
|
|
delta: 1,
|
|
|
- success: () => {
|
|
|
- wx.showToast({
|
|
|
- icon: 'success',
|
|
|
- title: '识别成功',
|
|
|
- })
|
|
|
- }
|
|
|
})
|
|
|
},
|
|
|
fail: (error) => {
|
|
|
@@ -305,14 +391,9 @@ Page({
|
|
|
backStatus: false
|
|
|
})
|
|
|
}
|
|
|
- wx.navigateBack({
|
|
|
- delta: 1,
|
|
|
- success: () => {
|
|
|
- wx.showToast({
|
|
|
- icon: 'none',
|
|
|
- title: '识别失败',
|
|
|
- })
|
|
|
- }
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: error.Error.Message + ',请重试!',
|
|
|
})
|
|
|
}
|
|
|
})
|