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

297 lines
6.6 KiB

6 months ago
6 months ago
4 months ago
6 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
4 months ago
6 months ago
4 months ago
4 months ago
6 months ago
4 months ago
4 months ago
6 months ago
4 months ago
4 months ago
5 months ago
4 months ago
4 months ago
6 months ago
4 months ago
4 months ago
6 months ago
4 months ago
4 months ago
6 months ago
4 months ago
6 months ago
4 months ago
4 months ago
6 months ago
5 months ago
4 months ago
4 months ago
5 months ago
6 months ago
4 months ago
4 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
4 months ago
4 months ago
6 months ago
6 months ago
6 months ago
4 months ago
4 months ago
6 months ago
6 months ago
5 months ago
4 months ago
4 months ago
6 months ago
6 months ago
4 months ago
4 months ago
6 months ago
5 months ago
5 months ago
6 months ago
4 months ago
4 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 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. addProduct: {
  89. url: '/product/addProduct',
  90. method: 'POST',
  91. limit: 1500,
  92. showLoading: true,
  93. },
  94. // 修改产品报价
  95. updateProduct: {
  96. url: '/product/updateProduct',
  97. method: 'POST',
  98. limit: 1500,
  99. showLoading: true,
  100. },
  101. // 下订单
  102. addProductOrder: {
  103. url: '/product/addProductOrder',
  104. method: 'POST',
  105. limit: 1500,
  106. showLoading: true,
  107. },
  108. // 确认-取消订单
  109. updateOrder: {
  110. url: '/product/updateOrder',
  111. method: 'POST',
  112. limit: 1500,
  113. showLoading: true,
  114. },
  115. // 我的挂单列表
  116. getMyProductlist: {
  117. url: '/product/myProductlist',
  118. method: 'GET',
  119. },
  120. // 撤单
  121. noShow: {
  122. url: '/product/noShow',
  123. method: 'GET',
  124. limit: 1500,
  125. showLoading: true,
  126. },
  127. // 现货/期货列表
  128. productList: {
  129. url: '/product/productList',
  130. method: 'GET',
  131. },
  132. // 交易平台挂单列表
  133. productlist: {
  134. url: '/product/productlist',
  135. method: 'GET',
  136. },
  137. // ========================用户地址===============================
  138. // 用户地址表-添加
  139. addAddress: {
  140. url: '/address/add',
  141. method: 'POST',
  142. limit: 1500,
  143. showLoading: true,
  144. },
  145. // 用户地址表-编辑
  146. editAddress: {
  147. url: '/address/edit',
  148. method: 'POST',
  149. limit: 1500,
  150. showLoading: true,
  151. },
  152. // 用户地址表-删除
  153. deleteAddress: {
  154. url: '/address/edit',
  155. method: 'POST',
  156. limit: 1500,
  157. showLoading: true,
  158. },
  159. // 用户地址表-分页列表查询
  160. addressList: {
  161. url: '/address/list',
  162. method: 'GET',
  163. },
  164. // ========================首页等展示接口===============================
  165. // 帮助与反馈
  166. addSuggest: {
  167. url: '/index/addSuggest',
  168. method: 'POST',
  169. limit: 1500,
  170. showLoading: true,
  171. },
  172. // 铝价接口
  173. getAlPrice: {
  174. url: '/index/alprice',
  175. method: 'POST',
  176. },
  177. // 我的头像昵称,平台客户电话等信息
  178. getImagePhoneOther: {
  179. url: '/index/index',
  180. method: 'POST',
  181. },
  182. // 我的订单列表
  183. myOrderlist: {
  184. url: '/product/myOrderlist',
  185. method: 'GET',
  186. },
  187. // 采购商根据订单id查询订单信息
  188. getMyOrderInfo: {
  189. url: '/product/myOrderlist',
  190. method: 'GET',
  191. },
  192. // 供应商根据挂单id查询挂单详情的接口
  193. getProductInfo: {
  194. url: '/product/myOrderlist',
  195. method: 'GET',
  196. },
  197. // 获取banner列表
  198. bannerList: {
  199. url: '/index/bannerList',
  200. method: 'POST',
  201. },
  202. // 规格分页列表查询
  203. specsList: {
  204. url: '/product/specsList',
  205. method: 'GET',
  206. },
  207. // 新铝价接口
  208. alpriceNew: {
  209. url: '/index/alpriceNew',
  210. method: 'POST',
  211. },
  212. // 查询仓库地址
  213. confAddressList : {
  214. url: '/address/confAddressList',
  215. method: 'GET',
  216. },
  217. }
  218. export function api(key, data, callback, loadingTitle) {
  219. let req = config[key]
  220. if (!req) {
  221. console.error('无效key' + key);
  222. return
  223. }
  224. if (typeof callback == 'string') {
  225. loadingTitle = callback
  226. }
  227. if (typeof data == 'function') {
  228. callback = data
  229. data = {}
  230. }
  231. // 接口限流
  232. if (req.limit) {
  233. let storageKey = req.url
  234. let storage = limit[storageKey]
  235. if (storage && new Date().getTime() - storage < req.limit) {
  236. return
  237. }
  238. limit[storageKey] = new Date().getTime()
  239. }
  240. //必须登录
  241. if (req.auth) {
  242. if (!uni.getStorageSync('token')) {
  243. uni.navigateTo({
  244. url: '/pages_order/auth/loginAndRegisterAndForgetPassword'
  245. })
  246. console.error('需要登录')
  247. return
  248. }
  249. }
  250. // 接口防抖
  251. if (req.debounce) {
  252. let storageKey = req.url
  253. let storage = debounce[storageKey]
  254. if (storage) {
  255. clearTimeout(storage)
  256. }
  257. debounce[storageKey] = setTimeout(() => {
  258. clearTimeout(storage)
  259. delete debounce[storageKey]
  260. http.http(req.url, data, callback, req.method,
  261. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  262. }, req.debounce)
  263. return
  264. }
  265. http.http(req.url, data, callback, req.method,
  266. loadingTitle || req.showLoading, loadingTitle || req.loadingTitle)
  267. }
  268. export default api