Browse Source

全局馆代码处理

master
xuhuajiao 3 weeks ago
parent
commit
fd03424e1e
  1. 87
      App.vue
  2. 8
      api/user.js
  3. 61
      pages/home/home.vue
  4. 2
      pages/lendCar/lendCar.vue
  5. 6
      pages/login/login.vue
  6. 4
      pages/search/search.vue
  7. 2
      pages/user/user.vue
  8. 15
      subpkg/pages/activity-detail/activity-detail.vue
  9. 6
      subpkg/pages/activity-record/activity-record.vue
  10. 8
      subpkg/pages/agreement/agreement.vue
  11. 6
      subpkg/pages/book-detail/book-detail.vue
  12. 9
      subpkg/pages/book-list/book-list.vue
  13. 12
      subpkg/pages/collect-list/collect-list.vue
  14. 4
      subpkg/pages/feedback-detail/feedback-detail.vue
  15. 6
      subpkg/pages/feedback-list/feedback-list.vue
  16. 13
      subpkg/pages/feedback/feedback.vue
  17. 20
      subpkg/pages/myLending/myLending.vue
  18. 10
      subpkg/pages/ranking/ranking.vue
  19. 24
      subpkg/pages/reader-card/reader-card.vue
  20. 6
      subpkg/pages/register/register-form.vue
  21. 2
      subpkg/pages/register/register.vue
  22. 60
      subpkg/pages/seat-booking/seat-booking.vue
  23. 9
      subpkg/pages/seat-record/seat-record.vue
  24. 10
      subpkg/pages/user-info/user-info.vue
  25. 1
      utils/config.js
  26. 18
      utils/global.js
  27. 6
      utils/storage.js

87
App.vue

@ -1,32 +1,71 @@
<script> <script>
export default {
onLaunch: function() {
console.warn('当前组件仅支持 uni_modules 目录结构 ,请升级 HBuilderX 到 3.1.0 版本以上!')
console.log('App Launch')
import { FetchLibcodeBycode } from '@/api/user'
export default {
globalData: {
appid: '',
libcode: '', // libcode getApp().globalData.libcode 访
}, },
onShow: function() {
console.log('App Show')
onLaunch() {
this.initAppIdAndLibcode()
}, },
onHide: function() {
console.log('App Hide')
methods: {
// appid libcodeglobalData
async initAppIdAndLibcode() {
// #ifdef MP-WEIXIN
try {
// 1appid
const accountInfo = wx.getAccountInfoSync()
const appid = accountInfo.miniProgram.appId
this.globalData.appid = appid
// libcode
let cacheLibcode = uni.getStorageSync('GLOBAL_LIBCODE')
if(cacheLibcode){
this.globalData.libcode = cacheLibcode
console.log('使用缓存libcode:', cacheLibcode)
return
} }
// 2 FetchLibcodeBycodeappidlibcode
const res = await FetchLibcodeBycode({
code: 'vx_mini_appId',
value: appid
})
if(res.code === 200 && res.data){
const libcode = res.data
this.globalData.libcode = libcode
uni.setStorageSync('GLOBAL_LIBCODE', libcode)
console.log('接口获取全局libcode成功:', libcode)
}else{
console.error('FetchLibcodeBycode 获取libcode失败', res)
} }
</script>
<style lang="scss">
/*每个页面公共css */
@import '@/uni_modules/uni-scss/index.scss';
/* #ifndef APP-NVUE */
@import '@/static/customicons.css';
//
page {
background-color: #f5f5f5;
} catch(e){
console.error('初始化appid/libcode异常', e)
} }
// #endif
},
// 退
// logout(){
// // 1.
// uni.removeStorageSync('wx_login_code')
// uni.removeStorageSync('READER_CARD_LIST')
// uni.removeStorageSync('CURRENT_READER_CARD')
// // 2.libcode
// uni.removeStorageSync('GLOBAL_LIBCODE')
// getApp().globalData.libcode = ''
/* #endif */
.example-info {
font-size: 14px;
color: #333;
padding: 10px;
// //
// uni.reLaunch({url:'/pages/login/login'})
// }
// libcode
// refreshLibcode(){
// uni.removeStorageSync('GLOBAL_LIBCODE')
// getApp().globalData.libcode = ''
// uni.showToast({title:"libcode",icon:"none"})
// // App.vue
// getApp().$options.methods.initAppIdAndLibcode()
// }
} }
</style>
}
</script>

8
api/user.js

@ -183,3 +183,11 @@ export function FetchMsgSecCheck(data) {
data data
}); });
} }
// 根据微信code 获取馆代码
export function FetchLibcodeBycode(data) {
return request({
url: '/api/screenSetting/getLibcodeBycode',
data
});
}

61
pages/home/home.vue

@ -237,6 +237,7 @@ import { FetchInitScreenSetting, FetchOpenId, FetchFindAllReaderBindByOpenId} fr
import { FetchInitScreenBookRecommend } from '@/api/book'; import { FetchInitScreenBookRecommend } from '@/api/book';
import config from '@/utils/config'; import config from '@/utils/config';
import { STORAGE_KEYS } from '@/utils/storage'; import { STORAGE_KEYS } from '@/utils/storage';
import { waitLibcodeReady } from '@/utils/global'
export default { export default {
data() { data() {
@ -255,16 +256,25 @@ export default {
}; };
}, },
onLoad() { onLoad() {
this.getRecommendBooks();
this.getScreenSetting()
// this.getRecommendBooks();
// this.getScreenSetting()
this.initPage()
}, },
onShow() { onShow() {
this.initUserAndCheckBind(); this.initUserAndCheckBind();
}, },
methods:{ methods:{
async getScreenSetting() {
const res = await FetchInitScreenSetting({ libcode: config.LIB_CODE });
async initPage(){
const libcode = await waitLibcodeReady()
if(!libcode){
uni.showToast({title:'获取图书馆编码失败',icon:'none'})
return
}
this.getRecommendBooks(libcode);
this.getScreenSetting(libcode)
},
async getScreenSetting(libcode) {
const res = await FetchInitScreenSetting({ libcode });
// //
if (res.data.wechat_qr_code && res.data.wechat_qr_code.context) { if (res.data.wechat_qr_code && res.data.wechat_qr_code.context) {
@ -310,17 +320,11 @@ export default {
} }
this.$refs.erweimapopup.open() this.$refs.erweimapopup.open()
}, },
// //
formatCardNo(cardNo) { formatCardNo(cardNo) {
if (!cardNo) return ''; if (!cardNo) return '';
const str = String(cardNo); const str = String(cardNo);
const len = str.length; const len = str.length;
if (len > 8) { if (len > 8) {
// 2 + * + 2 // 2 + * + 2
const front = str.substring(0, 2); const front = str.substring(0, 2);
@ -338,6 +342,8 @@ export default {
// openid // openid
async initUserAndCheckBind() { async initUserAndCheckBind() {
try { try {
const libcode = await waitLibcodeReady()
if(!libcode) return
// 1. openId // 1. openId
let openId = uni.getStorageSync('wx_login_code'); let openId = uni.getStorageSync('wx_login_code');
@ -350,43 +356,28 @@ export default {
}); });
}); });
if (!loginRes.code) { if (!loginRes.code) {
uni.showToast({ title: '授权失败', icon: 'none' }); uni.showToast({ title: '授权失败', icon: 'none' });
return; return;
} }
// 3. openId // 3. openId
const openRes = await FetchOpenId({ const openRes = await FetchOpenId({
libcode: config.LIB_CODE,
libcode,
code: loginRes.code code: loginRes.code
}); });
if (openRes.code !== 200 || !openRes.data) { if (openRes.code !== 200 || !openRes.data) {
return; return;
} }
openId = openRes.data; openId = openRes.data;
uni.setStorageSync('wx_login_code', openId); uni.setStorageSync('wx_login_code', openId);
} }
// 4. openId // 4. openId
const res = await FetchFindAllReaderBindByOpenId({ const res = await FetchFindAllReaderBindByOpenId({
libcode: config.LIB_CODE,
libcode,
openId: openId openId: openId
}); });
if (res.code === 200 && res.data.length > 0) { if (res.code === 200 && res.data.length > 0) {
this.isBindLibraryCard = true; this.isBindLibraryCard = true;
// //
@ -404,8 +395,6 @@ export default {
uni.setStorageSync(STORAGE_KEYS.CURRENT_READER_CARD, null); uni.setStorageSync(STORAGE_KEYS.CURRENT_READER_CARD, null);
} }
} catch (err) { } catch (err) {
console.error('初始化失败:', err); console.error('初始化失败:', err);
const list = uni.getStorageSync(STORAGE_KEYS.READER_CARD_LIST) || []; const list = uni.getStorageSync(STORAGE_KEYS.READER_CARD_LIST) || [];
@ -413,20 +402,15 @@ export default {
const defaultCard = list.find(item => item.bindDefault === true); const defaultCard = list.find(item => item.bindDefault === true);
const otherCards = list.filter(item => !item.bindDefault); const otherCards = list.filter(item => !item.bindDefault);
this.readerCardList = defaultCard ? [defaultCard, ...otherCards] : list; this.readerCardList = defaultCard ? [defaultCard, ...otherCards] : list;
this.isBindLibraryCard = list.length > 0; this.isBindLibraryCard = list.length > 0;
} }
}, },
// + base64 // + base64
async getRecommendBooks() {
async getRecommendBooks(libcode) {
try { try {
const res = await FetchInitScreenBookRecommend({ libcode: config.LIB_CODE });
const res = await FetchInitScreenBookRecommend({ libcode });
let books = res.data || []; let books = res.data || [];
// 3setData // 3setData
const limit = 3; const limit = 3;
const displayBooks = books.slice(0, limit); const displayBooks = books.slice(0, limit);
@ -448,9 +432,6 @@ export default {
item.base64Cover = ''; item.base64Cover = '';
} }
} }
// 3setData // 3setData
this.recommendedBooks = displayBooks; this.recommendedBooks = displayBooks;
this.isLoading = false; this.isLoading = false;

2
pages/lendCar/lendCar.vue

@ -140,7 +140,7 @@ export default {
* 获取屏幕配置 * 获取屏幕配置
*/ */
async getScreenSetting() { async getScreenSetting() {
const res = await FetchInitScreenSetting({ libcode: config.LIB_CODE });
const res = await FetchInitScreenSetting({ libcode: getApp().globalData.libcode });
this.screenConfig = { this.screenConfig = {
thirdUrl: res.data.open_lib_http?.context || '', thirdUrl: res.data.open_lib_http?.context || '',
thirdAppid: res.data.open_lib_appId?.context || '', thirdAppid: res.data.open_lib_appId?.context || '',

6
pages/login/login.vue

@ -134,7 +134,7 @@ export default {
async getScreenSetting() { async getScreenSetting() {
try { try {
const res = await FetchInitScreenSetting({ libcode: config.LIB_CODE });
const res = await FetchInitScreenSetting({ libcode: getApp().globalData.libcode });
const data = res.data; const data = res.data;
this.screenConfig = { this.screenConfig = {
thirdUrl: data.open_lib_http?.context || '', thirdUrl: data.open_lib_http?.context || '',
@ -211,7 +211,7 @@ export default {
openid: openId, openid: openId,
bindValue: this.queryvalue, bindValue: this.queryvalue,
bindType: 'rdid', bindType: 'rdid',
libcode: config.LIB_CODE,
libcode: getApp().globalData.libcode,
} }
// //
const bindRes = await FetchBindReadCard(bindParams); const bindRes = await FetchBindReadCard(bindParams);
@ -225,7 +225,7 @@ export default {
icon: 'success' icon: 'success'
}); });
const data = { const data = {
libcode: config.LIB_CODE,
libcode: getApp().globalData.libcode,
openId: openId openId: openId
} }
FetchFindAllReaderBindByOpenId(data).then(res => { FetchFindAllReaderBindByOpenId(data).then(res => {

4
pages/search/search.vue

@ -139,7 +139,7 @@ export default {
// opacUrl // opacUrl
async getOpacUrl() { async getOpacUrl() {
try { try {
const res = await FetchInitScreenSetting({ libcode: config.LIB_CODE });
const res = await FetchInitScreenSetting({ libcode: getApp().globalData.libcode });
this.opacUrl = res.data.opac_url?.context || ''; this.opacUrl = res.data.opac_url?.context || '';
} catch (err) { } catch (err) {
console.error('获取配置失败', err); console.error('获取配置失败', err);
@ -240,7 +240,7 @@ export default {
const openId = await getOpenId(); const openId = await getOpenId();
if (openId) { if (openId) {
const res = await FetchFindAllBookCollectionByOpenId({ const res = await FetchFindAllBookCollectionByOpenId({
libcode: config.LIB_CODE,
libcode: getApp().globalData.libcode,
openId: openId, openId: openId,
page: 0, page: 0,
size: 100 size: 100

2
pages/user/user.vue

@ -100,7 +100,7 @@ export default {
if (openId) { if (openId) {
const res = await FetchFindAllReaderByOpenId({ const res = await FetchFindAllReaderByOpenId({
libcode: config.LIB_CODE,
libcode: getApp().globalData.libcode,
openId: openId openId: openId
}); });

15
subpkg/pages/activity-detail/activity-detail.vue

@ -85,7 +85,7 @@
</template> </template>
<script> <script>
import config from '@/utils/config';
// import config from '@/utils/config';
// import { getOpenId } from '@/utils/storage'; // import { getOpenId } from '@/utils/storage';
import { FetchSessionKey, FetchDecryptPhone } from '@/api/user.js'; import { FetchSessionKey, FetchDecryptPhone } from '@/api/user.js';
import { FetchSignActivity, FetchCancelSignActivity } from '@/api/activity.js'; import { FetchSignActivity, FetchCancelSignActivity } from '@/api/activity.js';
@ -123,7 +123,6 @@ export default {
this.activityId = item.id || item.activityId; this.activityId = item.id || item.activityId;
this.formatContent(); this.formatContent();
this.rangeText = this.personOptions.map(item => item.text); this.rangeText = this.personOptions.map(item => item.text);
this.joinForm.personCount = this.personOptions[0].value; this.joinForm.personCount = this.personOptions[0].value;
this.joinForm.personCountText = this.personOptions[0].text; this.joinForm.personCountText = this.personOptions[0].text;
@ -140,7 +139,6 @@ export default {
} }
content = content.replace(/&amp;/g, '&'); content = content.replace(/&amp;/g, '&');
// ========== ==========
const imgReg = /<img\s+[^>]*src\s*=\s*["']?([^"'> ]+)["']?[^>]*>/gi; const imgReg = /<img\s+[^>]*src\s*=\s*["']?([^"'> ]+)["']?[^>]*>/gi;
content = content.replace(imgReg, (match, src) => { content = content.replace(imgReg, (match, src) => {
return `<div><img src="${src}" style="width:100%;max-width:750px;display:block;margin:0 auto;"></div>`; return `<div><img src="${src}" style="width:100%;max-width:750px;display:block;margin:0 auto;"></div>`;
@ -186,7 +184,7 @@ export default {
console.log('loginRes',loginRes) console.log('loginRes',loginRes)
if (loginRes.code) { if (loginRes.code) {
const res = await FetchSessionKey({ const res = await FetchSessionKey({
libcode: config.LIB_CODE,
libcode: getApp().globalData.libcode,
code: loginRes.code code: loginRes.code
}); });
if (res.code === 200) { if (res.code === 200) {
@ -200,18 +198,15 @@ export default {
console.error('获取sessionKey失败:', error); console.error('获取sessionKey失败:', error);
} }
}, },
getPhoneNumber(e) { getPhoneNumber(e) {
if (e.detail.errMsg !== 'getPhoneNumber:ok') { if (e.detail.errMsg !== 'getPhoneNumber:ok') {
uni.showToast({ title: '取消授权', icon: 'none' }); uni.showToast({ title: '取消授权', icon: 'none' });
return; return;
} }
if (!this.sessionKey) { if (!this.sessionKey) {
uni.showToast({ title: '请稍后再试', icon: 'none' }); uni.showToast({ title: '请稍后再试', icon: 'none' });
return; return;
} }
FetchDecryptPhone({ FetchDecryptPhone({
sessionKey: this.sessionKey, sessionKey: this.sessionKey,
encryptedData: e.detail.encryptedData, encryptedData: e.detail.encryptedData,
@ -252,7 +247,6 @@ export default {
if (['已结束', '已取消'].includes(d.status)) { if (['已结束', '已取消'].includes(d.status)) {
return; return;
} }
// //
if(d.status === '未开始' && d.isCancel === false && !!d.signId){ if(d.status === '未开始' && d.isCancel === false && !!d.signId){
uni.showModal({ uni.showModal({
@ -283,7 +277,6 @@ export default {
}) })
return return
} }
// //
this.openJoinModal(); this.openJoinModal();
}, },
@ -318,7 +311,7 @@ export default {
return; return;
} }
const params = { const params = {
// libcode: config.LIB_CODE,
// libcode: getApp().globalData.libcode,
activityId: this.activityId, activityId: this.activityId,
signName: this.joinForm.name, signName: this.joinForm.name,
signPhone: this.joinForm.phone, signPhone: this.joinForm.phone,
@ -507,13 +500,11 @@ export default {
justify-content: space-between; justify-content: space-between;
padding: 15px; padding: 15px;
border-bottom: 1px solid #f0f0f0; border-bottom: 1px solid #f0f0f0;
.modal-title { .modal-title {
font-size: 16px; font-size: 16px;
font-weight: bold; font-weight: bold;
color: #333; color: #333;
} }
.close-icon { .close-icon {
color: #999; color: #999;
} }

6
subpkg/pages/activity-record/activity-record.vue

@ -194,7 +194,7 @@ export default {
console.log('loginRes', loginRes) console.log('loginRes', loginRes)
if (loginRes.code) { if (loginRes.code) {
const res = await FetchSessionKey({ const res = await FetchSessionKey({
libcode: config.LIB_CODE,
libcode: getApp().globalData.libcode,
code: loginRes.code code: loginRes.code
}); });
if (res.code === 200) { if (res.code === 200) {
@ -273,19 +273,15 @@ export default {
this.loading = false; this.loading = false;
} }
}, },
onRefresh() { onRefresh() {
if(this.loading) return if(this.loading) return
this.getActivityList(true); this.getActivityList(true);
}, },
onScrollLower() { onScrollLower() {
if(this.loading || this.noMore) return; if(this.loading || this.noMore) return;
this.page += 1; this.page += 1;
this.getActivityList(false); this.getActivityList(false);
}, },
cancelAppoint(item) { cancelAppoint(item) {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',

8
subpkg/pages/agreement/agreement.vue

@ -206,14 +206,6 @@ export default {
padding: 12px; padding: 12px;
} }
.chapter {
// background-color: #fff;
// border-radius: 12rpx;
// padding: 30rpx;
// margin-bottom: 24rpx;
// box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.05);
}
.chapter-title { .chapter-title {
font-size: 30rpx; font-size: 30rpx;
font-weight: bold; font-weight: bold;

6
subpkg/pages/book-detail/book-detail.vue

@ -234,7 +234,7 @@ export default {
// //
async getOpacUrl() { async getOpacUrl() {
try { try {
const res = await FetchInitScreenSetting({ libcode: config.LIB_CODE });
const res = await FetchInitScreenSetting({ libcode: getApp().globalData.libcode });
this.opacUrl = res.data.opac_url?.context || ''; this.opacUrl = res.data.opac_url?.context || '';
this.getDictionaryTree(); this.getDictionaryTree();
this.getBookDetail(); this.getBookDetail();
@ -257,7 +257,7 @@ export default {
this.bookInfo = apiData.biblios || {}; this.bookInfo = apiData.biblios || {};
this.holdingsData = apiData.holdings || []; this.holdingsData = apiData.holdings || [];
// searchListInfo
// searchListInfo
if(!this.searchListInfo || !this.searchListInfo.bookrecno){ if(!this.searchListInfo || !this.searchListInfo.bookrecno){
this.searchListInfo = { this.searchListInfo = {
bookrecno: this.bookInfo.bookrecno, bookrecno: this.bookInfo.bookrecno,
@ -353,7 +353,7 @@ export default {
const params = { const params = {
...this.searchListInfo, ...this.searchListInfo,
openid: openId, openid: openId,
libcode: config.LIB_CODE
libcode: getApp().globalData.libcode
}; };
const res = await FetchCollectionBook(params); const res = await FetchCollectionBook(params);
if (res.code === 200) { if (res.code === 200) {

9
subpkg/pages/book-list/book-list.vue

@ -65,18 +65,16 @@ export default {
}); });
}); });
}, },
// //
refresh() { refresh() {
this.bookList = []; this.bookList = [];
this.noMore = false; this.noMore = false;
this.getBookRecommendList(); this.getBookRecommendList();
}, },
async getBookRecommendList() { async getBookRecommendList() {
this.loading = true; this.loading = true;
try { try {
const res = await FetchInitScreenBookRecommend({ libcode: config.LIB_CODE });
const res = await FetchInitScreenBookRecommend({ libcode: getApp().globalData.libcode });
let books = res.data || []; let books = res.data || [];
// 1. // 1.
@ -100,26 +98,21 @@ export default {
uni.stopPullDownRefresh(); uni.stopPullDownRefresh();
} }
}, },
async loadImagesOneByOne() { async loadImagesOneByOne() {
for (let i = 0; i < this.bookList.length; i++) { for (let i = 0; i < this.bookList.length; i++) {
let item = this.bookList[i]; let item = this.bookList[i];
if (!item.imgVxPath) continue; if (!item.imgVxPath) continue;
// //
// const url = this.baseUrl + '/api/fileRelevant/getImg?imgType=2&imgId=' + item.imgPath; // const url = this.baseUrl + '/api/fileRelevant/getImg?imgType=2&imgId=' + item.imgPath;
// const base64 = await this.urlToBase64(url); // const base64 = await this.urlToBase64(url);
const imageUrl = this.baseUrl + '/files/' + item.imgVxPath; const imageUrl = this.baseUrl + '/files/' + item.imgVxPath;
console.log('imageUrl:', imageUrl); console.log('imageUrl:', imageUrl);
if (imageUrl) { if (imageUrl) {
item.base64Cover = imageUrl; item.base64Cover = imageUrl;
this.$set(this.bookList, i, item); // this.$set(this.bookList, i, item); //
} }
} }
}, },
goToDetail(item) { goToDetail(item) {
uni.navigateTo({ uni.navigateTo({
url: "/subpkg/pages/book-detail/book-detail?bookData=" + encodeURIComponent(JSON.stringify(item)) + "&fromRecommend=true" url: "/subpkg/pages/book-detail/book-detail?bookData=" + encodeURIComponent(JSON.stringify(item)) + "&fromRecommend=true"

12
subpkg/pages/collect-list/collect-list.vue

@ -27,7 +27,7 @@
import BookListItem from "@/components/book-list-item/book-list-item.vue"; import BookListItem from "@/components/book-list-item/book-list-item.vue";
import { FetchFindAllBookCollectionByOpenId } from '@/api/book'; import { FetchFindAllBookCollectionByOpenId } from '@/api/book';
import { getOpenId } from '@/utils/storage'; import { getOpenId } from '@/utils/storage';
import config from '@/utils/config';
// import config from '@/utils/config';
import { loadBookCoversBase64 } from '@/utils/bookCover'; import { loadBookCoversBase64 } from '@/utils/bookCover';
export default { export default {
@ -44,7 +44,6 @@ export default {
hasLoadedAll: false, hasLoadedAll: false,
} }
}, },
onLoad() { onLoad() {
}, },
onShow() { onShow() {
@ -79,7 +78,7 @@ export default {
} }
const res = await FetchFindAllBookCollectionByOpenId({ const res = await FetchFindAllBookCollectionByOpenId({
libcode: config.LIB_CODE,
libcode: getApp().globalData.libcode,
openId: openId, openId: openId,
page: this.pageNum, page: this.pageNum,
size: this.pageSize, size: this.pageSize,
@ -102,7 +101,6 @@ export default {
this.isLoading = false; this.isLoading = false;
} }
}, },
async refreshData() { async refreshData() {
this.pageNum = 0; this.pageNum = 0;
this.noMore = false; this.noMore = false;
@ -115,10 +113,8 @@ export default {
}); });
uni.stopPullDownRefresh(); uni.stopPullDownRefresh();
}, },
async loadMore() { async loadMore() {
if (this.noMore || this.isLoading) return; if (this.noMore || this.isLoading) return;
this.pageNum++; this.pageNum++;
this.isLoading = true; this.isLoading = true;
@ -129,14 +125,12 @@ export default {
this.isLoading = false; this.isLoading = false;
return; return;
} }
const res = await FetchFindAllBookCollectionByOpenId({ const res = await FetchFindAllBookCollectionByOpenId({
libcode: config.LIB_CODE,
libcode: getApp().globalData.libcode,
openId: openId, openId: openId,
page: this.pageNum, page: this.pageNum,
size: this.pageSize, size: this.pageSize,
}); });
if (res.code === 200) { if (res.code === 200) {
const newData = res.data.content || []; const newData = res.data.content || [];
this.bookCollectList = [...this.bookCollectList, ...newData]; this.bookCollectList = [...this.bookCollectList, ...newData];

4
subpkg/pages/feedback-detail/feedback-detail.vue

@ -17,7 +17,6 @@
<script> <script>
import { FetchReaderMessageDetailsById } from '@/api/user'; import { FetchReaderMessageDetailsById } from '@/api/user';
export default { export default {
data() { data() {
return { return {
@ -38,13 +37,10 @@ export default {
console.warn('缺少留言 ID'); console.warn('缺少留言 ID');
return; return;
} }
const res = await FetchReaderMessageDetailsById({ const res = await FetchReaderMessageDetailsById({
id: this.detail.id id: this.detail.id
}); });
console.log(res);
if (res && res.code === 200) { if (res && res.code === 200) {
this.detail = res.data || {}; this.detail = res.data || {};
} else { } else {

6
subpkg/pages/feedback-list/feedback-list.vue

@ -37,7 +37,7 @@
<script> <script>
import { FetchInitReaderMessage } from '@/api/user'; import { FetchInitReaderMessage } from '@/api/user';
import config from '@/utils/config';
// import config from '@/utils/config';
import { getOpenId } from '@/utils/storage'; import { getOpenId } from '@/utils/storage';
export default { export default {
@ -71,7 +71,7 @@ export default {
} }
// const currentReaderCard = await getCurrentReaderCard(); // const currentReaderCard = await getCurrentReaderCard();
const res = await FetchInitReaderMessage({ const res = await FetchInitReaderMessage({
libcode: config.LIB_CODE,
libcode: getApp().globalData.libcode,
openId: openId, openId: openId,
// readCardNo: currentReaderCard.readCardNo, // readCardNo: currentReaderCard.readCardNo,
// readName: '', // readName: '',
@ -123,7 +123,7 @@ export default {
} }
const res = await FetchInitReaderMessage({ const res = await FetchInitReaderMessage({
libcode: config.LIB_CODE,
libcode: getApp().globalData.libcode,
openId: openId, openId: openId,
page: this.pageNum, page: this.pageNum,
size: this.pageSize, size: this.pageSize,

13
subpkg/pages/feedback/feedback.vue

@ -54,9 +54,8 @@
<script> <script>
import { FetchReaderMessage,FetchAccessToken,FetchMsgSecCheck } from '@/api/user'; import { FetchReaderMessage,FetchAccessToken,FetchMsgSecCheck } from '@/api/user';
import config from '@/utils/config';
// import config from '@/utils/config';
import { getCurrentReaderCard,getOpenId } from '@/utils/storage'; import { getCurrentReaderCard,getOpenId } from '@/utils/storage';
const USER_KEY = 'user-info'; const USER_KEY = 'user-info';
export default { export default {
@ -87,7 +86,6 @@ export default {
console.error('获取读者证信息失败:', err); console.error('获取读者证信息失败:', err);
} }
}, },
loadUserInfo() { loadUserInfo() {
const userInfo = uni.getStorageSync(USER_KEY) || {}; const userInfo = uni.getStorageSync(USER_KEY) || {};
if (userInfo.nickname) { if (userInfo.nickname) {
@ -95,12 +93,10 @@ export default {
this.hasNickname = true; this.hasNickname = true;
} }
}, },
validatePhone(phone) { validatePhone(phone) {
const phoneReg = /^1[3-9]\d{9}$/; const phoneReg = /^1[3-9]\d{9}$/;
return phoneReg.test(phone); return phoneReg.test(phone);
}, },
async onBtnClick() { async onBtnClick() {
const { name, readerCard, subject, phone, content } = this.formData; const { name, readerCard, subject, phone, content } = this.formData;
@ -151,7 +147,6 @@ export default {
}); });
return; return;
} }
uni.showLoading({ uni.showLoading({
title: '提交中' title: '提交中'
}); });
@ -163,7 +158,7 @@ export default {
} }
// 1. access_token // 1. access_token
const tokenRes = await FetchAccessToken({ libcode: config.LIB_CODE });
const tokenRes = await FetchAccessToken({ libcode: getApp().globalData.libcode });
if (!tokenRes || tokenRes.code !== 200 || !tokenRes.data) { if (!tokenRes || tokenRes.code !== 200 || !tokenRes.data) {
uni.showToast({ title: '获取访问令牌失败', icon: 'none' }); uni.showToast({ title: '获取访问令牌失败', icon: 'none' });
return; return;
@ -172,7 +167,7 @@ export default {
// 2. // 2.
const secCheckRes = await FetchMsgSecCheck({ const secCheckRes = await FetchMsgSecCheck({
libcode: config.LIB_CODE,
libcode: getApp().globalData.libcode,
content: content, content: content,
version: 2, version: 2,
scene: 2, scene: 2,
@ -232,7 +227,7 @@ export default {
// 3. // 3.
const res = await FetchReaderMessage({ const res = await FetchReaderMessage({
libcode: config.LIB_CODE,
libcode: getApp().globalData.libcode,
openid: openId, openid: openId,
phone, phone,
readCardNo: readerCard, readCardNo: readerCard,

20
subpkg/pages/myLending/myLending.vue

@ -71,7 +71,7 @@ import { FetchHistoryloan, FetchRdloanlist, FetchCoverByISBN } from '@/api/book'
import myTabs from "@/components/my-tabs/my-tabs.vue"; import myTabs from "@/components/my-tabs/my-tabs.vue";
import lendingListItem from "@/components/lending-list-item/lending-list-item.vue"; import lendingListItem from "@/components/lending-list-item/lending-list-item.vue";
import { getCurrentReaderCard } from '@/utils/storage'; import { getCurrentReaderCard } from '@/utils/storage';
import config from '@/utils/config';
// import config from '@/utils/config';
import { loadBookCoversBase64 } from '@/utils/bookCover'; import { loadBookCoversBase64 } from '@/utils/bookCover';
export default { export default {
@ -84,27 +84,22 @@ export default {
{ label: '历史借阅', status: 'all' }, { label: '历史借阅', status: 'all' },
], ],
currentIndex: 0, currentIndex: 0,
// //
allList: [], allList: [],
loadingAll: false, loadingAll: false,
pageAll: 1, pageAll: 1,
hasMoreAll: true, hasMoreAll: true,
loadMoreStatusAll: '', loadMoreStatusAll: '',
// //
lendingList: [], lendingList: [],
loadingLending: false, loadingLending: false,
swiperHeightData: {}, swiperHeightData: {},
currentSwiperHeight: 400, currentSwiperHeight: 400,
}; };
}, },
onLoad() { onLoad() {
this.getScreenSetting(); this.getScreenSetting();
}, },
onShow() { onShow() {
const tabIndex = uni.getStorageSync('switch_tab_index'); const tabIndex = uni.getStorageSync('switch_tab_index');
if (tabIndex !== '') { if (tabIndex !== '') {
@ -112,7 +107,6 @@ export default {
uni.removeStorageSync('switch_tab_index'); uni.removeStorageSync('switch_tab_index');
} }
}, },
onPullDownRefresh() { onPullDownRefresh() {
if (this.currentIndex === 0) { if (this.currentIndex === 0) {
this.getLendingList(); this.getLendingList();
@ -120,7 +114,6 @@ export default {
this.getAllList(true); this.getAllList(true);
} }
}, },
onReachBottom() { onReachBottom() {
if (this.currentIndex === 0) { if (this.currentIndex === 0) {
this.getLendingList(); this.getLendingList();
@ -128,11 +121,10 @@ export default {
this.getAllList(); this.getAllList();
} }
}, },
methods: { methods: {
async getScreenSetting() { async getScreenSetting() {
try { try {
const res = await FetchInitScreenSetting({ libcode: config.LIB_CODE });
const res = await FetchInitScreenSetting({ libcode: getApp().globalData.libcode });
const data = res.data; const data = res.data;
this.screenConfig = { this.screenConfig = {
thirdUrl: data.open_lib_http?.context || '', thirdUrl: data.open_lib_http?.context || '',
@ -140,12 +132,10 @@ export default {
thirdSecret: data.open_lib_secret?.context || '', thirdSecret: data.open_lib_secret?.context || '',
sm4Key: data.sm4_key?.context || '' sm4Key: data.sm4_key?.context || ''
}; };
// tab // tab
this.getLendingList(true); this.getLendingList(true);
} catch (err) {} } catch (err) {}
}, },
async getAllList(isRefresh = false) { async getAllList(isRefresh = false) {
if (this.loadingAll) return; if (this.loadingAll) return;
this.loadingAll = true; this.loadingAll = true;
@ -190,7 +180,6 @@ export default {
}, 100); }, 100);
} }
}, },
async getLendingList() { async getLendingList() {
this.loadingLending = true; this.loadingLending = true;
try { try {
@ -222,7 +211,6 @@ export default {
}, 100); }, 100);
} }
}, },
// //
async loadCoversForList(list) { async loadCoversForList(list) {
await loadBookCoversBase64(list, (index, coverUrl) => { await loadBookCoversBase64(list, (index, coverUrl) => {
@ -231,7 +219,6 @@ export default {
} }
}); });
}, },
// //
calcHeight(type) { calcHeight(type) {
const selector = `.list-item-${type}`; const selector = `.list-item-${type}`;
@ -247,7 +234,6 @@ export default {
this.currentSwiperHeight = totalHeight + 20; this.currentSwiperHeight = totalHeight + 20;
}).exec(); }).exec();
}, },
tabClick(index) { tabClick(index) {
this.currentIndex = index; this.currentIndex = index;
if (index === 0) { if (index === 0) {
@ -264,11 +250,9 @@ export default {
} }
} }
}, },
onSwiperChange(e) { onSwiperChange(e) {
if (e.detail.source === 'touch') this.currentIndex = e.detail.current; if (e.detail.source === 'touch') this.currentIndex = e.detail.current;
}, },
onSwiperEnd() { onSwiperEnd() {
this.tabClick(this.currentIndex); this.tabClick(this.currentIndex);
}, },

10
subpkg/pages/ranking/ranking.vue

@ -78,8 +78,8 @@
<script> <script>
import { FetchInitScreenSetting } from '@/api/user'; import { FetchInitScreenSetting } from '@/api/user';
import { FetchBookRanking } from '@/api/book'; import { FetchBookRanking } from '@/api/book';
import config from '@/utils/config';
import { loadBookCoversBase64 } from '@/utils/bookCover'; import { loadBookCoversBase64 } from '@/utils/bookCover';
// import config from '@/utils/config';
export default { export default {
data() { data() {
@ -89,21 +89,18 @@ export default {
loading: true, loading: true,
}; };
}, },
onLoad() { onLoad() {
this.getScreenSetting(); this.getScreenSetting();
}, },
methods: { methods: {
async getScreenSetting() { async getScreenSetting() {
try { try {
const res = await FetchInitScreenSetting({ libcode: config.LIB_CODE });
const res = await FetchInitScreenSetting({ libcode: getApp().globalData.libcode });
this.getReadRanking(res.data); this.getReadRanking(res.data);
} catch (err) { } catch (err) {
console.error('获取屏幕配置失败:', err); console.error('获取屏幕配置失败:', err);
} }
}, },
getFormattedDate(date) { getFormattedDate(date) {
const year = date.getFullYear(); const year = date.getFullYear();
const month = date.getMonth() + 1; const month = date.getMonth() + 1;
@ -120,7 +117,7 @@ export default {
const formattedDate = `${year}-${month < 10 ? '0' + month : month}-${day < 10 ? '0' + day : day}` const formattedDate = `${year}-${month < 10 ? '0' + month : month}-${day < 10 ? '0' + day : day}`
const params = { const params = {
'libcode': 'GD',
'libcode': getApp().globalData.libcode,
'starttime': formattedDate, 'starttime': formattedDate,
'endtime': this.getFormattedDate(new Date()), 'endtime': this.getFormattedDate(new Date()),
'rownum': 10, 'rownum': 10,
@ -150,7 +147,6 @@ export default {
this.loading = false; this.loading = false;
}) })
}, },
// //
async loadCoversForList() { async loadCoversForList() {
await loadBookCoversBase64(this.rankingData, (index, coverUrl) => { await loadBookCoversBase64(this.rankingData, (index, coverUrl) => {

24
subpkg/pages/reader-card/reader-card.vue

@ -1,7 +1,6 @@
<template> <template>
<view class="reader-card"> <view class="reader-card">
<image class="card-top-bg" src="/subpkg/static/card-img1.png" mode="widthFix" /> <image class="card-top-bg" src="/subpkg/static/card-img1.png" mode="widthFix" />
<view class="edit-btn" @click="toggleEditMode"> <view class="edit-btn" @click="toggleEditMode">
{{ isEditMode ? '完成' : '解绑' }} {{ isEditMode ? '完成' : '解绑' }}
</view> </view>
@ -69,13 +68,10 @@
</template> </template>
<script> <script>
import {
FetchFindAllReaderBindByOpenId,
FetchSetDefaultReadCard,
FetchUnbindReadCard
} from '@/api/user';
// FetchFindAllReaderBindByOpenId,
import { FetchSetDefaultReadCard, FetchUnbindReadCard } from '@/api/user';
import { getReaderCardList, getOpenId, setCurrentReaderCard, clearReaderCardCache, STORAGE_KEYS } from '@/utils/storage'; import { getReaderCardList, getOpenId, setCurrentReaderCard, clearReaderCardCache, STORAGE_KEYS } from '@/utils/storage';
import config from '@/utils/config';
// import config from '@/utils/config';
export default { export default {
data() { data() {
@ -105,12 +101,10 @@ export default {
return '***' + str.substring(len - 2); return '***' + str.substring(len - 2);
} }
}, },
toggleEditMode() { toggleEditMode() {
this.isEditMode = !this.isEditMode; this.isEditMode = !this.isEditMode;
this.selectedValue = ''; this.selectedValue = '';
}, },
async getBindReaderCardList(forceRefresh = false) { async getBindReaderCardList(forceRefresh = false) {
if (this.loading) return; if (this.loading) return;
this.loading = true; this.loading = true;
@ -126,13 +120,11 @@ export default {
this.loading = false; this.loading = false;
} }
}, },
handleSelectItem(value) { handleSelectItem(value) {
if (this.isEditMode) { if (this.isEditMode) {
this.selectedValue = this.selectedValue === value ? '' : value; this.selectedValue = this.selectedValue === value ? '' : value;
} }
}, },
async setDefaultCard(value) { async setDefaultCard(value) {
const currentDefault = this.cardList.find(item => item.bindDefault === true); const currentDefault = this.cardList.find(item => item.bindDefault === true);
if (currentDefault && currentDefault.bindValue === value) { if (currentDefault && currentDefault.bindValue === value) {
@ -155,7 +147,7 @@ export default {
await FetchSetDefaultReadCard({ await FetchSetDefaultReadCard({
bindType: 'rdid', bindType: 'rdid',
bindValue: value, bindValue: value,
libcode: config.LIB_CODE,
libcode: getApp().globalData.libcode,
openid: openId openid: openId
}); });
setCurrentReaderCard(value); setCurrentReaderCard(value);
@ -168,17 +160,14 @@ export default {
} }
}); });
}, },
showQrcode(bindValue) { showQrcode(bindValue) {
this.qrcodeText = bindValue; this.qrcodeText = bindValue;
this.$refs.popup.open(); this.$refs.popup.open();
}, },
closePopup() { closePopup() {
this.qrcodeText = ''; this.qrcodeText = '';
this.$refs.popup.close(); this.$refs.popup.close();
}, },
async handleUnbind() { async handleUnbind() {
if (!this.selectedValue) { if (!this.selectedValue) {
uni.showToast({ title: '请选择要解绑的读者证', icon: 'none' }); uni.showToast({ title: '请选择要解绑的读者证', icon: 'none' });
@ -204,7 +193,7 @@ export default {
const result = await FetchUnbindReadCard({ const result = await FetchUnbindReadCard({
bindType: "rdid", bindType: "rdid",
bindValue: this.selectedValue, bindValue: this.selectedValue,
libcode: config.LIB_CODE,
libcode: getApp().globalData.libcode,
openid: openId openid: openId
}); });
@ -218,7 +207,7 @@ export default {
await FetchSetDefaultReadCard({ await FetchSetDefaultReadCard({
bindType: 'rdid', bindType: 'rdid',
bindValue: newValue, bindValue: newValue,
libcode: config.LIB_CODE,
libcode: getApp().globalData.libcode,
openid: openId openid: openId
}); });
setCurrentReaderCard(newValue); setCurrentReaderCard(newValue);
@ -237,7 +226,6 @@ export default {
} }
}); });
}, },
toAddReaderCard() { toAddReaderCard() {
uni.navigateTo({ url: "/pages/login/login" }); uni.navigateTo({ url: "/pages/login/login" });
}, },

6
subpkg/pages/register/register-form.vue

@ -152,7 +152,7 @@ export default {
console.log('loginRes',loginRes) console.log('loginRes',loginRes)
if (loginRes.code) { if (loginRes.code) {
const res = await FetchSessionKey({ const res = await FetchSessionKey({
libcode: config.LIB_CODE,
libcode: getApp().globalData.libcode,
code: loginRes.code code: loginRes.code
}); });
if (res.code === 200) { if (res.code === 200) {
@ -167,7 +167,7 @@ export default {
} }
}, },
async getScreenSetting() { async getScreenSetting() {
const res = await FetchInitScreenSetting({ libcode: config.LIB_CODE });
const res = await FetchInitScreenSetting({ libcode: getApp().globalData.libcode });
if(res.data.library_logo && res.data.library_logo.context){ if(res.data.library_logo && res.data.library_logo.context){
this.libraryLogo = config.baseUrl + '/files/' + res.data.library_logo.context; this.libraryLogo = config.baseUrl + '/files/' + res.data.library_logo.context;
@ -352,7 +352,7 @@ export default {
// phone: this.formData.phone.trim(), // phone: this.formData.phone.trim(),
// password: this.formData.password, // password: this.formData.password,
// openId, // openId,
// libcode: config.LIB_CODE
// libcode: getApp().globalData.libcode
// } // }
// }); // });

2
subpkg/pages/register/register.vue

@ -67,7 +67,7 @@ export default {
}, },
methods: { methods: {
async getScreenSetting() { async getScreenSetting() {
const res = await FetchInitScreenSetting({ libcode: config.LIB_CODE });
const res = await FetchInitScreenSetting({ libcode: getApp().globalData.libcode });
if(res.data.library_logo && res.data.library_logo.context){ if(res.data.library_logo && res.data.library_logo.context){
this.libraryLogo = config.baseUrl + '/files/' + res.data.library_logo.context; this.libraryLogo = config.baseUrl + '/files/' + res.data.library_logo.context;

60
subpkg/pages/seat-booking/seat-booking.vue

@ -37,7 +37,6 @@
</view> </view>
</view> </view>
<!-- 时间选择闭馆时整体禁用 --> <!-- 时间选择闭馆时整体禁用 -->
<view class="section" :class="{disabled: isSelectCloseDay}"> <view class="section" :class="{disabled: isSelectCloseDay}">
<view class="section-title">时间选择</view> <view class="section-title">时间选择</view>
@ -75,7 +74,6 @@
<view class="notice-content">{{ closeNoticeText }}</view> <view class="notice-content">{{ closeNoticeText }}</view>
</view> </view>
<view class="section operate-desc"> <view class="section operate-desc">
<view class="section-title" style="font-size: 14px;">预约说明</view> <view class="section-title" style="font-size: 14px;">预约说明</view>
<view class="desc-item"> <view class="desc-item">
@ -106,8 +104,7 @@
<script> <script>
import { FetchInitLibraryReservationSettings, FetchInitMyReservation,FetchReserve } from '@/api/reservation'; import { FetchInitLibraryReservationSettings, FetchInitMyReservation,FetchReserve } from '@/api/reservation';
import { getOpenId } from '@/utils/storage'; import { getOpenId } from '@/utils/storage';
import config from '@/utils/config';
// import config from '@/utils/config';
export default { export default {
data() { data() {
@ -208,7 +205,7 @@ export default {
try { try {
const openId = await getOpenId(); const openId = await getOpenId();
const res = await FetchInitMyReservation({ const res = await FetchInitMyReservation({
libcode: config.LIB_CODE,
libcode: getApp().globalData.libcode,
openId: openId openId: openId
}) })
console.log('初始化我的预约',res) console.log('初始化我的预约',res)
@ -294,13 +291,11 @@ export default {
weekDays weekDays
} }
}, },
// //
async initReservationSettings() { async initReservationSettings() {
try { try {
const res = await FetchInitLibraryReservationSettings({ const res = await FetchInitLibraryReservationSettings({
libcode: config.LIB_CODE
libcode: getApp().globalData.libcode
}) })
if (res && res.code === 200 && res.data) { if (res && res.code === 200 && res.data) {
this.reserveConfig = this.transformReserveConfig(res.data); this.reserveConfig = this.transformReserveConfig(res.data);
@ -311,8 +306,6 @@ export default {
console.error('获取预约设置异常', e) console.error('获取预约设置异常', e)
} }
}, },
getWeekNum(dateStr) { getWeekNum(dateStr) {
const d = new Date(dateStr); const d = new Date(dateStr);
const day = d.getDay(); const day = d.getDay();
@ -322,8 +315,6 @@ export default {
const map = {1:'周一',2:'周二',3:'周三',4:'周四',5:'周五',6:'周六',7:'周日'} const map = {1:'周一',2:'周二',3:'周三',4:'周四',5:'周五',6:'周六',7:'周日'}
return map[weekNo] return map[weekNo]
}, },
generateCalendar() { generateCalendar() {
if(!this.reserveConfig) return; if(!this.reserveConfig) return;
const today = new Date(); const today = new Date();
@ -337,19 +328,14 @@ export default {
allowDateList.push(ds) allowDateList.push(ds)
} }
const list = [] const list = []
allowDateList.forEach(dateStr=>{ allowDateList.forEach(dateStr=>{
const weekNo = this.getWeekNum(dateStr) const weekNo = this.getWeekNum(dateStr)
const weekCfg = this.reserveConfig.weekDays.find(w => w.id === weekNo) const weekCfg = this.reserveConfig.weekDays.find(w => w.id === weekNo)
const available = !!weekCfg?.checked const available = !!weekCfg?.checked
const d = new Date(dateStr) const d = new Date(dateStr)
const tempClose = this.tempCloseDateList.includes(dateStr) const tempClose = this.tempCloseDateList.includes(dateStr)
const userHasBooked = this.userBookedDateList.includes(dateStr) const userHasBooked = this.userBookedDateList.includes(dateStr)
list.push({ list.push({
day: d.getDate(), day: d.getDate(),
date: dateStr, date: dateStr,
@ -402,8 +388,6 @@ export default {
// //
this.selectedTimeList = [...bookedTimeArr] this.selectedTimeList = [...bookedTimeArr]
}, },
selectDate(day) { selectDate(day) {
// //
if (!day.available && !day.tempClose) { if (!day.available && !day.tempClose) {
@ -429,7 +413,6 @@ export default {
return return
} }
const idx = this.selectedTimeList.indexOf(slot.time) const idx = this.selectedTimeList.indexOf(slot.time)
if(idx > -1){ if(idx > -1){
// //
@ -447,19 +430,13 @@ export default {
uni.showToast({ title: '请选择日期', icon: 'none' }); uni.showToast({ title: '请选择日期', icon: 'none' });
return; return;
} }
const bookedTimeArr = this.userBookedMap[this.selectedDate] || [] const bookedTimeArr = this.userBookedMap[this.selectedDate] || []
// //
const newSelectTimes = this.selectedTimeList.filter(item=> !bookedTimeArr.includes(item)) const newSelectTimes = this.selectedTimeList.filter(item=> !bookedTimeArr.includes(item))
if (!newSelectTimes || newSelectTimes.length === 0) { if (!newSelectTimes || newSelectTimes.length === 0) {
uni.showToast({ title: '请选择需要新增预约的时间段', icon: 'none' }); uni.showToast({ title: '请选择需要新增预约的时间段', icon: 'none' });
return; return;
} }
uni.showLoading({ title: '预约中...' }); uni.showLoading({ title: '预约中...' });
const openId = await getOpenId(); const openId = await getOpenId();
if (!openId) { if (!openId) {
@ -467,28 +444,22 @@ export default {
uni.showToast({ title: '获取用户openid失败', icon: 'none' }); uni.showToast({ title: '获取用户openid失败', icon: 'none' });
return; return;
} }
// //
const param = newSelectTimes.map(timeStr => { const param = newSelectTimes.map(timeStr => {
const [startPart, endPart] = timeStr.split(' - '); const [startPart, endPart] = timeStr.split(' - ');
const startTime = startPart.trim() + ':00'; const startTime = startPart.trim() + ':00';
const endTime = endPart.trim() + ':00'; const endTime = endPart.trim() + ':00';
return { return {
libcode: config.LIB_CODE, //
libcode: getApp().globalData.libcode, //
openid: openId, // OpenID openid: openId, // OpenID
specificDate: this.selectedDate, // specificDate: this.selectedDate, //
startTime: startTime, // startTime: startTime, //
endTime: endTime // endTime: endTime //
} }
}) })
try { try {
const res = await FetchReserve(param); const res = await FetchReserve(param);
uni.hideLoading(); uni.hideLoading();
if(res.code === 200){ if(res.code === 200){
// //
if(!this.userBookedDateList.includes(this.selectedDate)){ if(!this.userBookedDateList.includes(this.selectedDate)){
@ -497,7 +468,6 @@ export default {
const old = this.userBookedMap[this.selectedDate] || [] const old = this.userBookedMap[this.selectedDate] || []
this.userBookedMap[this.selectedDate] = [...new Set([...old,...newSelectTimes])] this.userBookedMap[this.selectedDate] = [...new Set([...old,...newSelectTimes])]
const timeText = newSelectTimes.map(t=>this.formatShowTime(t)).join('\n'); const timeText = newSelectTimes.map(t=>this.formatShowTime(t)).join('\n');
uni.showModal({ uni.showModal({
title: '预约成功', title: '预约成功',
@ -536,7 +506,6 @@ export default {
padding-bottom: 70px; padding-bottom: 70px;
} }
.section { .section {
background-color: #fff; background-color: #fff;
margin: 10px; margin: 10px;
@ -559,7 +528,6 @@ export default {
} }
} }
// //
.section.disabled{ .section.disabled{
opacity:0.55; opacity:0.55;
@ -572,7 +540,6 @@ export default {
text-align:center; text-align:center;
} }
.calendar-wrap{ .calendar-wrap{
background:#ffffff; background:#ffffff;
border-radius:16px; border-radius:16px;
@ -594,7 +561,6 @@ export default {
font-weight:bold; font-weight:bold;
} }
.calendar-days-grid{ .calendar-days-grid{
display:flex; display:flex;
flex-wrap:wrap; flex-wrap:wrap;
@ -613,7 +579,6 @@ export default {
overflow: hidden; overflow: hidden;
} }
/* 今天左上角蓝色三角 */ /* 今天左上角蓝色三角 */
.corner-block-today{ .corner-block-today{
position:absolute; position:absolute;
@ -635,7 +600,6 @@ export default {
border-right: 12px solid transparent; border-right: 12px solid transparent;
} }
.card-week{ .card-week{
font-size:12px; font-size:12px;
color:#666; color:#666;
@ -651,7 +615,6 @@ export default {
margin-top:4px; margin-top:4px;
} }
/* 可预约 */ /* 可预约 */
.day-card.card-available{ .day-card.card-available{
background:#e8f4fd; background:#e8f4fd;
@ -659,8 +622,6 @@ export default {
.day-card.card-available .card-status{ .day-card.card-available .card-status{
color:#01a4fe; color:#01a4fe;
} }
/* 闭馆/不可选 */ /* 闭馆/不可选 */
.day-card.card-disabled{ .day-card.card-disabled{
background:#f7f8fa; background:#f7f8fa;
@ -670,8 +631,6 @@ export default {
.day-card.card-disabled .card-status{ .day-card.card-disabled .card-status{
color:#999; color:#999;
} }
/* 选中状态 */ /* 选中状态 */
.day-card.card-selected{ .day-card.card-selected{
background:#01a4fe; background:#01a4fe;
@ -689,8 +648,6 @@ export default {
.day-card.card-user-booked .card-status{ .day-card.card-user-booked .card-status{
color:#ff7800; color:#ff7800;
} }
.day-card.card-user-booked.card-selected{ .day-card.card-user-booked.card-selected{
background:#ff7800; background:#ff7800;
} }
@ -699,26 +656,17 @@ export default {
.day-card.card-user-booked.card-selected .card-status{ .day-card.card-user-booked.card-selected .card-status{
color:#fff; color:#fff;
} }
.day-card.card-temp-close .card-status{ .day-card.card-temp-close .card-status{
color:#999; color:#999;
} }
.day-card.card-temp-close.card-selected { .day-card.card-temp-close.card-selected {
background:#888; background:#888;
} }
.day-card.card-temp-close.card-selected .card-week, .day-card.card-temp-close.card-selected .card-week,
.day-card.card-temp-close.card-selected .card-num, .day-card.card-temp-close.card-selected .card-num,
.day-card.card-temp-close.card-selected .card-status{ .day-card.card-temp-close.card-selected .card-status{
color:#fff; color:#fff;
} }
/* 时间选择 */ /* 时间选择 */
.section-title { .section-title {
font-size: 16px; font-size: 16px;

9
subpkg/pages/seat-record/seat-record.vue

@ -80,7 +80,7 @@
<script> <script>
import { FetchMyReservation, FetchCancelReservation } from '@/api/reservation'; import { FetchMyReservation, FetchCancelReservation } from '@/api/reservation';
import { getOpenId } from '@/utils/storage'; import { getOpenId } from '@/utils/storage';
import config from '@/utils/config';
// import config from '@/utils/config';
export default { export default {
data() { data() {
@ -114,10 +114,8 @@ export default {
// 0 // 0
const todayTs = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime() const todayTs = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime()
const oneDay = 24 * 60 * 60 * 1000 const oneDay = 24 * 60 * 60 * 1000
const target = new Date(dateStr) const target = new Date(dateStr)
const targetTs = new Date(target.getFullYear(), target.getMonth(), target.getDate()).getTime() const targetTs = new Date(target.getFullYear(), target.getMonth(), target.getDate()).getTime()
const diffDay = Math.round((targetTs - todayTs) / oneDay) const diffDay = Math.round((targetTs - todayTs) / oneDay)
if(diffDay === 0){ if(diffDay === 0){
@ -152,7 +150,7 @@ export default {
async fetchMyReservation() { async fetchMyReservation() {
const openId = await getOpenId(); const openId = await getOpenId();
const res = await FetchMyReservation({ const res = await FetchMyReservation({
libcode: config.LIB_CODE,
libcode: getApp().globalData.libcode,
openId: openId, openId: openId,
page: this.page, page: this.page,
size: this.pageSize, size: this.pageSize,
@ -183,7 +181,6 @@ export default {
} }
return { list: [], noMore: true } return { list: [], noMore: true }
}, },
async getActivityList(isRefresh = false) { async getActivityList(isRefresh = false) {
if (this.loading) return; if (this.loading) return;
if (isRefresh) { if (isRefresh) {
@ -211,13 +208,11 @@ export default {
this.loading = false; this.loading = false;
} }
}, },
onScrollLower() { onScrollLower() {
if (this.loading || this.noMore) return; if (this.loading || this.noMore) return;
this.page += 1; this.page += 1;
this.getActivityList(false); this.getActivityList(false);
}, },
async cancelAppoint(item) { async cancelAppoint(item) {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',

10
subpkg/pages/user-info/user-info.vue

@ -33,7 +33,6 @@
<script> <script>
import config from '@/utils/config' import config from '@/utils/config'
import { FetchBindRead } from '@/api/user'; import { FetchBindRead } from '@/api/user';
const USER_KEY = 'user-info'; const USER_KEY = 'user-info';
export default { export default {
@ -76,8 +75,6 @@ export default {
this.imgId = ''; this.imgId = '';
} }
}, },
// + + base64 // + + base64
async onChooseAvatar(e) { async onChooseAvatar(e) {
const tempFilePath = e.detail.avatarUrl; const tempFilePath = e.detail.avatarUrl;
@ -99,13 +96,12 @@ export default {
const resData = JSON.parse(uploadRes.data); const resData = JSON.parse(uploadRes.data);
const imgId = resData.data; const imgId = resData.data;
this.imgId = imgId; this.imgId = imgId;
// base64 // base64
// const url = `${config.baseUrl}/api/fileRelevant/getImg?imgType=5&imgId=${imgId}`; // const url = `${config.baseUrl}/api/fileRelevant/getImg?imgType=5&imgId=${imgId}`;
const url = `${config.baseUrl}/files/${imgId}`;
// this.avatarUrl = await this.urlToBase64(url); // this.avatarUrl = await this.urlToBase64(url);
this.avatarUrl = url
const url = `${config.baseUrl}/files/${imgId}`;
this.avatarUrl = url
uni.showToast({ title: '头像上传成功', icon: 'success' }); uni.showToast({ title: '头像上传成功', icon: 'success' });
} catch (err) { } catch (err) {
console.error(err); console.error(err);
@ -149,7 +145,7 @@ export default {
const openId = uni.getStorageSync('wx_login_code') || ''; const openId = uni.getStorageSync('wx_login_code') || '';
const params = { const params = {
avatar: this.imgId, avatar: this.imgId,
libcode: config.LIB_CODE,
libcode: getApp().globalData.libcode,
nickname: this.nickname, nickname: this.nickname,
openid: openId openid: openId
}; };

1
utils/config.js

@ -3,7 +3,6 @@ const config = {
// baseUrl: 'http://192.168.99.63:14000', // baseUrl: 'http://192.168.99.63:14000',
// 线上 // 线上
baseUrl: 'https://wechatapi.aiyxlib.com', baseUrl: 'https://wechatapi.aiyxlib.com',
LIB_CODE: 'GD'
}; };
export default config; export default config;

18
utils/global.js

@ -0,0 +1,18 @@
// utils/global.js
export function waitLibcodeReady(){
return new Promise((resolve)=>{
const app = getApp()
if(app.globalData.libcode){
return resolve(app.globalData.libcode)
}
// 轮询等待,最多3秒
let count = 0
const timer = setInterval(()=>{
count++
if(app.globalData.libcode || count>30){
clearInterval(timer)
resolve(app.globalData.libcode || '')
}
},100)
})
}

6
utils/storage.js

@ -42,7 +42,7 @@ export async function getOpenId() {
// 4. 获取 openId // 4. 获取 openId
const openRes = await FetchOpenId({ const openRes = await FetchOpenId({
libcode: config.LIB_CODE,
libcode: getApp().globalData.libcode,
code: loginRes.code code: loginRes.code
}); });
@ -85,7 +85,7 @@ export async function getCurrentReaderCard() {
} }
const res = await FetchFindAllReaderBindByOpenId({ const res = await FetchFindAllReaderBindByOpenId({
libcode: config.LIB_CODE,
libcode: getApp().globalData.libcode,
openId: openId openId: openId
}); });
@ -137,7 +137,7 @@ export async function getReaderCardList(forceRefresh = false) {
} }
const res = await FetchFindAllReaderBindByOpenId({ const res = await FetchFindAllReaderBindByOpenId({
libcode: config.LIB_CODE,
libcode: getApp().globalData.libcode,
openId: openId openId: openId
}); });

Loading…
Cancel
Save