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

467 lines
8.4 KiB

8 months ago
7 months ago
8 months ago
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
7 months ago
7 months ago
7 months ago
7 months ago
6 months ago
6 months ago
6 months ago
6 months ago
4 days ago
6 months ago
6 months ago
6 months ago
8 months ago
7 months ago
8 months ago
7 months ago
8 months ago
7 months ago
8 months ago
7 months ago
8 months ago
3 months ago
8 months ago
7 months ago
8 months ago
  1. import http from './http.js'
  2. import utils from '../utils/utils.js'
  3. let limit = {}
  4. let debounce = {}
  5. const config = {
  6. // 示例
  7. // wxLogin : {url : '/api/wxLogin', method : 'POST',
  8. // auth : false, showLoading : true, loadingTitle : '加载中...',
  9. // limit : 1000
  10. // },
  11. getConfig : {url : '/login/getConfigInfo', method : 'GET', limit : 500},
  12. // 微信登录接口
  13. wxLogin: {
  14. url: '/login/login',
  15. method: 'GET',
  16. limit : 500,
  17. showLoading : true,
  18. },
  19. // 修改个人信息接口
  20. updateInfo: {
  21. url: '/token/updateInfo',
  22. method: 'POST',
  23. auth: true,
  24. limit : 500,
  25. showLoading : true,
  26. },
  27. // 获取个人信息接口
  28. getInfo: {
  29. url: '/token/getInfo',
  30. method: 'GET',
  31. auth: true,
  32. limit : 500,
  33. },
  34. // 绑定手机号码
  35. bindPhone: {
  36. url: '/login/bindPhone',
  37. method: 'GET',
  38. auth: true,
  39. limit : 500,
  40. },
  41. //隐私政策
  42. getPrivacyPolicy: {
  43. url: '/login/getPrivacyPolicy',
  44. method: 'GET',
  45. },
  46. //用户协议
  47. getUserAgreement: {
  48. url: '/login/getUserAgreement',
  49. method: 'GET',
  50. },
  51. // 不需要登录的接口
  52. //获取分类
  53. getClassInfo: {
  54. url: '/city/getClassInfo',
  55. method: 'GET',
  56. },
  57. //获取首页头部信息
  58. getIndexHeaderInfo: {
  59. url: '/city/getIndexHeaderInfo',
  60. method: 'GET',
  61. },
  62. //获取banner列表
  63. getBannerList: {
  64. url: '/city/getBannerList',
  65. method: 'GET',
  66. },
  67. //获取分类类型列表
  68. getClassifyList: {
  69. url: '/city/getClassifyList',
  70. method: 'GET',
  71. },
  72. //获取工作信息列表
  73. getJobPage: {
  74. url: '/city/getJobPage',
  75. method: 'GET',
  76. },
  77. //获取工作详情
  78. getJobDetail: {
  79. url: '/city/getJobDetail',
  80. method: 'GET',
  81. },
  82. //根据分类获取租房信息列表
  83. getRentPage: {
  84. url: '/city/getRentPage',
  85. method: 'GET',
  86. },
  87. //获取租房详情
  88. getRentDetail: {
  89. url: '/city/getRentDetail',
  90. method: 'GET',
  91. },
  92. //获取动态帖子列表
  93. getPostPage: {
  94. url: '/city/getPostPage',
  95. method: 'GET',
  96. },
  97. //获取帖子详情
  98. getPostDetail: {
  99. url: '/city/getPostDetail',
  100. method: 'GET',
  101. },
  102. //获取活动列表信息
  103. getActivityPage: {
  104. url: '/city/getActivityPage',
  105. method: 'GET',
  106. },
  107. //获取活动详情
  108. getActivityDetail: {
  109. url: '/city/getActivityDetail',
  110. method: 'GET',
  111. },
  112. //获取活动详情
  113. getActivityDetail: {
  114. url: '/city/getActivityDetail',
  115. method: 'GET',
  116. },
  117. //获取门店信息列表(美食)
  118. getStorePage: {
  119. url: '/city/getStorePage',
  120. method: 'GET',
  121. },
  122. //获取门店详情(美食)
  123. getStoreDetail: {
  124. url: '/city/getStoreDetail',
  125. method: 'GET',
  126. },
  127. //发布按钮列表
  128. getPublishList: {
  129. url: '/city/getPublishList',
  130. method: 'GET',
  131. },
  132. //获取城市列表服务区域
  133. getCityList: {
  134. url: '/city/getCityList',
  135. method: 'GET',
  136. },
  137. //获取景点列表带分页
  138. getScenicPage: {
  139. url: '/city/getScenicPage',
  140. method: 'GET',
  141. },
  142. //获取景点详情
  143. getScenicDetail: {
  144. url: '/city/getScenicDetail',
  145. method: 'GET',
  146. },
  147. //获取评论列表type-0帖子-1租房-2工作-3景点-4美食-5活动-6人找车-7车找人
  148. getCommentPage: {
  149. url: '/city/getCommentPage',
  150. method: 'GET',
  151. },
  152. //获取江华人信息接口
  153. getJiangHuInfo: {
  154. url: '/city/getJiangHuInfo',
  155. method: 'GET',
  156. },
  157. //获取人找车分页列表
  158. getPeoplePage: {
  159. url: '/city/getPeoplePage',
  160. method: 'GET',
  161. },
  162. //获取人找车详情
  163. getPeopleDetail: {
  164. url: '/city/getPeopleDetail',
  165. method: 'GET',
  166. },
  167. //获取车找人分页列表
  168. getCatPage: {
  169. url: '/city/getCatPage',
  170. method: 'GET',
  171. },
  172. //获取车找人详情
  173. getCatDetail: {
  174. url: '/city/getCatDetail',
  175. method: 'GET',
  176. },
  177. //查询商城信息列表带分页
  178. getShopPingPage : {
  179. url: '/city/getShopPingPage',
  180. method: 'GET',
  181. },
  182. //根据商品标识查询商品信息详情
  183. getShopPingDetail : {
  184. url: '/city/getShopPingDetail',
  185. method: 'GET',
  186. },
  187. //发布帖子\动态
  188. publishPost: {
  189. url: '/token/publishPost',
  190. method: 'POST',
  191. limit : 1000,
  192. auth : true,
  193. showLoading : true,
  194. },
  195. //发布评论
  196. addComment: {
  197. url: '/token/addComment',
  198. method: 'POST',
  199. limit : 1000,
  200. auth : true,
  201. showLoading : true,
  202. },
  203. //发布租房信息
  204. publishRent: {
  205. url: '/token/publishRent',
  206. method: 'POST',
  207. limit : 1000,
  208. auth : true,
  209. showLoading : true,
  210. },
  211. //发布招聘信息
  212. publishJob: {
  213. url: '/token/publishJob',
  214. method: 'POST',
  215. limit : 1000,
  216. auth : true,
  217. showLoading : true,
  218. },
  219. //发布车找人信息
  220. publishCar: {
  221. url: '/token/publishCar',
  222. method: 'POST',
  223. limit : 1000,
  224. auth : true,
  225. showLoading : true,
  226. },
  227. //查询自己发布的动态
  228. getMyPostPage: {
  229. url: '/token/getMyPostPage',
  230. method: 'GET',
  231. auth : true,
  232. },
  233. //删除自己发布的动态
  234. deletePost: {
  235. url: '/token/deletePost',
  236. method: 'POST',
  237. auth : true,
  238. showLoading : true,
  239. },
  240. //店铺认证
  241. companyAuthentication: {
  242. url: '/token/companyAuthentication',
  243. method: 'POST',
  244. limit : 1000,
  245. auth : true,
  246. showLoading : true,
  247. },
  248. //个人认证
  249. personalAuthentication: {
  250. url: '/token/personalAuthentication',
  251. method: 'POST',
  252. limit : 1000,
  253. auth : true,
  254. showLoading : true,
  255. },
  256. //获取分享二维码
  257. getQrCode: {
  258. url: '/token/getQrCode',
  259. method: 'GET',
  260. auth : true,
  261. },
  262. //获取粉丝列表接口
  263. getFansList: {
  264. url: '/token/getFansList',
  265. method: 'GET',
  266. auth : true,
  267. },
  268. // 用户查询地址列表
  269. getAddressList : {
  270. url: '/token/getAddressList',
  271. method: 'GET',
  272. auth : true,
  273. },
  274. // 用户获取地址信息列表详情
  275. getAddressDetail : {
  276. url: '/token/getAddressDetail',
  277. method: 'GET',
  278. auth : true,
  279. },
  280. // 用户增加或者编辑地址信息
  281. addOrEditAddress : {
  282. url: '/token/addOrEditAddress',
  283. method: 'POST',
  284. auth : true,
  285. showLoading : true,
  286. limit : 1000,
  287. },
  288. // 删除地址
  289. deleteAddress : {
  290. url: '/token/deleteAddress',
  291. method: 'POST',
  292. auth : true,
  293. showLoading : true,
  294. },
  295. // 获取今日是否签到
  296. getTodaySign : {
  297. url: '/token/getTodaySign',
  298. method: 'GET',
  299. auth : true,
  300. showLoading : true,
  301. },
  302. // 签到
  303. sign : {
  304. url: '/token/sign',
  305. method: 'POST',
  306. auth : true,
  307. showLoading : true,
  308. },
  309. // 查看积分流水
  310. getPointsFlow : {
  311. url: '/token/getPointsFlow',
  312. method: 'GET',
  313. auth : true,
  314. showLoading : true,
  315. },
  316. // 查看钱包流水
  317. getWalletFlow : {
  318. url: '/token/getWalletFlow',
  319. method: 'GET',
  320. auth : true,
  321. showLoading : true,
  322. },
  323. //提现
  324. storeWithdrawalApplication : {
  325. url: '/token/withdraw',
  326. method: 'POST',
  327. auth : true,
  328. showLoading : true,
  329. },
  330. // 点击查看联系方式 类型 0帖子 1租房 2工作 3门店
  331. checkGivePhone : {
  332. url: '/token/checkGivePhone',
  333. method: 'POST',
  334. auth : true,
  335. showLoading : true,
  336. },
  337. // 查询店铺中的商品、美食
  338. getGoodsList : {
  339. url: '/token/getGoodsList',
  340. method: 'GET',
  341. auth : true,
  342. },
  343. // 查询我的店铺
  344. myShop : {
  345. url: '/token/myShop',
  346. method: 'GET',
  347. auth : true,
  348. },
  349. // 领取提现成功
  350. requestMerchantTransfer : {
  351. url: '/cashout/getMoney',
  352. method: 'GET',
  353. auth : true,
  354. }
  355. }
  356. const models = ['order']
  357. models.forEach(key => {
  358. addApiModel(require(`./model/${key}.js`).default, key)
  359. })
  360. export function api(key, data, callback, loadingTitle) {
  361. let req = config[key]
  362. if (!req) {
  363. console.error('无效key--------' + key);
  364. return
  365. }
  366. if (typeof callback == 'string') {
  367. loadingTitle = callback
  368. }
  369. if (typeof data == 'function') {
  370. callback = data
  371. data = {}
  372. }
  373. // 接口限流
  374. if (req.limit) {
  375. let storageKey = req.url
  376. let storage = limit[storageKey]
  377. if (storage && new Date().getTime() - storage < req.limit) {
  378. return
  379. }
  380. limit[storageKey] = new Date().getTime()
  381. }
  382. //必须登录
  383. if (req.auth) {
  384. if (!uni.getStorageSync('token')) {
  385. utils.toLogin()
  386. console.error('需要登录')
  387. return
  388. }
  389. }
  390. // 接口防抖
  391. if(req.debounce){
  392. let storageKey = req.url
  393. let storage = debounce[storageKey]
  394. if (storage) {
  395. clearTimeout(storage)
  396. }
  397. debounce[storageKey] = setTimeout(() => {
  398. clearTimeout(storage)
  399. delete debounce[storageKey]
  400. http.http(req.url, data, callback, req.method,
  401. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  402. }, req.debounce)
  403. return
  404. }
  405. http.http(req.url, data, callback, req.method,
  406. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle,
  407. req)
  408. }
  409. function addApiModel(model, key){
  410. for(let k in model){
  411. if(config[`${k}`]){
  412. console.error(`重名api------model=${key},key=${k}`);
  413. continue
  414. }
  415. config[`${k}`] = model[k]
  416. // config[`${key}_${k}`] = model[k]
  417. }
  418. }
  419. export default api