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

316 lines
5.7 KiB

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
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
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. 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. deleteCollection: {
  175. url: '/user/deleteCollection',
  176. method: 'POST',
  177. showLoading: true,
  178. },
  179. // 获取收藏列表
  180. queryCollectionList: {
  181. url: '/user/queryCollectionList',
  182. method: 'GET',
  183. showLoading: true,
  184. },
  185. // 查询预约时间段
  186. queryOrderTime: {
  187. url: '/order/queryOrderTime',
  188. method: 'GET',
  189. showLoading: true,
  190. },
  191. // 查询订单列表
  192. queryOrderList: {
  193. url: '/order/queryOrderList',
  194. method: 'GET',
  195. showLoading: true,
  196. },
  197. //文创好物-获取商品详情
  198. queryWaresById: {
  199. url: '/wares/queryWaresById',
  200. method: 'GET',
  201. showLoading: true,
  202. },
  203. //文创好物-获取商品列表
  204. queryWaresList: {
  205. url: '/wares/queryWaresList',
  206. method: 'GET',
  207. showLoading: true,
  208. },
  209. // 添加购物车
  210. addShopcar: {
  211. url: '/wares/addShopcar',
  212. method: 'POST',
  213. showLoading: true,
  214. },
  215. // 获取购物车列表
  216. queryShopcarList: {
  217. url: '/wares/queryShopcarList',
  218. method: 'GET',
  219. showLoading: true,
  220. },
  221. }
  222. export function api(key, data, callback, loadingTitle) {
  223. let req = config[key]
  224. if (!req) {
  225. console.error('无效key' + key);
  226. return
  227. }
  228. if (typeof callback == 'string') {
  229. loadingTitle = callback
  230. }
  231. if (typeof data == 'function') {
  232. callback = data
  233. data = {}
  234. }
  235. // 接口限流
  236. if (req.limit) {
  237. let storageKey = req.url
  238. let storage = limit[storageKey]
  239. if (storage && new Date().getTime() - storage < req.limit) {
  240. return
  241. }
  242. limit[storageKey] = new Date().getTime()
  243. }
  244. //必须登录
  245. if (req.auth) {
  246. if (!uni.getStorageSync('token')) {
  247. uni.navigateTo({
  248. url: '/pages_order/auth/wxLogin'
  249. })
  250. console.error('需要登录')
  251. return
  252. }
  253. }
  254. // 接口防抖
  255. if(req.debounce){
  256. let storageKey = req.url
  257. let storage = debounce[storageKey]
  258. if (storage) {
  259. clearTimeout(storage)
  260. }
  261. debounce[storageKey] = setTimeout(() => {
  262. clearTimeout(storage)
  263. delete debounce[storageKey]
  264. http.http(req.url, data, callback, req.method,
  265. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  266. }, req.debounce)
  267. return
  268. }
  269. http.http(req.url, data, callback, req.method,
  270. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  271. }
  272. export default api