scan-result.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import { VueLikePage } from '../../../utils/page'
  2. import UserApi from '../../../apis/user'
  3. import Router from '../../../utils/routes'
  4. VueLikePage([], {
  5. data: {
  6. isLoading: true,
  7. detail: {}
  8. },
  9. methods: {
  10. onLoad (options) {
  11. this.handle(options.filePath)
  12. },
  13. bindinput (e) {
  14. const { value } = e.detail
  15. const { key } = e.currentTarget.dataset
  16. const detail = this.data.detail
  17. detail[key] = value
  18. this.setData({
  19. detail
  20. })
  21. },
  22. handle (filePath) {
  23. wx.uploadFile({
  24. filePath: filePath,
  25. name: 'file',
  26. url: `http://39.108.220.65:8075/app/viewer/recognizeBusinessCard`,
  27. formData: {
  28. viewerId: getApp().globalData.userinfo.viewerId
  29. },
  30. success: (res) => {
  31. const data = JSON.parse(res.data)
  32. const aliyunRsp = data.data.aliyunRsp
  33. const detail = {
  34. name: aliyunRsp.name,
  35. companyAddress: aliyunRsp.addresses.join(),
  36. companyName: aliyunRsp.companies.join(),
  37. email: aliyunRsp.emails.join(),
  38. phoneNum: aliyunRsp.cellPhoneNumbers.join(),
  39. telNum: aliyunRsp.officePhoneNumbers.join(),
  40. companyPosition: aliyunRsp.titles.join(),
  41. picUrl: data.data.picUrl,
  42. fromScan: 1
  43. }
  44. this.setData({
  45. isLoading: false,
  46. detail: detail
  47. })
  48. },
  49. fail (err) {
  50. console.log(err, 'err')
  51. }
  52. })
  53. },
  54. createCard () {
  55. return UserApi.createVisitCard(this.data.detail).then(res => {
  56. Router.push('businessCard')
  57. })
  58. }
  59. }
  60. })