瑶都万能墙
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.

287 lines
5.1 KiB

8 months ago
7 months ago
8 months ago
7 months ago
8 months ago
7 months ago
8 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
8 months ago
7 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 : {url : '/api/getConfig', method : 'GET', limit : 500},
  11. // 微信登录接口
  12. wxLogin: {
  13. url: '/login/login',
  14. method: 'GET',
  15. limit : 500,
  16. showLoading : true,
  17. },
  18. // 修改个人信息接口
  19. updateInfo: {
  20. url: '/token/updateInfo',
  21. method: 'POST',
  22. auth: true,
  23. limit : 500,
  24. showLoading : true,
  25. },
  26. // 获取个人信息接口
  27. getInfo: {
  28. url: '/token/getInfo',
  29. method: 'GET',
  30. auth: true,
  31. limit : 500,
  32. },
  33. //隐私政策
  34. getPrivacyPolicy: {
  35. url: '/login/getPrivacyPolicy',
  36. method: 'GET',
  37. },
  38. //用户协议
  39. getUserAgreement: {
  40. url: '/login/getUserAgreement',
  41. method: 'GET',
  42. },
  43. // 不需要登录的接口
  44. //获取分类
  45. getClassInfo: {
  46. url: '/city/getClassInfo',
  47. method: 'GET',
  48. },
  49. //获取首页头部信息
  50. getIndexHeaderInfo: {
  51. url: '/city/getIndexHeaderInfo',
  52. method: 'GET',
  53. },
  54. //获取banner列表
  55. getBannerList: {
  56. url: '/city/getBannerList',
  57. method: 'GET',
  58. },
  59. //获取分类类型列表
  60. getClassifyList: {
  61. url: '/city/getClassifyList',
  62. method: 'GET',
  63. },
  64. //获取工作信息列表
  65. getJobPage: {
  66. url: '/city/getJobPage',
  67. method: 'GET',
  68. },
  69. //获取工作详情
  70. getJobDetail: {
  71. url: '/city/getJobDetail',
  72. method: 'GET',
  73. },
  74. //根据分类获取租房信息列表
  75. getRentPage: {
  76. url: '/city/getRentPage',
  77. method: 'GET',
  78. },
  79. //获取租房详情
  80. getRentDetail: {
  81. url: '/city/getRentDetail',
  82. method: 'GET',
  83. },
  84. //获取动态帖子列表
  85. getPostPage: {
  86. url: '/city/getPostPage',
  87. method: 'GET',
  88. },
  89. //获取帖子详情
  90. getPostDetail: {
  91. url: '/city/getPostDetail',
  92. method: 'GET',
  93. },
  94. //获取活动列表信息
  95. getActivityPage: {
  96. url: '/city/getActivityPage',
  97. method: 'GET',
  98. },
  99. //获取活动详情
  100. getActivityDetail: {
  101. url: '/city/getActivityDetail',
  102. method: 'GET',
  103. },
  104. //获取门店信息列表(美食)
  105. getStorePage: {
  106. url: '/city/getStorePage',
  107. method: 'GET',
  108. },
  109. //获取门店详情(美食)
  110. getStoreDetail: {
  111. url: '/city/getStoreDetail',
  112. method: 'GET',
  113. },
  114. //发布按钮列表
  115. getPublishList: {
  116. url: '/city/getPublishList',
  117. method: 'GET',
  118. },
  119. //获取城市列表服务区域
  120. getCityList: {
  121. url: '/city/getCityList',
  122. method: 'GET',
  123. },
  124. //获取景点列表带分页
  125. getScenicPage: {
  126. url: '/city/getScenicPage',
  127. method: 'GET',
  128. },
  129. //获取景点详情
  130. getScenicDetail: {
  131. url: '/city/getScenicDetail',
  132. method: 'GET',
  133. },
  134. //获取评论列表type-0帖子-1租房-2工作-3景点-4美食-5活动
  135. getCommentPage: {
  136. url: '/city/getCommentPage',
  137. method: 'GET',
  138. },
  139. //获取江华人信息接口
  140. getJiangHuInfo: {
  141. url: '/city/getJiangHuInfo',
  142. method: 'GET',
  143. },
  144. //发布帖子\动态
  145. publishPost: {
  146. url: '/token/publishPost',
  147. method: 'POST',
  148. limit : 1000,
  149. auth : true,
  150. showLoading : true,
  151. },
  152. //查询自己发布的动态
  153. getMyPostPage: {
  154. url: '/token/getMyPostPage',
  155. method: 'GET',
  156. auth : true,
  157. },
  158. //删除自己发布的动态
  159. deletePost: {
  160. url: '/token/deletePost',
  161. method: 'POST',
  162. auth : true,
  163. showLoading : true,
  164. },
  165. //店铺认证
  166. companyAuthentication: {
  167. url: '/token/companyAuthentication',
  168. method: 'POST',
  169. limit : 1000,
  170. auth : true,
  171. showLoading : true,
  172. },
  173. //个人认证
  174. personalAuthentication: {
  175. url: '/token/personalAuthentication',
  176. method: 'POST',
  177. limit : 1000,
  178. auth : true,
  179. showLoading : true,
  180. },
  181. //获取分享二维码
  182. getQrCode: {
  183. url: '/token/getQrCode',
  184. method: 'GET',
  185. auth : true,
  186. },
  187. //发布评论
  188. addComment: {
  189. url: '/token/addComment',
  190. method: 'POST',
  191. limit : 1000,
  192. auth : true,
  193. showLoading : true,
  194. },
  195. //获取粉丝列表接口
  196. getFansList: {
  197. url: '/token/getFansList',
  198. method: 'GET',
  199. auth : true,
  200. },
  201. }
  202. export function api(key, data, callback, loadingTitle) {
  203. let req = config[key]
  204. if (!req) {
  205. console.error('无效key--------' + key);
  206. return
  207. }
  208. if (typeof callback == 'string') {
  209. loadingTitle = callback
  210. }
  211. if (typeof data == 'function') {
  212. callback = data
  213. data = {}
  214. }
  215. // 接口限流
  216. if (req.limit) {
  217. let storageKey = req.url
  218. let storage = limit[storageKey]
  219. if (storage && new Date().getTime() - storage < req.limit) {
  220. return
  221. }
  222. limit[storageKey] = new Date().getTime()
  223. }
  224. //必须登录
  225. if (req.auth) {
  226. if (!uni.getStorageSync('token')) {
  227. uni.navigateTo({
  228. url: '/pages_order/auth/wxLogin'
  229. })
  230. console.error('需要登录')
  231. return
  232. }
  233. }
  234. // 接口防抖
  235. if(req.debounce){
  236. let storageKey = req.url
  237. let storage = debounce[storageKey]
  238. if (storage) {
  239. clearTimeout(storage)
  240. }
  241. debounce[storageKey] = setTimeout(() => {
  242. clearTimeout(storage)
  243. delete debounce[storageKey]
  244. http.http(req.url, data, callback, req.method,
  245. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  246. }, req.debounce)
  247. return
  248. }
  249. http.http(req.url, data, callback, req.method,
  250. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  251. }
  252. export default api