加油站付款小程序,打印小票
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.5 KiB

11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
  1. import http from './http.js'
  2. const config = {
  3. //示例
  4. // getConfig: { url: '/api/getConfig', method: 'GET', limit: 500 },
  5. // 修改个人信息接口
  6. infoUpdateInfo: { url: '/cheer/info/updateInfo', method: 'POST', auth: true },
  7. // 登录接口
  8. loginLogin: { url: '/cheer/login/login', method: 'GET', },
  9. // 获取个人信息接口
  10. infoGetInfo: { url: '/cheer/info/getInfo', method: 'GET', auth: true },
  11. //下单
  12. createOrderPay: { url: '/cheer/info/createOrderPay', method: 'GET', auth: true },
  13. //获取折扣、客户电话、微信
  14. getConfig: { url: '/cheer/info/getConfig', method: 'GET'},
  15. //获取充值套餐
  16. getRechargePage: { url: '/cheer/info/getRechargePage', method: 'GET'},
  17. }
  18. export function api(key, data, callback, loadingTitle) {
  19. let req = config[key]
  20. if (!req) {
  21. console.error('无效key' + key);
  22. return
  23. }
  24. if (typeof callback == 'string') {
  25. loadingTitle = callback
  26. }
  27. if (typeof data == 'function') {
  28. callback = data
  29. data = {}
  30. }
  31. // 接口限流
  32. if (req.limit) {
  33. let storageKey = 'limit:' + req.url
  34. let storage = uni.getStorageSync(storageKey)
  35. if (storage && new Date().getTime() - parseInt(storage) < req.limit) {
  36. return
  37. }
  38. uni.setStorageSync(storageKey, new Date().getTime())
  39. }
  40. //必须登录
  41. if (req.auth) {
  42. if (!uni.getStorageSync('token')) {
  43. // uni.navigateTo({
  44. // url: '/pages/login/mobile'
  45. // })
  46. console.error('需要登录')
  47. return
  48. }
  49. }
  50. http.http(req.url, data, callback, req.method,
  51. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  52. }
  53. export default api