idCard.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. const app = require('../../utils/util.js');
  2. // var util = require('../../utils/md5.js')
  3. Page({
  4. data: {
  5. imgPath: '',
  6. isTrue: true,
  7. },
  8. goShenFen() {
  9. if (!this.data.isTrue) {
  10. wx.request({
  11. url: app.globalData.publicUrl + '/applet/suppleUserInfo',
  12. method: "POST",
  13. header: {
  14. appletsId: wx.getStorageSync('openId')
  15. },
  16. data: {
  17. headPicPath: this.data.imgPath
  18. },
  19. success: (res) => {
  20. console.log(res, "111");
  21. wx.redirectTo({
  22. url: '/pages/idCardDetail/idCardDetail',
  23. })
  24. }
  25. })
  26. } else {
  27. wx.showToast({
  28. title: "请点击相机上传照片",
  29. icon: 'none',
  30. duration: 2000,
  31. })
  32. }
  33. },
  34. goPhoto() {
  35. wx.chooseImage({
  36. count: 1,
  37. sizeType: ['compressed'],
  38. sourceType: ['camera'],
  39. success: (res) => {
  40. var tempFilePaths = res.tempFilePaths
  41. wx.uploadFile({
  42. url: app.globalData.publicUrl + '/sys/user/upload',
  43. filePath: tempFilePaths[0],
  44. name: 'uploadFile',
  45. formData: {
  46. "user": "test",
  47. },
  48. header: {
  49. appletsId: wx.getStorageSync('openId'),
  50. },
  51. success: (res) => {
  52. console.log(JSON.parse(res.data), "45454545");
  53. let datas = JSON.parse(res.data)
  54. if (datas.code == 0) {
  55. this.setData({
  56. imgPath: datas.data,
  57. isTrue: false
  58. })
  59. }
  60. }
  61. })
  62. }
  63. })
  64. },
  65. closeImage(e) {
  66. this.setData({
  67. isTrue: true,
  68. imgPath: '',
  69. })
  70. },
  71. onLoad: function () {},
  72. })