景徳镇旅游微信小程序
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.

170 lines
3.2 KiB

8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
  1. import http from './http.js'
  2. const config = {
  3. // 示例
  4. // wxLogin : {url : '/api/wxLogin', method : 'POST',
  5. // auth : false, showLoading : true, loadingTitle : '加载中...',
  6. // limit : 1000
  7. // },
  8. // getConfig: {
  9. // url: '/api/getConfig',
  10. // method: 'GET',
  11. // limit: 500
  12. // },
  13. // 微信登录接口
  14. wxLogin: {
  15. url: '/login/login',
  16. method: 'POST',
  17. limit: 500,
  18. showLoading: true,
  19. },
  20. // 修改个人信息接口
  21. updateInfo: {
  22. url: '/info/updateInfo',
  23. method: 'POST',
  24. auth: true,
  25. limit: 500,
  26. showLoading: true,
  27. },
  28. //隐私政策
  29. getPrivacyPolicy: {
  30. url: '/login/getPrivacyPolicy',
  31. method: 'GET',
  32. },
  33. //用户协议
  34. getUserAgreement: {
  35. url: '/login/getUserAgreement',
  36. method: 'GET',
  37. },
  38. /**
  39. * 首页相关接口
  40. */
  41. // 添加建议
  42. addAdvice: {
  43. url: '/info/addAdvice',
  44. method: 'POST',
  45. limit: 500,
  46. showLoading: true,
  47. },
  48. // 添加志愿者
  49. addVolunteer: {
  50. url: '/info/addVolunteer',
  51. method: 'POST',
  52. limit: 500,
  53. showLoading: true,
  54. },
  55. // 获取景区列表
  56. queryAreaList: {
  57. url: '/info/queryAreaList',
  58. method: 'GET',
  59. showLoading: true,
  60. },
  61. // 根据id获取文章详情
  62. queryArticleById: {
  63. url: '/info/queryArticleById',
  64. method: 'GET',
  65. showLoading: true,
  66. },
  67. // 获取文章列表
  68. queryArticleList: {
  69. url: '/info/queryArticleList',
  70. method: 'GET',
  71. showLoading: true,
  72. },
  73. // 根据分类获取文章列表
  74. queryArticleListByType: {
  75. url: '/info/queryArticleListByType',
  76. method: 'GET',
  77. showLoading: true,
  78. },
  79. // 获取banner图列表
  80. queryBannerList: {
  81. url: '/info/queryBannerList',
  82. method: 'GET',
  83. showLoading: true,
  84. },
  85. // 根据角色Id获取角色信息详情
  86. queryRoleInfoById: {
  87. url: '/info/queryRoleInfoById',
  88. method: 'GET',
  89. showLoading: true,
  90. },
  91. // 根据角色类型获取角色信息列表-讲解员-达人-摄影师
  92. queryRoleInfoList: {
  93. url: '/info/queryRoleInfoList',
  94. method: 'GET',
  95. showLoading: true,
  96. },
  97. // 根据景区id获取该景区下的地点列表:景点-厕所-美食店铺-民宿
  98. querySpotList: {
  99. url: '/info/querySpotList',
  100. method: 'GET',
  101. showLoading: true,
  102. },
  103. // 根据角色id获取视频列表
  104. queryVedioBySpot: {
  105. url: '/info/queryVedioBySpot',
  106. method: 'GET',
  107. showLoading: true,
  108. },
  109. // 获取视频列表
  110. queryVideoList: {
  111. url: '/info/queryVideoList',
  112. method: 'GET',
  113. showLoading: true,
  114. },
  115. }
  116. export function api(key, data, callback, loadingTitle) {
  117. let req = config[key]
  118. if (!req) {
  119. console.error('无效key' + key);
  120. return
  121. }
  122. if (typeof callback == 'string') {
  123. loadingTitle = callback
  124. }
  125. if (typeof data == 'function') {
  126. callback = data
  127. data = {}
  128. }
  129. // 接口限流
  130. if (req.limit) {
  131. let storageKey = 'limit:' + req.url
  132. let storage = uni.getStorageSync(storageKey)
  133. if (storage && new Date().getTime() - parseInt(storage) < req.limit) {
  134. return
  135. }
  136. uni.setStorageSync(storageKey, new Date().getTime())
  137. }
  138. //必须登录
  139. if (req.auth) {
  140. if (!uni.getStorageSync('token')) {
  141. uni.navigateTo({
  142. url: '/pages/login/mobile'
  143. })
  144. console.error('需要登录')
  145. return
  146. }
  147. }
  148. http.http(req.url, data, callback, req.method,
  149. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  150. }
  151. export default api