index.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. console.log('jj', index)
  27. var up_type;
  28. switch (index) {
  29. case 1:
  30. up_type = '1';
  31. break;
  32. case 2:
  33. up_type = '2';
  34. break;
  35. case 3:
  36. up_type = '3';
  37. break;
  38. }
  39. uploadImg(up_type).then(res => {
  40. console.log("hh", res.data)
  41. let image = res.data.imgUrl
  42. if (index == 1) {
  43. this.setData({
  44. idFrontPic: image
  45. })
  46. } else if (index == 2) {
  47. this.setData({
  48. idBackPic: image
  49. })
  50. } else if (index == 3) {
  51. this.setData({
  52. idPersonPic: image
  53. })
  54. }
  55. })
  56. },
  57. changeName(e) {
  58. this.setData({
  59. realName: e.detail.value.trim()
  60. })
  61. },
  62. changeId(e) {
  63. console.log(e)
  64. this.setData({
  65. idNum: e.detail.value.trim()
  66. })
  67. },
  68. submit(e) {
  69. console.log('form发生了submit事件,事件数据为:', e)
  70. let {
  71. formId
  72. } = e.detail
  73. let {
  74. realName,
  75. idNum,
  76. idFrontPic,
  77. idBackPic,
  78. idPersonPic
  79. } = this.data
  80. if (realName == "") {
  81. wx.showToast({
  82. title: '请输入姓名',
  83. icon: 'none'
  84. })
  85. return false;
  86. }
  87. if (idNum.toString().length != 18) {
  88. wx.showToast({
  89. title: '请输入18位身份证号码',
  90. icon: 'none'
  91. })
  92. return false;
  93. }
  94. if (idFrontPic == "") {
  95. wx.showToast({
  96. title: '请上传身份证正面照',
  97. icon: 'none'
  98. })
  99. return false;
  100. }
  101. if (idBackPic == "") {
  102. wx.showToast({
  103. title: '请上传身份证反面照',
  104. icon: 'none'
  105. })
  106. return false;
  107. }
  108. if (idPersonPic == "") {
  109. wx.showToast({
  110. title: '请上传手持身份证照片',
  111. icon: 'none'
  112. })
  113. return false;
  114. }
  115. wx.showLoading({
  116. title: '正在创建...',
  117. mask: true
  118. })
  119. wx.hideLoading()
  120. wx.showLoading({
  121. title: '正在提交...',
  122. mask: true
  123. })
  124. let paramsObj = {
  125. realName: realName,
  126. idCardNumber: idNum,
  127. idFrontPic: idFrontPic,
  128. idBackPic: idBackPic,
  129. idPersonPic: idPersonPic,
  130. minaType: 1, //1:代表小程序
  131. user_id: app.globalData.userId,
  132. user_token: app.globalData.userToken,
  133. member_id: app.globalData.memberId
  134. }
  135. Object.assign(paramsObj);
  136. postApprove(paramsObj).then(data => {
  137. console.log("11", data)
  138. wx.hideLoading()
  139. wx.showToast({
  140. title: '提交成功',
  141. })
  142. wx.redirectTo({
  143. url: '../result/index?type=auth&status=2',
  144. })
  145. })
  146. },
  147. onError(err) {
  148. app.aldstat.sendEvent('报错', {
  149. 'err': err
  150. });
  151. },
  152. })