zfbThree.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import {
  2. request
  3. } from '@/utils/request'
  4. const getZFBThree = function(callback = null) {
  5. my.getAuthCode({
  6. scopes: 'auth_user',
  7. success: function(res) {
  8. const authCode = res.authCode
  9. uni.showLoading({
  10. title: "加载中..."
  11. })
  12. request({
  13. url: 'https://ldb-permit.hz-hanghui.com:8088/hanghui/outapi/alipayApi/faceAuth/common/getAlipayUserInfo',
  14. method: 'POST',
  15. data: {
  16. authCode: authCode,
  17. appId: getApp().globalData.appId
  18. },
  19. dataType: 'json',
  20. header: {
  21. 'Content-type': 'application/json'
  22. },
  23. success: res => {
  24. uni.hideLoading()
  25. const result = {}
  26. if (res.data) {
  27. result.code = 200
  28. result.data = {
  29. username: res.data.userName,
  30. idNumber: res.data.certNo,
  31. phone: res.data.mobile,
  32. userId: res.data.userId,
  33. avatar: res.data.avatar || null,
  34. personPictures: res.data.personPictures || null,
  35. photoBase64: res.data.photoBase64 || null
  36. }
  37. result.msg = '授权成功!'
  38. } else {
  39. result.code = 500
  40. result.data = null
  41. result.msg = res.errmsg || '授权失败!'
  42. }
  43. if (callback) {
  44. callback(result)
  45. }
  46. },
  47. fail: res => {
  48. uni.hideLoading()
  49. }
  50. })
  51. }
  52. })
  53. }
  54. module.exports = {
  55. getZFBThree
  56. }