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

392 lines
7.0 KiB

9 months ago
8 months ago
9 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
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
8 months ago
9 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. queryVedioById: {
  109. url: '/info/queryVedioById',
  110. method: 'GET',
  111. showLoading: true,
  112. },
  113. // amusement 游玩项目相关接口
  114. // 获取非遗体验列表
  115. queryExperienceList: {
  116. url: '/info/queryExperienceList',
  117. method: 'GET',
  118. showLoading: true,
  119. },
  120. // 获取非遗体验详情
  121. queryExperienceById: {
  122. url: '/info/queryExperienceById',
  123. method: 'GET',
  124. showLoading: true,
  125. },
  126. // 获取路径定制、我要研学列表
  127. queryAmusementList: {
  128. url: '/info/queryAmusementList',
  129. method: 'GET',
  130. showLoading: true,
  131. },
  132. // 获取路径定制、我要研学详情
  133. queryAmusementById: {
  134. url: '/info/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: '/info/queryRoleInfoById',
  171. method: 'GET',
  172. showLoading: true,
  173. },
  174. // 根据角色类型获取角色信息列表-讲解员-达人-摄影师
  175. queryRoleInfoList: {
  176. url: '/info/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: '/user/queryOrderTime',
  201. method: 'GET',
  202. showLoading: true,
  203. },
  204. // 查询订单列表
  205. queryOrderList: {
  206. url: '/user/queryOrderList',
  207. method: 'GET',
  208. showLoading: true,
  209. },
  210. //文创好物-获取商品详情
  211. queryWaresById: {
  212. url: '/info/queryWaresById',
  213. method: 'GET',
  214. showLoading: true,
  215. },
  216. //文创好物-获取商品列表
  217. queryWaresList: {
  218. url: '/info/queryWaresList',
  219. method: 'GET',
  220. showLoading: true,
  221. },
  222. // 添加购物车
  223. addShopcar: {
  224. url: '/user/addShopcar',
  225. method: 'POST',
  226. showLoading: true,
  227. auth: true,
  228. },
  229. // 获取购物车列表
  230. queryShopcarList: {
  231. url: '/user/queryShopcarList',
  232. method: 'GET',
  233. showLoading: true,
  234. auth: true,
  235. },
  236. // 取消购物车
  237. deleteShopcar: {
  238. url: '/user/deleteShopcar',
  239. method: 'DELETE',
  240. showLoading: true,
  241. auth: true,
  242. },
  243. // 修改购物车信息
  244. updateShopcar: {
  245. url: '/user/updateShopcar',
  246. method: 'POST',
  247. debounce : 500,
  248. auth: true,
  249. },
  250. /**
  251. * 10月7日新接口
  252. */
  253. // 语音播放
  254. textToAudio: {
  255. url: '/info/textToAudio',
  256. method: 'GET',
  257. },
  258. // 根据id给视频点赞
  259. addThumpup: {
  260. url: '/info/addThumpup',
  261. method: 'POST',
  262. showLoading: true,
  263. limit : 500,
  264. },
  265. // 我的预约-创建预约订单
  266. createOrder: {
  267. url: '/user/addOrder',
  268. method: 'POST',
  269. showLoading: true,
  270. limit : 500,
  271. },
  272. // 创建文创好物订单
  273. addWaresOrder: {
  274. url: '/info/addWaresOrder',
  275. method: 'POST',
  276. showLoading: true,
  277. limit : 500,
  278. },
  279. // 查询文创好物订单列表
  280. queryWaresOrderList: {
  281. url: '/info/queryWaresOrderList',
  282. method: 'GET',
  283. showLoading: true,
  284. limit : 500,
  285. },
  286. // 搜索文章
  287. queryArticleListByTitle: {
  288. url: '/info/queryArticleListByTitle',
  289. method: 'GET',
  290. showLoading: true,
  291. },
  292. }
  293. export function api(key, data, callback, loadingTitle) {
  294. let req = config[key]
  295. if (!req) {
  296. console.error('无效key' + key);
  297. return
  298. }
  299. if (typeof callback == 'string') {
  300. loadingTitle = callback
  301. }
  302. if (typeof data == 'function') {
  303. callback = data
  304. data = {}
  305. }
  306. // 接口限流
  307. if (req.limit) {
  308. let storageKey = req.url
  309. let storage = limit[storageKey]
  310. if (storage && new Date().getTime() - storage < req.limit) {
  311. return
  312. }
  313. limit[storageKey] = new Date().getTime()
  314. }
  315. //必须登录
  316. if (req.auth) {
  317. if (!uni.getStorageSync('token')) {
  318. uni.navigateTo({
  319. url: '/pages_order/auth/wxLogin'
  320. })
  321. console.error('需要登录')
  322. return
  323. }
  324. }
  325. // 接口防抖
  326. if(req.debounce){
  327. let storageKey = req.url
  328. let storage = debounce[storageKey]
  329. if (storage) {
  330. clearTimeout(storage)
  331. }
  332. debounce[storageKey] = setTimeout(() => {
  333. clearTimeout(storage)
  334. delete debounce[storageKey]
  335. http.http(req.url, data, callback, req.method,
  336. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  337. }, req.debounce)
  338. return
  339. }
  340. http.http(req.url, data, callback, req.method,
  341. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  342. }
  343. export default api