diff --git a/api/book.js b/api/book.js new file mode 100644 index 0000000..aa6d90a --- /dev/null +++ b/api/book.js @@ -0,0 +1,17 @@ +import request from '../utils/request'; + +// 图书推荐 +export function FetchInitScreenBookRecommend(data) { + return request({ + url: '/api/screenSetting/initScreenBookRecommend', + data + }) +} + + +// export function FetchInitScreenBookRecommend(data) { +// return request({ +// url: '/qyzt/getNewBook', +// data +// }) +// } \ No newline at end of file diff --git a/api/user.js b/api/user.js index 7918f46..327ab2d 100644 --- a/api/user.js +++ b/api/user.js @@ -1,53 +1,157 @@ import request from '../utils/request'; -/** - * 用户登录 - */ -export function login(data) { +// 获取第三方url/appid/Secret/sm4_key +export function FetchInitScreenSetting(data) { return request({ - url: '/sys/login', + url: '/api/screenSetting/initScreenSetting', + data + }) +} + +//根据微信code 获取openId +export function FetchOpenId(data) { + return request({ + url: '/api/weixin/getOpenId', + data + }); +} +// 根据openid获取所有绑定读者证列表 +// ?libcode=&openId= +export function FetchFindAllReaderBindByOpenId(data) { + return request({ + url: '/api/weixin/findAllReaderBindByOpenId', + data + }); +} + +// 根据openid获取用户信息 +// ?libcode=&openId= +export function FetchFindAllReaderByOpenId(data) { + return request({ + url: '/api/weixin/findReaderByOpenId', + data + }); +} + + +// 读者认证 +export function FetchReaderList(data) { + return request({ + url: '/api/screenSetting/searchreaderlist2', + data + }); +} + +// 用户绑定读者证 +// { +// "openid":"小程序用户openID", +// "bindValue":"绑定值", +// "bindType":"绑定方式(rdid 读者证号 rdname读者姓名 rdcertify身份证号 othercardno其他编号 workcardno工作/学生证号 rdphone电话 rdloginid手机 cardid附属卡(IC卡))", +// "libcode":"馆代码" +// } +export function FetchBindReadCard(data) { + return request({ + url: '/api/weixin/bindReadCard', method: 'POST', data }); } -/** - * 关注用户 - */ -export function userFollow(data) { +// 绑定用户 +// { +// "avatar": "头像", +// "libcode": "馆代码", +// "nickname": "昵称", +// "openid": "" +// } +export function FetchBindRead(data) { return request({ - url: '/user/follow', + url: '/api/weixin/bindReader', + method: 'POST', data }); } -/** - * 发表评论 - */ -export function userArticleComment(data) { +// 设置默认读者证 +// { +// "bindType": "string", +// "bindValue": "string", +// "libcode": "string", +// "openid": "string" +// } +export function FetchSetDefaultReadCard(data) { return request({ - url: '/user/article/comment', + url: '/api/weixin/setDefaultReadCard', method: 'POST', data }); } + -/** - * 用户点赞 - */ -export function userPraise(data) { +// 用户解绑读者证 +// { +// "bindType": "string", +// "bindValue": "string", +// "libcode": "string", +// "openid": "string" +// } +export function FetchUnbindReadCard(data) { return request({ - url: '/user/praise', + url: '/api/weixin/unbindReadCard', + method: 'POST', data }); } + /** - * 用户收藏 + * 用户登录 */ -export function userCollect(data) { +export function login(data) { return request({ - url: '/user/collect', + url: '/sys/login', + method: 'POST', data }); } + +/** + * 关注用户 + */ +// export function userFollow(data) { +// return request({ +// url: '/user/follow', +// data +// }); +// } + +/** + * 发表评论 + */ +// export function userArticleComment(data) { +// return request({ +// url: '/user/article/comment', +// method: 'POST', +// data +// }); +// } + +/** + * 用户点赞 + */ +// export function userPraise(data) { +// return request({ +// url: '/user/praise', +// data +// }); +// } + +/** + * 用户收藏 + */ +// export function userCollect(data) { +// return request({ +// url: '/user/collect', +// data +// }); +// } diff --git a/components/book-list-item/book-list-item.vue b/components/book-list-item/book-list-item.vue index 924e4d5..85ecef4 100644 --- a/components/book-list-item/book-list-item.vue +++ b/components/book-list-item/book-list-item.vue @@ -2,16 +2,21 @@ - + /> --> + - {{ data.title || '暂无标题' }} - {{ data.nickname || '佚名' }} - {{ data.publish || '暂无出版社数据' }} + {{ data.name || '暂无标题' }} + {{ data.author || '佚名' }} + {{ data.publisher || '暂无出版社数据' }} @@ -55,12 +54,6 @@ 书目检索 - - - - - 扫码借书 - @@ -97,10 +90,6 @@ 电子证 - - - - @@ -111,14 +100,40 @@ - - + + + 我的借阅证 + + + + + + + + + 读者证号 + {{ item.bindValue }} + + 默认证件 + + + + + + + 借阅证 - - 您还没有绑定读者证哦~ + + 您还没有绑定读者证哦~ + 图书推荐 @@ -129,9 +144,13 @@ - - - {{item.title}} + + + + {{item.name}} @@ -140,6 +159,12 @@ + + \ No newline at end of file diff --git a/pages/login/login copy.vue b/pages/login/login copy.vue new file mode 100644 index 0000000..c3f5e75 --- /dev/null +++ b/pages/login/login copy.vue @@ -0,0 +1,252 @@ + + + + + \ No newline at end of file diff --git a/pages/login/login-no-clear.vue b/pages/login/login-no-clear.vue new file mode 100644 index 0000000..ce5c235 --- /dev/null +++ b/pages/login/login-no-clear.vue @@ -0,0 +1,297 @@ + + + + + \ No newline at end of file diff --git a/pages/login/login-pay.vue b/pages/login/login-pay.vue new file mode 100644 index 0000000..3d1d935 --- /dev/null +++ b/pages/login/login-pay.vue @@ -0,0 +1,269 @@ + + + + + \ No newline at end of file diff --git a/pages/login/login.vue b/pages/login/login.vue index cedda16..ada82da 100644 --- a/pages/login/login.vue +++ b/pages/login/login.vue @@ -1,142 +1,395 @@ \ No newline at end of file diff --git a/subpkg/pages/book-list/book-list.vue b/subpkg/pages/book-list/book-list.vue index 1753c04..5e3b4ef 100644 --- a/subpkg/pages/book-list/book-list.vue +++ b/subpkg/pages/book-list/book-list.vue @@ -19,6 +19,7 @@ + + \ No newline at end of file diff --git a/subpkg/pages/reader-card/reader-card.vue b/subpkg/pages/reader-card/reader-card.vue index 22f25ad..f217aa6 100644 --- a/subpkg/pages/reader-card/reader-card.vue +++ b/subpkg/pages/reader-card/reader-card.vue @@ -1,83 +1,127 @@ \ No newline at end of file diff --git a/subpkg/pages/unbind-card/unbind-card.vue b/subpkg/pages/unbind-card/unbind-card.vue new file mode 100644 index 0000000..0fdb929 --- /dev/null +++ b/subpkg/pages/unbind-card/unbind-card.vue @@ -0,0 +1,245 @@ + + + + + \ No newline at end of file diff --git a/utils/config.js b/utils/config.js new file mode 100644 index 0000000..abacd40 --- /dev/null +++ b/utils/config.js @@ -0,0 +1,14 @@ +const CONFIG = { + // 开发环境配置 + development: { + // assetsPath: 'https://m.siccat.com/public/static/images/', // 静态资源路径 + baseUrl: 'http://192.168.99.63:14000', // 后台接口请求地址 + }, + // 生产环境配置 + production: { + // assetsPath: 'https://m.siccat.com/public/static/images/', // 静态资源路径 + baseUrl: 'http://192.168.99.63:14000', // 后台接口请求地址 + } + +}; +export default CONFIG[process.env.NODE_ENV]; \ No newline at end of file diff --git a/utils/request.js b/utils/request.js index 979f556..8deeb6e 100644 --- a/utils/request.js +++ b/utils/request.js @@ -1,20 +1,27 @@ import store from '../store'; -const BASE_URL = 'https://api.imooc-blog.lgdsunday.club/api'; -function request({ url, data, method }) { +import config from '@/utils/config.js' +const BASE_URL = config.baseUrl + +function request({ url, data, method = 'GET' }) { return new Promise((resolve, reject) => { + // 自动带上 token + const header = {}; + if (store.state.user.token) { + header.Authorization = store.state.user.token; + } + uni.request({ url: BASE_URL + url, data, - method, - header: { - Authorization: store.state.user.token - }, + method: method.toUpperCase(), + header, success: ({ data }) => { - if (data.success) { + if (data.code === 200) { + // 直接返回后端的 data 结构 resolve(data); } else { uni.showToast({ - title: data.message, + title: data.message || '请求失败', icon: 'none', mask: true, duration: 3000 @@ -23,14 +30,17 @@ function request({ url, data, method }) { } }, fail: (error) => { + uni.showToast({ + title: '网络异常', + icon: 'none' + }); reject(error); }, complete: () => { - // 关闭加载 uni.hideLoading(); } }); }); } -export default request; +export default request; \ No newline at end of file