123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- import { getInstance } from './httpRequest';
- import { apiUrl } from './const.js';
- 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();
- }
-
- 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;
|