You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
223 lines
5.2 KiB
223 lines
5.2 KiB
const app = getApp(),
|
|
g = app.globalData;
|
|
const utils = require('../../../utils/util');
|
|
const utilSha = require('../../../utils/sha256');
|
|
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
formData: {
|
|
sfzzm: '', // 身份证正面
|
|
applyPerson: '', // 申请人
|
|
sfzh: '', // 身份证号
|
|
csrq: '', // 出生日期
|
|
domicile: '', // 户籍地
|
|
orgcode: '',
|
|
jgxh: ''
|
|
},
|
|
defaultImg: '/images/b1.png',
|
|
subFlag: false,
|
|
isConfirm: [],
|
|
maskShow: false
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
this.setData({
|
|
['formData.jgdm']: options.jgdm || '',
|
|
['formData.jgxh']: options.jgxh || '',
|
|
})
|
|
},
|
|
openRules: function(e) {
|
|
const type = e.currentTarget.dataset.type;
|
|
const url = type == 1 ? '/pages/familys/agreement/agreement' : '/pages/familys/privacy/privacy';
|
|
app.justpage(url)
|
|
},
|
|
changeSure: function(e) {
|
|
this.setData({
|
|
isConfirm: e.detail.value
|
|
})
|
|
},
|
|
changeImages(e) {
|
|
let that = this
|
|
let dataset = e.currentTarget.dataset
|
|
app.chooseImage(0,function (res) {
|
|
wx.uploadFile({
|
|
url: app.globalData.apiPath+'qny/file/wxUpload',
|
|
filePath: res[0],
|
|
name: 'file',
|
|
header: {
|
|
token:app.globalData.token
|
|
},
|
|
success (result){
|
|
wx.hideLoading()
|
|
let data=JSON.parse(result.data)
|
|
that.setData({
|
|
[`formData.sfzzm`]: data.data
|
|
})
|
|
that.getCardInfo(res[0]);
|
|
}
|
|
})
|
|
})
|
|
},
|
|
getCardInfo(file) {
|
|
let that = this;
|
|
wx.uploadFile({
|
|
url: app.globalData.apiPath+'jjSubsidyApply/client/image/upload',
|
|
filePath: file,
|
|
name: 'file',
|
|
header: {
|
|
token:app.globalData.token
|
|
},
|
|
success: (res)=>{
|
|
const result = JSON.parse(res.data);
|
|
let { code, data, msg } = result
|
|
if(code == 200) {
|
|
console.log(data.info)
|
|
that.setData({
|
|
['formData.applyPerson']: data.info.name,
|
|
["formData.sfzh"]: data.info.IDNumber,
|
|
["formData.csrq"]: `${data.info.IDNumber.substring(6,10)}-${data.info.IDNumber.substring(10,12)}-${data.info.IDNumber.substring(12,14)} 00:00:00`,
|
|
["formData.domicile"]: data.info.address
|
|
})
|
|
}else{
|
|
app.tips(msg)
|
|
}
|
|
},
|
|
fail: (err)=> {
|
|
console.log(err)
|
|
}
|
|
})
|
|
},
|
|
// 提交
|
|
confirmSubmits() {
|
|
if (this.data.isConfirm.length == 0) {
|
|
app.tips('请先阅读并同意《用户服务协议》及《隐私政策》');
|
|
return
|
|
}
|
|
if(this.data.subFlag) return;
|
|
let formData = {...this.data.formData};
|
|
const infoObj = {
|
|
sfzzm: '请上传身份证正面',
|
|
applyPerson: '请输入申请人姓名',
|
|
sfzh: '请输入身份证号',
|
|
csrq: '请输入出生日期',
|
|
domicile: '请输入户籍地'
|
|
}
|
|
try {
|
|
Object.keys(infoObj).forEach(key=> {
|
|
if(formData[key] == '') {
|
|
app.tips(infoObj[key])
|
|
throw Error(infoObj[key])
|
|
}
|
|
})
|
|
} catch (error) {
|
|
app.tips(error)
|
|
return
|
|
}
|
|
this.setData({
|
|
subFlag: true
|
|
})
|
|
app.ajax("jjSubsidyApplyVerify/verifyConfirm", 'POST', formData, '', res => {
|
|
app.tips('提交成功');
|
|
this.setData({
|
|
subFlag: false
|
|
})
|
|
this.checkInit(res);
|
|
}, err => {
|
|
app.tips(err.msg)
|
|
this.setData({
|
|
subFlag: false
|
|
})
|
|
})
|
|
},
|
|
// 活体检测初始化
|
|
checkInit(id) {
|
|
console.log(id);
|
|
const appId = '2NePzNYbzT3PegUd';
|
|
const timestamp = new Date().getTime();
|
|
const appSecret = 'fe613c2e6965f6d1c4db8dd734bb2ff7';
|
|
const str = appId + appSecret + timestamp;
|
|
const sign = utilSha.sha256_digest(str).toString();
|
|
const params = {
|
|
'appId': appId,
|
|
'timestamp': timestamp,
|
|
'sign': sign,
|
|
'returnUrl': `wx.redirect:/pages/familys/advanced/advanced?jgdm=${this.data.formData.jgdm}&jgxh=${this.data.formData.jgxh}&isCheck=1`
|
|
}
|
|
wx.request({
|
|
url: app.globalData.apiPath + 'jumdata/lifecheck/init',
|
|
method: "POST",
|
|
data: params,
|
|
dataType: "JSON",
|
|
success: (res)=> {
|
|
const { code, data } = JSON.parse(res.data);
|
|
if (code == "200") {
|
|
const {token, checkUrl} = JSON.parse(data).data;
|
|
wx.setStorageSync('checkToken', token);
|
|
console.log(id);
|
|
wx.setStorageSync('pid', id);
|
|
app.justpage(`/pages/webView/webview?checkUrl=${encodeURIComponent(checkUrl)}`)
|
|
} else {
|
|
app.tips(data);
|
|
}
|
|
},
|
|
error: (err)=> {
|
|
app.tips(err);
|
|
},
|
|
})
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage() {
|
|
|
|
}
|
|
})
|