requestApi.js 696 B

123456789101112131415161718192021222324252627282930
  1. import { hideLoading, showLoading } from '../utils/plugIn/globalLoading.js'
  2. import { J_STORAGE_KEY } from './constant'
  3. // const NET = require('../utils/request')
  4. const API = require('../config/api')
  5. export function doPointRequest(data) {
  6. // return NET.request(API.doPointer, data, 'post')
  7. return new Promise((resolve, reject) => {
  8. const header = {
  9. 'Content-Type': 'application/json'
  10. }
  11. const res = uni.getStorageSync(J_STORAGE_KEY)
  12. const token = res.token
  13. if (token) {
  14. header.Authorization = token
  15. }
  16. uni.request({
  17. url: API.doPointer,
  18. data,
  19. method: 'post',
  20. header,
  21. success: (res) => {
  22. resolve(res)
  23. },
  24. fail: (res) => {
  25. reject(res)
  26. }
  27. })
  28. })
  29. }