智慧申请系统
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.

222 lines
5.2 KiB

  1. const app = getApp(),
  2. g = app.globalData;
  3. const utils = require('../../../utils/util');
  4. const utilSha = require('../../../utils/sha256');
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. formData: {
  11. sfzzm: '', // 身份证正面
  12. applyPerson: '', // 申请人
  13. sfzh: '', // 身份证号
  14. csrq: '', // 出生日期
  15. domicile: '', // 户籍地
  16. orgcode: '',
  17. jgxh: ''
  18. },
  19. defaultImg: '/images/b1.png',
  20. subFlag: false,
  21. isConfirm: [],
  22. maskShow: false
  23. },
  24. /**
  25. * 生命周期函数--监听页面加载
  26. */
  27. onLoad(options) {
  28. this.setData({
  29. ['formData.jgdm']: options.jgdm || '',
  30. ['formData.jgxh']: options.jgxh || '',
  31. })
  32. },
  33. openRules: function(e) {
  34. const type = e.currentTarget.dataset.type;
  35. const url = type == 1 ? '/pages/familys/agreement/agreement' : '/pages/familys/privacy/privacy';
  36. app.justpage(url)
  37. },
  38. changeSure: function(e) {
  39. this.setData({
  40. isConfirm: e.detail.value
  41. })
  42. },
  43. changeImages(e) {
  44. let that = this
  45. let dataset = e.currentTarget.dataset
  46. app.chooseImage(0,function (res) {
  47. wx.uploadFile({
  48. url: app.globalData.apiPath+'qny/file/wxUpload',
  49. filePath: res[0],
  50. name: 'file',
  51. header: {
  52. token:app.globalData.token
  53. },
  54. success (result){
  55. wx.hideLoading()
  56. let data=JSON.parse(result.data)
  57. that.setData({
  58. [`formData.sfzzm`]: data.data
  59. })
  60. that.getCardInfo(res[0]);
  61. }
  62. })
  63. })
  64. },
  65. getCardInfo(file) {
  66. let that = this;
  67. wx.uploadFile({
  68. url: app.globalData.apiPath+'jjSubsidyApply/client/image/upload',
  69. filePath: file,
  70. name: 'file',
  71. header: {
  72. token:app.globalData.token
  73. },
  74. success: (res)=>{
  75. const result = JSON.parse(res.data);
  76. let { code, data, msg } = result
  77. if(code == 200) {
  78. console.log(data.info)
  79. that.setData({
  80. ['formData.applyPerson']: data.info.name,
  81. ["formData.sfzh"]: data.info.IDNumber,
  82. ["formData.csrq"]: `${data.info.IDNumber.substring(6,10)}-${data.info.IDNumber.substring(10,12)}-${data.info.IDNumber.substring(12,14)} 00:00:00`,
  83. ["formData.domicile"]: data.info.address
  84. })
  85. }else{
  86. app.tips(msg)
  87. }
  88. },
  89. fail: (err)=> {
  90. console.log(err)
  91. }
  92. })
  93. },
  94. // 提交
  95. confirmSubmits() {
  96. if (this.data.isConfirm.length == 0) {
  97. app.tips('请先阅读并同意《用户服务协议》及《隐私政策》');
  98. return
  99. }
  100. if(this.data.subFlag) return;
  101. let formData = {...this.data.formData};
  102. const infoObj = {
  103. sfzzm: '请上传身份证正面',
  104. applyPerson: '请输入申请人姓名',
  105. sfzh: '请输入身份证号',
  106. csrq: '请输入出生日期',
  107. domicile: '请输入户籍地'
  108. }
  109. try {
  110. Object.keys(infoObj).forEach(key=> {
  111. if(formData[key] == '') {
  112. app.tips(infoObj[key])
  113. throw Error(infoObj[key])
  114. }
  115. })
  116. } catch (error) {
  117. app.tips(error)
  118. return
  119. }
  120. this.setData({
  121. subFlag: true
  122. })
  123. app.ajax("jjSubsidyApplyVerify/verifyConfirm", 'POST', formData, '', res => {
  124. app.tips('提交成功');
  125. this.setData({
  126. subFlag: false
  127. })
  128. this.checkInit(res);
  129. }, err => {
  130. app.tips(err.msg)
  131. this.setData({
  132. subFlag: false
  133. })
  134. })
  135. },
  136. // 活体检测初始化
  137. checkInit(id) {
  138. console.log(id);
  139. const appId = '2NePzNYbzT3PegUd';
  140. const timestamp = new Date().getTime();
  141. const appSecret = 'fe613c2e6965f6d1c4db8dd734bb2ff7';
  142. const str = appId + appSecret + timestamp;
  143. const sign = utilSha.sha256_digest(str).toString();
  144. const params = {
  145. 'appId': appId,
  146. 'timestamp': timestamp,
  147. 'sign': sign,
  148. 'returnUrl': `wx.redirect:/pages/familys/advanced/advanced?jgdm=${this.data.formData.jgdm}&jgxh=${this.data.formData.jgxh}&isCheck=1`
  149. }
  150. wx.request({
  151. url: app.globalData.apiPath + 'jumdata/lifecheck/init',
  152. method: "POST",
  153. data: params,
  154. dataType: "JSON",
  155. success: (res)=> {
  156. const { code, data } = JSON.parse(res.data);
  157. if (code == "200") {
  158. const {token, checkUrl} = JSON.parse(data).data;
  159. wx.setStorageSync('checkToken', token);
  160. console.log(id);
  161. wx.setStorageSync('pid', id);
  162. app.justpage(`/pages/webView/webview?checkUrl=${encodeURIComponent(checkUrl)}`)
  163. } else {
  164. app.tips(data);
  165. }
  166. },
  167. error: (err)=> {
  168. app.tips(err);
  169. },
  170. })
  171. },
  172. /**
  173. * 生命周期函数--监听页面初次渲染完成
  174. */
  175. onReady() {
  176. },
  177. /**
  178. * 生命周期函数--监听页面显示
  179. */
  180. onShow() {
  181. },
  182. /**
  183. * 生命周期函数--监听页面隐藏
  184. */
  185. onHide() {
  186. },
  187. /**
  188. * 生命周期函数--监听页面卸载
  189. */
  190. onUnload() {
  191. },
  192. /**
  193. * 页面相关事件处理函数--监听用户下拉动作
  194. */
  195. onPullDownRefresh() {
  196. },
  197. /**
  198. * 页面上拉触底事件的处理函数
  199. */
  200. onReachBottom() {
  201. },
  202. /**
  203. * 用户点击右上角分享
  204. */
  205. onShareAppMessage() {
  206. }
  207. })