// pages/family/advanced/advanced.js var app = getApp(), g = app.globalData; const util = require('../../../utils/util'); const utilSha = require('../../../utils/sha256'); Page({ /** * 页面的初始数据 */ data: { type: '', list: [], page: 1, pageSize: 10, total: 10, loadStatus: 0, // 0=>未加载 1=> 加载中 2=> 加载完 shObj: { // 驳回原因 "1": "图片不清晰", "2": "不符合要求", "3": "图片不清晰", "4": "不符合要求", }, searchKey: '', // 搜索词 tabList: [{ name: '老人活体验证', type: 1 },{ name: '验证失败记录', type: 2 }], curTab: 1, jgdm: '', jgxh: '' }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.setData({ type: options.type ? options.type : 1, jgdm: options.jgdm, jgxh: options.jgxh }) if(options.isCheck == '1') { this.setData({ curTab: 1 }) const token = wx.getStorageSync('checkToken'); const pid = wx.getStorageSync('pid'); console.log(pid); const params = { 'token': token, 'subsidyApplyVerifyPid': pid } wx.request({ url: app.globalData.apiPath + 'jumdata/lifecheck/subsidy/result', method: "POST", data: params, dataType: "JSON", success: (res)=> { wx.removeStorageSync('checkToken'); const { code, data } = JSON.parse(res.data); if(code == 200) { this.setData({ page: 1, loadStatus: 0, total: 0, list: [], curTab: 1 }) this.getCheckList() app.tips('检测成功!'); }else{ app.tips('检测失败!'); } }, error: (err)=> { wx.removeStorageSync('checkToken'); app.tips('检测失败!'); } }) }else{ this.setData({ page: 1, loadStatus: 0, total: 0, list: [] }) this.getCheckList() } }, changeTab(e) { const type = e.target.dataset.type; if(this.data.curTab == type) return; this.setData({ curTab: type }) this.setData({ page: 1, loadStatus: 0, total: 0, list: [] }) this.getCheckList() }, setKey(e) { this.setData({ searchKey: e.detail.value }) }, getCheckList: function() { let params = { "pageIndex": this.data.page, "pageSize": this.data.pageSize, "jgdm": this.data.jgdm, "jgxh": this.data.jgxh, "faceStatus": this.data.curTab } app.ajax('jjSubsidyApplyVerify/search', 'post', params, null, (res)=> { if(res.list.length >= this.data.pageSize) { this.setData({ page: this.data.page+1, loadStatus: 0, total: res.total }) }else{ this.setData({ page: this.data.page+1, loadStatus: 2 }) } this.setData({ list: [...this.data.list, ...res.list] }) },(err)=> { app.tips(err) }) }, linkTo: function() { app.justpage(`/pages/familys/advancedAdd/advancedAdd?jgdm=${this.data.jgdm}&jgxh=${this.data.jgxh}`) }, // 去验证 toCheck(e) { const dataset = e.currentTarget.dataset; const { id } = dataset; 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.jgdm}&jgxh=${this.data.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('pid', id); wx.setStorageSync('checkToken', token); app.justpage(`/pages/webView/webview?checkUrl=${encodeURIComponent(checkUrl)}`) } else { app.tips(data); } }, error: (err)=> { app.tips(err); }, }) }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { this.getCheckList() } })