index.js 967 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /**
  2. * Created by JianJia.Zhou<jianjia.zhou> on 2022/8/14.
  3. */
  4. import { getToken } from '../../utils/auth'
  5. const request = uni.$u.http
  6. export async function login() {
  7. console.log('-->data', 1)
  8. return new Promise(resolve => {
  9. uni.showLoading({
  10. title: '数据加载中...',
  11. mask: true
  12. })
  13. uni.login({
  14. provider: uni.$u.platform,
  15. success: loginRes => {
  16. console.log('-->data', loginRes)
  17. uni.hideLoading()
  18. const url = '/auth/kuaishou'
  19. return request.post(
  20. url,
  21. { code: loginRes.code, anonymousCode: loginRes.anonymousCode }
  22. ).then(res => {
  23. resolve(res)
  24. })
  25. }
  26. })
  27. })
  28. }
  29. export function update(data) {
  30. return request.post(
  31. 'user/update',
  32. data
  33. )
  34. }
  35. export async function info() {
  36. return request.get(
  37. 'user/info'
  38. )
  39. }
  40. export function isLogin() {
  41. return !!getToken()
  42. }
  43. export default {
  44. login,
  45. update,
  46. info,
  47. isLogin
  48. }