Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
CS-Tao committed Nov 20, 2018
2 parents 9be7b58 + a62e978 commit 19a6bed
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 33 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
### 最新版本下载

- Windows
- 链接: [whu-library-seat-setup-1.7.0.exe](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.7.0/whu-library-seat-setup-1.7.0.exe)
- 链接: [whu-library-seat-setup-1.7.1.exe](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.7.1/whu-library-seat-setup-1.7.1.exe)

- Mac OS
- 链接: [whu-library-seat-1.7.0.dmg](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.7.0/whu-library-seat-1.7.0.dmg)
- 链接: [whu-library-seat-1.7.1.dmg](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.7.1/whu-library-seat-1.7.1.dmg)

- Linux
- 链接: [whu-library-seat-1.7.0-x86_64.AppImage](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.7.0/whu-library-seat-1.7.0-x86_64.AppImage)
- 链接: [whu-library-seat-1.7.1-x86_64.AppImage](https://github.com/CS-Tao/whu-library-seat/releases/download/v1.7.1/whu-library-seat-1.7.1-x86_64.AppImage)

### 安装软件

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "whu-library-seat",
"version": "1.7.0",
"version": "1.7.1",
"author": "CS-Tao <[email protected]>",
"description": "武汉大学图书馆抢座软件",
"license": null,
Expand Down
67 changes: 63 additions & 4 deletions src/renderer/components/Body/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<el-form v-show="showMode==='normal'" :model="form" ref="seatForm" label-width="50px" class="flex-row form">
<div style="margin:auto;text-align:center;">
<el-form-item label="日期">
<el-select v-model="form.date" placeholder="请选择日期" class="input" @change="updateSeatsStatus()">
<el-option key="0" label="今天" :value="freeDates[0]"><span>今天&nbsp;&nbsp;{{freeDates[0]}}</span></el-option>
<el-option key="1" label="明天" :value="freeDates[1]"><span>明天&nbsp;&nbsp;{{freeDates[1]}}</span></el-option>
<el-select v-model="form.date" placeholder="请选择日期" class="input" @focus="$store.dispatch('updateFreeDates')" @change="updateSeatsStatus()">
<el-option key="0" :label="'今天' + ' - ' + getWeekDay(freeDates[0])" :value="freeDates[0]"><span>{{'今天 / ' + freeDates[0] + ' / ' + getWeekDay(freeDates[0])}}</span></el-option>
<el-option key="1" :label="'明天' + ' - ' + getWeekDay(freeDates[1])" :value="freeDates[1]"><span>{{'明天 / ' + freeDates[1] + ' / ' + getWeekDay(freeDates[1])}}</span></el-option>
</el-select>
</el-form-item>
<el-form-item label="时间">
Expand Down Expand Up @@ -251,6 +251,12 @@ export default {
this.showWarning('请选择日期')
return
}
let today = this.formatDate(new Date())
let tomorrow = this.formatDate(this.getTomorrow())
if (this.freeDates[0] !== today || this.freeDates[1] !== tomorrow || !this.freeDates.includes(this.form.date)) {
this.showWarning('日期已刷新,请重新选择日期')
return
}
if (this.form.beginTime === null) {
this.showWarning('请选择开始时间')
return
Expand Down Expand Up @@ -483,7 +489,12 @@ export default {
// 位置不可用,如果未达抢座上限则继续抢
usageApi.grabState(this.userAccount, false, 12, `位置不可用,如果未达抢座上限则继续抢(${seatNum}:${this.grabCount}/${maxGrabCount}):${response.data.message}`)
this.grabCount += 1
var cancelCurrentBool = response.data.message === '已有1个有效预约,请在使用结束后再次进行选择' && this.grabCount < 2
var haveReservation = response.data.message.indexOf('已有') !== -1 &&
response.data.message.indexOf('预约') !== -1 &&
response.data.message.indexOf('') !== -1 &&
response.data.message.indexOf('结束') !== -1
var cancelCurrentBool = haveReservation && this.grabCount < 2
// var cancelCurrentBool = response.data.message === '已有1个有效预约,请在使用结束后再次进行选择' && this.grabCount < 2
var newSeatId = -1
if (cancelCurrentBool) {
newSeatId = seatNum
Expand Down Expand Up @@ -679,6 +690,54 @@ export default {
} else {
return 'rgb(0, 204, 0)'
}
},
getWeekDay (dateStr) {
var str = '星期'
var week = new Date(dateStr).getDay()
switch (week) {
case 0 :
str += ''
break
case 1 :
str += ''
break
case 2 :
str += ''
break
case 3 :
str += ''
break
case 4 :
str += ''
break
case 5 :
str += ''
break
case 6 :
str += ''
break
}
return str
},
formatDate (date, options) {
options = options || {}
options.sign = options.sign || 'yyyy-MM-dd'
var _complete = function (n) {
return (n > 9) ? n : '0' + n
}
var year = date.getFullYear()
var month = _complete(date.getMonth() + 1)
var day = _complete(date.getDate())
var result = options.sign
result = result.replace('yyyy', year)
result = result.replace('MM', month)
result = result.replace('dd', day)
return result
},
getTomorrow () {
var tomorrow = new Date()
tomorrow.setDate(tomorrow.getDate() + 1)
return tomorrow
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/renderer/components/Header/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ export default {
if (response.data.status === 'success') {
this.$store.dispatch('saveLibraryInfo', response.data.data)
this.$store.dispatch('setToken', token)
this.$store.dispatch('updateFreeDates')
if (this.isLover) {
this.$message({
iconClass: 'null',
Expand Down
26 changes: 2 additions & 24 deletions src/renderer/store/getters/index.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,3 @@
function formatDate (date, options) {
options = options || {}
options.sign = options.sign || 'yyyy-MM-dd'
var _complete = function (n) {
return (n > 9) ? n : '0' + n
}
var year = date.getFullYear()
var month = _complete(date.getMonth() + 1)
var day = _complete(date.getDate())
var result = options.sign
result = result.replace('yyyy', year)
result = result.replace('MM', month)
result = result.replace('dd', day)
return result
}

function getTomorrow () {
var tomorrow = new Date()
tomorrow.setDate(tomorrow.getDate() + 1)
return tomorrow
}

function getTimeInterval (beginTime = 0, count = 48, interval = 30) {
var timeArray = []
for (var i = 0; i < count; i++) {
Expand Down Expand Up @@ -54,8 +32,8 @@ const getters = {
userToken: state => state.app.userInfo.token,
hasToken: state => !!state.app.userInfo.token,
// time info
freeDates: state => [formatDate(new Date()), formatDate(getTomorrow())],
freeDatesDefault: state => [formatDate(new Date()), formatDate(getTomorrow())][state.app.seatInfo.date],
freeDates: state => state.app.freeDates,
freeDatesDefault: state => state.app.freeDates[state.app.seatInfo.date],
freeBeginTime: state => getTimeInterval(),
freeEndTime: state => getTimeInterval(),
// seat info
Expand Down
15 changes: 14 additions & 1 deletion src/renderer/store/modules/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ function formatDate (date, options) {
return result
}

function getTomorrow () {
var tomorrow = new Date()
tomorrow.setDate(tomorrow.getDate() + 1)
return tomorrow
}

function getTodayTime (hours, minutes, seconds) {
var today = new Date()
today.setHours(hours)
Expand Down Expand Up @@ -110,7 +116,8 @@ const app = {
dates: []
},
timerInfo: {...defaultTimerInfo},
announceViewed: true
announceViewed: true,
freeDates: [formatDate(new Date()), formatDate(getTomorrow())]
},
mutations: {
SET_ACCOUNT: (state, account) => {
Expand Down Expand Up @@ -222,6 +229,9 @@ const app = {
},
SET_ANNOUNCE_VIEWED: (state, viewed) => {
state.announceViewed = viewed
},
UPDATE_FREE_DATES: (state) => {
state.freeDates = [formatDate(new Date()), formatDate(getTomorrow())]
}
},
actions: {
Expand Down Expand Up @@ -348,6 +358,9 @@ const app = {
},
setAnnounceViewed ({ commit }, viewed) {
commit('SET_ANNOUNCE_VIEWED', viewed)
},
updateFreeDates ({ commit }) {
commit('UPDATE_FREE_DATES')
}
}
}
Expand Down

0 comments on commit 19a6bed

Please sign in to comment.