| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272 |
- <template>
- <view>
- <lxCalendar @change="changeTime" :dot_lists="list" :value="dateValue"></lxCalendar>
- <view class="hours-box">
- <view class="hours-title">可选时间段</view>
- <view class="hours-content">
- <view v-for="(hour,index) in hourList" :key="index"
- :class="hourListSelceted[index] ? 'selected' : 'default'"
- v-show="hour.enable" @click="selectHour(index,hour.hour)">{{hour.show}}</button>
- </view>
- </view>
- </view>
- <view class="share-box">
- <view class="button">
- <button @click="goSubmit()" class="start" >
- 提交资料
- </button>
- </view>
- </view>
- </view>
- </template>
- <script>
- import md5 from "@/common/md5.js";
- import lxCalendar from '@/components/lx-calendar/lx-calendar.vue'
- export default {
- components:{
- lxCalendar,
- },
- data() {
- return {
- fieldList: [],
- shareUrl:getApp().globalData.shareUrl,
- areaId:'',
- list: [],
- dateValue:'',
- hourList:[],
- hourListSelceted:[],
- selectDate:getApp().globalData.nowTime,
- selectedHour:[],
- };
- },
- onLoad(option) {
- this.areaId = option.id || '4'
- this.getDaysTime(option.id);
- },
- methods: {
- changeTime(e){
- this.selectDate = e.fulldate;
- this.getHoursTime(this.areaId,this.selectDate)
- },
- selectHour(index,param){
- this.hourListSelceted.splice(index,1,!this.hourListSelceted[index])
- },
- goSubmit(){
- if (!this.selectDate){
- uni.showToast({
- title:"请选择日期",
- icon:'none'
- });
- return;
- }
-
- if(!this.hourListSelceted.includes(true)) {
- uni.showToast({
- title:'请选择时间段',
- icon:'none'
- })
- }else {
- let filterArr = []
- this.hourListSelceted.forEach((item,index)=>{
- if(item){
- filterArr.push(this.hourList[index].hour)
- }
- })
- filterArr.join(',')
- uni.navigateTo({
- url: "/pages/makeField/fieldForm?id=" + this.areaId +'&day=' + this.selectDate +'&hour=' + filterArr,
- });
- }
- },
- getDaysTime(id) {
- let md5Sign = md5(
- "method=" +
- "area" +
- "×tamp=" +
- getApp().globalData.globalTimestamp +
- "&secret=" +
- getApp().globalData.secret
- );
- let url =
- getApp().globalData.shareUrl +
- "api/api.php" +
- "?method=area&source=area&action=get_days×tamp=" +
- getApp().globalData.globalTimestamp +
- "&sign=" +
- md5Sign;
- uni.request({
- url: url,
- method: "POST",
- header: {
- "content-type": "application/x-www-form-urlencoded",
- },
- data: {
- area_id :id,
- days:'30'
- },
- success: (res) => {
- if (res.data.code === 200) {
- let dayList = res.data.data;
- if(dayList.length){
- this.dateValue = dayList[0]
- }
- this.list = dayList;
- this.getHoursTime(id,this.selectDate)
- }
- },
- fail: () => {
- console.log("连接失败");
- },
- });
- },
- getHoursTime(id,time) {
- let md5Sign = md5(
- "method=" +
- "area" +
- "×tamp=" +
- getApp().globalData.globalTimestamp +
- "&secret=" +
- getApp().globalData.secret
- );
- let url =
- getApp().globalData.shareUrl +
- "api/api.php" +
- "?method=area&source=area&action=get_hours×tamp=" +
- getApp().globalData.globalTimestamp +
- "&sign=" +
- md5Sign;
- uni.request({
- url: url,
- method: "POST",
- header: {
- "content-type": "application/x-www-form-urlencoded",
- },
- data: {
- area_id :id,
- date :time,
- //order_id : 2 //如果是自己修改自己的预定,传入预定ID,否则可不传
- },
- success: (res) => {
- if (res.data.code === 200) {
- let hourArr = res.data.data;
- let hourCss = [];
- hourArr.forEach((item,index)=>{
- hourCss.push(false)
- })
- this.hourListSelceted = hourCss;
- this.hourList = res.data.data
- }
- },
- fail: () => {
- console.log("连接失败");
- },
- });
- },
- },
- };
- </script>
- <style lang="scss" scope>
- .calendar-box {
- display: flex;
- justify-content: center;
- }
- .hours-box {
- margin-top: 30rpx;
- min-height: 500rpx;
- overflow-x: scroll;
- .hours-title {
- padding-left: 20rpx;
- font-weight: 600;
- font-size: 26rpx;
- }
- .hours-content {
- display: flex;
- flex-wrap: wrap;
- justify-content: space-around;
- align-items: center;
- margin-top: 20rpx;
- view {
- width: 45%;
- height: 80rpx;
- background: #f4f4f4;
- text-align: center;
- line-height: 80rpx;
- margin-bottom: 20rpx;
- border-radius: 10rpx;
- font-size: 24rpx;
- }
- }
- .selected {
- background: #5398ff!important;
- color:#fff;
- }
- .default{
- background: #f4f4f4!important;
- color:#000
- }
- }
- .share-box {
- box-sizing: border-box;
- height: 150rpx;
- width: 100%;
- align-items: center;
- justify-content: space-evenly;
- position: fixed;
- bottom: 0;
- display: flex;
- background: #ffffff;
- .share {
- display: flex;
- justify-content: center;
- align-items: center;
- width: 60rpx;
- height: 60rpx;
- position: relative;
- button::after {
- border: none;
- }
- image {
- width: 100%;
- height: 100%;
- position: absolute;
- }
- .shareCount {
- display: flex;
- justify-content: center;
- align-items: center;
- position: absolute;
- top: -20%;
- right: -25%;
- color: #ffffff;
- height: 30rpx;
- width: 30rpx;
- padding: 3rpx;
- font-size: 16rpx;
- border-radius: 50%;
- background: #fe3637;
- }
- }
- .button {
- height: 100rpx;
- width: 75%;
- display: flex;
- justify-content: center;
- button {
- width: 80%;
- height: 80%;
- border: 1px solid;
- outline: none;
- background: none;
- font-size: 30rpx;
- background-color: transparent;
- border-color: none;
- color: #00a8ea;
- }
- }
- }
- </style>
|