Browse Source

全局优化

master
xuhuajiao 3 weeks ago
parent
commit
ea9ddc003f
  1. 47
      App.vue
  2. 8
      api/user.js
  3. 2
      pages.json
  4. 20
      pages/home/home.vue
  5. 6
      pages/login/login.vue
  6. 2
      pages/search/search.vue
  7. 3
      subpkg/pages/activity-detail/activity-detail.vue
  8. 3
      subpkg/pages/activity-record/activity-record.vue
  9. 7
      subpkg/pages/book-detail/book-detail.vue
  10. 1
      subpkg/pages/feedback-list/feedback-list.vue
  11. 3
      subpkg/pages/register/register-form.vue
  12. 5
      subpkg/pages/register/register.vue
  13. 1
      subpkg/pages/seat-booking/seat-booking.vue
  14. 3
      utils/bookCover.js
  15. 18
      utils/global.js

47
App.vue

@ -1,10 +1,11 @@
<script>
import { FetchLibcodeBycode } from '@/api/user'
import { FetchLibcodeBycode,FetchInitFondsList } from '@/api/user'
export default {
globalData: {
appid: '',
libcode: '', // libcode getApp().globalData.libcode 访
libcode: '', // libcode
fondsName: '' // 使
},
onLaunch() {
this.initAppIdAndLibcode()
@ -24,8 +25,11 @@ export default {
if(cacheLibcode){
this.globalData.libcode = cacheLibcode
console.log('使用缓存libcode:', cacheLibcode)
// libcode fondsName
await this.getFondsName(cacheLibcode)
return
}
// 2 FetchLibcodeBycodeappidlibcode
const res = await FetchLibcodeBycode({
code: 'vx_mini_appId',
@ -36,6 +40,10 @@ export default {
this.globalData.libcode = libcode
uni.setStorageSync('GLOBAL_LIBCODE', libcode)
console.log('接口获取全局libcode成功:', libcode)
// libcodeFetchInitFondsList
await this.getFondsName(libcode)
}else{
console.error('FetchLibcodeBycode 获取libcode失败', res)
}
@ -44,6 +52,36 @@ export default {
}
// #endif
},
/**
* 根据libcode获取馆藏名称 fondsName
*/
async getFondsName(libcode) {
try {
//
let cacheFondsName = uni.getStorageSync('GLOBAL_FONDS_NAME')
if (cacheFondsName) {
this.globalData.fondsName = cacheFondsName
console.log('使用缓存 fondsName:', cacheFondsName)
return
}
// libcode
const fondRes = await FetchInitFondsList({
'fondsNo': libcode
})
// console.log('FetchInitFondsList', fondRes)
if (fondRes.code === 200 && fondRes.data) {
const fondsName = fondRes.data.fondsName || ''
this.globalData.fondsName = fondsName
uni.setStorageSync('GLOBAL_FONDS_NAME', fondsName)
console.log('获取馆藏名称成功:', fondsName)
} else {
console.error('FetchInitFondsList 获取馆藏失败', fondRes)
}
} catch (err) {
console.error('getFondsName异常', err)
}
},
// 退
// logout(){
// // 1.
@ -53,15 +91,20 @@ export default {
// // 2.libcode
// uni.removeStorageSync('GLOBAL_LIBCODE')
// uni.removeStorageSync('GLOBAL_FONDS_NAME') //
// getApp().globalData.libcode = ''
// getApp().globalData.fondsName = ''
// //
// uni.reLaunch({url:'/pages/login/login'})
// }
// libcode
// refreshLibcode(){
// uni.removeStorageSync('GLOBAL_LIBCODE')
// uni.removeStorageSync('GLOBAL_FONDS_NAME') //
// getApp().globalData.libcode = ''
// getApp().globalData.fondsName = ''
// uni.showToast({title:"libcode",icon:"none"})
// // App.vue
// getApp().$options.methods.initAppIdAndLibcode()

8
api/user.js

@ -191,3 +191,11 @@ export function FetchLibcodeBycode(data) {
data
});
}
// 根据馆代码拿fondName
export function FetchInitFondsList(data) {
return request({
url: '/api/fonds/getFondsDetailByFondsNo',
data
});
}

2
pages.json

@ -3,7 +3,7 @@
{
"path": "pages/home/home",
"style": {
"navigationBarTitleText": "葛店经济技术开发区图书馆"
"navigationBarTitleText": ""
}
},
{

20
pages/home/home.vue

@ -5,13 +5,11 @@
<image class="top-bar-bg" src="@/static/images/mingqi-beij@2x.png" mode="aspectFill"></image>
<view class="library-info">
<image class="avatar" :src="libraryLogo" mode="aspectFill"></image>
<view class="library-name">葛店经济技术开发区图书馆</view>
<view class="library-name">{{ fondsName }}</view>
</view>
<uni-icons class="search-icon" type="search" size="24" @click="onToSearch"></uni-icons>
</view>
<view class="status-cards">
<view class="status-card" @click="toBorrowPage(0)">
<view class="status-icon icon-color1" >
@ -237,11 +235,12 @@ import { FetchInitScreenSetting, FetchOpenId, FetchFindAllReaderBindByOpenId} fr
import { FetchInitScreenBookRecommend } from '@/api/book';
import config from '@/utils/config';
import { STORAGE_KEYS } from '@/utils/storage';
import { waitLibcodeReady } from '@/utils/global'
import { waitLibcodeReady,waitFondsNameReady } from '@/utils/global'
export default {
data() {
return {
fondsName: getApp().globalData.fondsName || '',
isLoading: true,
recommendedBooks: [],
userInfo: {},
@ -255,9 +254,19 @@ export default {
bannerList: [] // banner
};
},
onLoad() {
async onLoad() {
// this.getRecommendBooks();
// this.getScreenSetting()
const fondsName = await waitFondsNameReady()
if(fondsName){
uni.setNavigationBarTitle({
title: fondsName
})
}else{
uni.setNavigationBarTitle({
title: "图书馆"
})
}
this.initPage()
},
onShow() {
@ -420,7 +429,6 @@ export default {
if (item.imgVxPath) {
// const imageUrl = this.baseUrl + '/api/fileRelevant/getImg?imgType=2&imgId=' + item.imgPath;
const imageUrl = this.baseUrl + '/files/' + item.imgVxPath;
console.log('imageUrl:', imageUrl);
item.base64Cover = imageUrl;
// try {
// const base64 = await this.urlToBase64(imageUrl);

6
pages/login/login.vue

@ -4,7 +4,7 @@
<image class="top-bar-bg" src="@/static/images/mingqi-beij@2x.png" mode="aspectFill"></image>
<view class="library-info">
<image class="avatar" :src="libraryLogo" mode="aspectFill"></image>
<view class="library-name">葛店经济技术开发区图书馆</view>
<view class="library-name">{{ fondsName }}</view>
</view>
</view>
@ -57,6 +57,7 @@ import { STORAGE_KEYS } from '@/utils/storage';
export default {
data() {
return {
fondsName: getApp().globalData.fondsName || '',
queryvalue: '',
rdpasswd: '',
libraryLogo: null,
@ -215,10 +216,9 @@ export default {
}
//
const bindRes = await FetchBindReadCard(bindParams);
// console.log('', bindRes);
console.log('绑定结果', bindRes);
if(bindRes.code === 200 ){
uni.hideLoading();
uni.showToast({
title: bindRes.data || '读者证绑定成功',

2
pages/search/search.vue

@ -266,7 +266,7 @@ export default {
...item,
id: collectId // id
};
console.log('itemWithCollectInfo',itemWithCollectInfo)
// console.log('itemWithCollectInfo',itemWithCollectInfo)
const isCollectedParam = isCollected ? '&isCollected=true' : '';
uni.navigateTo({
url: "/subpkg/pages/book-detail/book-detail?searchData=" + encodeURIComponent(JSON.stringify(itemWithCollectInfo)) + isCollectedParam

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

@ -116,7 +116,6 @@ export default {
};
},
onLoad(options) {
console.log(options);
const item = JSON.parse(decodeURIComponent(options.item));
this.detail = item;
console.log('this.detail',this.detail);
@ -181,7 +180,6 @@ export default {
try {
uni.login({
success: async (loginRes) => {
console.log('loginRes',loginRes)
if (loginRes.code) {
const res = await FetchSessionKey({
libcode: getApp().globalData.libcode,
@ -319,7 +317,6 @@ export default {
openid: this.openid,
// sessionKey: this.sessionKey
}
console.log('params',params)
FetchSignActivity(params).then(res => {
console.log('FetchSignActivity',res)
if (res.code === 200) {

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

@ -191,7 +191,6 @@ export default {
return new Promise((resolve) => {
uni.login({
success: async (loginRes) => {
console.log('loginRes', loginRes)
if (loginRes.code) {
const res = await FetchSessionKey({
libcode: getApp().globalData.libcode,
@ -238,7 +237,6 @@ export default {
try {
const res = await FetchMySignActivityInfo(params);
console.log('FetchMySignActivityInfo返回结果', res)
if (res.code === 200) {
const pageData = res.data;
const list = pageData.content || [];
@ -331,7 +329,6 @@ export default {
})
},
toActivityDetail(item) {
console.log('toActivityDetail',item);
uni.navigateTo({
url: "/subpkg/pages/activity-detail/activity-detail?item=" + encodeURIComponent(JSON.stringify(item))
});

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

@ -104,6 +104,7 @@ import { fetchBookCoverBase64 } from '@/utils/bookCover';
export default {
data() {
return {
fondsName: getApp().globalData.fondsName || '',
baseUrl: config.baseUrl,
currentTab: 0,
isCollected: false,
@ -119,7 +120,7 @@ export default {
};
},
onLoad(options) {
console.log('options',options)
// console.log('options',options)
const fromShare = options.fromShare === 'true'
// 1. / bookData
@ -299,8 +300,8 @@ export default {
//
getLibraryName(orglib) {
if (!orglib) return '葛店经济技术开发区图书馆';
return this.libraryMap[orglib] || orglib || '葛店经济技术开发区图书馆';
if (!orglib) return this.fondsName;
return this.libraryMap[orglib] || orglib || this.fondsName;
},
//

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

@ -90,7 +90,6 @@ export default {
});
},
goDetail(item) {
console.log(item);
uni.navigateTo({
url: '/subpkg/pages/feedback-detail/feedback-detail?item=' + encodeURIComponent(JSON.stringify(item))
});

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

@ -5,7 +5,7 @@
<image class="top-bar-bg" src="@/static/images/mingqi-beij@2x.png" mode="aspectFill"></image>
<view class="library-info">
<image class="avatar" :src="libraryLogo" mode="aspectFill"></image>
<view class="library-name">葛店经济技术开发区图书馆</view>
<view class="library-name">{{ fondsName }}</view>
<view class="sub-title">读者证办理</view>
</view>
</view>
@ -123,6 +123,7 @@ import {FetchInitScreenSetting, FetchSessionKey, FetchDecryptPhone } from '@/api
export default {
data() {
return {
fondsName: getApp().globalData.fondsName || '',
sessionKey: '',
openid: '',
formData: {

5
subpkg/pages/register/register.vue

@ -5,7 +5,7 @@
<image class="top-bar-bg" src="@/static/images/mingqi-beij@2x.png" mode="aspectFill"></image>
<view class="library-info">
<image class="avatar" :src="libraryLogo" mode="aspectFill"></image>
<view class="library-name">葛店经济技术开发区图书馆</view>
<view class="library-name">{{ fondsName }}</view>
<view class="sub-title">信用免押金办证流程</view>
</view>
</view>
@ -20,7 +20,7 @@
<image src="/subpkg/static/register/2.jpg" mode="widthFix" />
</view>
<view class="online-item">
<text>点击切换进入葛店经济技术开发区图书馆</text>
<text>点击切换进入{{ fondsName }}</text>
<text>然后点击暂无借阅证点击注册</text>
<image src="/subpkg/static/register/3.jpg" mode="widthFix" />
</view>
@ -59,6 +59,7 @@ import config from '@/utils/config';
export default {
data() {
return {
fondsName: getApp().globalData.fondsName || '',
libraryLogo: null,
};
},

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

@ -208,7 +208,6 @@ export default {
libcode: getApp().globalData.libcode,
openId: openId
})
console.log('初始化我的预约',res)
if(res.code === 200 && res.data){
//
this.tempCloseDateList = []

3
utils/bookCover.js

@ -157,9 +157,8 @@ export async function fetchCoversByBookrecno(bookrecnoList) {
method: 'POST',
success: (res) => {
const result = {};
console.log('bookrecnoList',res)
const existsList = res.data || [];
console.log('existsList',existsList)
// console.log('existsList',existsList)
existsList.forEach(bookrecno => {
const timestamp = new Date().getTime();
result[bookrecno] = `http://218.200.95.251:8081/opac/bscover/${bookrecno}?timestamp=${timestamp}`;

18
utils/global.js

@ -16,3 +16,21 @@ export function waitLibcodeReady(){
},100)
})
}
// 新增:等待馆藏名称 fondsName
export function waitFondsNameReady(){
return new Promise((resolve)=>{
const app = getApp()
if(app.globalData.fondsName){
return resolve(app.globalData.fondsName)
}
let count = 0
const timer = setInterval(()=>{
count++
if(app.globalData.fondsName || count>30){
clearInterval(timer)
resolve(app.globalData.fondsName || '')
}
},100)
})
}
Loading…
Cancel
Save