Browse Source

日历组件

master
Enzo 4 years ago
parent
commit
21430867a4
  1. 4
      common/api.js
  2. 115
      pages/goodsDetail/index.vue
  3. 248
      pages/order/confirm_order.vue
  4. 25
      uview-ui/components/u-calendar/u-calendar.vue

4
common/api.js

@ -1,7 +1,7 @@
// appId: 正式 null | 测试 wxeb58570b5e04d147 // appId: 正式 null | 测试 wxeb58570b5e04d147
export const DEV = "prod"; // dev 测试 | prod 正式
export const DEV = "dev"; // dev 测试 | prod 正式
export const VERSION = '1.0.0'; // 版本号 export const VERSION = '1.0.0'; // 版本号
export const DEVURL = 'https://hainan.lanzulive.com'; // 测试服请求地址
export const DEVURL = 'https://yytx.eugyl.com'; // 测试服请求地址
// export const DEVURL = 'http://hainan.com'; // 测试服请求地址 // export const DEVURL = 'http://hainan.com'; // 测试服请求地址
export const PRODURL = 'https://yytx.eugyl.com'; // 正式服请求地址 export const PRODURL = 'https://yytx.eugyl.com'; // 正式服请求地址

115
pages/goodsDetail/index.vue

@ -74,7 +74,8 @@
</view> </view>
</view> </view>
<!-- 景区类型弹窗 --> <!-- 景区类型弹窗 -->
<u-popup v-model="scenic_spot" mode="bottom" :closeable="true" border-radius="20">
<u-calendar v-model="show" mode="date" zIndex="100000" :monthPrice="goods_detail.spec[type_index].list" :min-date='goods_detail.spec[type_index].date_start' :max-date="goods_detail.spec[type_index].date_end" @change="change" z-index="9999"></u-calendar>
<u-popup class="pop-self" v-model="scenic_spot" mode="bottom" :closeable="true" border-radius="20">
<view class="lf-p-32"> <view class="lf-p-32">
<view class="price lf-flex"> <view class="price lf-flex">
<lf-price :price="choose_date_price || goods_detail.spec[type_index].price"></lf-price> <lf-price :price="choose_date_price || goods_detail.spec[type_index].price"></lf-price>
@ -93,13 +94,13 @@
<text class="lf-font-32 lf-font-bold" style="color: #131315;">使用时间</text> <text class="lf-font-32 lf-font-bold" style="color: #131315;">使用时间</text>
<view class="lf-row-between list-item lf-m-t-20" style="padding: 0!important;"> <view class="lf-row-between list-item lf-m-t-20" style="padding: 0!important;">
<view class="lf-row-center"> <view class="lf-row-center">
<text class="lf-font-28 lf-color-gray">使用时间</text>
<text class="lf-font-28 lf-color-gray" @click="show = true">使用时间</text>
</view> </view>
<view class="lf-flex"> <view class="lf-flex">
<picker mode="date" :end="goods_detail.spec[type_index].date_end" :start="goods_detail.spec[type_index].date_start" :value="go_date" @change="goChange">
<!-- <view class="lf-color-555 lf-text-right" style="width: 400rpx;">{{ '请选择收货时间...' }}</view> -->
<!-- <picker mode="date" :end="goods_detail.spec[type_index].date_end" :start="goods_detail.spec[type_index].date_start" :value="go_date" @change="goChange">
<view class="lf-color-333 lf-text-right lf-font-28" style="width: 400rpx;">{{ go_date }}</view> <view class="lf-color-333 lf-text-right lf-font-28" style="width: 400rpx;">{{ go_date }}</view>
</picker>
</picker> -->
<text @click="show = true">{{go_date}}</text>
<text class="lf-iconfont lf-icon-xiangyou lf-text-vertical lf-m-l-10"></text> <text class="lf-iconfont lf-icon-xiangyou lf-text-vertical lf-m-l-10"></text>
</view> </view>
</view> </view>
@ -151,21 +152,6 @@
<view class="lf-iconfont lf-icon-dizhi lf-color-blue"></view> <view class="lf-iconfont lf-icon-dizhi lf-color-blue"></view>
</view> </view>
</view> </view>
<view v-for="(item,index) of goods_detail.spec" :key="index">
<self-line></self-line>
<view class="calendar-box lf-bg-white lf-p-b-20">
<view class="month lf-p-l-10 lf-p-r-10">
<view>{{item.name}}</view>
</view>
<view class="day">
<view style="border: 1px solid #0081FF;margin-bottom: 20rpx;border-radius: 10rpx;" :class="days.date==nowTime?'sign':''" v-for="(days,index2) in item.list" :key="index2">
<text class="lf-font-24">09-26</text>
<text class="lf-m-t-10 lf-font-24 lf-color-price">{{days.price}}</text>
<text class="lf-m-t-10 lf-font-24">{{days.stock}}</text>
</view>
</view>
</view>
</view>
<!-- <zwyCalendar class="lf-m-t-20" type="sign" :startTime="'2021-10-01'" :endTime="'2021-11-01'"/> --> <!-- <zwyCalendar class="lf-m-t-20" type="sign" :startTime="'2021-10-01'" :endTime="'2021-11-01'"/> -->
<view class="goods-detail" style="padding-bottom: 0;"> <view class="goods-detail" style="padding-bottom: 0;">
<view class="lf-font-32 lf-font-bold lf-m-b-20">酒店设施</view> <view class="lf-font-32 lf-font-bold lf-m-b-20">酒店设施</view>
@ -469,7 +455,9 @@
total_hotel_orginalprice: 0, total_hotel_orginalprice: 0,
live_index: 0, live_index: 0,
leave_index: 0, leave_index: 0,
hotel_specid: []
hotel_specid: [],
//uview picker
show: false,
} }
}, },
components: {zwyCalendar}, components: {zwyCalendar},
@ -487,6 +475,10 @@
} }
}, },
methods: { methods: {
change(e) {
console.log(e);
this.go_date = e.result
},
compareDate(val) { compareDate(val) {
var nowTime = new Date(new Date().toLocaleDateString()).getTime(); var nowTime = new Date(new Date().toLocaleDateString()).getTime();
let oldTime = new Date(new Date(val).toLocaleDateString()).getTime(); let oldTime = new Date(new Date(val).toLocaleDateString()).getTime();
@ -929,85 +921,8 @@
} }
</style> </style>
<style lang="scss" scoped="scoped"> <style lang="scss" scoped="scoped">
.calendar-box {
width: 100%;
flex-direction: column;
justify-content: center;
}
.calendar-box,
.month,
.week,
.day {
display: flex;
align-items: center;
justify-content: space-between;
}
.month,
.week,
.day {
width: 700rpx;
}
.month {
margin: 30rpx 0;
position: relative;
}
.picker {
width: 160rpx;
height: 40rpx;
position: absolute;
top: 20rpx;
left: 50%;
transform: translate(-50%, -50%);
}
.day {
flex-wrap: wrap;
}
.week>view,
.day>view {
width: 120rpx;
height: 120rpx;
text-align: center;
position: relative;
display: flex;
flex-direction: column;
font-size: 18rpx;
align-items: center;
justify-content: center;
}
.checkday {
color: #999;
margin-top: 10rpx;
}
.choose {
color: #777;
border-radius: 50%;
background-color: #c3e4ff;
}
.circle {
width: 10rpx;
height: 10rpx;
border-radius: 50%;
position: absolute;
bottom: 10%;
left: 50%;
transform: translate(-50%, -50%);
}
.sign {
background-color: #0089fe;
}
.repair {
background-color: #1998FE;
/deep/.pop-self .u-drawer .u-mask{
z-index: 99!important;
} }
.choose_btn { .choose_btn {
width: 686rpx; width: 686rpx;

248
pages/order/confirm_order.vue

@ -26,6 +26,59 @@
<text class="lf-color-555 lf-font-28">年龄</text> <text class="lf-color-555 lf-font-28">年龄</text>
<input type="number" v-model="age" disabled class="lf-color-999 lf-font-28 lf-text-left" style="position:absolute;right:180rpx" placeholder="请输入年龄"/> <input type="number" v-model="age" disabled class="lf-color-999 lf-font-28 lf-text-left" style="position:absolute;right:180rpx" placeholder="请输入年龄"/>
</view> </view>
<view class="padding-lr lf-m-b-40 lf-m-t-30">
<text class="lf-color-555 lf-font-28">是否携带小孩(单选)</text>
<view class="lf-m-t-20">
<u-radio-group v-model="value" @change="radioGroupChange">
<u-radio
@change="radioChange"
v-for="(item, index) in radion_list" :key="index"
:name="item.name"
:disabled="item.disabled"
>
{{item.name}}
</u-radio>
</u-radio-group>
</view>
</view>
<view class="padding-lr lf-m-b-40">
<text class="lf-color-555 lf-font-28">添加人选(多选)</text>
<view class="lf-m-t-20">
<u-checkbox-group @change="checkboxGroupChange">
<u-checkbox
@change="checkboxChange"
v-model="item.checked"
shape="circle"
v-for="(item, index) in check_list" :key="index"
:name="item.name"
>{{item.name}}</u-checkbox>
</u-checkbox-group>
</view>
</view>
<view class="padding-lr lf-m-b-40">
<text class="lf-color-555 lf-font-28">多行文本(不超过300字)</text>
<view class="lf-m-t-20">
<view class="cu-self menu" style="margin-top: 30rpx; position: relative;">
<textarea :cursor-spacing="120" maxlength="300" :adjust-position="true" type="text" v-model="applyInfo" style="background-color: #F8F8F8;border-radius: 20rpx;" class="text-left lf-font-28 area-self lf-w-100 lf-p-20" placeholder="请输入内容" />
</view>
</view>
</view>
<view class="lf-flex-column lf-p-b-30 padding-lr">
<text class="lf-color-555 lf-font-28 lf-m-b-20">添加图片(最多三张)</text>
<view class="grid col-3 grid-square flex-sub">
<view style="width: 212rpx;height: 212rpx;border-radius: 10rpx;" class="bg-img" v-for="(item,index) in img_list" :key="index" @tap="showImg(index)" :data-url="img_list[index]">
<image :src="img_list[index]" mode="aspectFill"></image>
<view class="cu-tag bg-red" @tap.stop="DelImg(index)" :data-index="index">
<!-- <text class='cuIcon-close'></text> -->
<text class="lf-iconfont lf-icon-cuowu lf-font-40 lf-color-price"></text>
</view>
</view>
<view style="width: 212rpx;height: 212rpx;border-radius: 10rpx;" class="solids" @tap="ChooseImage" v-if="img_list.length<3">
<text class='cuIcon-cameraadd'></text>
</view>
</view>
</view>
</view> </view>
<self-line/> <self-line/>
<view class="lf-bg-white lf-p-t-30 lf-p-b-30 lf-p-l-32 lf-p-r-32"> <view class="lf-bg-white lf-p-t-30 lf-p-b-30 lf-p-l-32 lf-p-r-32">
@ -181,7 +234,43 @@
check_out_time: '', check_out_time: '',
arrival_time: '', arrival_time: '',
totalLive: '', totalLive: '',
hotel_specid: []
hotel_specid: [],
//
radion_list: [
{
name: '是',
disabled: false
},
{
name: '否',
disabled: false
}
],
// u-radio-groupv-modelradioname
value: 'orange',
//
check_list: [
{
name: 'apple',
checked: false,
disabled: false
},
{
name: 'banner',
checked: false,
disabled: false
},
{
name: 'orange',
checked: false,
disabled: false
}
],
//
applyInfo: '',
//
hostImg: '',
img_list: [], //
} }
}, },
onLoad(e) { onLoad(e) {
@ -230,6 +319,156 @@
uni.$off('payState'); uni.$off('payState');
}, },
methods: { methods: {
checkImgInfo(tempFilePath, suc){
uni.getImageInfo({
src: tempFilePath,
success (res) {
let type = res.type;
console.log('checkImgInfo...', type);
if(type == 'png' || type == 'jpeg' || type == 'jpg'){
suc && suc(true);
} else {
suc && suc(false);
}
},
fail(err) {
suc && suc(false);
}
})
},
//
ChooseImage(e) {
let that = this;
uni.chooseImage({
count: 1,
sizeType: ['original'], // originalcompressed
sourceType: ['album', 'camera'], // album camera 使
success: res => {
that.hostImg = res.tempFilePaths[0];
let tempFile = res.tempFiles.shift();
let tempFilePath = res.tempFilePaths.shift();
console.log('临时路径',res)
that.checkImgInfo(tempFilePath, (res) => {
// pngjpeg
if(res){
if(tempFile.size > 10000000){
uni.showModal({
title: '',
content: '您选择的图片过大:'+ (tempFile.size / 1024000).toFixed(2) +"M,请点击确定重新上传",
success: res2 => {
if(res2.confirm){
uni.chooseImage({
count: 1,
sizeType: ['compressed'],
sourceType: ['album', 'camera'],
success: (res3) => {
let tempFilePath = res3.tempFilePaths.shift();
that.is_wx_reduce = true;
that.img_list.push(tempFilePath);
}
})
}
}
})
} else{
that.img_list.push(tempFilePath);
console.log('图片数组',that.img_list)
}
} else {
uni.showModal({
title: '',
content: '选择的图片须为jpg、jpeg或png格式',
showCancel: false,
confirmColor: '#1697EE'
})
}
});
}
});
},
//
upload(url){
let that = this;
let uploads = [];
// banner
if (that.img_list.length > 0) {
for (let i = 0; i < that.img_list.length; i++) {
let upload_img = new Promise((resolve, reject) => {
that.uploadFile(that.img_list[i], (res) => {
resolve(res);
}, (err) => {
reject(err);
});
})
uploads.push(upload_img);
}
}
if(uploads.length == 0) {
that.realSubmitInfo([]);
return
}
Promise.all(uploads).then((result) => {
let img_url_list = [];
if(result.length > 0){
img_url_list = result;
}
if(img_url_list) {
that.realSubmitInfo(img_url_list);
}
}).catch(err => {
that.is_publish = false; //
uni.showModal({
title: '',
content: '图片上传失败,请重新提交',
confirmColor: '#1697EE'
})
})
},
//
showImg(index) {
this.$u.throttle(() => {
let goods_banner = this.img_list || [];
let banners = goods_banner.map(item => item);
uni.previewImage({
urls: banners,
current: index
})
}, 200);
},
//
DelImg(index) {
uni.showModal({
title: '提示',
content: '即将取消上传这张图片,请确认?',
success: e => {
if (!e.confirm) return;
this.img_list.splice(index, 1);
}
});
},
dynamicLength(){
return parseInt(this.applyInfo.length);
},
//
checkboxGroupChange(e) {
console.log(e);
},
// checkbox
checkboxChange(e) {
//console.log(e);
},
//
radioChange(e) {
// console.log(e);
},
// radioradio-group
radioGroupChange(e) {
console.log(e);
},
computedAge() { computedAge() {
this.$check(this.vertify_code,'card'); this.$check(this.vertify_code,'card');
let judge_sex = this.vertify_code[16]; let judge_sex = this.vertify_code[16];
@ -406,4 +645,11 @@
-webkit-line-clamp: 2; -webkit-line-clamp: 2;
-webkit-box-orient: vertical; -webkit-box-orient: vertical;
} }
.font-change{
position: absolute;
right: 10rpx;
bottom: 10rpx;
width: max-content;
color: #777777;
}
</style> </style>

25
uview-ui/components/u-calendar/u-calendar.vue

@ -38,10 +38,13 @@
}" :style="{backgroundColor: getColor(index,1)}" v-for="(item, index) in daysArr" :key="index" }" :style="{backgroundColor: getColor(index,1)}" v-for="(item, index) in daysArr" :key="index"
@tap="dateClick(index)"> @tap="dateClick(index)">
<view class="u-calendar__content__item__inner" :style="{color: getColor(index,2)}"> <view class="u-calendar__content__item__inner" :style="{color: getColor(index,2)}">
<view>{{ index + 1 }}</view>
<view class="lf-flex-column" style="justify-content: center;align-items: center;">
<text>{{ index + 1 }}</text>
<text class="lf-font-24" v-if="!openDisAbled(year,month,index+1)">788</text>
</view>
</view> </view>
<view class="u-calendar__content__item__tips" :style="{color:activeColor}" v-if="mode== 'range' && startDate==`${year}-${month}-${index+1}` && startDate!=endDate">{{startText}}</view>
<view class="u-calendar__content__item__tips" :style="{color:activeColor}" v-if="mode== 'range' && endDate==`${year}-${month}-${index+1}`">{{endText}}</view>
<!-- <view class="u-calendar__content__item__tips" :style="{color:activeColor}" v-if="mode== 'range' && startDate==`${year}-${month}-${index+1}` && startDate!=endDate">{{startText}}</view>
<view class="u-calendar__content__item__tips" :style="{color:activeColor}" v-if="mode== 'range' && endDate==`${year}-${month}-${index+1}`">{{endText}}</view> -->
</view> </view>
<view class="u-calendar__content__bg-month">{{month}}</view> <view class="u-calendar__content__bg-month">{{month}}</view>
</view> </view>
@ -224,7 +227,12 @@
toolTip: { toolTip: {
type: String, type: String,
default: '选择日期' default: '选择日期'
}
},
//
monthPrice: {
type: Array,
default: []
},
}, },
data() { data() {
return { return {
@ -251,7 +259,8 @@
isStart: true, isStart: true,
min: null, min: null,
max: null, max: null,
weekDayZh: ['日', '一', '二', '三', '四', '五', '六']
weekDayZh: ['日', '一', '二', '三', '四', '五', '六'],
today_index: 0,
}; };
}, },
computed: { computed: {
@ -270,6 +279,8 @@
}, },
created() { created() {
this.init() this.init()
console.log('当前规格的价格',this.monthPrice)
console.log('当前aaaa的天数',this.daysArr)
}, },
methods: { methods: {
getColor(index, type) { getColor(index, type) {
@ -382,7 +393,8 @@
}, },
changeData() { changeData() {
this.days = this.getMonthDay(this.year, this.month); this.days = this.getMonthDay(this.year, this.month);
this.daysArr=this.generateArray(1,this.days)
this.daysArr=this.generateArray(1,this.days);
console.log('当前天数',this.daysArr)
this.weekday = this.getWeekday(this.year, this.month); this.weekday = this.getWeekday(this.year, this.month);
this.weekdayArr=this.generateArray(1,this.weekday) this.weekdayArr=this.generateArray(1,this.weekday)
this.showTitle = `${this.year}${this.month}`; this.showTitle = `${this.year}${this.month}`;
@ -391,6 +403,7 @@
} }
}, },
dateClick: function(day) { dateClick: function(day) {
this.today_index = day;
day += 1; day += 1;
if (!this.openDisAbled(this.year, this.month, day)) { if (!this.openDisAbled(this.year, this.month, day)) {
this.day = day; this.day = day;

Loading…
Cancel
Save