酒店桌布为微信小程序
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.

430 lines
7.0 KiB

9 months ago
6 months ago
9 months ago
8 months ago
9 months ago
8 months ago
7 months ago
7 months ago
7 months ago
8 months ago
8 months ago
8 months ago
8 months ago
7 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
7 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
6 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
7 months ago
8 months ago
8 months ago
8 months ago
8 months ago
7 months ago
8 months ago
8 months ago
8 months ago
8 months ago
7 months ago
8 months ago
8 months ago
7 months ago
7 months ago
7 months ago
7 months ago
8 months ago
6 months ago
7 months ago
6 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
6 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
9 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: {
  12. url: '/api/getConfig',
  13. method: 'GET'
  14. },
  15. // 获取客服联系电话
  16. customUser: {
  17. url: '/user/custom',
  18. method: 'get',
  19. },
  20. // 获取配置
  21. getConfigOne: {
  22. url: '/conf/one',
  23. method: 'POST',
  24. },
  25. // banner列表
  26. bannerList: {
  27. url: '/banner/list',
  28. method: 'GET',
  29. },
  30. // 公告列表
  31. noticeList: {
  32. url: '/notice/list',
  33. method: 'GET',
  34. },
  35. // 公告详情
  36. noticeOne: {
  37. url: '/notice/one',
  38. method: 'GET',
  39. },
  40. // 商品列表
  41. goodsPage: {
  42. url: '/goods/page',
  43. method: 'GET',
  44. showLoading: true,
  45. debounce : 300,
  46. },
  47. // 商品详情
  48. goodsOne: {
  49. url: '/goods/one',
  50. method: 'GET',
  51. showLoading: true,
  52. },
  53. // 购物车分页
  54. cartPage: {
  55. url: '/goods/shopping/cart/page',
  56. method: 'GET',
  57. showLoading: true,
  58. auth: true,
  59. },
  60. // 加入购物车
  61. cartAdd: {
  62. url: '/goods/join/shopping/cart',
  63. method: 'POST',
  64. showLoading: true,
  65. auth: true,
  66. },
  67. // 删除购物车
  68. cartDel: {
  69. url: '/goods/shopping/cart/delete',
  70. method: 'POST',
  71. showLoading: true,
  72. auth: true,
  73. },
  74. // 修改购物车数量
  75. cartNum: {
  76. url: '/goods/shopping/cart/add/or/delete',
  77. method: 'POST',
  78. auth: true,
  79. debounce: 1000,
  80. },
  81. //分类列表
  82. categoryList: {
  83. url: '/category/list',
  84. method: 'GET',
  85. showLoading: true,
  86. },
  87. //新增地址
  88. addressAdd: {
  89. url: '/address/add',
  90. method: 'POST',
  91. limit: 500,
  92. auth: true,
  93. showLoading: true,
  94. },
  95. //修改默认地址
  96. addressDefault: {
  97. url: '/address/default',
  98. method: 'POST',
  99. auth: true,
  100. showLoading: true,
  101. },
  102. //删除地址
  103. addressDelete: {
  104. url: '/address/delete',
  105. method: 'POST',
  106. auth: true,
  107. showLoading: true,
  108. },
  109. //修改地址
  110. addressEdit: {
  111. url: '/address/edit',
  112. method: 'POST',
  113. limit: 500,
  114. auth: true,
  115. showLoading: true,
  116. },
  117. //分页查询地址
  118. addressPage: {
  119. url: '/address/page',
  120. method: 'GET',
  121. auth: true,
  122. showLoading: true,
  123. },
  124. // 分页查询我的客户
  125. getMyUserPage: {
  126. url: '/shop/user',
  127. method: 'GET',
  128. auth: true,
  129. showLoading: true,
  130. },
  131. //优惠券分页接口
  132. couponPage: {
  133. url: '/coupon/page',
  134. method: 'GET',
  135. auth: true,
  136. showLoading: true,
  137. },
  138. //分页查询订单
  139. orderPage: {
  140. url: '/order/page',
  141. method: 'GET',
  142. auth: true,
  143. showLoading: true,
  144. },
  145. //查询订单详情
  146. orderOne: {
  147. url: '/order/one',
  148. method: 'GET',
  149. auth: true,
  150. showLoading: true,
  151. },
  152. // 微信登录接口
  153. wxLogin: {
  154. url: '/login/login',
  155. method: 'POST',
  156. limit: 500,
  157. showLoading: true,
  158. },
  159. // 修改个人信息接口
  160. updateInfo: {
  161. url: '/user/edit',
  162. method: 'POST',
  163. auth: true,
  164. limit: 500,
  165. showLoading: true,
  166. },
  167. // 获取用户信息
  168. getInfo: {
  169. url: '/user/info',
  170. method: 'GET',
  171. auth: true,
  172. showLoading: true,
  173. },
  174. // 获取我的租赁
  175. getLeasePage: {
  176. url: '/user/lease/page',
  177. method: 'POST',
  178. showLoading: true,
  179. },
  180. // 获取我的租金
  181. getRentPrice : {
  182. url : '/user/lease/all/deposit/price',
  183. method: 'GET',
  184. auth: true,
  185. },
  186. // 申请成为水洗店
  187. applyShopHotel: {
  188. url: '/shop/apply',
  189. method: 'POST',
  190. showLoading: true,
  191. auth: true,
  192. },
  193. // 店铺申请提现
  194. storeWithdrawalApplication: {
  195. url: '/shop/withdrawal/apply',
  196. method: 'POST',
  197. showLoading: true,
  198. auth: true,
  199. },
  200. // 提现日志
  201. withdrawalLog: {
  202. url: '/shop/withdrawal/page',
  203. method: 'GET',
  204. showLoading: true,
  205. auth: true,
  206. },
  207. // 水洗店首页数据
  208. laundryStoreHomeData: {
  209. url: '/shop/index',
  210. method: 'GET',
  211. // showLoading : true,
  212. auth: true,
  213. },
  214. // 修改店铺信息
  215. shopEditInfo: {
  216. url: '/shop/edit/info',
  217. method: 'POST',
  218. showLoading : true,
  219. auth: true,
  220. },
  221. // 获取绑定店铺的数据
  222. bindShop: {
  223. url: '/shop/bind',
  224. method: 'GET',
  225. // showLoading : true,
  226. auth: true,
  227. },
  228. // 修改店铺营业时间
  229. updateJobTime: {
  230. url: '/shop/job/time',
  231. method: 'POST',
  232. // showLoading : true,
  233. auth: true,
  234. },
  235. // 退货、换货申请
  236. refundOrder: {
  237. url: '/order/refund',
  238. method: 'POST',
  239. // showLoading : true,
  240. auth: true,
  241. },
  242. // 商品租赁下订单
  243. orderCreate: {
  244. url: '/order/create',
  245. method: 'POST',
  246. showLoading : true,
  247. limit: 500,
  248. auth: true,
  249. },
  250. // 取消订单
  251. orderCancel: {
  252. url: '/order/cancel',
  253. method: 'POST',
  254. showLoading : true,
  255. limit: 500,
  256. auth: true,
  257. },
  258. // 商品租赁订单支付
  259. orderPay: {
  260. url: '/order/pay',
  261. method: 'POST',
  262. showLoading : true,
  263. limit: 500,
  264. auth: true,
  265. },
  266. // 确认收货
  267. orderConfirm: {
  268. url: '/order/confirm',
  269. method: 'POST',
  270. showLoading : true,
  271. limit: 500,
  272. auth: true,
  273. },
  274. // 订单详情列表
  275. detailList: {
  276. // order/detail/list
  277. url: '/order/detail/list',
  278. method: 'GET',
  279. showLoading : true,
  280. limit: 500,
  281. auth: true,
  282. },
  283. // 根据商品id获取规格
  284. goodsSku: {
  285. url: '/goods/sku',
  286. method: 'GET',
  287. auth: true,
  288. },
  289. // 购物车修改多规格
  290. editSku: {
  291. url: '/goods/shopping/cart/edit/sku',
  292. method: 'POST',
  293. auth: true,
  294. },
  295. // 水洗店账号绑定微信
  296. bindWx: {
  297. url: '/shop/bind/wx',
  298. method: 'POST',
  299. auth: true,
  300. },
  301. // 上传自己的桌布
  302. tablecloth: {
  303. url: '/order/upload/tablecloth',
  304. method: 'POST',
  305. auth: true,
  306. },
  307. // 水洗店确认接单
  308. orderConfirmAccept: {
  309. url: '/order/confirm/accept',
  310. method: 'POST',
  311. auth: true,
  312. },
  313. // 酒店换货支付
  314. replacePay: {
  315. url: '/order/replace/pay',
  316. method: 'POST',
  317. auth: true,
  318. },
  319. // 水洗店发货
  320. sendLogistics: {
  321. url: '/order/send/logistics',
  322. method: 'POST',
  323. auth: true,
  324. },
  325. // 获取全局总金额优惠满减
  326. confCoupon: {
  327. url: '/conf/coupon',
  328. method: 'GET',
  329. },
  330. // 水洗订单,水洗店确认快递收货完成
  331. orderConfirmWashReceipt : {
  332. url: '/order/shop/wash/receipt',
  333. method: 'POST',
  334. auth: true,
  335. }
  336. }
  337. export function api(key, data, callback, loadingTitle) {
  338. let req = config[key]
  339. if (!req) {
  340. console.error('无效key' + key);
  341. return
  342. }
  343. if (typeof callback == 'string') {
  344. loadingTitle = callback
  345. }
  346. if (typeof data == 'function') {
  347. callback = data
  348. data = {}
  349. }
  350. // 接口限流
  351. if (req.limit) {
  352. let storageKey = req.url
  353. let storage = limit[storageKey]
  354. if (storage && new Date().getTime() - storage < req.limit) {
  355. return
  356. }
  357. limit[storageKey] = new Date().getTime()
  358. }
  359. //必须登录
  360. if (req.auth) {
  361. if (!uni.getStorageSync('token')) {
  362. utils.toLogin()
  363. console.error('需要登录')
  364. return
  365. }
  366. }
  367. // 接口防抖
  368. if (req.debounce) {
  369. let storageKey = req.url
  370. let storage = debounce[storageKey]
  371. if (storage) {
  372. clearTimeout(storage)
  373. }
  374. debounce[storageKey] = setTimeout(() => {
  375. clearTimeout(storage)
  376. delete debounce[storageKey]
  377. http.http(req.url, data, callback, req.method,
  378. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  379. }, req.debounce)
  380. return
  381. }
  382. http.http(req.url, data, callback, req.method,
  383. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  384. }
  385. export default api