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

272 lines
6.0 KiB

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