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(id) { let url = getProductUrl(`wx/product/${id}`); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).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(); }, // 发布作品 postWork(uid, data) { console.log(data); let url = getBaseUrl(`wx/userRead`); return request.getInstance().header({ uid }).url(url).data(data).method('POST').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(); }, // 发布讨论 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(); }, // 收藏课程 collectBook(uid, data){ let url = getBaseUrl(`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(); }, // 发起奖励 rewardMoney(uid, data){ let url = getBaseUrl(`wx/wallet/award`); return request.getInstance().header({ uid }).url(url).data(data).method('POST').send(); }, // 修改资料 settingUserInfo( wechatName, birthday, gender, eyeshield){ let url = getBaseUrl(`wx/user`); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).data({ wechatName: wechatName, birthday: birthday, gender: gender, eyeshield: eyeshield }).url(url).method('PUT').send(); }, //获取个人信息 getUserInfo () { let url = getBaseUrl(`wx/user`); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).data({ uid: wx.getStorageSync('uid') }).url(url).send(); } }