Skip to content

Commit

Permalink
Merge pull request #881 from 18148764734:master
Browse files Browse the repository at this point in the history
feat: 针对抖音小程序virtualHost特别判断
  • Loading branch information
18148764734 authored Apr 18, 2024
2 parents 64bf4eb + b5a3534 commit d0e7e2e
Show file tree
Hide file tree
Showing 24 changed files with 492 additions and 368 deletions.
2 changes: 1 addition & 1 deletion pages/index/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
url: 'data-picker'
},
// #endif
// #ifndef APP-NVUE || MP-KUAISHOU || MP-LARK || MP-TOUTIAO || MP-BAIDU
// #ifndef APP-NVUE || MP-KUAISHOU || MP-LARK || MP-BAIDU
{
name: 'DatetimePicker 日期时间选择',
url: 'datetime-picker'
Expand Down
2 changes: 1 addition & 1 deletion pages/vue/search-bar/search-bar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</uni-card>

<uni-section title="基本用法" type="line">
<uni-search-bar @confirm="search" :focus="true" v-model="searchValue" @blur="blur" @focus="focus" @input="input" class="search-result-text" @cancel="cancel" @clear="clear" text-color="#ff261d">
<uni-search-bar textColor="#3c35f4" @confirm="search" :focus="true" v-model="searchValue" @blur="blur" @focus="focus" @input="input" class="search-result-text" @cancel="cancel" @clear="clear" text-color="#ff261d">
</uni-search-bar>
<view class="search-result">
<text class="search-result-text">当前输入为:{{ searchValue }}</text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@
return {
currentPage: ""
}
},
options: {
virtualHost: true
},
options: {
// #ifdef MP-TOUTIAO
virtualHost: false,
// #endif
// #ifndef MP-TOUTIAO
virtualHost: true
// #endif
},
props: {
to: {
Expand Down Expand Up @@ -113,7 +118,7 @@
&:first-child &--slot {
padding-left: 0;
}
&:last-child &--separator {
display: none;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
*/
export default {
options: {
// #ifdef MP-TOUTIAO
virtualHost: false,
// #endif
// #ifndef MP-TOUTIAO
virtualHost: true
// #endif
},
props: {
separator: {
Expand Down
2 changes: 2 additions & 0 deletions uni_modules/uni-datetime-picker/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## 2.2.33(2024-04-15)
- 修复 抖音小程序事件传递失效bug
## 2.2.32(2024-02-20)
- 修复 日历的close事件触发异常的bug [详情](https://github.com/dcloudio/uni-ui/issues/844)
## 2.2.31(2024-02-20)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@

<view class="uni-calendar__weeks" v-for="(item,weekIndex) in weeks" :key="weekIndex">
<view class="uni-calendar__weeks-item" v-for="(weeks,weeksIndex) in item" :key="weeksIndex">
<calendar-item class="uni-calendar-item--hook" :weeks="weeks" :calendar="calendar"
:selected="selected" :checkHover="range" @change="choiceDate"
@handleMouse="handleMouse">
<calendar-item class="uni-calendar-item--hook" :weeks="weeks" :calendar="calendar" :selected="selected"
:checkHover="range" @change="choiceDate" @handleMouse="handleMouse">
</calendar-item>
</view>
</view>
Expand Down Expand Up @@ -101,13 +100,21 @@
</template>

<script>
import { Calendar, getDate, getTime } from './util.js';
import {
Calendar,
getDate,
getTime
} from './util.js';
import calendarItem from './calendar-item.vue'
import timePicker from './time-picker.vue'
import { initVueI18n } from '@dcloudio/uni-i18n'
import {
initVueI18n
} from '@dcloudio/uni-i18n'
import i18nMessages from './i18n/index.js'
const { t } = initVueI18n(i18nMessages)
const {
t
} = initVueI18n(i18nMessages)
/**
* Calendar 日历
Expand All @@ -134,6 +141,15 @@
calendarItem,
timePicker
},
options: {
// #ifdef MP-TOUTIAO
virtualHost: false,
// #endif
// #ifndef MP-TOUTIAO
virtualHost: true
// #endif
},
props: {
date: {
type: String,
Expand Down Expand Up @@ -163,8 +179,8 @@
type: String,
default: ''
},
startPlaceholder: {
type: String,
startPlaceholder: {
type: String,
default: ''
},
endPlaceholder: {
Expand Down Expand Up @@ -210,10 +226,10 @@
}
}
},
defaultValue: {
type: [String, Object, Array],
default: ''
}
defaultValue: {
type: [String, Object, Array],
default: ''
}
},
data() {
return {
Expand Down Expand Up @@ -260,7 +276,7 @@
},
startDate(val) {
// 字节小程序 watch 早于 created
if(!this.cale){
if (!this.cale) {
return
}
this.cale.setStartDate(val)
Expand All @@ -269,7 +285,7 @@
},
endDate(val) {
// 字节小程序 watch 早于 created
if(!this.cale){
if (!this.cale) {
return
}
this.cale.setEndDate(val)
Expand All @@ -278,7 +294,7 @@
},
selected(newVal) {
// 字节小程序 watch 早于 created
if(!this.cale){
if (!this.cale) {
return
}
this.cale.setSelectInfo(this.nowDate.fullDate, newVal)
Expand Down Expand Up @@ -309,16 +325,16 @@
this.cale.lastHover = false
}
} else {
// 字节小程序 watch 早于 created
if(!this.cale){
return
}
// 字节小程序 watch 早于 created
if (!this.cale) {
return
}
this.cale.setDefaultMultiple(before, after)
if (which === 'left' && before) {
this.setDate(before)
this.weeks = this.cale.weeks
} else if(after) {
} else if (after) {
this.setDate(after)
this.weeks = this.cale.weeks
}
Expand Down Expand Up @@ -423,7 +439,7 @@
},
// 蒙版点击事件
maskClick() {
this.close()
this.close()
this.$emit('maskClose')
},
Expand Down Expand Up @@ -454,36 +470,38 @@
* @param {Object} date
*/
init(date) {
// 字节小程序 watch 早于 created
if(!this.cale){
// 字节小程序 watch 早于 created
if (!this.cale) {
return
}
this.cale.setDate(date || new Date())
this.weeks = this.cale.weeks
this.nowDate = this.cale.getInfo(date)
this.calendar = {...this.nowDate}
if(!date){
// 优化date为空默认不选中今天
this.calendar.fullDate = ''
if(this.defaultValue && !this.range){
// 暂时只支持移动端非范围选择
const defaultDate = new Date(this.defaultValue)
const fullDate = getDate(defaultDate)
const year = defaultDate.getFullYear()
const month = defaultDate.getMonth()+1
const date = defaultDate.getDate()
const day = defaultDate.getDay()
this.calendar = {
fullDate,
year,
month,
date,
day
},
this.tempSingleDate = fullDate
this.time = getTime(defaultDate, this.hideSecond)
}
}
this.calendar = {
...this.nowDate
}
if (!date) {
// 优化date为空默认不选中今天
this.calendar.fullDate = ''
if (this.defaultValue && !this.range) {
// 暂时只支持移动端非范围选择
const defaultDate = new Date(this.defaultValue)
const fullDate = getDate(defaultDate)
const year = defaultDate.getFullYear()
const month = defaultDate.getMonth() + 1
const date = defaultDate.getDate()
const day = defaultDate.getDay()
this.calendar = {
fullDate,
year,
month,
date,
day
},
this.tempSingleDate = fullDate
this.time = getTime(defaultDate, this.hideSecond)
}
}
},
/**
* 打开日历弹窗
Expand Down Expand Up @@ -545,13 +563,13 @@
* @param {Object} name
*/
setEmit(name) {
if(!this.range){
if(!this.calendar.fullDate){
this.calendar = this.cale.getInfo(new Date())
this.tempSingleDate = this.calendar.fullDate
if (!this.range) {
if (!this.calendar.fullDate) {
this.calendar = this.cale.getInfo(new Date())
this.tempSingleDate = this.calendar.fullDate
}
if(this.hasTime && !this.time) {
this.time = getTime(new Date(), this.hideSecond)
if (this.hasTime && !this.time) {
this.time = getTime(new Date(), this.hideSecond)
}
}
let {
Expand Down Expand Up @@ -595,17 +613,17 @@
}
this.change()
},
changeMonth(type) {
let newDate
if(type === 'pre') {
newDate = this.cale.getPreMonthObj(this.nowDate.fullDate).fullDate
} else if(type === 'next') {
newDate = this.cale.getNextMonthObj(this.nowDate.fullDate).fullDate
}
changeMonth(type) {
let newDate
if (type === 'pre') {
newDate = this.cale.getPreMonthObj(this.nowDate.fullDate).fullDate
} else if (type === 'next') {
newDate = this.cale.getNextMonthObj(this.nowDate.fullDate).fullDate
}
this.setDate(newDate)
this.setDate(newDate)
this.monthSwitch()
},
},
/**
* 设置日期
* @param {Object} date
Expand All @@ -619,7 +637,7 @@
}
</script>

<style lang="scss" >
<style lang="scss">
$uni-primary: #007aff !default;
.uni-calendar {
Expand Down Expand Up @@ -855,17 +873,17 @@
.uni-date-changed--time-end {
/* #ifndef APP-NVUE */
display: flex;
display: flex;
/* #endif */
align-items: center;
}
.uni-date-changed--time-date {
color: #999;
color: #999;
line-height: 50px;
/* #ifdef MP-TOUTIAO */
font-size: 16px;
/* #endif */
/* #ifdef MP-TOUTIAO */
font-size: 16px;
/* #endif */
margin-right: 5px;
// opacity: 0.6;
}
Expand Down Expand Up @@ -924,5 +942,6 @@
.uni-datetime-picker--btn:active {
opacity: 0.7;
}
/* #endif */
</style>
</style>
Loading

0 comments on commit d0e7e2e

Please sign in to comment.