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

185 lines
4.5 KiB

  1. // pages/family/advanced/advanced.js
  2. var app = getApp(),
  3. g = app.globalData;
  4. const util = require('../../../utils/util');
  5. const utilSha = require('../../../utils/sha256');
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. type: '',
  12. list: [],
  13. page: 1,
  14. pageSize: 10,
  15. total: 10,
  16. loadStatus: 0, // 0=>未加载 1=> 加载中 2=> 加载完
  17. shObj: { // 驳回原因
  18. "1": "图片不清晰",
  19. "2": "不符合要求",
  20. "3": "图片不清晰",
  21. "4": "不符合要求",
  22. },
  23. searchKey: '', // 搜索词
  24. tabList: [{
  25. name: '老人活体验证',
  26. type: 1
  27. },{
  28. name: '验证失败记录',
  29. type: 2
  30. }],
  31. curTab: 1,
  32. jgdm: '',
  33. jgxh: ''
  34. },
  35. /**
  36. * 生命周期函数--监听页面加载
  37. */
  38. onLoad(options) {
  39. this.setData({
  40. type: options.type ? options.type : 1,
  41. jgdm: options.jgdm,
  42. jgxh: options.jgxh
  43. })
  44. if(options.isCheck == '1') {
  45. this.setData({
  46. curTab: 1
  47. })
  48. const token = wx.getStorageSync('checkToken');
  49. const pid = wx.getStorageSync('pid');
  50. console.log(pid);
  51. const params = {
  52. 'token': token,
  53. 'subsidyApplyVerifyPid': pid
  54. }
  55. wx.request({
  56. url: app.globalData.apiPath + 'jumdata/lifecheck/subsidy/result',
  57. method: "POST",
  58. data: params,
  59. dataType: "JSON",
  60. success: (res)=> {
  61. wx.removeStorageSync('checkToken');
  62. const { code, data } = JSON.parse(res.data);
  63. if(code == 200) {
  64. this.setData({
  65. page: 1,
  66. loadStatus: 0,
  67. total: 0,
  68. list: [],
  69. curTab: 1
  70. })
  71. this.getCheckList()
  72. app.tips('检测成功!');
  73. }else{
  74. app.tips('检测失败!');
  75. }
  76. },
  77. error: (err)=> {
  78. wx.removeStorageSync('checkToken');
  79. app.tips('检测失败!');
  80. }
  81. })
  82. }else{
  83. this.setData({
  84. page: 1,
  85. loadStatus: 0,
  86. total: 0,
  87. list: []
  88. })
  89. this.getCheckList()
  90. }
  91. },
  92. changeTab(e) {
  93. const type = e.target.dataset.type;
  94. if(this.data.curTab == type) return;
  95. this.setData({
  96. curTab: type
  97. })
  98. this.setData({
  99. page: 1,
  100. loadStatus: 0,
  101. total: 0,
  102. list: []
  103. })
  104. this.getCheckList()
  105. },
  106. setKey(e) {
  107. this.setData({
  108. searchKey: e.detail.value
  109. })
  110. },
  111. getCheckList: function() {
  112. let params = {
  113. "pageIndex": this.data.page,
  114. "pageSize": this.data.pageSize,
  115. "jgdm": this.data.jgdm,
  116. "jgxh": this.data.jgxh,
  117. "faceStatus": this.data.curTab
  118. }
  119. app.ajax('jjSubsidyApplyVerify/search', 'post', params, null, (res)=> {
  120. if(res.list.length >= this.data.pageSize) {
  121. this.setData({
  122. page: this.data.page+1,
  123. loadStatus: 0,
  124. total: res.total
  125. })
  126. }else{
  127. this.setData({
  128. page: this.data.page+1,
  129. loadStatus: 2
  130. })
  131. }
  132. this.setData({
  133. list: [...this.data.list, ...res.list]
  134. })
  135. },(err)=> {
  136. app.tips(err)
  137. })
  138. },
  139. linkTo: function() {
  140. app.justpage(`/pages/familys/advancedAdd/advancedAdd?jgdm=${this.data.jgdm}&jgxh=${this.data.jgxh}`)
  141. },
  142. // 去验证
  143. toCheck(e) {
  144. const dataset = e.currentTarget.dataset;
  145. const { id } = dataset;
  146. const appId = '2NePzNYbzT3PegUd';
  147. const timestamp = new Date().getTime();
  148. const appSecret = 'fe613c2e6965f6d1c4db8dd734bb2ff7';
  149. const str = appId + appSecret + timestamp;
  150. const sign = utilSha.sha256_digest(str).toString();
  151. const params = {
  152. 'appId': appId,
  153. 'timestamp': timestamp,
  154. 'sign': sign,
  155. 'returnUrl': `wx.redirect:/pages/familys/advanced/advanced?jgdm=${this.data.jgdm}&jgxh=${this.data.jgxh}&isCheck=1`
  156. }
  157. wx.request({
  158. url: app.globalData.apiPath + 'jumdata/lifecheck/init',
  159. method: "POST",
  160. data: params,
  161. dataType: "JSON",
  162. success: (res)=> {
  163. const { code, data } = JSON.parse(res.data);
  164. if (code == "200") {
  165. const {token, checkUrl} = JSON.parse(data).data;
  166. wx.setStorageSync('pid', id);
  167. wx.setStorageSync('checkToken', token);
  168. app.justpage(`/pages/webView/webview?checkUrl=${encodeURIComponent(checkUrl)}`)
  169. } else {
  170. app.tips(data);
  171. }
  172. },
  173. error: (err)=> {
  174. app.tips(err);
  175. },
  176. })
  177. },
  178. /**
  179. * 页面上拉触底事件的处理函数
  180. */
  181. onReachBottom() {
  182. this.getCheckList()
  183. }
  184. })