Commit 572d5f36 authored by 沈翠玲's avatar 沈翠玲

修改uni-datetime-picker在PC端的显示

parent 29cbe3f5
...@@ -35,10 +35,10 @@ export default { ...@@ -35,10 +35,10 @@ export default {
max-height: 120px !important; max-height: 120px !important;
} }
/deep/ .times .uni-date-picker__container { .uni-date-picker__container {
height: 400px !important; height: 400px !important;
z-index: 10000 !important; z-index: 50000 !important;
position: fixed !important; position: absolute !important;
} }
/deep/ .uni-pagination__num-tag { /deep/ .uni-pagination__num-tag {
......
...@@ -25,3 +25,7 @@ ...@@ -25,3 +25,7 @@
.uni-page-body { .uni-page-body {
font-size: 14px; font-size: 14px;
} }
body {
position: relative;
}
\ No newline at end of file
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
<text class="uni-calendar__box-bg-text">{{nowDate.month}}</text> <text class="uni-calendar__box-bg-text">{{nowDate.month}}</text>
</view> </view>
<view class="uni-calendar__weeks" style="padding-bottom: 7px;"> <view class="uni-calendar__weeks">
<view class="uni-calendar__weeks-day"> <view class="uni-calendar__weeks-day">
<text class="uni-calendar__weeks-day-text">{{SUNText}}</text> <text class="uni-calendar__weeks-day-text">{{SUNText}}</text>
</view> </view>
...@@ -685,7 +685,7 @@ ...@@ -685,7 +685,7 @@
flex-direction: row; flex-direction: row;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
height: 50px; height: 30px;
} }
.uni-calendar__header-mobile { .uni-calendar__header-mobile {
...@@ -791,7 +791,7 @@ ...@@ -791,7 +791,7 @@
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
height: 40px; height: 25px;
border-bottom-color: #F5F5F5; border-bottom-color: #F5F5F5;
border-bottom-style: solid; border-bottom-style: solid;
border-bottom-width: 1px; border-bottom-width: 1px;
......
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
<view v-show="pickerVisible" class="uni-date-mask--pc" @click="close"></view> <view v-show="pickerVisible" class="uni-date-mask--pc" @click="close"></view>
<view v-if="!isPhone" v-show="pickerVisible" ref="datePicker" class="uni-date-picker__container"> <view v-if="!isPhone" v-show="pickerVisible" ref="datePicker" class="uni-date-picker__container" :style="pickerPositionStyle">
<view v-if="!isRange" class="uni-date-single--x" :style="pickerPositionStyle"> <view v-if="!isRange" class="uni-date-single--x">
<view class="uni-popper__arrow"></view> <view class="uni-popper__arrow"></view>
<view v-if="hasTime" class="uni-date-changed popup-x-header"> <view v-if="hasTime" class="uni-date-changed popup-x-header">
...@@ -335,6 +335,9 @@ ...@@ -335,6 +335,9 @@
// todo // todo
return this.isRange ? 653 : 301 return this.isRange ? 653 : 301
}, },
datePopupHight(){
return 403
},
/** /**
* for i18n * for i18n
...@@ -384,6 +387,11 @@ ...@@ -384,6 +387,11 @@
this.initI18nT() this.initI18nT()
this.platform() this.platform()
}, },
beforeDestroy() {
if(!this.isPhone) {
document.body.removeChild(this.$refs.datePicker.$el);
}
},
methods: { methods: {
initI18nT() { initI18nT() {
const vueI18n = initVueI18n(i18nMessages) const vueI18n = initVueI18n(i18nMessages)
...@@ -459,10 +467,12 @@ ...@@ -459,10 +467,12 @@
return return
} }
const { const {
windowWidth windowWidth,
windowHeight
} = uni.getSystemInfoSync() } = uni.getSystemInfoSync()
this.isPhone = windowWidth <= 1200 this.isPhone = windowWidth <= 1200
this.windowWidth = windowWidth this.windowWidth = windowWidth
this.windowHeight = windowHeight
}, },
show() { show() {
this.$emit("show") this.$emit("show")
...@@ -479,11 +489,24 @@ ...@@ -479,11 +489,24 @@
this.pickerPositionStyle = { this.pickerPositionStyle = {
top: '10px' top: '10px'
} }
const {
windowHeight
} = uni.getSystemInfoSync()
const dateEditor = uni.createSelectorQuery().in(this).select(".uni-date-editor") const dateEditor = uni.createSelectorQuery().in(this).select(".uni-date-editor")
dateEditor.boundingClientRect(rect => { dateEditor.boundingClientRect(rect => {
if (this.windowWidth - rect.left < this.datePopupWidth) { if (this.windowWidth - rect.left < this.datePopupWidth) {
this.pickerPositionStyle.right = 0 this.pickerPositionStyle.right = 0
} }
let top = rect.top
this.pickerPositionStyle.left = rect.left + 'px'
if (windowHeight - rect.top < this.datePopupHight) {
// delete this.pickerPositionStyle.top
top = (windowHeight - rect.top)
}
if (top + this.datePopupHight > windowHeight) {
top = top - ((top + this.datePopupHight) - windowHeight)
}
this.pickerPositionStyle.top = top + 'px'
}).exec() }).exec()
setTimeout(() => { setTimeout(() => {
this.pickerVisible = !this.pickerVisible this.pickerVisible = !this.pickerVisible
...@@ -504,7 +527,9 @@ ...@@ -504,7 +527,9 @@
} }
} }
} }
if(!this.isPhone && this.isFirstShow) {
document.body.appendChild(this.$refs.datePicker.$el);
}
}, 50) }, 50)
}, },
close() { close() {
...@@ -893,9 +918,9 @@ ...@@ -893,9 +918,9 @@
} }
.uni-date__input { .uni-date__input {
height: 40px; height: 30px;
width: 100%; width: 100%;
line-height: 40px; line-height: 30px;
font-size: 14px; font-size: 14px;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment