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

90 lines
2.8 KiB

10 months ago
10 months ago
10 months ago
10 months ago
9 months ago
10 months ago
10 months ago
10 months ago
9 months ago
9 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
  1. import http from './http.js'
  2. import utils from '../utils/utils.js'
  3. const config = {
  4. //示例
  5. // getConfig: { url: '/api/getConfig', method: 'GET', limit: 500 },
  6. // 修改个人信息接口
  7. infoUpdateInfo: { url: '/cheer/info/updateInfo', method: 'POST', auth: true },
  8. // 登录接口
  9. loginLogin: { url: '/cheer/login/login', method: 'GET' },
  10. // 获取个人信息接口
  11. infoGetInfo: { url: '/cheer/info/getInfo', method: 'GET', auth: true, showLoading : true },
  12. //下单
  13. // createOrderPay: { url: '/cheer/info/createOrderPay', method: 'GET', auth: true, limit : 2000, showLoading : true },
  14. //获取折扣、客户电话、微信
  15. // getConfig: { url: '/cheer/info/getConfig', method: 'GET'},
  16. //获取充值套餐
  17. // getRechargePage: { url: '/cheer/info/getRechargePage', method: 'GET'},
  18. //获取加油流水订单
  19. // getOrderWaterPage: { url: '/cheer/info/getOrderWaterPage', method: 'GET', showLoading : true },
  20. //获取隐私政策
  21. getPrivacyPolicy: { url: '/cheer/login/getPrivacyPolicy', method: 'GET'},
  22. //获取用户协议
  23. getUserAgreement: { url: '/cheer/login/getUserAgreement', method: 'GET'},
  24. /**
  25. * 新版本接口
  26. */
  27. //根据加油站标识获取相关配置信息
  28. twogetConfig: { url: '/cheer/two/getConfig', method: 'GET'},
  29. //获取加油站列表信息接口
  30. getGasStationList: { url: '/cheer/two/getGasStationList', method: 'GET'},
  31. //根据加油站标识获取加油流水订单
  32. twogetOrderWaterPage: { url: '/cheer/two/getOrderWaterPage', method: 'GET'},
  33. //根据加油站标识获取加油站充值套餐信息
  34. twogetRechargeList: { url: '/cheer/two/getRechargeList', method: 'GET'},
  35. //获取推广二维码
  36. getQrCode: { url: '/cheer/two/getQrCode', method: 'GET'},
  37. //查询当前用户是否是管理员
  38. isAdmin: { url: '/cheer/two/isAdmin', method: 'GET'},
  39. //用户输入支付创建支付订单并且支付
  40. twocreateOrderPay: { url: '/cheer/two/createOrderPay', method: 'POST'},
  41. }
  42. export function api(key, data, callback, loadingTitle) {
  43. let req = config[key]
  44. if (!req) {
  45. console.error('无效key' + key);
  46. return
  47. }
  48. if (typeof callback == 'string') {
  49. loadingTitle = callback
  50. }
  51. if (typeof data == 'function') {
  52. callback = data
  53. data = {}
  54. }
  55. // 接口限流
  56. if (req.limit) {
  57. let storageKey = 'limit:' + req.url
  58. let storage = uni.getStorageSync(storageKey)
  59. if (storage && new Date().getTime() - parseInt(storage) < req.limit) {
  60. return
  61. }
  62. uni.setStorageSync(storageKey, new Date().getTime())
  63. }
  64. //必须登录
  65. if (req.auth) {
  66. if (!uni.getStorageSync('token')) {
  67. // uni.navigateTo({
  68. // url: '/pages/login/mobile'
  69. // })
  70. console.error('需要登录')
  71. return
  72. }
  73. }
  74. http.http(req.url, data, callback, req.method,
  75. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  76. }
  77. export default api