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

422 lines
6.8 KiB

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