123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299 |
- // const { useParamsEaseFuncs } = require('XrFrame/xrFrameSystem');
- const { request } = require('../utils/request')
- const {ws} = require('../utils/util')
- const API = {
- createCommentURL: '/appraise/create',
- loginURL: '/user/login',
- getUserInfoURL: '/user/info',
- registerURL: '/user/register',
- modifyURL: '/user/modify',
- getOrderURL: '/order/user',
- getCategoryURL: '/category',
- getCategoryGoods: '/goods/category',
- getUserRelationUrl: '/relation/friend',
- addUserRelationUrl: '/relation/create',
- getUserInfoListUrl: '/user/list',
- getGoodsInfoListUrl: '/goods/list',
- chatUrl: '/chat',
- getChattingRecordUrl: '/chat/msg',
- getGoodsInfoUrl: '/goods/detail',
- getLatestChattingRecordUrl: '/chat/latest',
- getUserAllOrderUrl: '/order/user',
- getCategoryGoodsURL: '/goods/category',
- getAllGoodsURL: '/goods',
- getSearchGoodsURL: '/goods/search',
- postGoodsURL: '/goods/create',
- getGoodsDetailURL: '/goods/detail',
- postReviseOrder: '/order/revise',
- getRecommendUrl: '/goods/recommend',
- getUserAllGoodsUrl:'/goods/user',
- initRecommendURL:'/user/rec/new'
- }
- //查询列表时传参---注意参数数据类型
- function createCommont(data) {
- //Promise
- return request.post(
- API.createCommentURL,
- {
- data: data
- }
- );
- }
- /**
- * @param: {pageNum, pageSize}
- */
- //传对象给params
- function getCommentList(params) {
- return request.get(
- API.createCommentURL,
- {
- params: params,//是传入的形参
- }
- );
- }
- // //超时设置:timeout: 1000 * 60 * 30
- // function deleteComment() {
- // }
- function login(params) {
- return request.post(
- API.loginURL,
- {
- header: params.header,
- data: params.data,
- }
- );
- }
- function getUserInfo(params) {
- return request.get(
- API.getUserInfoURL,
- );
- }
- function register(params) {
- return request.post(
- API.registerURL,
- {
- data: params.data,
- }
- );
- }
- function modify(params) {
- return request.post(
- API.modifyURL,
- {
- data: params.data,
- }
- );
- }
- function getOrder(params) {
- return request.get(
- API.getOrderURL,
- {
- params: params.data,
- }
- )
- }
- // 获取分类信息
- function getCategoryAPI() {
- // return http( API.getCategoryURL, {data: data})
- return request.get(
- API.getCategoryURL,
- )
- }
- // 获取分类出来的商品信息
- function getClassifyGoods(data) {
- return request.get(
- API.getCategoryGoodsURL + `/${data.page}/${data.pageSize}` + '?category=' + data.id
- )
- }
- //获取所有的商品
- function getAllGoods(data) {
- return request.get(
- API.getAllGoodsURL + `/${data.page}/${data.pageSize}`
- )
- }
- //搜索获取商品
- function searchGoods(data) {
- return request.get(
- API.getSearchGoodsURL + `/${data.page}/${data.pageSize}` + '?keyword=' + data.inputValue
- )
- }
- //获取商品详细描述
- function getGoodsDetail(data) {
- return request.get(
- API.getGoodsDetailURL + `/${data.id}` + '?id=' + data.id + '&uid=' + data.uid + '&date=' + data.time
- )
- }
- //上传商品
- function upLoadGoods(data) {
- return request.post(
- API.postGoodsURL,
- {
- data: {
- "categories": [data.gid],
- "desc": data.desc,
- "ownerId": 0,
- "pic": data.fileList,
- "place": data.address,
- "price": data.price,
- "state": 0,
- "title": data.title
- }
- }
- )
- }
- //获取用户好友关系
- function getUserRelation(params) {
- return request.get(
- API.getUserRelationUrl,
- {
- data:params.data
- }
- )
- }
- //添加用户关系
- function addUserRelation(params) {
- return request.post(
- API.addUserRelationUrl,
- {
- data:params.data,
- }
- )
- }
- //传入uid批量获取用户信息
- function getUserInfoList(params) {
- return request.post(
- API.getUserInfoListUrl,
- {
- data:params.data
- }
- )
- }
- //传入商品id批量获取商品信息
- function getGoodsInfoList(params) {
- return request.post(
- API.getGoodsInfoListUrl,
- {
- data:params.data,
- }
- )
- }
- function setWsConnect(params) {
- return ws(
- API.chatUrl+'?uid='+params.uid,
- )
- }
- //获取两个用户之间的所有聊天记录
- function getChattingRecord(params) {
- return request.get(
- API.getChattingRecordUrl+'?uid='+params.uid+'&target='+params.target
- )
- }
- //根据商品id获取商品详细信息
- function getGoodsInfo(data) {
- return request.get(
- API.getGoodsInfoUrl+`/${data.id}`+'?uid='+data.uid+'&date='+data.date
- )
- }
- //获取与特定用户相关的最后一条聊天记录
- function getLatestChattingRecord(params) {
- return request.get(
- API.getLatestChattingRecordUrl+'?uid='+params.uid+'&target='+params.target
- )
- }
- //传入用户uid获取用户所有订单
- function getUserAllOrder(params) {
- return request.get(
- API.getUserAllOrderUrl+'?id='+params.uid
- // API.getUserAllOrderUrl+`/${params.uid}`
- )
- }
- //根据用户id获取用户的所有商品
- function getUserAllGoods(data) {
- return request.get(
- API.getUserAllGoodsUrl+`/${data.id}`
- )
- }
- //根据传入的订单id和需要改变的状态修改订单状态
- function postOrderChange(params) {
- // const data = {params};
- // console.log(data);
- console.log(params);
- return request.post(
- API.postReviseOrder,
- {
- data: params.data
- }
- )
- }
- //获取推荐商品
- function getRecommend(data) {
- return request.get(
- API.getRecommendUrl +`?id=${data.user_id}&size=${data.recommendNum}`
- )
- }
- /**
- * 初始化用户推荐数据
- * @param {Array} cIds 分类Id
- * @param {number} uid 用户Id
- * @returns
- */
- function initRecommend(data) {
- return request.post(API.initRecommendURL,{
- data:data
- })
- }
- module.exports = {
- createCommont,
- getCommentList,
- login,
- getUserInfo,
- register,
- modify,
- getOrder,
- getCategoryAPI,
- getClassifyGoods,
- getUserRelation,
- addUserRelation,
- getUserInfoList,
- getGoodsInfoList,
- getChattingRecord,
- getGoodsInfo,
- setWsConnect,
- getLatestChattingRecord,
- getUserAllOrder,
- getUserAllGoods,
- getAllGoods,
- searchGoods,
- upLoadGoods,
- getGoodsDetail,
- loginURl: API.loginURL,
- registerURL: API.registerURL,
- postOrderChange,
- getRecommend,
- initRecommend
- }
|