You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

566 lines
15 KiB

4 years ago
<template>
<view class="content">
<view class="box-top">
<image src="../../static/img/index_bg.jpg" class="index_bg"></image>
</view>
<view class="box-notice">
4 years ago
<u-notice-bar @click="openInfo" :text="list" direction="column" color="#9E8F8B"></u-notice-bar>
4 years ago
</view>
<view class="box-body">
<view class="box-body-title">
<image src="../../static/img/index_name.png" class="box-body-title-img"></image>
4 years ago
<view class="box-body-sub-title">开馆时间{{info.sub_title||""}}</view>
4 years ago
</view>
<view style="margin-top: 56rpx;">
<view class="box-row">
4 years ago
<view class="box-col" @click="handleBook(1)">
4 years ago
<image src="../../static/img/index_icon_1.png" class="box-body-icon"></image>
</view>
4 years ago
<view class="box-col" @click="handleBook(2)">
4 years ago
<image src="../../static/img/index_icon_2.png" class="box-body-icon"></image>
</view>
4 years ago
<view class="box-col" @click="handleBook(3)">
4 years ago
<image src="../../static/img/index_icon_3.png" class="box-body-icon"></image>
4 years ago
</view>
</u-row>
</view>
</view>
</view>
4 years ago
<view class="box-footer"
style="position: fixed;bottom: -60rpx;left: 0;text-align: center;width: 100%;z-index: -1;">
4 years ago
<image src="../../static/img/footer_logo.png" class="footer-img"></image>
</view>
4 years ago
4 years ago
<u-popup :show="showBook" mode="bottom" @close="closeBook" :round="10" closeable>
4 years ago
<view class="mpopup">
<view class="mpopup-title">
参观预约
</view>
<view class="mpopup-content">
<view class="book-box">
<view class="book-box-card">
<view class="book-box-title">
日期
</view>
<view class="book-box-row">
<view class="book-box-row-date">
4 years ago
<block v-for="(item,index) in listDatePrice" :key="index">
<view class="book-box-row-dateitem" :class="{'book-box-row-dateitem-on':item.checked,
4 years ago
'book-box-row-dateitem-none':item.is_open==0,
'book-box-row-dateitem-none':item.remain_count==0}" @click="handleDate(index)">
4 years ago
<view class="book-box-row-dateitem-status">
<u-icon name="checkmark" color="#fff" size="20rpx" v-if="item.checked">
</u-icon>
4 years ago
<view v-else>
<text
v-if="item.is_open==1">{{item.remain_count==0?"售罄":"余票"}}</text>
<text v-else></text>
</view>
4 years ago
</view>
<view>{{item.week}}</view>
<view>{{item.datef}}</view>
4 years ago
</view>
4 years ago
</block>
4 years ago
</view>
4 years ago
<view class="book-box-row-select" @click="openCalendar">
4 years ago
<view>
<view>指定</view>
<view>日期</view>
</view>
<view class="book-box-row-select-more">
<u-icon name="arrow-right" color="#EF9525" size="20rpx"></u-icon>
</view>
</view>
</view>
</view>
<view class="book-box-card">
<view class="book-box-title">
参观时间
</view>
<view class="book-box-timerow">
4 years ago
<view class="book-box-row-timeitem" v-for="(item,index) in currentDate.rules"
4 years ago
:class="{'book-box-row-timeitem-on':item.checked,'timeitem-none':item.remain_count==0}"
:key="index" @click="handleSelectTime(index)">
4 years ago
<view class="book-box-row-timeitem-status" v-if="item.checked">
4 years ago
<u-icon name="checkmark" color="#fff" size="20rpx"></u-icon>
</view>
4 years ago
<view class="book-box-row-timeitem-txt">{{item.start_time+'-'+item.end_time}}</view>
4 years ago
<view class="book-box-row-timeitem-txt" v-if="item.remain_count>0">
{{item.remain_count}}
</view>
<view class="book-box-row-timeitem-txt" v-else></view>
4 years ago
</view>
</view>
</view>
</view>
</view>
<view class="book-box-selectInfo">
4 years ago
<view class="book-box-selectInfo-left">已选{{currentDate.datef||""}}
{{(currentTime.start_time||"")+"-"+(currentTime.end_time||"")}}
</view>
4 years ago
<view class="book-box-selectInfo-right">
</view>
</view>
<view class="mpopup-footer">
<view style="margin-right: 14rpx;flex: 1;">
<u-button type="primary" @click="tobook('team')"></u-button>
</view>
<view style="margin-left: 14rpx;flex: 1;">
<u-button type="primary" @click="tobook('user')"></u-button>
</view>
</view>
</view>
</u-popup>
4 years ago
<u-calendar ref="calendar" :show-confirm="false" :show="showCalendar" :minDate="minDate" :maxDate="maxDate"
color="#EF9525" round="20" defaultDate="2022-02-15" @confirm="handleSelectDate" @close="closecalendar">
</u-calendar>
4 years ago
<u-popup :show="showInfo" mode="center" @close="closeInfo" :round="10" closeable>
4 years ago
<view class="mpopup">
<view class="mpopup-title">
4 years ago
{{currentNotice.name}}
4 years ago
</view>
4 years ago
<view class="mpopup-content" style="padding: 40rpx 20rpx;">
<rich-text :nodes="currentNotice.content"></rich-text>
</view>
</view>
</u-popup>
<u-popup :show="showAuthorization" closeable mode="bottom" @close="closePhone" :round="10">
<view class="box">
<view class="box-title" style="text-align: center;padding: 20rpx 0;font-size: 32rpx;">
请授权您的手机号
</view>
<view class="box-content" style="padding: 20px;">
<u-button type="primary" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
</u-button>
4 years ago
</view>
4 years ago
</view>
</u-popup>
4 years ago
4 years ago
</view>
</template>
<script>
export default {
data() {
4 years ago
const d = new Date()
const year = d.getFullYear()
let month = d.getMonth() + 1
month = month < 10 ? `0${month}` : month
const date = d.getDate()
4 years ago
return {
4 years ago
showInfo: false,
4 years ago
showBook: false,
4 years ago
minDate: `${year}-${month}-${date + 1}`,
maxDate: `${year}-${month}-${date + 7}`,
showCalendar: false,
4 years ago
list: ["暂无通知通告"],
4 years ago
info: {},
listDatePrice: [],
currentDate: {},
4 years ago
currentTime: {},
4 years ago
currentIndex: 0,
4 years ago
listCalendar: [],
listNotice: [],
currentNotice: {},
showAuthorization: false,
openType: 1
4 years ago
}
},
onLoad() {
4 years ago
this.loadInfo();
this.loadNotice();
4 years ago
},
onReady() {
// 如果需要兼容微信小程序的话,需要用此写法
this.$refs.calendar.setFormatter(this.formatter)
4 years ago
},
methods: {
4 years ago
closePhone() {
this.showAuthorization = false
},
getPhoneNumber(e) {
var that = this;
this.util.request({
api: '/api/mobile/user/mobile',
data: {
code: e.detail.code
},
utilSuccess: function(res) {
that.util.getUserInfo(function(r) {
that.checkUser();
}, true)
},
utilFail: function(res) {
}
})
},
4 years ago
closecalendar() {
this.showCalendar = false;
},
handleSelectDate(e) {
4 years ago
let that = this;
4 years ago
if (e.length != 0) {
4 years ago
var date = e[0]
4 years ago
var mod = this.listCalendar.filter((p) => {
return p.is_open == 1 && p.remain_count != 0 && p.date == date;
})
if (mod.length != 0) {
this.load3Day(date, function(isCanbook) {
if (isCanbook) {
that.showCalendar = false;
} else {
that.util.toast("您选择的日期不可预约")
}
});
} else {
that.util.toast("您选择的日期不可预约")
}
4 years ago
}
},
openCalendar() {
var that = this;
var edate = this.$moment().add('days', 7).format("yyyy-MM-DD");
var ndate = this.$moment().add('days', 1).format("yyyy-MM-DD")
this.loadCalendar(ndate, edate, function(res) {
that.listCalendar = res;
that.showCalendar = true;
});
},
formatter(day) {
for (var m of this.listCalendar) {
let date = this.$moment(day.date).format("yyyy-MM-DD");
if (date == m.date) {
if (m.is_open == 1)
4 years ago
if (m.remain_count == 0) {
day.bottomInfo = '售罄'
} else {
day.bottomInfo = '余票'
}
4 years ago
else {
4 years ago
day.bottomInfo = '闭馆'
4 years ago
}
}
}
return day
},
handleDate(index) {
var nt = this.$moment().format("yyyy-MM-DD");
let list = this.listDatePrice;
let cdate = list[index];
4 years ago
4 years ago
if (cdate.is_open === 0) {
4 years ago
uni.showToast({
icon: "none",
title: "该日期已经闭馆"
})
return;
}
if (cdate.remain_count === 0) {
4 years ago
uni.showToast({
icon: "none",
title: "该日期已经售罄"
})
return;
}
4 years ago
4 years ago
for (var m of list) {
m.checked = false;
}
cdate.checked = true;
4 years ago
this.loadDefaultTime(cdate.rules);
4 years ago
this.currentDate = cdate;
this.listDatePrice = list;
this.$forceUpdate();
},
handleSelectTime(index) {
4 years ago
var mod = this.currentDate.rules[index];
if (mod.remain_count == 0) {
this.util.toast("该时段已售罄");
return false
}
4 years ago
for (var m of this.currentDate.rules) {
m.checked = false;
}
4 years ago
mod.checked = true;
this.currentTime = mod;
4 years ago
this.$forceUpdate();
},
4 years ago
openActivity() {
uni.navigateTo({
url: "../activity/index"
})
},
4 years ago
openPark() {
uni.navigateTo({
url: "/pages/park/index"
})
},
4 years ago
openInfo(e) {
this.currentNotice = this.listNotice[e];
4 years ago
this.showInfo = true;
4 years ago
},
closeInfo() {
this.showInfo = false;
},
4 years ago
loadUser(cb) {
var that = this;
this.util.getOpenidInfo(function(res) {
that.util.getUserInfo(function(r) {
cb(r);
}, true)
}, true);
},
handleBook(type) {
this.openType = type;
uni.$u.throttle(this.checkUser, 1500)
},
checkUser() {
let type = this.openType;
var that = this;
that.loadUser(function(res) {
if (that.util.isNull(res.mobile)) {
that.showAuthorization = true;
} else {
that.showAuthorization = false;
if (type == 1) that.openBook();
else if (type == 2) that.openActivity()
else if (type == 3) that.openPark()
}
})
},
4 years ago
openBook() {
4 years ago
var that = this;
4 years ago
this.currentTime = this.currentDate = {};
4 years ago
var sdate = that.$moment().format("yyyy-MM-DD");
that.showBook = true;
that.load3Day(sdate)
4 years ago
},
closeBook() {
this.showBook = false;
},
tobook(type) {
4 years ago
if (this.util.isNull(this.currentDate.date)) {
this.util.toast("请选择预约的日期");
return false;
}
if (this.util.isNull(this.currentTime.id)) {
this.util.toast("请选择预约的时段");
return false;
}
4 years ago
uni.navigateTo({
url: "/pages/visit/book?from=" + type + "&currentDate=" + JSON.stringify(this.currentDate) +
"&currentTime=" + JSON.stringify(this.currentTime)
})
4 years ago
},
loadInfo() {
var that = this;
this.util.request({
api: '/api/mobile/visit/introduce',
utilSuccess: function(res) {
4 years ago
console.log(res);
that.info = res;
},
utilFail: function(res) {
}
})
},
loadNotice() {
var that = this;
this.util.request({
api: '/api/mobile/other/notice-index',
utilSuccess: function(res) {
let arr = [];
for (var m of res.data) {
arr.push(m.name)
}
that.listNotice = res.data;
that.list = arr;
4 years ago
},
utilFail: function(res) {
}
})
},
4 years ago
load3Day(sdate, callbak) { //加载7天数据
4 years ago
var that = this;
that.listDatePrice = [];
var edate = this.$moment(sdate).add('days', 2).format("yyyy-MM-DD");
4 years ago
var ndate = this.$moment(sdate).add('days', 0).format("yyyy-MM-DD")
4 years ago
var nt = this.$moment().format("yyyy-MM-DD");
4 years ago
var mt = this.$moment().add('days', 1).format("yyyy-MM-DD");
var ht = this.$moment().add('days', 2).format("yyyy-MM-DD");
4 years ago
var selectDate = (nt == sdate) ? ndate : sdate;
this.loadCalendar(sdate, edate, function(res) {
that.listDatePrice = res;
var i = 0;
4 years ago
let isOpenDate = false;
4 years ago
for (var m of that.listDatePrice) {
m.checked = false;
m.datef = that.$moment(m.date).format("MM月DD日");
var week = that.$moment(m.date).format("dddd");
if (m.date == nt)
m.week = "今天";
4 years ago
else if (m.date == mt) {
4 years ago
m.week = "明天";
4 years ago
} else if (m.date == ht) {
4 years ago
m.week = "后天";
} else {
m.week = week;
4 years ago
}
if (m.date == selectDate) {
4 years ago
if (m.is_open == 1 && m.remain_count > 0) {
4 years ago
m.checked = true;
that.currentDate = m;
that.currentIndex = i;
that.loadDefaultTime(m.rules);
4 years ago
isOpenDate = true;
4 years ago
} else {
4 years ago
isOpenDate = false;
/* uni.showToast({
4 years ago
icon: "none",
title: selectDate + "不可以预约",
complete() {
setTimeout(function() {
that.load3Day(that.$moment(selectDate).add('days', 1)
.format("yyyy-MM-DD"))
}, 2000)
}
4 years ago
}, 2000) */
4 years ago
}
4 years ago
}
4 years ago
i++;
}
4 years ago
if (callbak)
callbak(isOpenDate);
4 years ago
})
4 years ago
4 years ago
},
4 years ago
loadDefaultTime(rules) {
var that = this;
that.currentTime = {};
let isDefault = false;
for (var mod of rules) {
mod.checked = false;
if (!isDefault && mod.remain_count > 0) {
isDefault = true;
mod.checked = true;
that.currentTime = mod;
}
}
},
4 years ago
loadCalendar(sdate, edate, cb) {
var that = this;
this.util.request({
api: '/api/mobile/visit/get-calendar',
data: {
start_date: sdate,
end_date: edate
},
utilSuccess: function(res) {
cb(res);
},
utilFail: function(res) {
}
})
4 years ago
}
4 years ago
}
}
</script>
<style>
4 years ago
@import url("@/static/css/bookbox.css");
4 years ago
4 years ago
.timeitem-none {
color: #ccc;
}
4 years ago
4 years ago
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.box-row {
4 years ago
display: flex;
4 years ago
justify-content: space-around;
4 years ago
padding: 0rpx 37rpx;
4 years ago
}
.box-top {
width: 100%;
}
.index_bg {
width: 100%;
4 years ago
height: 613rpx;
4 years ago
}
.box-notice {
width: 100%;
background-color: #F9F7F3;
height: 63rpx;
margin-top: -20rpx;
border-top-left-radius: 15rpx !important;
border-top-right-radius: 15rpx !important;
}
4 years ago
.u-notice-bar {
4 years ago
border-top-left-radius: 15rpx !important;
border-top-right-radius: 15rpx !important;
}
.box-body {
width: 100%;
4 years ago
padding: 82rpx 0;
}
.box-body-title {
padding: 0rpx 37rpx;
4 years ago
}
.box-body-title-img {
height: 36rpx;
width: 329rpx;
4 years ago
4 years ago
}
.box-body-sub-title {
4 years ago
font-size: 24rpx;
4 years ago
font-family: PingFang SC;
font-weight: 400;
color: #8A8A8A;
4 years ago
margin-top: 20rpx;
4 years ago
}
.box-body-icon {
width: 217rpx;
4 years ago
height: 230rpx;
4 years ago
}
.footer-img {
width: 421rpx;
height: 364rpx;
4 years ago
}
</style>