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

406 lines
7.3 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year 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. getActivityDetail: {
  106. url: '/city/getActivityDetail',
  107. method: 'GET',
  108. },
  109. //获取门店信息列表(美食)
  110. getStorePage: {
  111. url: '/city/getStorePage',
  112. method: 'GET',
  113. },
  114. //获取门店详情(美食)
  115. getStoreDetail: {
  116. url: '/city/getStoreDetail',
  117. method: 'GET',
  118. },
  119. //发布按钮列表
  120. getPublishList: {
  121. url: '/city/getPublishList',
  122. method: 'GET',
  123. },
  124. //获取城市列表服务区域
  125. getCityList: {
  126. url: '/city/getCityList',
  127. method: 'GET',
  128. },
  129. //获取景点列表带分页
  130. getScenicPage: {
  131. url: '/city/getScenicPage',
  132. method: 'GET',
  133. },
  134. //获取景点详情
  135. getScenicDetail: {
  136. url: '/city/getScenicDetail',
  137. method: 'GET',
  138. },
  139. //获取评论列表type-0帖子-1租房-2工作-3景点-4美食-5活动-6人找车-7车找人
  140. getCommentPage: {
  141. url: '/city/getCommentPage',
  142. method: 'GET',
  143. },
  144. //获取江华人信息接口
  145. getJiangHuInfo: {
  146. url: '/city/getJiangHuInfo',
  147. method: 'GET',
  148. },
  149. //获取人找车分页列表
  150. getPeoplePage: {
  151. url: '/city/getPeoplePage',
  152. method: 'GET',
  153. },
  154. //获取人找车详情
  155. getPeopleDetail: {
  156. url: '/city/getPeopleDetail',
  157. method: 'GET',
  158. },
  159. //获取车找人分页列表
  160. getCatPage: {
  161. url: '/city/getCatPage',
  162. method: 'GET',
  163. },
  164. //获取车找人详情
  165. getCatDetail: {
  166. url: '/city/getCatDetail',
  167. method: 'GET',
  168. },
  169. //查询商城信息列表带分页
  170. getShopPingPage : {
  171. url: '/city/getShopPingPage',
  172. method: 'GET',
  173. },
  174. //根据商品标识查询商品信息详情
  175. getShopPingDetail : {
  176. url: '/city/getShopPingDetail',
  177. method: 'GET',
  178. },
  179. //发布帖子\动态
  180. publishPost: {
  181. url: '/token/publishPost',
  182. method: 'POST',
  183. limit : 1000,
  184. auth : true,
  185. showLoading : true,
  186. },
  187. //发布评论
  188. addComment: {
  189. url: '/token/addComment',
  190. method: 'POST',
  191. limit : 1000,
  192. auth : true,
  193. showLoading : true,
  194. },
  195. //发布租房信息
  196. publishRent: {
  197. url: '/token/publishRent',
  198. method: 'POST',
  199. limit : 1000,
  200. auth : true,
  201. showLoading : true,
  202. },
  203. //发布招聘信息
  204. publishJob: {
  205. url: '/token/publishJob',
  206. method: 'POST',
  207. limit : 1000,
  208. auth : true,
  209. showLoading : true,
  210. },
  211. //发布车找人信息
  212. publishCar: {
  213. url: '/token/publishCar',
  214. method: 'POST',
  215. limit : 1000,
  216. auth : true,
  217. showLoading : true,
  218. },
  219. //查询自己发布的动态
  220. getMyPostPage: {
  221. url: '/token/getMyPostPage',
  222. method: 'GET',
  223. auth : true,
  224. },
  225. //删除自己发布的动态
  226. deletePost: {
  227. url: '/token/deletePost',
  228. method: 'POST',
  229. auth : true,
  230. showLoading : true,
  231. },
  232. //店铺认证
  233. companyAuthentication: {
  234. url: '/token/companyAuthentication',
  235. method: 'POST',
  236. limit : 1000,
  237. auth : true,
  238. showLoading : true,
  239. },
  240. //个人认证
  241. personalAuthentication: {
  242. url: '/token/personalAuthentication',
  243. method: 'POST',
  244. limit : 1000,
  245. auth : true,
  246. showLoading : true,
  247. },
  248. //获取分享二维码
  249. getQrCode: {
  250. url: '/token/getQrCode',
  251. method: 'GET',
  252. auth : true,
  253. },
  254. //获取粉丝列表接口
  255. getFansList: {
  256. url: '/token/getFansList',
  257. method: 'GET',
  258. auth : true,
  259. },
  260. // 用户查询地址列表
  261. getAddressList : {
  262. url: '/token/getAddressList',
  263. method: 'GET',
  264. auth : true,
  265. },
  266. // 用户获取地址信息列表详情
  267. getAddressDetail : {
  268. url: '/token/getAddressDetail',
  269. method: 'GET',
  270. auth : true,
  271. },
  272. // 用户增加或者编辑地址信息
  273. addOrEditAddress : {
  274. url: '/token/addOrEditAddress',
  275. method: 'POST',
  276. auth : true,
  277. showLoading : true,
  278. limit : 1000,
  279. },
  280. // 删除地址
  281. deleteAddress : {
  282. url: '/token/deleteAddress',
  283. method: 'POST',
  284. auth : true,
  285. showLoading : true,
  286. },
  287. // 商城-立即兑换商品
  288. createPointsOrder : {
  289. url: '/city/createPointsOrder',
  290. method: 'POST',
  291. auth : true,
  292. showLoading : true,
  293. limit : 1000,
  294. },
  295. // 商城-立即兑换商品,微信支付购买商品
  296. createOrder : {
  297. url: '/city/createOrder',
  298. method: 'POST',
  299. auth : true,
  300. showLoading : true,
  301. limit : 1000,
  302. },
  303. // 商城-订单列表
  304. getOrderList : {
  305. url: '/city/getOrderList',
  306. method: 'POST',
  307. auth : true,
  308. },
  309. // 商城-订单详情
  310. getOrderDetail : {
  311. url: '/city/getOrderDetail',
  312. method: 'POST',
  313. auth : true,
  314. },
  315. }
  316. export function api(key, data, callback, loadingTitle) {
  317. let req = config[key]
  318. if (!req) {
  319. console.error('无效key--------' + key);
  320. return
  321. }
  322. if (typeof callback == 'string') {
  323. loadingTitle = callback
  324. }
  325. if (typeof data == 'function') {
  326. callback = data
  327. data = {}
  328. }
  329. // 接口限流
  330. if (req.limit) {
  331. let storageKey = req.url
  332. let storage = limit[storageKey]
  333. if (storage && new Date().getTime() - storage < req.limit) {
  334. return
  335. }
  336. limit[storageKey] = new Date().getTime()
  337. }
  338. //必须登录
  339. if (req.auth) {
  340. if (!uni.getStorageSync('token')) {
  341. uni.navigateTo({
  342. url: '/pages_order/auth/wxLogin'
  343. })
  344. console.error('需要登录')
  345. return
  346. }
  347. }
  348. // 接口防抖
  349. if(req.debounce){
  350. let storageKey = req.url
  351. let storage = debounce[storageKey]
  352. if (storage) {
  353. clearTimeout(storage)
  354. }
  355. debounce[storageKey] = setTimeout(() => {
  356. clearTimeout(storage)
  357. delete debounce[storageKey]
  358. http.http(req.url, data, callback, req.method,
  359. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  360. }, req.debounce)
  361. return
  362. }
  363. http.http(req.url, data, callback, req.method,
  364. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  365. }
  366. export default api