铝交易,微信公众号
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.

311 lines
6.8 KiB

4 months ago
4 months ago
2 months ago
4 months ago
4 months ago
2 months ago
4 months ago
2 months ago
4 months ago
2 months ago
4 months ago
2 months ago
2 months ago
4 months ago
2 months ago
2 months ago
4 months ago
2 months ago
2 months ago
4 months ago
2 months ago
2 months ago
3 months ago
2 months ago
2 months ago
4 months ago
2 months ago
2 months ago
4 months ago
1 day ago
4 months ago
2 months ago
2 months ago
4 months ago
2 months ago
4 months ago
2 months ago
2 months ago
4 months ago
4 months ago
2 months ago
2 months ago
4 months ago
4 months ago
2 months ago
2 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
2 months ago
2 months ago
4 months ago
4 months ago
4 months ago
2 months ago
2 months ago
4 months ago
4 months ago
3 months ago
2 months ago
2 months ago
4 months ago
4 months ago
2 months ago
2 months ago
4 months ago
1 day ago
1 month ago
4 months ago
1 month ago
4 months ago
4 months ago
1 day ago
4 months ago
3 months ago
4 months ago
2 months ago
2 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 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 : 1500
  9. // },
  10. getConfig: {url: '/index/getSysText', method: 'POST', limit: 1500},
  11. // 微信登录接口
  12. wxLogin: {
  13. url: '/login/login',
  14. method: 'POST',
  15. limit: 1500,
  16. showLoading: true,
  17. },
  18. // 修改个人信息接口
  19. updateInfo: {
  20. url: '/info/updateInfo',
  21. method: 'POST',
  22. auth: true,
  23. limit: 1500,
  24. showLoading: true,
  25. },
  26. //隐私政策
  27. getPrivacyPolicy: {
  28. url: '/login/getPrivacyPolicy',
  29. method: 'GET',
  30. },
  31. //用户协议
  32. getUserAgreement: {
  33. url: '/login/getUserAgreement',
  34. method: 'GET',
  35. },
  36. // ========================用户登录注册===============================
  37. //用户登录
  38. loginUser: {
  39. url: '/alUser/login',
  40. method: 'POST',
  41. limit: 1500,
  42. showLoading: true,
  43. },
  44. //用户注册
  45. registerUser: {
  46. url: '/alUser/regUesr',
  47. method: 'POST',
  48. limit: 1500,
  49. showLoading: true,
  50. },
  51. // 发送短信接口
  52. sendSms: {
  53. url: '/alUser/sendSms',
  54. method: 'POST',
  55. limit: 1500,
  56. showLoading: true,
  57. },
  58. // 选择身份
  59. roleOption: {
  60. url: '/alUser/role',
  61. method: 'POST',
  62. limit : 1500,
  63. showLoading: true,
  64. },
  65. // 修改身份信息
  66. updateRoleInfo: {
  67. url: '/alUser/updateRoleInfo',
  68. method: 'POST',
  69. limit : 1500,
  70. showLoading: true,
  71. },
  72. // 忘记密码
  73. newPassword: {
  74. url: '/alUser/newPassword',
  75. method: 'POST',
  76. limit : 1500,
  77. showLoading: true,
  78. },
  79. // ========================产品报价===============================
  80. // 清关申请
  81. addCustoms: {
  82. url: '/product/addCustoms',
  83. method: 'POST',
  84. limit : 1500,
  85. showLoading: true,
  86. },
  87. // 清关申请
  88. myCustoms: {
  89. url: '/product/myCustoms',
  90. method: 'POST',
  91. limit : 1500,
  92. showLoading: true,
  93. },
  94. // 产品报价
  95. addProduct: {
  96. url: '/product/addProduct',
  97. method: 'POST',
  98. limit: 1500,
  99. showLoading: true,
  100. },
  101. // 修改产品报价
  102. updateProduct: {
  103. url: '/product/updateProduct',
  104. method: 'POST',
  105. limit: 1500,
  106. showLoading: true,
  107. },
  108. // 下订单
  109. addProductOrder: {
  110. url: '/product/addProductOrder',
  111. method: 'POST',
  112. limit: 1500,
  113. showLoading: true,
  114. },
  115. // 确认-取消订单
  116. updateOrder: {
  117. url: '/product/updateOrder',
  118. method: 'POST',
  119. limit: 1500,
  120. showLoading: true,
  121. },
  122. // 我的挂单列表
  123. getMyProductlist: {
  124. url: '/product/myProductlist',
  125. method: 'GET',
  126. },
  127. // 撤单
  128. noShow: {
  129. url: '/product/noShow',
  130. method: 'GET',
  131. limit: 1500,
  132. showLoading: true,
  133. },
  134. // 现货/期货列表
  135. productList: {
  136. url: '/product/productList',
  137. method: 'GET',
  138. },
  139. // 交易平台挂单列表
  140. productlist: {
  141. url: '/product/productlist',
  142. method: 'GET',
  143. },
  144. // ========================用户地址===============================
  145. // 用户地址表-添加
  146. addAddress: {
  147. url: '/address/add',
  148. method: 'POST',
  149. limit: 1500,
  150. showLoading: true,
  151. },
  152. // 用户地址表-编辑
  153. editAddress: {
  154. url: '/address/edit',
  155. method: 'POST',
  156. limit: 1500,
  157. showLoading: true,
  158. },
  159. // 用户地址表-删除
  160. deleteAddress: {
  161. url: '/address/edit',
  162. method: 'POST',
  163. limit: 1500,
  164. showLoading: true,
  165. },
  166. // 用户地址表-分页列表查询
  167. addressList: {
  168. url: '/address/list',
  169. method: 'GET',
  170. },
  171. // ========================首页等展示接口===============================
  172. // 帮助与反馈
  173. addSuggest: {
  174. url: '/index/addSuggest',
  175. method: 'POST',
  176. limit: 1500,
  177. showLoading: true,
  178. },
  179. // 铝价接口
  180. getAlPrice: {
  181. url: '/index/alprice',
  182. method: 'POST',
  183. },
  184. // 获取个人信息
  185. getUserInfo: {
  186. url: '/index/index',
  187. method: 'POST',
  188. auth : true,
  189. },
  190. // 我的头像昵称,平台客户电话等信息
  191. getImagePhoneOther: {
  192. url: '/index/getIndex',
  193. method: 'POST',
  194. },
  195. // 我的订单列表
  196. myOrderlist: {
  197. url: '/product/myOrderlist',
  198. method: 'GET',
  199. auth : true,
  200. },
  201. // 采购商根据订单id查询订单信息
  202. getMyOrderInfo: {
  203. url: '/product/myOrderlist',
  204. method: 'GET',
  205. },
  206. // 供应商根据挂单id查询挂单详情的接口
  207. getProductInfo: {
  208. url: '/product/myOrderlist',
  209. method: 'GET',
  210. },
  211. // 获取banner列表
  212. bannerList: {
  213. url: '/index/bannerList',
  214. method: 'POST',
  215. },
  216. // 规格分页列表查询
  217. specsList: {
  218. url: '/product/specsList',
  219. method: 'GET',
  220. },
  221. // 新铝价接口
  222. alpriceNew: {
  223. url: '/index/alpriceNew',
  224. method: 'POST',
  225. },
  226. // 查询仓库地址
  227. confAddressList : {
  228. url: '/address/confAddressList',
  229. method: 'GET',
  230. },
  231. }
  232. export function api(key, data, callback, loadingTitle) {
  233. let req = config[key]
  234. if (!req) {
  235. console.error('无效key' + key);
  236. return
  237. }
  238. if (typeof callback == 'string') {
  239. loadingTitle = callback
  240. }
  241. if (typeof data == 'function') {
  242. callback = data
  243. data = {}
  244. }
  245. // 接口限流
  246. if (req.limit) {
  247. let storageKey = req.url
  248. let storage = limit[storageKey]
  249. if (storage && new Date().getTime() - storage < req.limit) {
  250. return
  251. }
  252. limit[storageKey] = new Date().getTime()
  253. }
  254. //必须登录
  255. if (req.auth) {
  256. if (!uni.getStorageSync('token')) {
  257. uni.navigateTo({
  258. url: '/pages_order/auth/loginAndRegisterAndForgetPassword'
  259. })
  260. console.error('需要登录')
  261. return
  262. }
  263. }
  264. // 接口防抖
  265. if (req.debounce) {
  266. let storageKey = req.url
  267. let storage = debounce[storageKey]
  268. if (storage) {
  269. clearTimeout(storage)
  270. }
  271. debounce[storageKey] = setTimeout(() => {
  272. clearTimeout(storage)
  273. delete debounce[storageKey]
  274. http.http(req.url, data, callback, req.method,
  275. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  276. }, req.debounce)
  277. return
  278. }
  279. http.http(req.url, data, callback, req.method,
  280. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  281. }
  282. export default api