app.js 884 B

123456789101112131415161718192021222324252627282930313233343536
  1. // import third from '@/sheep/api/third';
  2. // TODO 非繁人:等后面搞 App 再弄
  3. const login = () => {
  4. return new Promise(async (resolve, reject) => {
  5. const loginRes = await uni.login({
  6. provider: 'apple',
  7. success: () => {
  8. uni.getUserInfo({
  9. provider: 'apple',
  10. success: async (res) => {
  11. if (res.errMsg === 'getUserInfo:ok') {
  12. const payload = res.userInfo;
  13. const { error } = await third.apple.login({
  14. payload,
  15. shareInfo: uni.getStorageSync('shareLog') || {},
  16. });
  17. if (error === 0) {
  18. resolve(true);
  19. } else {
  20. resolve(false);
  21. }
  22. }
  23. },
  24. });
  25. },
  26. fail: (err) => {
  27. resolve(false);
  28. },
  29. });
  30. });
  31. };
  32. export default {
  33. login,
  34. };