var constant = require('const.js'); const HOST_PRODUCT = constant.productApi; const HOST_BASE = constant.baseApi; let request = require('WXHttpRequest.js'); const httputil = require('httpUtil.js'); function getProductUrl(action) { return HOST_PRODUCT + action; } function getBaseUrl(action) { return HOST_BASE + action; } module.exports = { //获取推荐首页信息 getIndex(uid) { let url = getProductUrl('wx/index'); return request.getInstance().header({ uid }).url(url).send(); }, // 获取首页人气推荐 getHotRecommend(uid, pageNo, pageSize) { let url = getBaseUrl('wx/userRead/recommend'); return request.getInstance().header({ uid }).data({ pageNo, pageSize, }).url(url).send(); }, // 获取用户朗读详细信息 getWorksDetail(uid, readId) { let url = getBaseUrl(`wx/userRead/info/${readId}`); return request.getInstance().header({ uid }).url(url).send(); }, // 获取全部课本 getAllBooks(pageNo, pageSize) { let url = getProductUrl('wx/product'); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).data({ pageNo, pageSize }).send(); }, // 获取课本详情 getBookDetail(uid, id) { let url = getProductUrl(`wx/product/${id}`); return request.getInstance().header({ uid }).url(url).send(); }, // 获取单课详情 getClassDetail(uid, id) { let url = getProductUrl(`wx/lesson/${id}`); return request.getInstance().header({ uid }).url(url).send(); }, // 检查是否收藏过课程 classIsLike(uid, data) { let url = getProductUrl(`wx/favorites/isLike`); return request.getInstance().header({ uid }).url(url).data(data).send(); }, getClassDetail(uid, id) { let url = getProductUrl(`wx/lesson/${id}`); return request.getInstance().header({ uid }).url(url).send(); }, // 获取单课朗读信息 getClassRead(uid, data) { let url = getBaseUrl(`wx/userRead`); return request.getInstance().header({ uid }).data(data).url(url).send(); }, // 作品播放了+1 playWorks(uid, readId) { let url = getBaseUrl(`wx/userRead/play/${readId}`); return request.getInstance().header({ uid }).url(url).send(); }, // 发布作品 postWork(uid, data) { console.log(data); let url = getBaseUrl(`wx/userRead`); return request.getInstance().header({ uid }).url(url).data(data).method('POST').send(); }, // 点赞作品 likeWorks(uid, readId) { let url = getBaseUrl(`wx/userRead/like/${readId}`); return request.getInstance().header({ uid }).url(url).send(); }, // 关注用户 followUser(uid, followUid) { let url = getBaseUrl(`wx/fans`); return request.getInstance().header({ uid }).url(url).data({ "uid": followUid }).method('POST').send(); }, //获取关注的用户列表 getFollowUsers(uid, pageNo, pageSize) { let url = getBaseUrl(`wx/fans`); return request.getInstance().header({ uid }).url(url).data({ pageNo: pageNo, pageSize: pageSize }).send(); }, // 获取关注用户的作品列表 getFollowWorks(uid, pageNo, pageSize) { let url = getBaseUrl(`wx/fans/interest`); return request.getInstance().header({ uid }).url(url).data({ pageNo: pageNo, pageSize: pageSize }).send(); }, // 搜索 getSearchResult(uid, key, pageNo, pageSize) { let url = getProductUrl(`wx/lesson`); return request.getInstance().header({ uid }).url(url).data({ title: key, productId: '', pageNo: pageNo, pageSize: pageSize }).send(); }, // 获取回复信息 getReply(uid, columnId, pageNo, pageSize) { let url = getBaseUrl(`wx/posts/reply`); return request.getInstance().header({ uid }).url(url).data({ columnId: columnId, pageNo: pageNo, pageSize: pageSize }).send(); }, // 获取回复(楼中楼) getReplyComment(uid, postId) { let url = getBaseUrl(`wx/posts/one/${postId}`); return request.getInstance().header({ uid }).url(url).send(); }, // 发布回复(楼中楼) postReplyComment(uid, data) { let url = getBaseUrl(`wx/reply`); return request.getInstance().header({ uid }).url(url).data(data).method('POST').send(); }, // 点赞评论 likeCommend(uid, likeUid) { let url = getBaseUrl(`wx/posts/attribute/${likeUid}`); return request.getInstance().header({ uid }).url(url).method('GET').send(); }, // 发布讨论 postReply(uid, data) { let url = getBaseUrl(`wx/posts`); return request.getInstance().header({ uid }).url(url).data(data).method('POST').send(); }, // 获取推荐团购信息 getGroupList() { let url = getBaseUrl(`wx/groupPurchaseInfo/recommend`); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).send(); }, // 获取课程团购信息 getGroupPurchaseInfo(productId) { let url = getBaseUrl(`wx/groupPurchaseInfo/info/${productId}`); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).send(); }, // 发起团购 SendGroupPurchas(data) { let url = getBaseUrl(`wx/groupPurchase/create`); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).data(data).method('POST').send(); }, // 参加团购 JoinGroupPurchas(orderId) { let url = getBaseUrl(`wx/groupPurchase/join`); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).data({ orderId }).method('POST').send(); }, // 收藏课程 collectClass(uid, data) { let url = getProductUrl(`wx/favorites`); return request.getInstance().header({ uid }).url(url).data(data).method('POST').send(); }, //我的团 getMygroup() { let url = getBaseUrl(`wx/groupPurchase/my`); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).data({ pageNo: 1, pageSize: 100 }).send(); }, //获取团购详情 getMygroupInfo(orderId) { let url = getBaseUrl(`wx/groupPurchase/info/${orderId}`); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).send(); }, //团购是否成功 groupSuccess(orderId) { let url = getBaseUrl(`wx/groupPurchase/joinStatus`); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).data({ orderId }).send(); }, // 发起奖励 rewardMoney(uid, data) { let url = getBaseUrl(`wx/wallet/award`); return request.getInstance().header({ uid }).url(url).data(data).method('POST').send(); }, // 修改资料 settingUserInfo(data) { let url = getBaseUrl(`wx/user`); return request.getInstance().header({ uid:wx.getStorageSync('uid') }).data(data).url(url).method('PUT').send(); }, //获取个人信息 getUserInfo() { let url = getBaseUrl(`wx/user`); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).send(); }, // 获取播放量等数据 getUserWorksInfo() { let url = getBaseUrl(`wx/user/my`); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).send(); }, // 生成二维码 createQRCode(data) { let url = getBaseUrl(`wx/qrCode`); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).data(data).url(url).send(); }, // 我的奖金 myWallet() { let url = getBaseUrl('wx/wallet/bonus'); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).send(); }, // 資金明細 myWalletDetails() { let url = getBaseUrl('wx/wallet/record'); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).send(); }, // 我的課程 myCourse() { let url = getBaseUrl('wx/groupPurchase/myCourse'); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).send(); }, // 我的朗读 myRead() { let url = getBaseUrl('wx/userRead/my'); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).send(); }, }