加油站付款小程序,打印小票
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.

71 lines
1.8 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
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, limit : 2000 },
  13. //获取折扣、客户电话、微信
  14. getConfig: { url: '/cheer/info/getConfig', method: 'GET'},
  15. //获取充值套餐
  16. getRechargePage: { url: '/cheer/info/getRechargePage', method: 'GET'},
  17. //获取加油流水订单
  18. getOrderWaterPage: { url: '/cheer/info/getOrderWaterPage', method: 'GET'},
  19. //获取隐私政策
  20. getPrivacyPolicy: { url: '/cheer/login/getPrivacyPolicy', method: 'GET'},
  21. //获取用户协议
  22. getUserAgreement: { url: '/cheer/login/getUserAgreement', method: 'GET'},
  23. }
  24. export function api(key, data, callback, loadingTitle) {
  25. let req = config[key]
  26. if (!req) {
  27. console.error('无效key' + key);
  28. return
  29. }
  30. if (typeof callback == 'string') {
  31. loadingTitle = callback
  32. }
  33. if (typeof data == 'function') {
  34. callback = data
  35. data = {}
  36. }
  37. // 接口限流
  38. if (req.limit) {
  39. let storageKey = 'limit:' + req.url
  40. let storage = uni.getStorageSync(storageKey)
  41. if (storage && new Date().getTime() - parseInt(storage) < req.limit) {
  42. return
  43. }
  44. uni.setStorageSync(storageKey, new Date().getTime())
  45. }
  46. //必须登录
  47. if (req.auth) {
  48. if (!uni.getStorageSync('token')) {
  49. // uni.navigateTo({
  50. // url: '/pages/login/mobile'
  51. // })
  52. console.error('需要登录')
  53. return
  54. }
  55. }
  56. http.http(req.url, data, callback, req.method,
  57. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  58. }
  59. export default api