appraise.js 6.1 KB

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