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

89 lines
2.7 KiB

11 months ago
11 months ago
11 months ago
10 months ago
11 months ago
11 months ago
11 months ago
9 months ago
9 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, 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. getQrCode: { url: '/cheer/two/getQrCode', method: 'GET'},
  36. //查询当前用户是否是管理员
  37. isAdmin: { url: '/cheer/two/isAdmin', method: 'GET'},
  38. //用户输入支付创建支付订单并且支付
  39. twocreateOrderPay: { url: '/cheer/two/createOrderPay', method: 'POST'},
  40. }
  41. export function api(key, data, callback, loadingTitle) {
  42. let req = config[key]
  43. if (!req) {
  44. console.error('无效key' + key);
  45. return
  46. }
  47. if (typeof callback == 'string') {
  48. loadingTitle = callback
  49. }
  50. if (typeof data == 'function') {
  51. callback = data
  52. data = {}
  53. }
  54. // 接口限流
  55. if (req.limit) {
  56. let storageKey = 'limit:' + req.url
  57. let storage = uni.getStorageSync(storageKey)
  58. if (storage && new Date().getTime() - parseInt(storage) < req.limit) {
  59. return
  60. }
  61. uni.setStorageSync(storageKey, new Date().getTime())
  62. }
  63. //必须登录
  64. if (req.auth) {
  65. if (!uni.getStorageSync('token')) {
  66. // uni.navigateTo({
  67. // url: '/pages/login/mobile'
  68. // })
  69. console.error('需要登录')
  70. return
  71. }
  72. }
  73. http.http(req.url, data, callback, req.method,
  74. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  75. }
  76. export default api