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

268 lines
4.8 KiB

7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
  1. import http from './http.js'
  2. let limit = {}
  3. let debounce = {}
  4. const config = {
  5. // 示例
  6. // wxLogin : {url : '/api/wxLogin', method : 'POST',
  7. // auth : false, showLoading : true, loadingTitle : '加载中...',
  8. // limit : 1000
  9. // },
  10. // getConfig: {
  11. // url: '/api/getConfig',
  12. // method: 'GET',
  13. // limit: 500
  14. // },
  15. // 微信登录接口
  16. wxLogin: {
  17. url: '/login/login',
  18. method: 'GET',
  19. limit: 500,
  20. showLoading: true,
  21. },
  22. // 修改个人信息接口
  23. updateInfo: {
  24. url: '/info/updateInfo',
  25. method: 'POST',
  26. auth: true,
  27. limit: 500,
  28. showLoading: true,
  29. },
  30. //隐私政策
  31. getPrivacyPolicy: {
  32. url: '/login/getPrivacyPolicy',
  33. method: 'GET',
  34. },
  35. //用户协议
  36. getUserAgreement: {
  37. url: '/login/getUserAgreement',
  38. method: 'GET',
  39. },
  40. /**
  41. * 首页相关接口
  42. */
  43. // 添加建议
  44. addAdvice: {
  45. url: '/info/addAdvice',
  46. method: 'POST',
  47. limit: 500,
  48. showLoading: true,
  49. },
  50. // 添加志愿者
  51. addVolunteer: {
  52. url: '/info/addVolunteer',
  53. method: 'POST',
  54. limit: 500,
  55. showLoading: true,
  56. },
  57. // 获取景区列表
  58. queryAreaList: {
  59. url: '/info/queryAreaList',
  60. method: 'GET',
  61. showLoading: true,
  62. },
  63. // 根据id获取文章详情
  64. queryArticleById: {
  65. url: '/info/queryArticleById',
  66. method: 'GET',
  67. showLoading: true,
  68. },
  69. // 获取文章列表
  70. queryArticleList: {
  71. url: '/info/queryArticleList',
  72. method: 'GET',
  73. showLoading: true,
  74. },
  75. // 根据分类获取文章列表
  76. queryArticleListByType: {
  77. url: '/info/queryArticleListByType',
  78. method: 'GET',
  79. showLoading: true,
  80. },
  81. // 获取banner图列表
  82. queryBannerList: {
  83. url: '/info/queryBannerList',
  84. method: 'GET',
  85. showLoading: true,
  86. },
  87. // 获取景点列表
  88. // areaId: 0-瓷都镇区 1-湖田片区 2-高岭片区 3-瑶里片区 4-蛟潭片区; categoryTyep: 0-景点 1-美食店铺 2-民宿 3-厕所
  89. querySpotList: {
  90. url: '/info/querySpotList',
  91. method: 'GET',
  92. showLoading: true,
  93. },
  94. // 获取视频列表
  95. queryVedioById: {
  96. url: '/info/queryVedioById',
  97. method: 'GET',
  98. showLoading: true,
  99. },
  100. // amusement 游玩项目相关接口
  101. // 获取非遗体验列表
  102. queryExperienceList: {
  103. url: '/amusement/queryExperienceList',
  104. method: 'GET',
  105. showLoading: true,
  106. },
  107. // 获取非遗体验详情
  108. queryExperienceById: {
  109. url: '/amusement/queryExperienceById',
  110. method: 'GET',
  111. showLoading: true,
  112. },
  113. // 获取路径定制、我要研学列表
  114. queryAmusementList: {
  115. url: '/amusement/queryAmusementList',
  116. method: 'GET',
  117. showLoading: true,
  118. },
  119. // 获取路径定制、我要研学详情
  120. queryAmusementById: {
  121. url: '/amusement/queryAmusementById',
  122. method: 'GET',
  123. showLoading: true,
  124. },
  125. // 修改地址
  126. updateAddress: {
  127. url: '/user/updateAddress',
  128. method: 'POST',
  129. showLoading: true,
  130. },
  131. // 查询地址
  132. queryAddress: {
  133. url: '/user/queryAddress',
  134. method: 'GET',
  135. showLoading: true,
  136. },
  137. // 删除地址
  138. deleteAddress: {
  139. url: '/user/deleteAddress',
  140. method: 'DELETE',
  141. showLoading: true,
  142. },
  143. // 添加地址
  144. addAddress: {
  145. url: '/user/addAddress',
  146. method: 'POST',
  147. showLoading: true,
  148. },
  149. // 根据角色Id获取角色信息详情
  150. queryRoleInfoById: {
  151. url: '/user/queryRoleInfoById',
  152. method: 'GET',
  153. showLoading: true,
  154. },
  155. // 根据角色类型获取角色信息列表-讲解员-达人-摄影师
  156. queryRoleInfoList: {
  157. url: '/user/queryRoleInfoList',
  158. method: 'GET',
  159. showLoading: true,
  160. },
  161. // 查询预约时间段
  162. queryOrderTime: {
  163. url: '/order/queryOrderTime',
  164. method: 'GET',
  165. showLoading: true,
  166. },
  167. // 查询订单列表
  168. queryOrderList: {
  169. url: '/order/queryOrderList',
  170. method: 'GET',
  171. showLoading: true,
  172. },
  173. }
  174. export function api(key, data, callback, loadingTitle) {
  175. let req = config[key]
  176. if (!req) {
  177. console.error('无效key' + key);
  178. return
  179. }
  180. if (typeof callback == 'string') {
  181. loadingTitle = callback
  182. }
  183. if (typeof data == 'function') {
  184. callback = data
  185. data = {}
  186. }
  187. // 接口限流
  188. if (req.limit) {
  189. let storageKey = req.url
  190. let storage = limit[storageKey]
  191. if (storage && new Date().getTime() - storage < req.limit) {
  192. return
  193. }
  194. limit[storageKey] = new Date().getTime()
  195. }
  196. //必须登录
  197. if (req.auth) {
  198. if (!uni.getStorageSync('token')) {
  199. uni.navigateTo({
  200. url: '/pages_order/auth/wxLogin'
  201. })
  202. console.error('需要登录')
  203. return
  204. }
  205. }
  206. // 接口防抖
  207. if(req.debounce){
  208. let storageKey = req.url
  209. let storage = debounce[storageKey]
  210. if (storage) {
  211. clearTimeout(storage)
  212. }
  213. debounce[storageKey] = setTimeout(() => {
  214. clearTimeout(storage)
  215. delete debounce[storageKey]
  216. http.http(req.url, data, callback, req.method,
  217. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  218. }, req.debounce)
  219. return
  220. }
  221. http.http(req.url, data, callback, req.method,
  222. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  223. }
  224. export default api