import { getInstance } from './httpRequest'; import { apiUrl } from './const.js'; //console.log(getInstance().url) const httpApiUrl = (str) => { return apiUrl + str; } class httpRequestApi { //课程表首页 static getCourse(data) { const url = httpApiUrl('wx/course'); return getInstance().header({ uid: wx.getStorageSync('uid'), }).url(url).data(data).send(); } //获取看nav切换 static getCategory() { const url = httpApiUrl('wx/category'); return getInstance().header({ uid: wx.getStorageSync('uid'), }).url(url).send(); } //获取课程详情 static getCourseDetails(id) { const url = httpApiUrl(`wx/course/${id}`); return getInstance().header({ uid: wx.getStorageSync('uid'), }).url(url).data().send(); } //添加播放记录 static addPlayLogList(data) { const url = httpApiUrl('wx/playLog'); return getInstance().header({ uid: wx.getStorageSync('uid'), }).url(url).data(data).method('POST').send(); } //收藏或者取消 static getDetailsFavorites(data) { const url = httpApiUrl('wx/favorites'); return getInstance().header({ uid: wx.getStorageSync('uid'), }).url(url).data(data).method('POST').send(); } //获取收藏列表 static getFavoritesList(data) { const url = httpApiUrl('wx/favorites'); return getInstance().header({ uid: wx.getStorageSync('uid'), }).url(url).data(data).send(); } //添加评论 static getDetailsPosts(data) { const url = httpApiUrl('wx/posts'); return getInstance().header({ uid: wx.getStorageSync('uid'), }).url(url).data(data).method('POST').send(); } //获取评论列表 static getPostsList(data) { const url = httpApiUrl('wx/posts'); return getInstance().header({ uid: wx.getStorageSync('uid'), }).url(url).data(data).send(); } //获取播放记录 static getPlayLogList(data) { const url = httpApiUrl('wx/playLog'); return getInstance().header({ uid: wx.getStorageSync('uid'), }).url(url).data(data).send(); } //上传图片到相册 static addPhotoList(data) { const url = httpApiUrl('wx/photoBox'); return getInstance().header({ uid: wx.getStorageSync('uid'), }).url(url).data(data).method('POST').send(); } //获取相册列表 static getPhotoList(data) { const url = httpApiUrl('wx/photoBox'); return getInstance().header({ uid: wx.getStorageSync('uid'), }).url(url).data(data).send(); } //删除相册 static removePhotoList(id) { const url = httpApiUrl(`wx/photoBox/${ id }`); return getInstance().header({ uid: wx.getStorageSync('uid'), }).url(url).method('DELETE').send(); } //相册设置 static setPhoto(photoBox) { const url = httpApiUrl(`wx/user/photoBox`); return getInstance().header({ uid: wx.getStorageSync('uid'), }).url(url).data({ photoBox, }).method('PUT').send(); } //获取用户信息 static getUserInfo() { const url = httpApiUrl(`wx/user`); return getInstance().header({ uid: wx.getStorageSync('uid'), }).url(url).send(); } //修改用户信息 static setUserInfo(data) { const url = httpApiUrl(`wx/user`); return getInstance().header({ uid: wx.getStorageSync('uid'), }).url(url).data(data).method('PUT').send(); } } export default httpRequestApi;