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

303 lines
4.9 KiB

10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 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. // banner列表
  15. bannerList: {
  16. url: '/banner/list',
  17. method: 'GET',
  18. showLoading: true,
  19. },
  20. // 公告列表
  21. noticeList: {
  22. url: '/notice/list',
  23. method: 'GET',
  24. showLoading: true,
  25. },
  26. // 公告详情
  27. noticeOne: {
  28. url: '/notice/one',
  29. method: 'GET',
  30. showLoading: true,
  31. },
  32. // 商品列表
  33. goodsPage: {
  34. url: '/goods/page',
  35. method: 'GET',
  36. showLoading: true,
  37. },
  38. // 商品详情
  39. goodsOne: {
  40. url: '/goods/one',
  41. method: 'GET',
  42. showLoading: true,
  43. },
  44. // 购物车分页
  45. cartPage: {
  46. url: '/goods/shopping/cart/page',
  47. method: 'GET',
  48. showLoading: true,
  49. auth: true,
  50. },
  51. // 加入购物车
  52. cartAdd: {
  53. url: '/goods/join/shopping/cart',
  54. method: 'POST',
  55. showLoading: true,
  56. auth: true,
  57. },
  58. // 删除购物车
  59. cartDel: {
  60. url: '/goods/shopping/cart/delete',
  61. method: 'POST',
  62. showLoading: true,
  63. auth: true,
  64. },
  65. // 修改购物车数量
  66. cartNum: {
  67. url: '/goods/shopping/cart/add/or/delete',
  68. method: 'POST',
  69. auth: true,
  70. debounce: 1000,
  71. },
  72. //分类列表
  73. categoryList: {
  74. url: '/category/list',
  75. method: 'GET',
  76. showLoading: true,
  77. },
  78. //新增地址
  79. addressAdd: {
  80. url: '/address/add',
  81. method: 'POST',
  82. limit: 500,
  83. auth: true,
  84. showLoading: true,
  85. },
  86. //修改默认地址
  87. addressDefault: {
  88. url: '/address/default',
  89. method: 'POST',
  90. auth: true,
  91. showLoading: true,
  92. },
  93. //删除地址
  94. addressDelete: {
  95. url: '/address/delete',
  96. method: 'POST',
  97. auth: true,
  98. showLoading: true,
  99. },
  100. //修改地址
  101. addressEdit: {
  102. url: '/address/edit',
  103. method: 'POST',
  104. limit: 500,
  105. auth: true,
  106. showLoading: true,
  107. },
  108. //分页查询地址
  109. addressPage: {
  110. url: '/address/page',
  111. method: 'GET',
  112. auth: true,
  113. showLoading: true,
  114. },
  115. // 分页查询我的客户
  116. getMyUserPage: {
  117. url: '/shop/user',
  118. method: 'GET',
  119. auth: true,
  120. showLoading: true,
  121. },
  122. //分页查询订单
  123. orderPage: {
  124. url: '/order/page',
  125. method: 'GET',
  126. auth: true,
  127. showLoading: true,
  128. },
  129. //查询订单详情
  130. orderOne: {
  131. url: '/order/one',
  132. method: 'GET',
  133. auth: true,
  134. showLoading: true,
  135. },
  136. // 微信登录接口
  137. wxLogin: {
  138. url: '/login/login',
  139. method: 'POST',
  140. limit: 500,
  141. showLoading: true,
  142. },
  143. // 修改个人信息接口
  144. updateInfo: {
  145. url: '/user/edit',
  146. method: 'POST',
  147. auth: true,
  148. limit: 500,
  149. showLoading: true,
  150. },
  151. // 获取用户信息
  152. getInfo: {
  153. url: '/user/info',
  154. method: 'GET',
  155. auth: true,
  156. showLoading: true,
  157. },
  158. // 获取我的租赁
  159. getLeasePage: {
  160. url: '/user/lease/page',
  161. method: 'POST',
  162. showLoading: true,
  163. },
  164. // 申请成为水洗店
  165. applyShopHotel: {
  166. url: '/shop/apply',
  167. method: 'POST',
  168. showLoading: true,
  169. auth: true,
  170. },
  171. // 店铺申请提现
  172. storeWithdrawalApplication: {
  173. url: '/shop/withdrawal/apply',
  174. method: 'POST',
  175. showLoading: true,
  176. auth: true,
  177. },
  178. // 提现日志
  179. withdrawalLog: {
  180. url: '/shop/withdrawal/page',
  181. method: 'GET',
  182. showLoading: true,
  183. auth: true,
  184. },
  185. // 水洗店首页数据
  186. laundryStoreHomeData: {
  187. url: '/shop/index',
  188. method: 'GET',
  189. // showLoading : true,
  190. auth: true,
  191. },
  192. // 获取绑定店铺的数据
  193. bindShop: {
  194. url: '/shop/bind',
  195. method: 'GET',
  196. // showLoading : true,
  197. auth: true,
  198. },
  199. // 修改店铺营业时间
  200. updateJobTime: {
  201. url: '/shop/job/time',
  202. method: 'POST',
  203. // showLoading : true,
  204. auth: true,
  205. },
  206. // 退货、换货申请
  207. refundOrder: {
  208. url: '/order/refund',
  209. method: 'POST',
  210. // showLoading : true,
  211. auth: true,
  212. },
  213. }
  214. export function api(key, data, callback, loadingTitle) {
  215. let req = config[key]
  216. if (!req) {
  217. console.error('无效key' + key);
  218. return
  219. }
  220. if (typeof callback == 'string') {
  221. loadingTitle = callback
  222. }
  223. if (typeof data == 'function') {
  224. callback = data
  225. data = {}
  226. }
  227. // 接口限流
  228. if (req.limit) {
  229. let storageKey = req.url
  230. let storage = limit[storageKey]
  231. if (storage && new Date().getTime() - storage < req.limit) {
  232. return
  233. }
  234. limit[storageKey] = new Date().getTime()
  235. }
  236. //必须登录
  237. if (req.auth) {
  238. if (!uni.getStorageSync('token')) {
  239. uni.navigateTo({
  240. url: '/pages_order/auth/wxLogin'
  241. })
  242. console.error('需要登录')
  243. return
  244. }
  245. }
  246. // 接口防抖
  247. if (req.debounce) {
  248. let storageKey = req.url
  249. let storage = debounce[storageKey]
  250. if (storage) {
  251. clearTimeout(storage)
  252. }
  253. debounce[storageKey] = setTimeout(() => {
  254. clearTimeout(storage)
  255. delete debounce[storageKey]
  256. http.http(req.url, data, callback, req.method,
  257. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  258. }, req.debounce)
  259. return
  260. }
  261. http.http(req.url, data, callback, req.method,
  262. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  263. }
  264. export default api