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

84 lines
2.4 KiB

9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
8 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 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, showLoading : true },
  11. //下单
  12. createOrderPay: { url: '/cheer/info/createOrderPay', method: 'GET', auth: true, limit : 2000, showLoading : true },
  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', showLoading : true },
  19. //获取隐私政策
  20. getPrivacyPolicy: { url: '/cheer/login/getPrivacyPolicy', method: 'GET'},
  21. //获取用户协议
  22. getUserAgreement: { url: '/cheer/login/getUserAgreement', method: 'GET'},
  23. /**
  24. * 新版本接口
  25. */
  26. //根据加油站标识获取相关配置信息
  27. twogetConfig: { url: '/cheer/two/getConfig', method: 'GET'},
  28. //获取加油站列表信息接口
  29. getGasStationList: { url: '/cheer/two/getGasStationList', method: 'GET'},
  30. //根据加油站标识获取加油流水订单
  31. twogetOrderWaterPage: { url: '/cheer/two/getOrderWaterPage', method: 'GET'},
  32. //根据加油站标识获取加油站充值套餐信息
  33. twogetRechargeList: { url: '/cheer/two/getRechargeList', method: 'GET'},
  34. }
  35. export function api(key, data, callback, loadingTitle) {
  36. let req = config[key]
  37. if (!req) {
  38. console.error('无效key' + key);
  39. return
  40. }
  41. if (typeof callback == 'string') {
  42. loadingTitle = callback
  43. }
  44. if (typeof data == 'function') {
  45. callback = data
  46. data = {}
  47. }
  48. // 接口限流
  49. if (req.limit) {
  50. let storageKey = 'limit:' + req.url
  51. let storage = uni.getStorageSync(storageKey)
  52. if (storage && new Date().getTime() - parseInt(storage) < req.limit) {
  53. return
  54. }
  55. uni.setStorageSync(storageKey, new Date().getTime())
  56. }
  57. //必须登录
  58. if (req.auth) {
  59. if (!uni.getStorageSync('token')) {
  60. // uni.navigateTo({
  61. // url: '/pages/login/mobile'
  62. // })
  63. console.error('需要登录')
  64. return
  65. }
  66. }
  67. http.http(req.url, data, callback, req.method,
  68. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  69. }
  70. export default api