first commit

This commit is contained in:
编码猿
2024-09-27 02:06:13 +08:00
commit 852d94fbb9
36760 changed files with 3274413 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
export default {
BaseUrl: 'http://127.0.0.1:3000',
apiUrl: {
index: '/index',
info: '/class/bookInfo',
userLogin: '/users/userLogin',
addLike: '/users/collection',
checkIslike: '/users/checkIslike',
selectUserBook: '/users/selectUserBook',
getClass: '/class/allClass',
getClassify:'/class/classInfo',
startRead: '/class/chapterRead'
}
}

View File

@@ -0,0 +1,74 @@
import config from "./config.js"
class Http {
constructor() {
}
get (params) {
uni.showLoading({
title: '加载中'
});
return new Promise(function(resolve, reject) {
uni.request({
url: `${config.BaseUrl}${params.url}`, //仅为示例,并非真实接口地址。
data: params.data || {},
method: 'GET',
header: params.header || {},
success: (res) => {
uni.hideLoading();
if(res.data.status == 200) {
resolve(res.data.data)
} else {
uni.showToast({
title: res.data.data,
duration: 2000
});
}
},
fail: (error) => {
uni.hideLoading();
uni.showToast({
title: error.message,
duration: 2000
});
}
});
})
}
post (params) {
uni.showLoading({
title: '加载中'
});
return new Promise(function(resolve, reject) {
uni.request({
url: `${config.BaseUrl}${params.url}`, //仅为示例,并非真实接口地址。
data: params.data || {},
method: 'POST',
header: params.header || {},
success: (res) => {
uni.hideLoading();
if(res.data.status == 200) {
resolve(res.data.data)
} else {
resolve(res.data.data)
uni.showToast({
title: res.data.data,
duration: 2000
});
}
},
fail: (error) => {
uni.hideLoading();
uni.showToast({
title: error.message,
duration: 2000
});
}
});
})
}
}
export default new Http()

View File

@@ -0,0 +1,4 @@
import index from "./index";
import info from "./info";
import user from "./user";
export default { ...index, ...info, ...user }

View File

@@ -0,0 +1,14 @@
import Http from "../http.js"
import config from "../config"
export default {
async getIndexData(params) {
return await Http.get({ url: config.apiUrl.index, data: params.data, header: params.header })
},
async getClass(params) {
return await Http.get({ url: config.apiUrl.getClass, data: params.data, header: params.header })
},
async getClassify(params){
return await Http.get({ url: config.apiUrl.getClassify, data: params.data, header: params.header })
}
}

View File

@@ -0,0 +1,11 @@
import Http from "../http.js"
import config from "../config"
export default {
async getBookInfo(params) {
return await Http.get({ url: config.apiUrl.info, data: params.data, header: params.header })
},
async startRead(params) {
return await Http.get({ url: config.apiUrl.startRead, data: params.data, header: params.header })
}
}

View File

@@ -0,0 +1,20 @@
import Http from "../http.js"
import config from "../config"
export default {
async userLogin(params) {
return await Http.post({ url: config.apiUrl.userLogin, data: params.data, header: params.header })
},
async addLike(params) {
return await Http.post({ url: config.apiUrl.addLike, data: params.data, header: params.header })
},
async checkBook(params) {
return await Http.post({ url: config.apiUrl.checkIslike, data: params.data, header: params.header })
},
async selectUserBook(params) {
return await Http.post({ url: config.apiUrl.selectUserBook, data: params.data, header: params.header })
}
}

View File

@@ -0,0 +1,24 @@
export default {
enterInfo(id) {
uni.navigateTo({
url: `/pages/bookinfo/bookinfo?id=${id}`
});
},
checkLogin () {
if (localStorage.getItem("LoginStatus") == null) {
return false;
} else {
return true;
}
},
// 写本地
setLocalStorage(name,value) {
localStorage.setItem(name, JSON.stringify(value))
},
// 读本地
getLocalStorage(name) {
return JSON.parse(localStorage.getItem(name))
},
}