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

347 lines
6.3 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
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. updateDefaultAddress: {
  146. url: '/user/updateDefaultAddress',
  147. method: 'POST',
  148. showLoading: true,
  149. },
  150. // 查询地址
  151. queryAddress: {
  152. url: '/user/queryAddress',
  153. method: 'GET',
  154. showLoading: true,
  155. },
  156. // 删除地址
  157. deleteAddress: {
  158. url: '/user/deleteAddress',
  159. method: 'DELETE',
  160. showLoading: true,
  161. },
  162. // 添加地址
  163. addAddress: {
  164. url: '/user/addAddress',
  165. method: 'POST',
  166. showLoading: true,
  167. },
  168. // 根据角色Id获取角色信息详情
  169. queryRoleInfoById: {
  170. url: '/user/queryRoleInfoById',
  171. method: 'GET',
  172. showLoading: true,
  173. },
  174. // 根据角色类型获取角色信息列表-讲解员-达人-摄影师
  175. queryRoleInfoList: {
  176. url: '/user/queryRoleInfoList',
  177. method: 'GET',
  178. showLoading: true,
  179. },
  180. // 添加收藏
  181. addCollection: {
  182. url: '/user/addCollection',
  183. method: 'POST',
  184. showLoading: true,
  185. },
  186. // 取消收藏
  187. deleteCollection: {
  188. url: '/user/deleteCollection',
  189. method: 'POST',
  190. showLoading: true,
  191. },
  192. // 获取收藏列表
  193. queryCollectionList: {
  194. url: '/user/queryCollectionList',
  195. method: 'GET',
  196. showLoading: true,
  197. },
  198. // 查询预约时间段
  199. queryOrderTime: {
  200. url: '/order/queryOrderTime',
  201. method: 'GET',
  202. showLoading: true,
  203. },
  204. // 查询订单列表
  205. queryOrderList: {
  206. url: '/order/queryOrderList',
  207. method: 'GET',
  208. showLoading: true,
  209. },
  210. //文创好物-获取商品详情
  211. queryWaresById: {
  212. url: '/wares/queryWaresById',
  213. method: 'GET',
  214. showLoading: true,
  215. },
  216. //文创好物-获取商品列表
  217. queryWaresList: {
  218. url: '/wares/queryWaresList',
  219. method: 'GET',
  220. showLoading: true,
  221. },
  222. // 添加购物车
  223. addShopcar: {
  224. url: '/wares/addShopcar',
  225. method: 'POST',
  226. showLoading: true,
  227. auth: true,
  228. },
  229. // 获取购物车列表
  230. queryShopcarList: {
  231. url: '/wares/queryShopcarList',
  232. method: 'GET',
  233. showLoading: true,
  234. auth: true,
  235. },
  236. // 取消购物车
  237. deleteShopcar: {
  238. url: '/wares/deleteShopcar',
  239. method: 'DELETE',
  240. showLoading: true,
  241. auth: true,
  242. },
  243. // 修改购物车信息
  244. updateShopcar: {
  245. url: '/wares/updateShopcar',
  246. method: 'POST',
  247. showLoading: true,
  248. debounce : 500,
  249. auth: true,
  250. },
  251. }
  252. export function api(key, data, callback, loadingTitle) {
  253. let req = config[key]
  254. if (!req) {
  255. console.error('无效key' + key);
  256. return
  257. }
  258. if (typeof callback == 'string') {
  259. loadingTitle = callback
  260. }
  261. if (typeof data == 'function') {
  262. callback = data
  263. data = {}
  264. }
  265. // 接口限流
  266. if (req.limit) {
  267. let storageKey = req.url
  268. let storage = limit[storageKey]
  269. if (storage && new Date().getTime() - storage < req.limit) {
  270. return
  271. }
  272. limit[storageKey] = new Date().getTime()
  273. }
  274. //必须登录
  275. if (req.auth) {
  276. if (!uni.getStorageSync('token')) {
  277. uni.navigateTo({
  278. url: '/pages_order/auth/wxLogin'
  279. })
  280. console.error('需要登录')
  281. return
  282. }
  283. }
  284. // 接口防抖
  285. if(req.debounce){
  286. let storageKey = req.url
  287. let storage = debounce[storageKey]
  288. if (storage) {
  289. clearTimeout(storage)
  290. }
  291. debounce[storageKey] = setTimeout(() => {
  292. clearTimeout(storage)
  293. delete debounce[storageKey]
  294. http.http(req.url, data, callback, req.method,
  295. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  296. }, req.debounce)
  297. return
  298. }
  299. http.http(req.url, data, callback, req.method,
  300. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  301. }
  302. export default api