index.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. import {
  2. postApprove
  3. } from '../../services/index.js'
  4. import {
  5. uploadImg
  6. } from '../../services/uploadFile.js'
  7. import {
  8. imgServerUrl,
  9. imgServerUrl_new
  10. } from '../../config/config.js'
  11. var app = getApp()
  12. Page({
  13. data: {
  14. imgServerUrl: imgServerUrl,
  15. imgServerUrl_new: imgServerUrl_new,
  16. realName: '',
  17. idNum: '',
  18. idFrontPic: '',
  19. idBackPic: '',
  20. idPersonPic: ''
  21. },
  22. onLoad: function (options) {
  23. },
  24. chooseImage(e) {
  25. let index = e.currentTarget.dataset.index
  26. var up_type;
  27. switch (index) {
  28. case 1:
  29. up_type = '1';
  30. break;
  31. case 2:
  32. up_type = '2';
  33. break;
  34. case 3:
  35. up_type = '3';
  36. break;
  37. }
  38. uploadImg(up_type).then(res => {
  39. let image = res.data.imgUrl
  40. if (index == 1) {
  41. this.setData({
  42. idFrontPic: image
  43. })
  44. } else if (index == 2) {
  45. this.setData({
  46. idBackPic: image
  47. })
  48. } else if (index == 3) {
  49. this.setData({
  50. idPersonPic: image
  51. })
  52. }
  53. })
  54. },
  55. changeName(e) {
  56. this.setData({
  57. realName: e.detail.value.trim()
  58. })
  59. },
  60. changeId(e) {
  61. this.setData({
  62. idNum: e.detail.value.trim()
  63. })
  64. },
  65. submit(e) {
  66. let {
  67. formId
  68. } = e.detail
  69. let {
  70. realName,
  71. idNum,
  72. idFrontPic,
  73. idBackPic,
  74. idPersonPic
  75. } = this.data;
  76. if (realName == "") {
  77. wx.showToast({
  78. title: '请输入姓名',
  79. icon: 'none'
  80. })
  81. return false;
  82. }
  83. if (idNum.toString().length != 18) {
  84. wx.showToast({
  85. title: '请输入18位身份证号码',
  86. icon: 'none'
  87. })
  88. return false;
  89. }
  90. if (idFrontPic == "") {
  91. wx.showToast({
  92. title: '请上传身份证正面照',
  93. icon: 'none'
  94. })
  95. return false;
  96. }
  97. if (idBackPic == "") {
  98. wx.showToast({
  99. title: '请上传身份证反面照',
  100. icon: 'none'
  101. })
  102. return false;
  103. }
  104. if (idPersonPic == "") {
  105. wx.showToast({
  106. title: '请上传手持身份证照片',
  107. icon: 'none'
  108. })
  109. return false;
  110. }
  111. wx.showLoading({
  112. title: '正在创建...',
  113. mask: true
  114. })
  115. wx.hideLoading()
  116. wx.showLoading({
  117. title: '正在提交...',
  118. mask: true
  119. })
  120. let paramsObj = {
  121. realName: realName,
  122. idCardNumber: idNum,
  123. idFrontPic: idFrontPic,
  124. idBackPic: idBackPic,
  125. idPersonPic: idPersonPic,
  126. minaType: 1, //1:代表小程序
  127. user_id: app.globalData.userId,
  128. user_token: app.globalData.userToken,
  129. member_id: app.globalData.memberId
  130. }
  131. Object.assign(paramsObj);
  132. postApprove(paramsObj).then(data => {
  133. wx.hideLoading()
  134. wx.showToast({
  135. title: '提交成功',
  136. })
  137. wx.redirectTo({
  138. url: '../result/index?type=auth&status=2',
  139. })
  140. })
  141. // 身份认证上报订阅信息
  142. wx.aldPushSubscribeMessage({
  143. eventId: '5ea25ae37739104342928e96'
  144. });
  145. },
  146. onError(err) {
  147. app.aldstat.sendEvent('报错', {
  148. 'err': err
  149. });
  150. },
  151. })