appraise.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. // const { useParamsEaseFuncs } = require('XrFrame/xrFrameSystem');
  2. const { request } = require('../utils/request')
  3. const {ws} = require('../utils/util')
  4. const API = {
  5. createCommentURL: '/appraise/create',
  6. loginURL: '/user/login',
  7. getUserInfoURL: '/user/info',
  8. registerURL: '/user/register',
  9. modifyURL: '/user/modify',
  10. getOrderURL: '/order/user',
  11. getCategoryURL: '/category',
  12. getCategoryGoods: '/goods/category',
  13. getUserRelationUrl: '/relation/friend',
  14. addUserRelationUrl: '/relation/create',
  15. getUserInfoListUrl: '/user/list',
  16. getGoodsInfoListUrl: '/goods/list',
  17. chatUrl: '/chat',
  18. getChattingRecordUrl: '/chat/msg',
  19. getGoodsInfoUrl: '/goods/detail',
  20. getLatestChattingRecordUrl: '/chat/latest',
  21. getUserAllOrderUrl: '/order/user',
  22. getCategoryGoodsURL: '/goods/category',
  23. getAllGoodsURL: '/goods',
  24. getSearchGoodsURL: '/goods/search',
  25. postGoodsURL: '/goods/create',
  26. getGoodsDetailURL: '/goods/detail',
  27. postReviseOrder: '/order/revise',
  28. getRecommendUrl: '/goods/recommend',
  29. getUserAllGoodsUrl:'/goods/user',
  30. initRecommendURL:'/user/rec/new'
  31. }
  32. //查询列表时传参---注意参数数据类型
  33. function createCommont(data) {
  34. //Promise
  35. return request.post(
  36. API.createCommentURL,
  37. {
  38. data: data
  39. }
  40. );
  41. }
  42. /**
  43. * @param: {pageNum, pageSize}
  44. */
  45. //传对象给params
  46. function getCommentList(params) {
  47. return request.get(
  48. API.createCommentURL,
  49. {
  50. params: params,//是传入的形参
  51. }
  52. );
  53. }
  54. // //超时设置:timeout: 1000 * 60 * 30
  55. // function deleteComment() {
  56. // }
  57. function login(params) {
  58. return request.post(
  59. API.loginURL,
  60. {
  61. header: params.header,
  62. data: params.data,
  63. }
  64. );
  65. }
  66. function getUserInfo(params) {
  67. return request.get(
  68. API.getUserInfoURL,
  69. );
  70. }
  71. function register(params) {
  72. return request.post(
  73. API.registerURL,
  74. {
  75. data: params.data,
  76. }
  77. );
  78. }
  79. function modify(params) {
  80. return request.post(
  81. API.modifyURL,
  82. {
  83. data: params.data,
  84. }
  85. );
  86. }
  87. function getOrder(params) {
  88. return request.get(
  89. API.getOrderURL,
  90. {
  91. params: params.data,
  92. }
  93. )
  94. }
  95. // 获取分类信息
  96. function getCategoryAPI() {
  97. // return http( API.getCategoryURL, {data: data})
  98. return request.get(
  99. API.getCategoryURL,
  100. )
  101. }
  102. // 获取分类出来的商品信息
  103. function getClassifyGoods(data) {
  104. return request.get(
  105. API.getCategoryGoodsURL + `/${data.page}/${data.pageSize}` + '?category=' + data.id
  106. )
  107. }
  108. //获取所有的商品
  109. function getAllGoods(data) {
  110. return request.get(
  111. API.getAllGoodsURL + `/${data.page}/${data.pageSize}`
  112. )
  113. }
  114. //搜索获取商品
  115. function searchGoods(data) {
  116. return request.get(
  117. API.getSearchGoodsURL + `/${data.page}/${data.pageSize}` + '?keyword=' + data.inputValue
  118. )
  119. }
  120. //获取商品详细描述
  121. function getGoodsDetail(data) {
  122. return request.get(
  123. API.getGoodsDetailURL + `/${data.id}` + '?id=' + data.id + '&uid=' + data.uid + '&date=' + data.time
  124. )
  125. }
  126. //上传商品
  127. function upLoadGoods(data) {
  128. return request.post(
  129. API.postGoodsURL,
  130. {
  131. data: {
  132. "categories": [data.gid],
  133. "desc": data.desc,
  134. "ownerId": 0,
  135. "pic": data.fileList,
  136. "place": data.address,
  137. "price": data.price,
  138. "state": 0,
  139. "title": data.title
  140. }
  141. }
  142. )
  143. }
  144. //获取用户好友关系
  145. function getUserRelation(params) {
  146. return request.get(
  147. API.getUserRelationUrl,
  148. {
  149. data:params.data
  150. }
  151. )
  152. }
  153. //添加用户关系
  154. function addUserRelation(params) {
  155. return request.post(
  156. API.addUserRelationUrl,
  157. {
  158. data:params.data,
  159. }
  160. )
  161. }
  162. //传入uid批量获取用户信息
  163. function getUserInfoList(params) {
  164. return request.post(
  165. API.getUserInfoListUrl,
  166. {
  167. data:params.data
  168. }
  169. )
  170. }
  171. //传入商品id批量获取商品信息
  172. function getGoodsInfoList(params) {
  173. return request.post(
  174. API.getGoodsInfoListUrl,
  175. {
  176. data:params.data,
  177. }
  178. )
  179. }
  180. function setWsConnect(params) {
  181. return ws(
  182. API.chatUrl+'?uid='+params.uid,
  183. )
  184. }
  185. //获取两个用户之间的所有聊天记录
  186. function getChattingRecord(params) {
  187. return request.get(
  188. API.getChattingRecordUrl+'?uid='+params.uid+'&target='+params.target
  189. )
  190. }
  191. //根据商品id获取商品详细信息
  192. function getGoodsInfo(data) {
  193. return request.get(
  194. API.getGoodsInfoUrl+`/${data.id}`+'?uid='+data.uid+'&date='+data.date
  195. )
  196. }
  197. //获取与特定用户相关的最后一条聊天记录
  198. function getLatestChattingRecord(params) {
  199. return request.get(
  200. API.getLatestChattingRecordUrl+'?uid='+params.uid+'&target='+params.target
  201. )
  202. }
  203. //传入用户uid获取用户所有订单
  204. function getUserAllOrder(params) {
  205. return request.get(
  206. API.getUserAllOrderUrl+'?id='+params.uid
  207. // API.getUserAllOrderUrl+`/${params.uid}`
  208. )
  209. }
  210. //根据用户id获取用户的所有商品
  211. function getUserAllGoods(data) {
  212. return request.get(
  213. API.getUserAllGoodsUrl+`/${data.id}`
  214. )
  215. }
  216. //根据传入的订单id和需要改变的状态修改订单状态
  217. function postOrderChange(params) {
  218. // const data = {params};
  219. // console.log(data);
  220. console.log(params);
  221. return request.post(
  222. API.postReviseOrder,
  223. {
  224. data: params.data
  225. }
  226. )
  227. }
  228. //获取推荐商品
  229. function getRecommend(data) {
  230. return request.get(
  231. API.getRecommendUrl +`?id=${data.user_id}&size=${data.recommendNum}`
  232. )
  233. }
  234. /**
  235. * 初始化用户推荐数据
  236. * @param {Array} cIds 分类Id
  237. * @param {number} uid 用户Id
  238. * @returns
  239. */
  240. function initRecommend(data) {
  241. return request.post(API.initRecommendURL,{
  242. data:data
  243. })
  244. }
  245. module.exports = {
  246. createCommont,
  247. getCommentList,
  248. login,
  249. getUserInfo,
  250. register,
  251. modify,
  252. getOrder,
  253. getCategoryAPI,
  254. getClassifyGoods,
  255. getUserRelation,
  256. addUserRelation,
  257. getUserInfoList,
  258. getGoodsInfoList,
  259. getChattingRecord,
  260. getGoodsInfo,
  261. setWsConnect,
  262. getLatestChattingRecord,
  263. getUserAllOrder,
  264. getUserAllGoods,
  265. getAllGoods,
  266. searchGoods,
  267. upLoadGoods,
  268. getGoodsDetail,
  269. loginURl: API.loginURL,
  270. registerURL: API.registerURL,
  271. postOrderChange,
  272. getRecommend,
  273. initRecommend
  274. }