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

311 lines
5.6 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
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. queryAreaListById: {
  65. url: '/info/queryAreaListById',
  66. method: 'GET',
  67. showLoading: true,
  68. },
  69. // 根据id获取文章详情
  70. queryArticleById: {
  71. url: '/info/queryArticleById',
  72. method: 'GET',
  73. showLoading: true,
  74. },
  75. // 获取文章列表
  76. queryArticleList: {
  77. url: '/info/queryArticleList',
  78. method: 'GET',
  79. showLoading: true,
  80. },
  81. // 根据分类获取文章列表
  82. queryArticleListByType: {
  83. url: '/info/queryArticleListByType',
  84. method: 'GET',
  85. showLoading: true,
  86. },
  87. // 获取banner图列表
  88. queryBannerList: {
  89. url: '/info/queryBannerList',
  90. method: 'GET',
  91. showLoading: true,
  92. },
  93. // 获取景点列表
  94. // areaId: 0-瓷都镇区 1-湖田片区 2-高岭片区 3-瑶里片区 4-蛟潭片区; categoryTyep: 0-景点 1-美食店铺 2-民宿 3-厕所
  95. querySpotList: {
  96. url: '/info/querySpotList',
  97. method: 'GET',
  98. showLoading: true,
  99. },
  100. // 获取视频列表
  101. queryVedioById: {
  102. url: '/info/queryVedioById',
  103. method: 'GET',
  104. showLoading: true,
  105. },
  106. // amusement 游玩项目相关接口
  107. // 获取非遗体验列表
  108. queryExperienceList: {
  109. url: '/amusement/queryExperienceList',
  110. method: 'GET',
  111. showLoading: true,
  112. },
  113. // 获取非遗体验详情
  114. queryExperienceById: {
  115. url: '/amusement/queryExperienceById',
  116. method: 'GET',
  117. showLoading: true,
  118. },
  119. // 获取路径定制、我要研学列表
  120. queryAmusementList: {
  121. url: '/amusement/queryAmusementList',
  122. method: 'GET',
  123. showLoading: true,
  124. },
  125. // 获取路径定制、我要研学详情
  126. queryAmusementById: {
  127. url: '/amusement/queryAmusementById',
  128. method: 'GET',
  129. showLoading: true,
  130. },
  131. // 修改地址
  132. updateAddress: {
  133. url: '/user/updateAddress',
  134. method: 'POST',
  135. showLoading: true,
  136. },
  137. // 查询地址
  138. queryAddress: {
  139. url: '/user/queryAddress',
  140. method: 'GET',
  141. showLoading: true,
  142. },
  143. // 删除地址
  144. deleteAddress: {
  145. url: '/user/deleteAddress',
  146. method: 'DELETE',
  147. showLoading: true,
  148. },
  149. // 添加地址
  150. addAddress: {
  151. url: '/user/addAddress',
  152. method: 'POST',
  153. showLoading: true,
  154. },
  155. // 根据角色Id获取角色信息详情
  156. queryRoleInfoById: {
  157. url: '/user/queryRoleInfoById',
  158. method: 'GET',
  159. showLoading: true,
  160. },
  161. // 根据角色类型获取角色信息列表-讲解员-达人-摄影师
  162. queryRoleInfoList: {
  163. url: '/user/queryRoleInfoList',
  164. method: 'GET',
  165. showLoading: true,
  166. },
  167. // 添加收藏
  168. addCollection: {
  169. url: '/user/addCollection',
  170. method: 'POST',
  171. showLoading: true,
  172. },
  173. // 获取收藏列表
  174. queryCollectionList: {
  175. url: '/user/queryCollectionList',
  176. method: 'GET',
  177. showLoading: true,
  178. },
  179. // 添加购物车
  180. addShopcar: {
  181. url: '/user/addShopcar',
  182. method: 'POST',
  183. showLoading: true,
  184. },
  185. // 获取购物车列表
  186. queryShopcarList: {
  187. url: '/user/queryShopcarList',
  188. method: 'GET',
  189. showLoading: true,
  190. },
  191. // 查询预约时间段
  192. queryOrderTime: {
  193. url: '/order/queryOrderTime',
  194. method: 'GET',
  195. showLoading: true,
  196. },
  197. // 查询订单列表
  198. queryOrderList: {
  199. url: '/order/queryOrderList',
  200. method: 'GET',
  201. showLoading: true,
  202. },
  203. //文创好物-获取商品详情
  204. queryWaresById: {
  205. url: '/wares/queryWaresById',
  206. method: 'GET',
  207. showLoading: true,
  208. },
  209. //文创好物-获取商品列表
  210. queryWaresList: {
  211. url: '/wares/queryWaresList',
  212. method: 'GET',
  213. showLoading: true,
  214. },
  215. }
  216. export function api(key, data, callback, loadingTitle) {
  217. let req = config[key]
  218. if (!req) {
  219. console.error('无效key' + key);
  220. return
  221. }
  222. if (typeof callback == 'string') {
  223. loadingTitle = callback
  224. }
  225. if (typeof data == 'function') {
  226. callback = data
  227. data = {}
  228. }
  229. // 接口限流
  230. if (req.limit) {
  231. let storageKey = req.url
  232. let storage = limit[storageKey]
  233. if (storage && new Date().getTime() - storage < req.limit) {
  234. return
  235. }
  236. limit[storageKey] = new Date().getTime()
  237. }
  238. //必须登录
  239. if (req.auth) {
  240. if (!uni.getStorageSync('token')) {
  241. uni.navigateTo({
  242. url: '/pages_order/auth/wxLogin'
  243. })
  244. console.error('需要登录')
  245. return
  246. }
  247. }
  248. // 接口防抖
  249. if(req.debounce){
  250. let storageKey = req.url
  251. let storage = debounce[storageKey]
  252. if (storage) {
  253. clearTimeout(storage)
  254. }
  255. debounce[storageKey] = setTimeout(() => {
  256. clearTimeout(storage)
  257. delete debounce[storageKey]
  258. http.http(req.url, data, callback, req.method,
  259. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  260. }, req.debounce)
  261. return
  262. }
  263. http.http(req.url, data, callback, req.method,
  264. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  265. }
  266. export default api