You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

uploadCorpPhoto.js 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * @Author: gaorf30153 gaorf30153@hundsun.com
  3. * @Date: 2024-06-18 10:39:19
  4. * @LastEditors: gaorf30153 gaorf30153@hundsun.com
  5. * @LastEditTime: 2024-06-24 16:00:17
  6. * @FilePath: \issuer-plugin\plugin\components\pickerTime\pickerTime.js
  7. * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  8. */
  9. import Api from "../../api/index.js"
  10. import { requestFnc } from "../../utils/request.js"
  11. import { getStore, setStore } from "../../utils/index.js"
  12. Component({
  13. properties: {
  14. type: {
  15. type: Number,
  16. value: 1,
  17. },
  18. },
  19. data: {
  20. isLoading: false,
  21. sides: 1,
  22. leftPath: "",
  23. rightPath: "",
  24. identity: {},
  25. },
  26. attached: function () {},
  27. methods: {
  28. //选择图片
  29. chooseImage(e) {
  30. console.log(e.currentTarget.dataset.side)
  31. this.setData({
  32. sides: e.currentTarget.dataset.side,
  33. })
  34. this.compressRef = this.selectComponent("#compress")
  35. this.compressRef._changImg()
  36. },
  37. ////图片压缩成功
  38. compressRes(file) {
  39. this.setData({
  40. isLoading: true,
  41. })
  42. //正面
  43. this.setData({
  44. leftPath: file.detail[0],
  45. })
  46. let imgStr = this.data.leftPath.split(";")[1].split(",")[1]
  47. this.triggerEvent("leftImage", imgStr)
  48. let data = {
  49. filename: Api.ocrCorp.filename,
  50. data: {
  51. imageStr: imgStr,
  52. vehicleId: getStore("vehicleId"),
  53. },
  54. }
  55. requestFnc(
  56. Api.ocrCorp.url,
  57. data,
  58. (res) => {
  59. let corpInfoObj = JSON.parse(res.encryptedData)
  60. corpInfoObj.imageId = res.imageId
  61. for (let key in corpInfoObj) {
  62. this.data.identity[key] = corpInfoObj[key]
  63. }
  64. this.setData({
  65. isLoading: false,
  66. identity: this.data.identity,
  67. })
  68. // setStore("corpInfo", this.data.identity)
  69. this.triggerEvent("ocrInfo", this.data.identity)
  70. },
  71. (msg) => {
  72. this.setData({
  73. isLoading: false,
  74. })
  75. }
  76. )
  77. },
  78. viewImage(e) {
  79. wx.previewImage({
  80. urls: [e.currentTarget.dataset.type],
  81. })
  82. },
  83. delImg(e) {
  84. let data = e.currentTarget.dataset.type
  85. wx.showModal({
  86. title: "提示",
  87. content: "确定要删除此照片吗?",
  88. success: (res) => {
  89. if (res.confirm) {
  90. this.setData({
  91. leftPath: "",
  92. })
  93. this.triggerEvent("delImg")
  94. }
  95. },
  96. })
  97. },
  98. },
  99. })