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

425 lines
7.6 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
9 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
10 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
9 months ago
10 months ago
10 months ago
9 months ago
10 months ago
10 months ago
10 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
10 months ago
9 months ago
10 months ago
10 months ago
9 months ago
10 months ago
10 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
5 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: '/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: '/user/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. querySpotById: {
  109. url: '/info/querySpotById',
  110. method: 'GET',
  111. showLoading: true,
  112. },
  113. // 获取视频列表
  114. queryVedioById: {
  115. url: '/info/queryVedioById',
  116. method: 'GET',
  117. showLoading: true,
  118. },
  119. // amusement 游玩项目相关接口
  120. // 获取非遗体验列表
  121. queryExperienceList: {
  122. url: '/info/queryExperienceList',
  123. method: 'GET',
  124. showLoading: true,
  125. },
  126. // 获取非遗体验详情
  127. queryExperienceById: {
  128. url: '/info/queryExperienceById',
  129. method: 'GET',
  130. showLoading: true,
  131. },
  132. // 获取路径定制、我要研学列表
  133. queryAmusementList: {
  134. url: '/info/queryAmusementList',
  135. method: 'GET',
  136. showLoading: true,
  137. },
  138. // 获取路径定制、我要研学详情
  139. queryAmusementById: {
  140. url: '/info/queryAmusementById',
  141. method: 'GET',
  142. showLoading: true,
  143. },
  144. // 修改地址
  145. updateAddress: {
  146. url: '/user/updateAddress',
  147. method: 'POST',
  148. showLoading: true,
  149. },
  150. // 修改默认地址
  151. updateDefaultAddress: {
  152. url: '/user/updateDefaultAddress',
  153. method: 'POST',
  154. showLoading: true,
  155. },
  156. // 查询地址
  157. queryAddress: {
  158. url: '/user/queryAddress',
  159. method: 'GET',
  160. showLoading: true,
  161. },
  162. // 删除地址
  163. deleteAddress: {
  164. url: '/user/deleteAddress',
  165. method: 'DELETE',
  166. showLoading: true,
  167. },
  168. // 添加地址
  169. addAddress: {
  170. url: '/user/addAddress',
  171. method: 'POST',
  172. showLoading: true,
  173. },
  174. // 根据角色Id获取角色信息详情
  175. queryRoleInfoById: {
  176. url: '/info/queryRoleInfoById',
  177. method: 'GET',
  178. showLoading: true,
  179. },
  180. // 根据角色类型获取角色信息列表-讲解员-达人-摄影师
  181. queryRoleInfoList: {
  182. url: '/info/queryRoleInfoList',
  183. method: 'GET',
  184. showLoading: true,
  185. },
  186. // 添加收藏
  187. addCollection: {
  188. url: '/user/addCollection',
  189. method: 'POST',
  190. showLoading: true,
  191. },
  192. // 取消收藏
  193. deleteCollection: {
  194. url: '/user/deleteCollection',
  195. method: 'POST',
  196. showLoading: true,
  197. },
  198. // 获取收藏列表
  199. queryCollectionList: {
  200. url: '/user/queryCollectionList',
  201. method: 'GET',
  202. showLoading: true,
  203. },
  204. // 查询预约时间段
  205. queryOrderTime: {
  206. url: '/user/queryOrderTime',
  207. method: 'GET',
  208. showLoading: true,
  209. },
  210. // 查询订单列表
  211. queryOrderList: {
  212. url: '/user/queryOrderList',
  213. method: 'GET',
  214. showLoading: true,
  215. },
  216. //文创好物-获取商品详情
  217. queryWaresById: {
  218. url: '/info/queryWaresById',
  219. method: 'GET',
  220. showLoading: true,
  221. },
  222. //文创好物-获取商品列表
  223. queryWaresList: {
  224. url: '/info/queryWaresList',
  225. method: 'GET',
  226. showLoading: true,
  227. },
  228. // 添加购物车
  229. addShopcar: {
  230. url: '/user/addShopcar',
  231. method: 'POST',
  232. showLoading: true,
  233. auth: true,
  234. },
  235. // 获取购物车列表
  236. queryShopcarList: {
  237. url: '/user/queryShopcarList',
  238. method: 'GET',
  239. showLoading: true,
  240. auth: true,
  241. },
  242. // 取消购物车
  243. deleteShopcar: {
  244. url: '/user/deleteShopcar',
  245. method: 'DELETE',
  246. showLoading: true,
  247. auth: true,
  248. },
  249. // 修改购物车信息
  250. updateShopcar: {
  251. url: '/user/updateShopcar',
  252. method: 'POST',
  253. debounce : 500,
  254. auth: true,
  255. },
  256. /**
  257. * 10月7日新接口
  258. */
  259. // 语音播放
  260. textToAudio: {
  261. url: '/info/textToAudio',
  262. method: 'GET',
  263. },
  264. // 根据id给视频点赞
  265. addThumpup: {
  266. url: '/info/addThumpup',
  267. method: 'POST',
  268. showLoading: true,
  269. limit : 500,
  270. },
  271. // 我的预约-创建预约订单
  272. createOrder: {
  273. url: '/user/addOrder',
  274. method: 'POST',
  275. showLoading: true,
  276. limit : 500,
  277. },
  278. // 创建文创好物订单
  279. addWaresOrder: {
  280. url: '/info/addWaresOrder',
  281. method: 'POST',
  282. showLoading: true,
  283. limit : 500,
  284. },
  285. // 查询文创好物订单列表
  286. queryWaresOrderList: {
  287. url: '/info/queryWaresOrderList',
  288. method: 'GET',
  289. showLoading: true,
  290. limit : 500,
  291. },
  292. // 查询文创好物订单详情
  293. queryWaresOrderById: {
  294. url: '/info/queryWaresOrderById',
  295. method: 'GET',
  296. showLoading: true,
  297. limit : 500,
  298. },
  299. // 搜索文章
  300. queryArticleListByTitle: {
  301. url: '/info/queryArticleListByTitle',
  302. method: 'GET',
  303. showLoading: true,
  304. },
  305. // 2025-2-18
  306. // 申遗新闻-获取新闻分类列表
  307. queryNewsTypeList: {
  308. url: '/info/queryNewsTypeList',
  309. method: 'GET',
  310. },
  311. // 申遗新闻-根据分类获取新闻列表
  312. queryNewsByType: {
  313. url: '/info/queryNewsByType',
  314. method: 'GET',
  315. },
  316. // 根据id获取新闻详情
  317. queryNewsById: {
  318. url: '/info/queryNewsById',
  319. method: 'GET',
  320. },
  321. }
  322. export function api(key, data, callback, loadingTitle) {
  323. let req = config[key]
  324. if (!req) {
  325. console.error('无效key' + key);
  326. return
  327. }
  328. if (typeof callback == 'string') {
  329. loadingTitle = callback
  330. }
  331. if (typeof data == 'function') {
  332. callback = data
  333. data = {}
  334. }
  335. // 接口限流
  336. if (req.limit) {
  337. let storageKey = req.url
  338. let storage = limit[storageKey]
  339. if (storage && new Date().getTime() - storage < req.limit) {
  340. return
  341. }
  342. limit[storageKey] = new Date().getTime()
  343. }
  344. //必须登录
  345. if (req.auth) {
  346. if (!uni.getStorageSync('token')) {
  347. uni.navigateTo({
  348. url: '/pages_order/auth/wxLogin'
  349. })
  350. console.error('需要登录')
  351. return
  352. }
  353. }
  354. // 接口防抖
  355. if(req.debounce){
  356. let storageKey = req.url
  357. let storage = debounce[storageKey]
  358. if (storage) {
  359. clearTimeout(storage)
  360. }
  361. debounce[storageKey] = setTimeout(() => {
  362. clearTimeout(storage)
  363. delete debounce[storageKey]
  364. http.http(req.url, data, callback, req.method,
  365. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  366. }, req.debounce)
  367. return
  368. }
  369. http.http(req.url, data, callback, req.method,
  370. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  371. }
  372. export default api