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

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