idCard.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. var that = this;
  36. wx.chooseImage({
  37. count: 1,
  38. sizeType: ['compressed'],
  39. sourceType: ['camera'],
  40. success: function (res) {
  41. var tempFilePaths = res.tempFilePaths
  42. wx.uploadFile({
  43. url: app.globalData.publicUrl + '/sys/user/upload',
  44. filePath: tempFilePaths[0],
  45. name: 'uploadFile',
  46. formData: {
  47. "user": "test",
  48. },
  49. header: {
  50. appletsId: wx.getStorageSync('openId'),
  51. },
  52. success: function (res) {
  53. console.log(JSON.parse(res.data), "45454545");
  54. let datas = JSON.parse(res.data)
  55. if (datas.code == 0) {
  56. that.setData({
  57. imgPath: datas.data,
  58. isTrue: false
  59. })
  60. }
  61. }
  62. })
  63. }
  64. })
  65. },
  66. closeImage(e) {
  67. this.setData({
  68. isTrue: true,
  69. imgPath: '',
  70. })
  71. },
  72. onLoad: function () {},
  73. })