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

415 lines
6.7 KiB

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