diff --git a/.env.development b/.env.development index 6740be0..d13c673 100644 --- a/.env.development +++ b/.env.development @@ -3,9 +3,8 @@ ENV = 'development' # 接口地址 #内网服务地址 -VUE_APP_BASE_API = 'http://192.168.99.107:7070' -VUE_APP_WS_API = 'ws://192.168.99.107:7071' -VUE_APP_CAMERA_API = '192.168.99.107' +VUE_APP_BASE_API = 'http://192.168.99.84:8080' +VUE_APP_WS_API = 'ws://192.168.99.84:8080' # 刘力-本地服地址 #VUE_APP_BASE_API = 'http://192.168.99.65:7070' diff --git a/src/api/inquiryMachine.js b/src/api/inquiryMachine.js new file mode 100644 index 0000000..bb7c840 --- /dev/null +++ b/src/api/inquiryMachine.js @@ -0,0 +1,72 @@ +import request from '@/utils/request' +// import qs from 'qs' + +// 活动资讯/活动预告 +export function activityInquiry(params) { + return request({ + url: '/dxhtsg/activityInquiry', + method: 'get', + params: params + }) +} + +// 图书馆简介 +export function libraryIntro(params) { + return request({ + url: '/dxhtsg/libraryIntro', + method: 'get', + params: params + }) +} + +// 阅读之星 +export function FetchBorrowStar(params) { + return request({ + url: '/txhtsg/borrowStar', + method: 'get', + params: params + }) +} + +// 新书推荐 +export function FetchNewBookRecommend(params) { + return request({ + url: '/txhtsg/newBookRecommend', + method: 'get', + params: params + }) +} + +// 通知公告 +export function FetchInitNotice(params) { + return request({ + url: '/txhtsg/initNotice', + method: 'get', + params: params + }) +} + +// 进馆人数 +export function FetchInitIntoNum(params) { + return request({ + url: '/txhtsg/initIntoNum', + method: 'get', + params: params + }) +} + +// 24小时借还量 +export function FetchHalfYearBRNum(params) { + return request({ + url: '/txhtsg/getHalfYearBRNum', + method: 'get', + params: params + }) +} + +export default { + activityInquiry, + libraryIntro, + FetchBorrowStar, + FetchNewBookRecommend +} diff --git a/src/main.js b/src/main.js index e24caa5..5ef492a 100644 --- a/src/main.js +++ b/src/main.js @@ -13,6 +13,13 @@ import './assets/fonts/fonts.css' import axios from 'axios' Vue.prototype.$axios = axios +// 馆代码 +Vue.prototype.libcode = 'FTZN' + +import { parseTime } from '@/utils/index.js' +Vue.filter('parseTime', function(time, cFormat) { + return parseTime(time, cFormat) +}) // 引入echart import echarts from 'echarts' diff --git a/src/utils/index.js b/src/utils/index.js index 3356ab6..0fbeff9 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -44,3 +44,49 @@ export function getCurrentTime() { const time = yy + '年' + mm + '月' + dd + '日 ' + hh + ':' + mf + ':' + ss return time } + +/** + * Parse the time to string + * @param {(Object|string|number)} time + * @param {string} cFormat + * @returns {string} + */ +export function parseTime(time, cFormat) { + if (arguments.length === 0) { + return null + } + const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}' + let date + if (typeof time === 'undefined' || time === null || time === 'null') { + return '' + } else if (typeof time === 'object') { + date = time + } else { + if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) { + time = parseInt(time) + } + if ((typeof time === 'number') && (time.toString().length === 10)) { + time = time * 1000 + } + date = new Date(time) + } + const formatObj = { + y: date.getFullYear(), + m: date.getMonth() + 1, + d: date.getDate(), + h: date.getHours(), + i: date.getMinutes(), + s: date.getSeconds(), + a: date.getDay() + } + const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => { + let value = formatObj[key] + // Note: getDay() returns 0 on Sunday + if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value ] } + if (result.length > 0 && value < 10) { + value = '0' + value + } + return value || 0 + }) + return time_str +} diff --git a/src/utils/request.js b/src/utils/request.js index 99f050b..62315fe 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -29,14 +29,16 @@ service.interceptors.request.use( // response 拦截器 service.interceptors.response.use( response => { - const errorMsg = response.data.message - if (response.data.code === 200) { + const errorMsg = response.data.errMsg + if (response.status === 200) { + console.log(response.data.data) return response.data.data } else { Message.error({ message: errorMsg, duration: 5000 }) + Promise.reject() } }, error => { diff --git a/src/views/activityFeed.vue b/src/views/activityFeed.vue index bf1aad3..5af5fd1 100644 --- a/src/views/activityFeed.vue +++ b/src/views/activityFeed.vue @@ -9,35 +9,43 @@