Adegreein.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. const app = getApp();
  2. Page({
  3. data: {
  4. //身份证手持页
  5. // 上传的案例图片集合
  6. scsfzImages: [],
  7. // 案例图片数目是否达到了最大数目
  8. scsfzImagesNum: false, //加号图标 显示
  9. scsfzimg: true, //上传图片 隐藏
  10. scsfzinitial: true, //初始图片 隐藏
  11. // 设置上传案例图片的最大数目
  12. maxImages: 1,
  13. img1: '', //手持身份证
  14. initial: [], //头部信息
  15. SubmissionHidden: true, //提交隐藏显示
  16. },
  17. onLoad: function (options) {
  18. var that = this;
  19. // // 获取信息
  20. let initial_url = 'my/authentication/educationchange';
  21. let initial_data = {
  22. };
  23. app.postRequest(initial_url, initial_data, function (res) {
  24. if (res.code == 201) {
  25. console.log(res.data.status);
  26. that.setData({
  27. initial: res.data, // 初始数据
  28. initialcode: res, //获取未上传状态
  29. })
  30. }
  31. if (res.data.status == 2) { //如果审核未通过 显示提交按钮
  32. that.setData({
  33. SubmissionHidden: false
  34. })
  35. } else if (res.code != 201) {
  36. that.setData({
  37. SubmissionHidden: false
  38. })
  39. }else{
  40. that.setData({
  41. SubmissionHidden: true
  42. })
  43. }
  44. })
  45. },
  46. // 上传学历
  47. scsfzclick: function (e) {
  48. var _this = this;
  49. wx.chooseImage({
  50. count: 1,
  51. sizeType: ['original', 'compressed'],
  52. sourceType: ['album', 'camera'],
  53. success(res) {
  54. let tempFilesSize = res.tempFiles[0].size;
  55. if (tempFilesSize > 1024 * 1024 * 3) {
  56. wx.showModal({
  57. title: '提示',
  58. content: '图片不得超过3MB',
  59. showCancel: false,
  60. })
  61. return;
  62. }
  63. _this.setData({
  64. scsfzImages: res.tempFilePaths[0],
  65. scsfzImagesNum: true,
  66. scsfzimg: false,
  67. img1: res.tempFilePaths[0],
  68. });
  69. }
  70. })
  71. },
  72. // //最后提交认证
  73. Submission: function (e) {
  74. var _this =this;
  75. console.log(this.data.img1)
  76. if (this.data.img1 == '') {
  77. var _qrcode = '请上传学历证明'
  78. getApp().Tips(_qrcode);
  79. }else{
  80. // console.log(this.data.img1)
  81. //上传图片
  82. wx.uploadFile({
  83. url: app.globalData.url + 'my/authentication/education',
  84. filePath: this.data.img1,
  85. name: 'img1',
  86. formData: {
  87. key: wx.getStorageSync('access_key'),
  88. token: wx.getStorageSync('access_token')
  89. },
  90. success: function (res) {
  91. var data = JSON.parse(res.data);
  92. if (data.code == 201) {
  93. wx.showToast({
  94. title: '提交成功',
  95. icon: 'success',
  96. duration: 2000
  97. })
  98. _this.onLoad();
  99. return
  100. }
  101. var _qrcode = data.msg
  102. getApp().Tips(_qrcode);
  103. }, fail: function (d) {
  104. wx.showToast({ //这里提示失败
  105. title: '上传失败',
  106. icon: 'none', // 不显示图标
  107. duration: 2000
  108. })
  109. }
  110. })
  111. }
  112. },
  113. })