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

525 lines
9.2 KiB

1 year ago
11 months 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
11 months ago
11 months ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
11 months ago
11 months ago
11 months ago
1 year ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
4 months ago
10 months ago
10 months ago
1 year ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
11 months ago
1 year ago
7 months ago
1 year ago
11 months ago
11 months ago
1 year ago
  1. import http from './http.js'
  2. import utils from '../utils/utils.js'
  3. import commentApi from './model/comment.js'
  4. let limit = {}
  5. let debounce = {}
  6. const config = {
  7. // 示例
  8. // wxLogin : {url : '/api/wxLogin', method : 'POST',
  9. // auth : false, showLoading : true, loadingTitle : '加载中...',
  10. // limit : 1000
  11. // },
  12. getConfig : {url : '/login/getConfigInfo', method : 'GET', auth: false, limit : 500},
  13. // 微信登录接口
  14. wxLogin: {
  15. url: '/login/login',
  16. method: 'GET',
  17. limit : 500,
  18. showLoading : true,
  19. },
  20. // 修改个人信息接口
  21. updateInfo: {
  22. url: '/token/updateInfo',
  23. method: 'POST',
  24. auth: true,
  25. limit : 500,
  26. showLoading : true,
  27. },
  28. // 获取个人信息接口
  29. getInfo: {
  30. url: '/token/getInfo',
  31. method: 'GET',
  32. auth: true,
  33. limit : 500,
  34. },
  35. // 绑定手机号码
  36. bindPhone: {
  37. url: '/login/bindPhone',
  38. method: 'GET',
  39. auth: true,
  40. limit : 500,
  41. },
  42. //隐私政策
  43. getPrivacyPolicy: {
  44. url: '/login/getPrivacyPolicy',
  45. method: 'GET',
  46. },
  47. //用户协议
  48. getUserAgreement: {
  49. url: '/login/getUserAgreement',
  50. method: 'GET',
  51. },
  52. // 不需要登录的接口
  53. //获取分类
  54. getClassInfo: {
  55. url: '/city/getClassInfo',
  56. method: 'GET',
  57. auth: false,
  58. },
  59. //获取首页头部信息
  60. getIndexHeaderInfo: {
  61. url: '/city/getIndexHeaderInfo',
  62. method: 'GET',
  63. auth: false,
  64. },
  65. //获取banner列表
  66. getBannerList: {
  67. url: '/city/getBannerList',
  68. method: 'GET',
  69. auth: false,
  70. },
  71. //获取分类类型列表
  72. getClassifyList: {
  73. url: '/city/getClassifyList',
  74. method: 'GET',
  75. auth: false,
  76. },
  77. //获取工作信息列表
  78. getJobPage: {
  79. url: '/city/getJobPage',
  80. method: 'GET',
  81. },
  82. //获取工作详情
  83. getJobDetail: {
  84. url: '/city/getJobDetail',
  85. method: 'GET',
  86. },
  87. //根据分类获取租房信息列表
  88. getRentPage: {
  89. url: '/city/getRentPage',
  90. method: 'GET',
  91. },
  92. //获取租房详情
  93. getRentDetail: {
  94. url: '/city/getRentDetail',
  95. method: 'GET',
  96. },
  97. //获取动态帖子列表
  98. getPostPage: {
  99. url: '/city/getPostPage',
  100. method: 'GET',
  101. },
  102. //获取帖子详情
  103. getPostDetail: {
  104. url: '/city/getPostDetail',
  105. method: 'GET',
  106. },
  107. //获取活动列表信息
  108. getActivityPage: {
  109. url: '/city/getActivityPage',
  110. method: 'GET',
  111. },
  112. //获取活动详情
  113. getActivityDetail: {
  114. url: '/city/getActivityDetail',
  115. method: 'GET',
  116. },
  117. //获取活动详情
  118. getActivityDetail: {
  119. url: '/city/getActivityDetail',
  120. method: 'GET',
  121. },
  122. //获取门店信息列表(美食)
  123. getStorePage: {
  124. url: '/city/getStorePage',
  125. method: 'GET',
  126. },
  127. //获取门店详情(美食)
  128. getStoreDetail: {
  129. url: '/city/getStoreDetail',
  130. method: 'GET',
  131. },
  132. //发布按钮列表
  133. getPublishList: {
  134. url: '/city/getPublishList',
  135. method: 'GET',
  136. },
  137. //获取城市列表服务区域
  138. getCityList: {
  139. url: '/city/getCityList',
  140. method: 'GET',
  141. },
  142. //获取景点列表带分页
  143. getScenicPage: {
  144. url: '/city/getScenicPage',
  145. method: 'GET',
  146. },
  147. //获取景点详情
  148. getScenicDetail: {
  149. url: '/city/getScenicDetail',
  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. 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. getTodaySign : {
  289. url: '/token/getTodaySign',
  290. method: 'GET',
  291. auth : true,
  292. showLoading : true,
  293. },
  294. // 签到
  295. sign : {
  296. url: '/token/sign',
  297. method: 'POST',
  298. auth : true,
  299. showLoading : true,
  300. },
  301. // 查看积分流水
  302. getPointsFlow : {
  303. url: '/token/getPointsFlow',
  304. method: 'GET',
  305. auth : true,
  306. showLoading : true,
  307. },
  308. // 查看钱包流水
  309. getWalletFlow : {
  310. url: '/token/getWalletFlow',
  311. method: 'GET',
  312. auth : true,
  313. showLoading : true,
  314. },
  315. //提现
  316. storeWithdrawalApplication : {
  317. url: '/token/withdraw',
  318. method: 'POST',
  319. auth : true,
  320. showLoading : true,
  321. },
  322. // 点击查看联系方式 类型 0帖子 1租房 2工作 3门店
  323. checkGivePhone : {
  324. url: '/token/checkGivePhone',
  325. method: 'POST',
  326. auth : true,
  327. showLoading : true,
  328. },
  329. // 查询店铺中的商品、美食
  330. getGoodsList : {
  331. url: '/token/getGoodsList',
  332. method: 'GET',
  333. },
  334. // 查询我的店铺
  335. myShop : {
  336. url: '/token/myShop',
  337. method: 'GET',
  338. auth : true,
  339. },
  340. // 领取提现成功
  341. requestMerchantTransfer : {
  342. url: '/cashout/getMoney',
  343. method: 'GET',
  344. auth : true,
  345. },
  346. // 删除我的招聘
  347. deleteMyJob : {
  348. url: '/token/deleteMyJob',
  349. method: 'POST',
  350. auth : true,
  351. },
  352. // 删除我的租房
  353. deleteMyRent : {
  354. url: '/token/deleteMyRent',
  355. method: 'POST',
  356. auth : true,
  357. },
  358. // 编辑我的招聘
  359. editMyJob : {
  360. url: '/token/editMyJob',
  361. method: 'POST',
  362. auth : true,
  363. },
  364. // 编辑我的租房
  365. editMyRent : {
  366. url: '/token/editMyRent',
  367. method: 'POST',
  368. auth : true,
  369. },
  370. // 查询我的招聘
  371. getMyJob : {
  372. url: '/token/getMyJob',
  373. method: 'GET',
  374. auth : true,
  375. },
  376. // 查询我的租房
  377. getMyRent : {
  378. url: '/token/getMyRent',
  379. method: 'GET',
  380. auth : true,
  381. },
  382. // 新-获取我的客服信息列表
  383. getMyService : {
  384. url: '/token/getMyService',
  385. method: 'GET',
  386. auth : true,
  387. },
  388. // 新-获取大转盘抽奖列表
  389. getLuckDrawList : {
  390. url: '/token/getLuckDrawList',
  391. method: 'GET',
  392. auth : true,
  393. },
  394. // 新-大转盘抽奖
  395. luckDraw : {
  396. url: '/token/luckDraw',
  397. method: 'POST',
  398. auth : true,
  399. showLoading : true,
  400. },
  401. }
  402. const models = ['order', 'group', 'article', 'browseRecord']
  403. models.forEach(key => {
  404. addApiModel(require(`./model/${key}.js`).default, key)
  405. })
  406. export function api(key, data, callback, loadingTitle) {
  407. let req = config[key]
  408. if (!req) {
  409. console.error('无效key--------' + key);
  410. return
  411. }
  412. if (typeof callback == 'string') {
  413. loadingTitle = callback
  414. }
  415. if (typeof data == 'function') {
  416. callback = data
  417. data = {}
  418. }
  419. // 接口限流
  420. if (req.limit) {
  421. let storageKey = req.url
  422. let storage = limit[storageKey]
  423. if (storage && new Date().getTime() - storage < req.limit) {
  424. return
  425. }
  426. limit[storageKey] = new Date().getTime()
  427. }
  428. //必须登录
  429. if (req.auth) {
  430. if (!uni.getStorageSync('token')) {
  431. utils.toLogin()
  432. console.error('需要登录')
  433. return
  434. }
  435. }
  436. // 接口防抖
  437. if(req.debounce){
  438. let storageKey = req.url
  439. let storage = debounce[storageKey]
  440. if (storage) {
  441. clearTimeout(storage)
  442. }
  443. debounce[storageKey] = setTimeout(() => {
  444. clearTimeout(storage)
  445. delete debounce[storageKey]
  446. http.http(req.url, data, callback, req.method,
  447. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  448. }, req.debounce)
  449. return
  450. }
  451. http.http(req.url, data, callback, req.method,
  452. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle,
  453. req)
  454. }
  455. function addApiModel(model, key){
  456. for(let k in model){
  457. if(config[`${k}`]){
  458. console.error(`重名api------model=${key},key=${k}`);
  459. continue
  460. }
  461. config[`${k}`] = model[k]
  462. // config[`${key}_${k}`] = model[k]
  463. }
  464. }
  465. // 添加评论模块API
  466. addApiModel(commentApi, 'comment')
  467. export default api