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 = getBaseUrl('wx/index'); return request.getInstance().header({ uid }).url(url).send(); }, // 获取首页人气推荐 getHotRecommendSecond(grade, pageNo, pageSize) { let url = getBaseUrl('wx/userRead/recommend'); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).data({ grade, pageNo, pageSize, }).url(url).send(); }, // 获取首页人气推荐2.0 getHotRecommend() { let url = getBaseUrl('wx/discovery'); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).send(); }, // 获取用户朗读详细信息 getWorksDetail(uid, readId, shareFlag) { let url = getBaseUrl(`wx/userRead/info/${readId}?join=${shareFlag}`); return request.getInstance().header({ uid }).url(url).send(); }, // 获取全部课本 getAllBooks(pageNo, pageSize) { let url = getBaseUrl('wx/product'); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).data({ pageNo, pageSize }).send(); }, // 获取课本详情 getBookDetail(uid, id) { let url = getBaseUrl(`wx/product/${id}`); return request.getInstance().header({ uid }).url(url).send(); }, // 获取朗读详情 // 获取单课详情 getClassDetail(id) { // let url = getProductUrl(`wx/lesson/${id}`); let url = getBaseUrl(`wx/userRead/readInfo/${id}`); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).send(); }, // 检查是否收藏过课程 classIsLike(uid, data) { let url = getBaseUrl(`wx/favorites/isLike`); return request.getInstance().header({ uid }).url(url).data(data).send(); }, // 获取单课朗读信息 getClassRead(data) { let url = getBaseUrl(`wx/userRead`); return request.getInstance().header({ uid:wx.getStorageSync('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(data) { console.log(data); let url = getBaseUrl(`wx/userRead`); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).data(data).method('POST').send(); }, // 修改作品状态 putWork(data) { console.log(data); let url = getBaseUrl(`wx/userRead`); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).data(data).method('PUT').send(); }, // 视频评测数据 postWorksScore(data){ let url = getBaseUrl(`wx/assessment`); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).data(data).method('POST').send(); }, // 点赞作品 likeWorks(readId) { let url = getBaseUrl(`wx/userRead/like/${readId}`); return request.getInstance().header({ uid: wx.getStorageSync('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(); }, // 取消关注 cancerFollow(uid, followUid) { let url = getBaseUrl(`wx/fans`); return request.getInstance().header({ uid }).url(url).data({ "uid": followUid }).method('PUT').send(); }, //获取关注的用户列表 getFollowUsers(uid, pageNo, pageSize) { let url = getBaseUrl(`wx/fans`); return request.getInstance().header({ uid }).url(url).data({ pageNo: pageNo, pageSize: pageSize }).send(); }, // 获取关注用户的作品列表 getFollowWorks(pageNo, pageSize) { let url = getBaseUrl(`wx/fans/interest`); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).data({ pageNo: pageNo, pageSize: pageSize }).send(); }, // 搜索 getCourses(grade, pageNo, pageSize) { let url = getBaseUrl(`wx/lesson`); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).data({ gradeClassify: grade, 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(postId) { let url = getBaseUrl(`wx/posts/one/${postId}`); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).send(); }, // 发布回复(楼中楼) postReplyComment(data) { let url = getBaseUrl(`wx/reply`); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).data(data).method('POST').send(); }, // 点赞评论 likeCommend(postId) { let url = getBaseUrl(`wx/posts/like/${postId}`); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).method('GET').send(); }, // 发布讨论 postReply(data) { let url = getBaseUrl(`wx/posts`); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).data(data).method('POST').send(); }, // 获取推荐团购信息 getGroupList(pageNo, osType) { let url = getBaseUrl(`wx/groupPurchaseInfo/recommend`); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).data({ pageNo, pageSize: 3, osType: osType }).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, formId) { console.log(formId) console.log(orderId) let url = getBaseUrl(`wx/groupPurchase/join`); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).data({ orderId, formId }).method('POST').send(); }, // 收藏课程 collectClass(data) { let url = getBaseUrl(`wx/favorites`); return request.getInstance().header({ uid: wx.getStorageSync('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(); }, // 我的收藏 myFavorites() { let url = getBaseUrl(`wx/favorites`); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).send(); }, // 我的关注 myFans() { let url = getBaseUrl(`wx/fans`); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).send(); }, // 课程鉴权 areYouSuper(productId) { let url = getBaseUrl(`wx/groupPurchase/auth`); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).data({ productId }).send(); }, // 课程鉴权 包括助力团 areYouSuperSecond(os, productId) { let url = getBaseUrl(`wx/groupPurchase/authAll`); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).data({ osType: os, productId }).send(); }, // // 课本鉴权 // areYouBookSuper(productArr){ // let url = getBaseUrl(`wx/groupPurchase/authAll`); // return request.getInstance().header({ // uid: wx.getStorageSync('uid') // }).url(url).data(productArr).method('POST').send(); // }, // 找到课程对应的课本 checkLesson(lessonId) { let url = getBaseUrl(`wx/lesson/product/${lessonId}`); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).send(); }, // 获取 用户朗读的作品 userWorks(followUid, pageNo, pageSize) { let url = getBaseUrl('wx/userRead'); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).data({ uid: followUid, pageNo: pageNo, pageSize: pageSize }).url(url).send(); }, // 获取用户信息 getUserMsg(followUid, pageNo, pageSize) { let url = getBaseUrl('wx/user/info'); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).data({ uid: followUid, pageNo: pageNo, pageSize: pageSize }).url(url).send(); }, // 获取站内消息列表 getMessageList(pageNo, pageSize) { let url = getBaseUrl('wx/message'); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).data({ pageNo: pageNo, pageSize: pageSize }).url(url).send(); }, // 更新消息状态 refreshMessageStatus() { let url = getBaseUrl('wx/message'); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).method('PUT').send(); }, // 获取正在进行中的团数量 getMyGroupGoing() { let url = getBaseUrl('wx/groupPurchase/underway'); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).send(); }, // 分享记录 shareRecord(data) { let url = getBaseUrl('wx/ShareStatistics/share'); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).data(data).url(url).method('POST').send(); }, shareLog(data){ let url = getBaseUrl('wx/shareLog'); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).data(data).url(url).method('POST').send(); }, // 由分享进入的记录 shareTagRecord(data) { let url = getBaseUrl('wx/ShareStatistics/click'); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).data(data).url(url).method('POST').send(); }, // 用户登录记录 userLoginRecord() { let url = getBaseUrl('wx/loginLog'); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).method('POST').send(); }, // 用户进入页面统计 userIntoPage(action, actionName) { let url = getBaseUrl('wx/userEvent'); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).data({ action, actionName }).url(url).method('POST').send(); }, // 用户播放视频时长统计 playLogReport(data) { let url = getBaseUrl('base/playLog'); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).data(data).url(url).method('POST').send(); }, // 小红花 获取任务列表 getMissionList() { let url = getBaseUrl('wx/task'); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).send(); }, // 获取用户连续签到日期 // getSignInData(){ // let url = getBaseUrl('wx/loginLog'); // return request.getInstance().header({ // uid: wx.getStorageSync('uid') // }).url(url).send(); // }, // 保存formId postFormId(formId) { let url = getBaseUrl('wx/form'); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).data({ formId }).url(url).method('POST').send(); }, // 获取签到信息 getSignInData() { let url = getBaseUrl('wx/loginLog/signIn'); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).send(); }, // 获取产品信息 getProductData() { let url = getBaseUrl('wx/product'); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).send(); }, // 创建订单 postOrder(productId) { let url = getBaseUrl('wx/order'); return request.getInstance().header({ uid: wx.getStorageSync('uid'), 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8' }).data({ productId }).url(url).method('POST').send(); }, //激活码激活 postActiveCode(code) { console.log(22222, code) let url = getBaseUrl('wx/activationCode'); return request.getInstance().header({ uid: wx.getStorageSync('uid'), }).data({ code }).url(url).method('POST').send(); }, // 会员鉴权 getUserAuth() { let url = getBaseUrl('wx/auth'); return request.getInstance().header({ uid: wx.getStorageSync('uid') }).url(url).send(); } }