zfb_getThree.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. const _my = require("../../__antmove/api/index.js")(my);
  2. const wx = _my;
  3. const util = require("../func/request");
  4. const {
  5. throttle
  6. } = require("../throttle/throttle")
  7. //根据auth-code获取用户三要素
  8. const getThree = throttle(function(callback = null) {
  9. my.getAuthCode({
  10. scopes: 'auth_user',
  11. success: function(res) {
  12. const authCode = res.authCode
  13. wx.showLoading({
  14. title: "加载中..."
  15. })
  16. util.request_wxrlxf({
  17. url: "https://ldb-permit.hz-hanghui.com:8088/hanghui/outapi/alipayApi/faceAuth/getAlipayUserInfo",
  18. data: {authCode: authCode},
  19. method: "post",
  20. type: "application/json"
  21. }).then(res => {
  22. wx.hideLoading()
  23. const result = {}
  24. if(res.data) {
  25. result.code = 200
  26. result.data = {
  27. username: res.data.userName,
  28. idNumber: res.data.certNo,
  29. phone: res.data.mobile,
  30. userId: res.data.userId,
  31. avatar: res.data.avatar || null,
  32. personPictures: res.data.personPictures || null,
  33. photoBase64: res.data.photoBase64 || null
  34. }
  35. result.msg = '授权成功!'
  36. } else {
  37. result.code = 500
  38. result.data = null
  39. result.msg = res.errmsg || '授权失败!'
  40. }
  41. if(callback) {
  42. callback(result)
  43. }
  44. })
  45. }
  46. })
  47. }, 5000)
  48. module.exports = getThree