common.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import http from '@/utils/http'
  2. // const appId = uni.getAccountInfoSync().miniProgram.appId
  3. export function loginByCode(data) {
  4. return new Promise((resolve, reject) => {
  5. uni.login({
  6. provider: 'weixin',
  7. success: function(res) {
  8. http.post('wxMini/login', {
  9. code: res.code,
  10. }, {
  11. isAuth: false,
  12. showLoading: false
  13. }).then(res => {
  14. resolve(res)
  15. }).catch(err => {
  16. reject(err)
  17. })
  18. }
  19. })
  20. })
  21. }
  22. export function login(data) {
  23. return http.post('user/login', data)
  24. }
  25. export function wxLogin(data) {
  26. return new Promise((resolve, reject) => {
  27. uni.login({
  28. provider: 'weixin',
  29. success: function(res) {
  30. http.post('wxMini/authLogin', {
  31. encryptedData: data.encryptedData,
  32. ivStr: data.iv,
  33. userInfo: JSON.stringify(data.userInfo),
  34. code: res.code,
  35. }, {
  36. isAuth: false,
  37. loadingTitle: '登录中...'
  38. }).then(res => {
  39. resolve(res)
  40. }).catch(err => {
  41. reject(err)
  42. })
  43. }
  44. })
  45. })
  46. }
  47. export function logout(data) {
  48. return http.post('user/logout', data)
  49. }
  50. // 意见反馈
  51. export function addAdvice(data) {
  52. return http.post('user/advice', data)
  53. }
  54. export function getAdviceList() {
  55. return http.get('user/advice/list')
  56. }
  57. // 版本信息
  58. export function getVersionList(data) {
  59. return http.get('user/version', data)
  60. }
  61. // 通讯录
  62. export function getAddrbookList() {
  63. return http.get('user/advice/list')
  64. }
  65. // 协议、隐私
  66. export function getPolicy() {
  67. return http.get('user/privacyPolicy')
  68. }
  69. export function getAgreement() {
  70. return http.get('user/userServiceAgreement')
  71. }