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

267 lines
4.8 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
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. 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. // areaId: 0-瓷都镇区 1-湖田片区 2-高岭片区 3-瑶里片区 4-蛟潭片区; categoryTyep: 0-景点 1-美食店铺 2-民宿 3-厕所
  88. querySpotList: {
  89. url: '/info/querySpotList',
  90. method: 'GET',
  91. showLoading: true,
  92. },
  93. // 获取视频列表
  94. queryVedioById: {
  95. url: '/info/queryVedioById',
  96. method: 'GET',
  97. showLoading: true,
  98. },
  99. // amusement 游玩项目相关接口
  100. // 获取非遗体验列表
  101. queryExperienceList: {
  102. url: '/amusement/queryExperienceList',
  103. method: 'GET',
  104. showLoading: true,
  105. },
  106. // 获取非遗体验详情
  107. queryExperienceById: {
  108. url: '/amusement/queryExperienceById',
  109. method: 'GET',
  110. showLoading: true,
  111. },
  112. // 获取路径定制、我要研学列表
  113. queryAmusementList: {
  114. url: '/amusement/queryAmusementList',
  115. method: 'GET',
  116. showLoading: true,
  117. },
  118. // 获取路径定制、我要研学详情
  119. queryAmusementById: {
  120. url: '/amusement/queryAmusementById',
  121. method: 'GET',
  122. showLoading: true,
  123. },
  124. // 修改地址
  125. updateAddress: {
  126. url: '/user/updateAddress',
  127. method: 'POST',
  128. showLoading: true,
  129. },
  130. // 查询地址
  131. queryAddress: {
  132. url: '/user/queryAddress',
  133. method: 'GET',
  134. showLoading: true,
  135. },
  136. // 删除地址
  137. deleteAddress: {
  138. url: '/user/deleteAddress',
  139. method: 'DELETE',
  140. showLoading: true,
  141. },
  142. // 添加地址
  143. addAddress: {
  144. url: '/user/addAddress',
  145. method: 'POST',
  146. showLoading: true,
  147. },
  148. // 根据角色Id获取角色信息详情
  149. queryRoleInfoById: {
  150. url: '/user/queryRoleInfoById',
  151. method: 'GET',
  152. showLoading: true,
  153. },
  154. // 根据角色类型获取角色信息列表-讲解员-达人-摄影师
  155. queryRoleInfoList: {
  156. url: '/user/queryRoleInfoList',
  157. method: 'GET',
  158. showLoading: true,
  159. },
  160. // 查询预约时间段
  161. queryOrderTime: {
  162. url: '/order/queryOrderTime',
  163. method: 'GET',
  164. showLoading: true,
  165. },
  166. // 查询订单列表
  167. queryOrderList: {
  168. url: '/order/queryOrderList',
  169. method: 'GET',
  170. showLoading: true,
  171. },
  172. }
  173. export function api(key, data, callback, loadingTitle) {
  174. let req = config[key]
  175. if (!req) {
  176. console.error('无效key' + key);
  177. return
  178. }
  179. if (typeof callback == 'string') {
  180. loadingTitle = callback
  181. }
  182. if (typeof data == 'function') {
  183. callback = data
  184. data = {}
  185. }
  186. // 接口限流
  187. if (req.limit) {
  188. let storageKey = req.url
  189. let storage = limit[storageKey]
  190. if (storage && new Date().getTime() - storage < req.limit) {
  191. return
  192. }
  193. limit[storageKey] = new Date().getTime()
  194. }
  195. //必须登录
  196. if (req.auth) {
  197. if (!uni.getStorageSync('token')) {
  198. uni.navigateTo({
  199. url: '/pages_order/auth/wxLogin'
  200. })
  201. console.error('需要登录')
  202. return
  203. }
  204. }
  205. // 接口防抖
  206. if(req.debounce){
  207. let storageKey = req.url
  208. let storage = debounce[storageKey]
  209. if (storage) {
  210. clearTimeout(storage)
  211. }
  212. debounce[storageKey] = setTimeout(() => {
  213. clearTimeout(storage)
  214. delete debounce[storageKey]
  215. http.http(req.url, data, callback, req.method,
  216. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  217. }, req.debounce)
  218. return
  219. }
  220. http.http(req.url, data, callback, req.method,
  221. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  222. }
  223. export default api