scan-result.js 1.7 KB

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