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

279 lines
6.2 KiB

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