已修改14个文件
已重命名1个文件
已添加28个文件
| | |
| | | <script>
|
| | | import Vue from 'vue' |
| | |
|
| | | export default {
|
| | | globalData: {
|
| | | token: ""
|
| | | },
|
| | | onLaunch: function() {
|
| | | |
| | |
|
| | |
|
| | | //æ¤å¤ä¸ºunipush2.0çæ¨éæ¹æ³
|
| | | // uni-app客æ·ç«¯è·åpush客æ·ç«¯æ è®°
|
| | | // uni.getPushClientId({
|
| | | // success: (res) => {
|
| | | // let push_clientid = res.cid
|
| | | // console.log('客æ·ç«¯æ¨éæ è¯:', push_clientid)
|
| | | // },
|
| | | // fail(err) {
|
| | | // console.log(err)
|
| | | // }
|
| | | // })
|
| | | // uni.onPushMessage((res) => {
|
| | | // console.log("æ¶å°æ¨éæ¶æ¯ï¼", res) //ç嬿¨éæ¶æ¯
|
| | | // })
|
| | |
|
| | |
|
| | | //æ¨éä»
æ¯æAndroid iosåçå¹³å°
|
| | | // #ifdef APP-PLUS
|
| | | console.log('APP-PLUS:')
|
| | | // æ¤å¤ä¸ºunipush1.0çæ¨éæ¹æ³
|
| | | plus.push.getClientInfoAsync((info) => {
|
| | | let cid = info["clientid"];
|
| | | console.log('客æ·ç«¯æ¨éæ è¯:', cid)
|
| | | this.$store.dispatch('setCid', cid); // ä½¿ç¨ action æ´æ° cid
|
| | | });
|
| | | // #endif
|
| | | uni.onPushMessage((res) => {
|
| | | console.log("æ¶å°æ¨éæ¶æ¯ï¼", res) //ç嬿¨éæ¶æ¯
|
| | | })
|
| | |
|
| | |
|
| | |
|
| | | uni.getSystemInfo({
|
| | | success: function(e) {
|
| | | // #ifndef MP
|
| | |
| | | <view class="content" :style="[{top:StatusBar + 'px'}]"> |
| | | <slot name="content"></slot> |
| | | </view> |
| | | <slot name="right"></slot> |
| | | <!-- <slot name="right"></slot> -->
|
| | | <view class="right" @tap="HandleRight" v-if="isRight">
|
| | | <text class="cuIcon-discover"></text>
|
| | | <slot name="rihjtText"></slot>
|
| | | </view> |
| | | </view> |
| | | </view> |
| | | </view> |
| | |
| | | type: [Boolean, String], |
| | | default: false |
| | | }, |
| | | isRight: {
|
| | | type: [Boolean, String],
|
| | | default: false
|
| | | }, |
| | | bgImage: { |
| | | type: String, |
| | | default: '' |
| | |
| | | uni.navigateBack({ |
| | | delta: 1 |
| | | }); |
| | | },
|
| | | HandleRight(){
|
| | | this.$emit('rightclick'); // 触åèªå®ä¹äºä»¶
|
| | | } |
| | | } |
| | | } |
| | |
| | | justify-content: center; |
| | | max-width: 100%; |
| | | } |
| | | .cu-bar .right { |
| | | position: absolute;
|
| | | right: 30upx;
|
| | | font-size: 36upx; |
| | | } |
| | | |
| | | .cu-bar .action.border-title { |
| | | position: relative; |
| | |
| | | const DEVICE_ID = "device_id"
|
| | |
|
| | |
|
| | | /***********************æå¡ç«¯å¹¿æ********************************/
|
| | | //广æä¸å¨ä¹å®¢æ·ç«¯idï¼åææå¨çº¿å®¢æ·ç«¯åé
|
| | | //广æåç¼
|
| | | const SERVICE_BROADCAST = "service/broadcast" |
| | | // //æå¡ç«¯ååç§æ·å®¢æ·ç«¯åé宿¶æ
é广æ
|
| | | const SERVICE_BROADCAST_TENANT_REAL_FAULT = SERVICE_BROADCAST + "/real/fault/%s"
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | /***********************EventBus function********************************/
|
| | |
|
| | | const MQTT_TOPIC_MESSAGE = "mqtt_topic_message"
|
| | |
|
| | |
|
| | |
|
| | | export default {
|
| | | MOBILE_QUERY_EQU_STATU, |
| | | SERVICE_RES_EQU_STATU, |
| | |
| | | MOBILE_REQ_EQU_CMD, |
| | | SERVICE_RES_EQU_CMD,
|
| | |
|
| | | SERVICE_BROADCAST_TENANT_REAL_FAULT,
|
| | |
|
| | | MQTT_TOPIC_MESSAGE,
|
| | |
|
| | | DEVICE_ID
|
| | | } |
| | |
| | | import get from 'lodash.get'
|
| | |
|
| | | export default function lget(data, item) { |
| | | if(!data || data == null) return "--";
|
| | | if(data & (!item || item == null)) return data; |
| | | let res = get(data, item) |
| | | return res == null ? "--" :res
|
| | |
|
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template>
|
| | | <view>
|
| | | <picker :title="index" @change="bindTimeChange" @columnchange="columnchange" mode="multiSelector" :disabled="disabled" :class="{disabled:disabled}"
|
| | | :value="index" :range="array">
|
| | | <view :style="{'line-height':inputHeight+'rpx','font-size':inputFont+'rpx'}" v-if="showTime">{{showTime}}
|
| | | </view>
|
| | | <view v-else class="placeholder" :style="{'line-height':inputHeight+'rpx','font-size':inputFont+'rpx'}">{{placeholder}}</view>
|
| | | </picker>
|
| | | </view>
|
| | | <!-- åªè¯» -->
|
| | | </template>
|
| | |
|
| | | <script>
|
| | | export default {
|
| | | name: 'dy-Date-Picker',
|
| | | props: {
|
| | | timeType: {
|
| | | type: String,
|
| | | default: () => 'day'
|
| | | },
|
| | | // è¾å
¥æ¡é«åº¦/è¡é«
|
| | | inputHeight:{
|
| | | type: Number,
|
| | | default:56
|
| | | },
|
| | | // è¾å
¥æ¡é«åº¦/æç¤ºè¯åä½å¤§å°
|
| | | inputFont:{
|
| | | type: Number,
|
| | | default:24
|
| | | },
|
| | | disabled: {
|
| | | type: Boolean,
|
| | | default: () => false
|
| | | },
|
| | | // æ¯å¦æ¾ç¤ºå¾æ
|
| | | iconshow: {
|
| | | type: Boolean,
|
| | | default: () => true
|
| | | },
|
| | | placeholder: {
|
| | | type: String,
|
| | | default () {
|
| | | return 'è¯·éæ©'
|
| | | }
|
| | | },
|
| | | childValue: {
|
| | | default () {
|
| | | return ''
|
| | | }
|
| | | },
|
| | | minSelect: {
|
| | | type: String,
|
| | | default: () => '1900/01/01'
|
| | | },
|
| | | maxSelect: {
|
| | | type: String,
|
| | | default: () => '2050/12/31'
|
| | | }
|
| | | },
|
| | | data() {
|
| | | return {
|
| | | index: [0],
|
| | | array: [],
|
| | | yearArr: [], // 年份æ°ç»
|
| | | monthArr: [], // æä»½æ°ç»
|
| | | yearIndex: 0, // 年份éä¸ä¸æ
|
| | | showTime: this.moment(this.childValue)
|
| | | }
|
| | | },
|
| | |
|
| | | methods: {
|
| | | clear(){
|
| | | this.showTime = ''
|
| | | this.$emit('getData', '')
|
| | | },
|
| | | moment(strTime) {
|
| | | let type = this.timeType
|
| | | if (!strTime) {
|
| | | return
|
| | | }
|
| | | let time = new Date(strTime)
|
| | | let y = time.getFullYear()
|
| | | let m = time.getMonth() + 1
|
| | | m = m < 10 ? `0${m}` : m
|
| | | let d = time.getDate()
|
| | | d = d < 10 ? `0${d}` : d
|
| | | let hh = time.getHours()
|
| | | hh = hh < 10 ? `0${hh}` : hh
|
| | | let mm = time.getMinutes()
|
| | | mm = mm < 10 ? `0${mm}` : mm
|
| | | let ss = time.getSeconds()
|
| | | ss = ss < 10 ? `0${ss}` : ss
|
| | | let value = `${y}/${m}/${d} ${hh}:${mm}:${ss}`
|
| | | if (type === 'year') {
|
| | | value = `${y}`
|
| | | }
|
| | | if (type === 'month') {
|
| | | value = `${y}-${m}`
|
| | | }
|
| | | if (type === 'day') {
|
| | | value = `${y}-${m}-${d}`
|
| | | }
|
| | | return value
|
| | | },
|
| | | /**
|
| | | * [setDefaultValue 设置é»è®¤å¼]
|
| | | */
|
| | | setDefaultValue() {
|
| | | let date = this.moment(new Date().getTime())
|
| | | this.valueEchoed(date)
|
| | | },
|
| | | bindDateChange(e) {
|
| | | this.childValue = e.target.value
|
| | | },
|
| | | dateInit() {
|
| | | this.array = []
|
| | | this.yearArr = []
|
| | | this.monthArr = []
|
| | | let minDate = this.moment(this.minSelect) || []
|
| | | let maxDate = this.moment(this.maxSelect) || []
|
| | | minDate = minDate ? minDate.split(' ') : ''
|
| | | maxDate = maxDate ? maxDate.split(' ') : ''
|
| | | minDate = minDate[0] ? minDate[0].split('-') : 1900
|
| | | maxDate = maxDate[0] ? maxDate[0].split('-') : 2050
|
| | | let type = this.timeType
|
| | | let {
|
| | | monthStar,
|
| | | monthEnd
|
| | | } = ''
|
| | | let yearStar = minDate[0] ? parseInt(minDate[0]) : 1900
|
| | | let yearEnd = maxDate[0] ? parseInt(maxDate[0]) : 2050
|
| | | if (type === 'day') {
|
| | | let dateStar = minDate[2] ? parseInt(minDate[2]) : 1
|
| | | let dateEnd = maxDate[2] ? parseInt(maxDate[2]) : 31
|
| | | }
|
| | | if (type === 'month' || type === 'day') {
|
| | | monthStar = minDate[1] ? parseInt(minDate[1]) : 1
|
| | | monthEnd = maxDate[1] ? parseInt(maxDate[1]) : 12
|
| | | }
|
| | |
|
| | | for (let y = yearStar; y <= yearEnd; y++) {
|
| | | let ytext = y < 10 ? `0${y}` : y
|
| | | this.yearArr.push(`${ytext}å¹´`)
|
| | | if (type === 'month' || type === 'day') {
|
| | | let mGroup = this.getMonthArr(
|
| | | y,
|
| | | yearStar,
|
| | | yearEnd,
|
| | | monthStar,
|
| | | monthEnd,
|
| | | type
|
| | | )
|
| | | mGroup.length && this.monthArr.push(mGroup)
|
| | | }
|
| | | }
|
| | |
|
| | | this.array[0] = this.yearArr
|
| | | |
| | | if (type === 'month' || type === 'day') {
|
| | | this.array[1] = this.monthArr.length && this.monthArr[0]
|
| | | }
|
| | | if (type === 'day') {
|
| | | this.array[2] = this.getDateArr(
|
| | | parseInt(this.yearArr[0]),
|
| | | parseInt(this.monthArr[0])
|
| | | )
|
| | | }
|
| | | },
|
| | |
|
| | | getMonthArr(y, yearStar, yearEnd, monthStar, monthEnd, type) {
|
| | | let mGroup = []
|
| | | let dateGroup = []
|
| | | if (y === yearStar && y !== yearEnd) {
|
| | | for (let m = monthStar; m <= 12; m++) {
|
| | | let mtext = m < 10 ? `0${m}` : m
|
| | | mGroup.push(`${mtext}æ`)
|
| | | }
|
| | | }
|
| | |
|
| | | if (y === yearEnd && y !== yearStar) {
|
| | |
|
| | | for (let m = 1; m <= monthEnd; m++) {
|
| | | let mtext = m < 10 ? `0${m}` : m
|
| | | mGroup.push(`${mtext}æ`)
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | if (y !== yearStar && y !== yearEnd) {
|
| | | for (let m = 1; m <= 12; m++) {
|
| | | let mtext = m < 10 ? `0${m}` : m
|
| | | mGroup.push(`${mtext}æ`)
|
| | | }
|
| | | }
|
| | |
|
| | | if (y === yearStar && y === yearEnd) {
|
| | | for (let m = monthStar; m <= monthEnd; m++) {
|
| | | let mtext = m < 10 ? `0${m}` : m
|
| | | mGroup.push(`${mtext}æ`)
|
| | | }
|
| | | }
|
| | | return mGroup
|
| | | },
|
| | | getDateArr(y, m) {
|
| | | let minDate = this.moment(this.minSelect) || []
|
| | | let maxDate = this.moment(this.maxSelect) || []
|
| | | minDate = minDate.length && minDate.split('-')
|
| | | maxDate = maxDate.length && maxDate.split('-')
|
| | | let yearStar = minDate[0] ? parseInt(minDate[0]) : 1900
|
| | | let yearEnd = maxDate[0] ? parseInt(maxDate[0]) : 2050
|
| | | let monthStar = minDate[1] ? parseInt(minDate[1]) : 1
|
| | | let monthEnd = maxDate[1] ? parseInt(maxDate[1]) : 12
|
| | | let datearr = []
|
| | | let maxnum = 30
|
| | | let date31 = [1, 3, 5, 7, 8, 10, 12]
|
| | | if (date31.includes(m)) {
|
| | | maxnum = 31
|
| | | }
|
| | | // 夿æ¯å¹³å¹´è¿æ¯é°å¹´ç2æä»½
|
| | | if (m === 2) {
|
| | | if (y % 400 == 0 || (y % 4 == 0 && y % 100 != 0)) {
|
| | | maxnum = 29
|
| | | } else {
|
| | | maxnum = 28
|
| | | }
|
| | | }
|
| | | let dateStar = minDate[2] ? parseInt(minDate[2]) : 1
|
| | | let dateEnd = maxDate[2] ? parseInt(maxDate[2]) : maxnum
|
| | | if (
|
| | | (y !== yearEnd && y !== yearStar) ||
|
| | | (y === yearStar && m !== monthStar && m !== monthEnd) ||
|
| | | (y === yearEnd && m !== monthEnd && m !== monthStar) ||
|
| | | (yearStar === yearEnd && m !== monthStar && m !== monthEnd) ||
|
| | | (yearStar !== yearEnd && y === yearEnd && m !== monthEnd) ||
|
| | | (y === yearStar && m !== monthStar && y < yearEnd)
|
| | | ) {
|
| | |
|
| | | for (let d = 1; d <= maxnum; d++) {
|
| | | let dtext = d < 10 ? `0${d}` : d
|
| | | datearr.push(`${dtext}æ¥`)
|
| | | }
|
| | | }
|
| | |
|
| | | if ((yearStar === yearEnd && y === yearStar && m === monthStar && m !== monthEnd) || (yearStar !== yearEnd && y ===
|
| | | yearStar && m === monthStar)) {
|
| | |
|
| | | for (let d = dateStar; d <= maxnum; d++) {
|
| | | let dtext = d < 10 ? `0${d}` : d
|
| | | datearr.push(`${dtext}æ¥`)
|
| | | }
|
| | | }
|
| | |
|
| | | if ((y === yearEnd && m === monthEnd && m !== monthStar && yearStar === yearEnd) || (y === yearEnd && yearStar !==
|
| | | yearEnd && m === monthEnd)) {
|
| | |
|
| | | for (let d = 1; d <= dateEnd; d++) {
|
| | | let dtext = d < 10 ? `0${d}` : d
|
| | | datearr.push(`${dtext}æ¥`)
|
| | | }
|
| | | }
|
| | |
|
| | | if (
|
| | | y === yearStar &&
|
| | | yearStar === yearEnd &&
|
| | | m === monthStar &&
|
| | | monthStar === monthEnd
|
| | | ) {
|
| | |
|
| | | for (let d = dateStar; d <= dateEnd; d++) {
|
| | | let dtext = d < 10 ? `0${d}` : d
|
| | | datearr.push(`${dtext}æ¥`)
|
| | | }
|
| | | }
|
| | | return datearr
|
| | | },
|
| | |
|
| | | bindTimeChange(e) {
|
| | | let timeValue = ''
|
| | | let indexArr = e.detail.value
|
| | | let type = this.timeType
|
| | | let year = parseInt(this.array[0][parseInt(indexArr[0]) || 0])
|
| | | let month = ''
|
| | | timeValue = year + ''
|
| | | if (type === 'month' || type === 'day') {
|
| | | let index = parseInt(indexArr[1]) || 0
|
| | | index = index < 0 ? 0 : index
|
| | | month = parseInt(this.array[1][index])
|
| | | month = month < 10 ? `0${month}` : month
|
| | | timeValue = `${timeValue}-${month}`
|
| | | }
|
| | | if (type === 'day') {
|
| | | let dateindex = parseInt(indexArr[2]) || 0
|
| | | dateindex = dateindex < 0 ? 0 : dateindex
|
| | | let date = parseInt(this.array[2][dateindex])
|
| | | date = date < 10 ? `0${date}` : date
|
| | | timeValue = `${timeValue}-${date}`
|
| | | }
|
| | | this.showTime = timeValue
|
| | | this.$emit('getData', timeValue)
|
| | | },
|
| | | // 彿¶åçæ¹åæ¶ å 载对åºçåéæ°ç»
|
| | | columnchange(e) {
|
| | | const minIndex = e.detail.value
|
| | | const column = e.detail.column
|
| | | let type = this.timeType
|
| | | this.$set(this.index, column, minIndex)
|
| | |
|
| | | if (column === 0) {
|
| | | this.yearIndex = minIndex
|
| | | if (type === 'month' || type === 'day') {
|
| | | this.$set(this.array, 1, this.monthArr[minIndex])
|
| | | }
|
| | | if (type === 'day') {
|
| | | let monthindex = this.index[1] || 0
|
| | |
|
| | | let newDateArr = this.getDateArr(
|
| | | parseInt(this.yearArr[minIndex]),
|
| | | parseInt(this.monthArr[this.yearIndex][monthindex])
|
| | | )
|
| | | this.$set(this.array, 2, newDateArr)
|
| | | }
|
| | | }
|
| | | if (column === 1 && type === 'day') {
|
| | | let newDateArr = this.getDateArr(
|
| | | parseInt(this.yearArr[this.yearIndex]),
|
| | | parseInt(this.monthArr[this.yearIndex][minIndex])
|
| | | )
|
| | | this.$set(this.array, 2, newDateArr)
|
| | | }
|
| | | },
|
| | | valueEchoed(defaultTime) {
|
| | | this.index = [0]
|
| | | if (this.childValue || defaultTime) {
|
| | | let value = this.childValue || defaultTime
|
| | | value = this.moment(value)
|
| | | value = value.split('-')
|
| | | let index =
|
| | | this.array[0].findIndex(
|
| | | item => parseInt(item) === parseInt(value[0])
|
| | | ) || 0
|
| | | index = index === -1 ? 0 : index
|
| | | this.index[0] = index
|
| | | this.yearIndex = index
|
| | | |
| | | let type = this.timeType
|
| | | if (type === 'month' || type === 'day') {
|
| | | this.array[1] = this.monthArr.length && this.monthArr[index]
|
| | | const monthindex =
|
| | | (this.array[1] && this.array[1].length &&
|
| | | this.array[1].findIndex(
|
| | | item => parseInt(item) === parseInt(value[1])
|
| | | )) ||
|
| | | 0
|
| | | this.index[1] = monthindex
|
| | | }
|
| | | if (type === 'day') {
|
| | | let index0 = this.index[0] || 0
|
| | | let index1 = this.index[1] || 0
|
| | | index0 = index0 === -1 ? 0 : index0
|
| | | index1 = index1 === -1 ? 0 : index1
|
| | | let newDay = this.getDateArr(
|
| | | parseInt(this.yearArr[index0]),
|
| | | parseInt(this.monthArr[index0][index1])
|
| | | )
|
| | | this.getDateIndex(newDay)
|
| | | }
|
| | | }
|
| | | },
|
| | | getDateIndex(newDay) {
|
| | | let defaultTime = this.moment(new Date().getTime())
|
| | | let value = this.childValue || defaultTime
|
| | | value = this.moment(value)
|
| | | value = value.split('-')
|
| | | this.array[2] = newDay
|
| | | let dateindex =
|
| | | this.array[2].findIndex(
|
| | | item => parseInt(item) === parseInt(value[2])
|
| | | ) || 0
|
| | | this.index[2] = dateindex
|
| | | }
|
| | | },
|
| | |
|
| | | watch: {
|
| | | // çæµç»ä»¶æå°éæ©èå´åçæ¹å åå§åæ¥ææ°æ®
|
| | | minSelect() {
|
| | | this.dateInit()
|
| | | this.setDefaultValue()
|
| | | },
|
| | | // çæµç»ä»¶æå¤§å¯éèå´åçæ¹å åå§åæ¥ææ°æ®
|
| | | maxSelect() {
|
| | | this.dateInit()
|
| | | this.setDefaultValue()
|
| | | },
|
| | | childValue() {
|
| | | this.showTime = ''
|
| | | this.showTime = this.moment(this.childValue)
|
| | | this.dateInit()
|
| | | this.setDefaultValue()
|
| | | }
|
| | | },
|
| | | created() {
|
| | | this.dateInit()
|
| | | this.valueEchoed()
|
| | | if (!this.childValue) {
|
| | | this.setDefaultValue()
|
| | | }
|
| | | }
|
| | | }
|
| | | </script>
|
| | |
|
| | | <style lang="less">
|
| | | .tx_r {
|
| | | line-height: 48px;
|
| | | font-size: 15px;
|
| | | font-weight: normal;
|
| | | color: #848b9a;
|
| | | }
|
| | |
|
| | | .placeholder {
|
| | | color: #b5b8c2;
|
| | | }
|
| | |
|
| | | .fa-angle-right {
|
| | | font-size: 36rpx;
|
| | | padding-left: 12rpx;
|
| | | }
|
| | | </style>
|
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template>
|
| | | <view class="content">
|
| | | <div class="item filter_input">
|
| | | <div class="lable">æ¥ææé´ï¼</div>
|
| | | <view class="date_item">
|
| | | <dyDatePicker placeholder="èµ·å§æ¥æ" :childValue="from" :minSelect="from_minSelect" :maxSelect="from_maxSelect"
|
| | | :iconshow="false" @getData="getFromData"></dyDatePicker>
|
| | | </view>
|
| | | <view class="filter_inputline"></view>
|
| | | <view class="date_item">
|
| | |
|
| | | <dyDatePicker placeholder="ç»ææ¥æ" :minSelect="to_minSelect" :childValue="to" :maxSelect="to_maxSelect" :iconshow="false"
|
| | | @getData="getToData"></dyDatePicker>
|
| | | </view>
|
| | | </div>
|
| | | <div class="item">
|
| | | <div class="lable">ç¦æ¢éæ©ï¼</div>
|
| | | <dyDatePicker childValue="2019/08/08" :disabled="true" @getData="getData" placeholder="è¯·éæ©æ¥æ"></dyDatePicker>
|
| | | </div>
|
| | | <div class="item">
|
| | | <div class="lable">æå®å¼å§ãç»ææ¶é´ï¼</div>
|
| | | <dyDatePicker @getData="getData" placeholder="è¯·éæ©æ¥æ" minSelect="2018/08/23" maxSelect="2019/08/28"></dyDatePicker>
|
| | | </div>
|
| | | <div class="item">
|
| | | <div class="lable">æå®å¼ï¼</div>
|
| | | <dyDatePicker @getData="getData" childValue="2019/08/08" placeholder="è¯·éæ©æ¥æ" minSelect="2000/01/01" maxSelect="2025/12/31"></dyDatePicker>
|
| | | </div>
|
| | | |
| | | <div class="item">
|
| | | <div class="lable">éæ©æä»½ï¼</div>
|
| | | <dyDatePicker timeType="month" @getData="getData" placeholder="è¯·éæ©æ¥æ" minSelect="2000/01/01" maxSelect="2025/12/31"></dyDatePicker>
|
| | | </div>
|
| | | <div class="item">
|
| | | <div class="lable">鿩年份ï¼</div>
|
| | | <dyDatePicker timeType="year" @getData="getData" placeholder="è¯·éæ©æ¥æ" minSelect="2000/01/01" maxSelect="2025/12/31"></dyDatePicker>
|
| | | </div>
|
| | | </view>
|
| | | </template>
|
| | |
|
| | | <script>
|
| | | import dyDatePicker from '../../components/dy-Date/dy-Date.vue'
|
| | | export default {
|
| | | components: {
|
| | | dyDatePicker
|
| | | },
|
| | | data() {
|
| | | return {
|
| | | from_minSelect: '1900/01/01',
|
| | | from_maxSelect: '2050/12/31',
|
| | | to_minSelect: '1900/01/01',
|
| | | to_maxSelect: '2050/12/31',
|
| | | from: '',
|
| | | to: '',
|
| | | }
|
| | | },
|
| | | onLoad() {
|
| | |
|
| | | },
|
| | | methods: {
|
| | | /**
|
| | | * @param {to_minSelect|from} to_minSelectç»ææ¶é´çæå°éæ©èå´ from=>å¼å§æ¥æ
|
| | | */
|
| | | getFromData(time) {
|
| | | this.to_minSelect = time
|
| | | this.from = time
|
| | | },
|
| | | /**
|
| | | * @param {from_maxSelect|to} from_maxSelect=>å¼å§æ¥æå¯éæå¤§å¯éå¼ to=> ç»ææ¥æ
|
| | | */
|
| | | getToData(time) {
|
| | | this.from_maxSelect = time
|
| | | this.to = time
|
| | | },
|
| | | getData() {
|
| | | // |
| | | }
|
| | | }
|
| | | }
|
| | | </script>
|
| | |
|
| | | <style lang="less" scoped>
|
| | | * {
|
| | | padding: 0px;
|
| | | margin: 0 auto;
|
| | | box-sizing: border-box;
|
| | | }
|
| | |
|
| | |
|
| | | .content {
|
| | | text-align: center;
|
| | |
|
| | | margin-top: 20px;
|
| | | font-size: 24rpx;
|
| | |
|
| | | }
|
| | |
|
| | | .item {
|
| | | box-sizing: border-box;
|
| | | width: 100%;
|
| | | height: 40px;
|
| | | line-height: 40px;
|
| | | background-color: #ffffff;
|
| | | position: relative;
|
| | | padding: 0px 10px 0px 100px;
|
| | | margin-bottom: 10px;
|
| | | text-align: right;
|
| | | }
|
| | |
|
| | | .item .lable {
|
| | | position: absolute;
|
| | | left: 10px;
|
| | | top: 0px;
|
| | | color: #333333;
|
| | | }
|
| | |
|
| | | uni-picker-view-column {
|
| | | font-size: 24rpx;
|
| | | }
|
| | |
|
| | | .filter_input {
|
| | | height: 92rpx;
|
| | | padding-top: 10rpx;
|
| | | }
|
| | |
|
| | | .date_item {
|
| | | float: left;
|
| | | width: 240upx;
|
| | | overflow: hidden;
|
| | | display: inline-block;
|
| | | text-align: center;
|
| | | border: 1px solid #ececec;
|
| | | height: 72rpx;
|
| | | line-height: 72rpx;
|
| | |
|
| | | // font-size: 28rpx;
|
| | | &:last-child {
|
| | | // float: right;
|
| | | }
|
| | |
|
| | | input {
|
| | | height: 72rpx;
|
| | |
|
| | | .uni-input-placeholder {
|
| | | color: #b5b8c2;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | .filter_inputline {
|
| | | float: left;
|
| | | margin: 0 4rpx;
|
| | | line-height: 72rpx;
|
| | |
|
| | | &:after {
|
| | | content: 'â';
|
| | | font-size: 28rpx;
|
| | | color: #848b9a;
|
| | | }
|
| | | }
|
| | | </style>
|
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template>
|
| | | <view class="dropdown">
|
| | | <view class="item">
|
| | | <view class="item-title">设å¤</view>
|
| | | <view class="item-box">
|
| | | <view v-for="(item,index) in menuList" :key="item.code" :class="['item-menu',item.ck?'active':'']"
|
| | | @click="changeMenu(index)">{{item.name}}
|
| | | </view>
|
| | | </view>
|
| | |
|
| | | <view class="item-title">æ¶é´</view>
|
| | | <view class="item-box">
|
| | | <view v-for="(item,index) in dateList" :key="item.code"
|
| | | :class="['item-menu',currentDate==index?'active':'']" @click="changeDate(index)">{{item.name}}
|
| | | </view>
|
| | | </view>
|
| | | <view class="custom-date" v-if="currentDate==3">
|
| | | <view class="custom-date-ipute">
|
| | | <dyDatePicker placeholder="å¼å§æ¥æ" :minSelect="from_minSelect" :maxSelect="from_maxSelect"
|
| | | :iconshow="false" @getData="starteDate" ref="startDatePickerRef"></dyDatePicker>
|
| | | </view>
|
| | | <view class="custom-date-line"></view>
|
| | | <view class="custom-date-ipute">
|
| | | <dyDatePicker placeholder="ç»ææ¥æ" :minSelect="to_minSelect" |
| | | :maxSelect="to_maxSelect" :iconshow="false" @getData="endDate" ref="endDatePickerRef">
|
| | | </dyDatePicker>
|
| | | </view>
|
| | | </view>
|
| | | </view>
|
| | |
|
| | | <view class="dropdown-footer">
|
| | | <view class="dropdown-footer-btn reset" @click="resetDropdown">éç½®</view>
|
| | | <view class="dropdown-footer-btn submit" @click="submitSelect">ç¡®å®</view>
|
| | | </view>
|
| | | </view>
|
| | | </template>
|
| | | <script>
|
| | | import dyDatePicker from '@/components/drop-down-menu/dy-Date/dy-Date.vue';
|
| | | import dayjs from 'dayjs'
|
| | | export default {
|
| | | components: {
|
| | | dyDatePicker
|
| | | },
|
| | | props: {
|
| | | list: {
|
| | | type: Array,
|
| | | default: () => []
|
| | | }
|
| | | },
|
| | | data() {
|
| | | return {
|
| | | menuList: [],
|
| | | dateList: [{
|
| | | code: 1,
|
| | | name: 'ä»å¤©',
|
| | | subDay: 0
|
| | | },
|
| | | {
|
| | | code: 2,
|
| | | name: 'æ¨å¤©',
|
| | | subDay: 1
|
| | | },
|
| | | {
|
| | | code: 3,
|
| | | name: 'è¿ä¸å¨',
|
| | | subDay: 7
|
| | | },
|
| | | {
|
| | | code: 4,
|
| | | name: 'èªå®ä¹æ¶é´',
|
| | | subDay: ''
|
| | | }
|
| | | ],
|
| | | from_minSelect: '1900/01/01',
|
| | | from_maxSelect: '2050/12/31',
|
| | | to_minSelect: '1900/01/01',
|
| | | to_maxSelect: '2050/12/31',
|
| | | currentDate: undefined,
|
| | | selectData: {
|
| | | menu: [],
|
| | | startTime: undefined,
|
| | | endTime: undefined
|
| | | },
|
| | |
|
| | | }
|
| | | },
|
| | | watch: {
|
| | | list: {
|
| | | handler(newVal, oldVal) {
|
| | | this.init()
|
| | | },
|
| | | deep: true,
|
| | | immediate: true
|
| | | }
|
| | | },
|
| | | |
| | | methods: {
|
| | | init() {
|
| | | const menuList = JSON.parse(JSON.stringify(this.list));
|
| | | menuList.forEach(item => item.ck = false);
|
| | | this.menuList = menuList
|
| | | const todayDate = dayjs().format('YYYY-MM-DD');
|
| | | const beforeDate = dayjs().subtract(5, 'year').format('YYYY-MM-DD')
|
| | | this.from_minSelect = beforeDate;
|
| | | this.from_maxSelect = todayDate;
|
| | | this.to_minSelect = beforeDate;
|
| | | this.to_maxSelect = todayDate;
|
| | | this.resetDropdown(false)
|
| | | },
|
| | | // change为falseæ¶ä¸åé changeäºä»¶ ä»
ä»
éç½®
|
| | | resetDropdown(change=true) {
|
| | | this.menuList.forEach(item => item.ck = false);
|
| | | if (this.currentDate == 3) {
|
| | | this.$refs.startDatePickerRef.clear();
|
| | | this.$refs.endDatePickerRef.clear();
|
| | | }
|
| | | this.currentDate = 999;
|
| | | this.initDate();
|
| | | this.selectData.menu = [];
|
| | | this.selectData.startTime = undefined;
|
| | | this.selectData.endTime = undefined;
|
| | | if(change){
|
| | | this.$emit('reset', this.selectData);
|
| | | }
|
| | | },
|
| | | submitSelect() {
|
| | | if (this.currentDate == 3) {
|
| | | if (!this.selectData.startTime || !this.selectData.endTime) {
|
| | | uni.showToast({
|
| | | icon: "none",
|
| | | title: "å¼å§æ¥æåç»ææ¥æé½ä¸è½ä¸ºç©ºï¼",
|
| | | duration: 3000
|
| | | })
|
| | | return
|
| | | };
|
| | | };
|
| | | this.$emit('change', this.selectData);
|
| | | },
|
| | | initDate() {
|
| | | const todayDate = dayjs().format('YYYY-MM-DD');
|
| | | const beforeDate = dayjs().subtract(5, 'year').format('YYYY-MM-DD')
|
| | | this.from_minSelect = beforeDate;
|
| | | this.from_maxSelect = todayDate;
|
| | | this.to_minSelect = beforeDate;
|
| | | this.to_maxSelect = todayDate
|
| | | },
|
| | | changeMenu(index) {
|
| | | const handelItem = this.menuList[index].ck;
|
| | | this.menuList[index].ck = !handelItem;
|
| | | const checkList = [];
|
| | | this.menuList.forEach(item => {
|
| | | if (item.ck) {
|
| | | checkList.push(item.code)
|
| | | }
|
| | | })
|
| | | this.selectData.menu = checkList;
|
| | | },
|
| | | changeDate(index) {
|
| | | this.currentDate = index;
|
| | | if (index == 3) {
|
| | | this.selectData.startTime = undefined;
|
| | | this.selectData.endTime = undefined;
|
| | | return
|
| | | }
|
| | | const todayDate = dayjs().format('YYYY-MM-DD');
|
| | | const beforeDate = dayjs().subtract(this.dateList[index].subDay, 'day').format('YYYY-MM-DD')
|
| | | this.selectData.startTime = beforeDate;
|
| | | this.selectData.endTime = todayDate;
|
| | | },
|
| | | starteDate(val) {
|
| | | if (this.selectData.endTime) {
|
| | | const diffDate = dayjs(this.selectData.endTime).diff(val, 'day');
|
| | | if (diffDate < 0) {
|
| | | uni.showToast({
|
| | | icon: "none",
|
| | | title: "å¼å§æ¥æä¸è½å¤§äºç»ææ¥æ",
|
| | | duration: 3000
|
| | | })
|
| | | this.$refs.startDatePickerRef.clear();
|
| | | return
|
| | | }
|
| | | }
|
| | | this.selectData.startTime = val;
|
| | | },
|
| | | endDate(val) {
|
| | | if (this.selectData.startTime) {
|
| | | const diffDate = dayjs(val).diff(this.selectData.startTime, 'day');
|
| | | if (diffDate < 0) {
|
| | | uni.showToast({
|
| | | icon: "none",
|
| | | title: "ç»ææ¥æä¸è½å°äºå¼å§æ¥æ",
|
| | | duration: 3000
|
| | | })
|
| | | this.$refs.endDatePickerRef.clear()
|
| | | return
|
| | | }
|
| | | }
|
| | | this.selectData.endTime = val;
|
| | | }
|
| | | }
|
| | | }
|
| | | </script>
|
| | |
|
| | | <style scoped lang="scss">
|
| | | .dropdown {
|
| | | ;
|
| | | padding: 32rpx 28rpx 48rpx 28rpx;
|
| | | box-sizing: border-box;
|
| | | background: #FFFFFF;
|
| | | box-shadow: 0rpx 4rpx 12rpx 0rpx rgba(0, 0, 0, 0.15);
|
| | | border-radius: 16rpx;
|
| | |
|
| | | .item {
|
| | | &-title {
|
| | | font-size: 24rpx;
|
| | | font-family: PingFangTC-Medium, PingFangTC;
|
| | | font-weight: 600;
|
| | | color: #000000;
|
| | | }
|
| | |
|
| | | &-box {
|
| | | width: 100%;
|
| | | display: flex;
|
| | | flex-wrap: wrap;
|
| | | |
| | | margin-bottom: 32rpx;
|
| | | }
|
| | |
|
| | | &-menu {
|
| | | box-sizing: border-box;
|
| | | flex: 0 0 calc(33.33% - 32rpx); |
| | | height: 56rpx;
|
| | | background: #ECEDF3;
|
| | | border-radius: 8rpx;
|
| | | text-align: center;
|
| | | line-height: 56rpx;
|
| | | margin: 24rpx 10rpx 0 20rpx;
|
| | | font-size: 24rpx;
|
| | | font-weight: 400;
|
| | | color: #000000;
|
| | | }
|
| | |
|
| | | .active {
|
| | | background: #0064FF;
|
| | | color: #fff;
|
| | |
|
| | | }
|
| | | }
|
| | |
|
| | | .custom-date {
|
| | | display: flex;
|
| | | align-items: center;
|
| | |
|
| | | .custom-date-line {
|
| | | width: 30rpx;
|
| | | height: 2px;
|
| | | background: #eee;
|
| | | margin: 0 10rpx;
|
| | | }
|
| | |
|
| | | .custom-date-ipute {
|
| | | border: 1px solid #0064FF;
|
| | | width: 50%;
|
| | | text-align: center;
|
| | | height: 56rpx;
|
| | | color: #0064FF;
|
| | | border-radius: 8rpx;
|
| | | }
|
| | | }
|
| | |
|
| | | &-footer {
|
| | | display: flex;
|
| | | justify-content: space-around;
|
| | | align-items: center;
|
| | | margin-top: 32rpx;
|
| | |
|
| | | &-btn {
|
| | | width: 298rpx;
|
| | | height: 82rpx;
|
| | | text-align: center;
|
| | | border-radius: 12rpx;
|
| | | font-weight: 500;
|
| | | line-height: 82rpx;
|
| | | font-size: 32rpx;
|
| | | }
|
| | |
|
| | | .reset {
|
| | | border: 2rpx solid #0064FF;
|
| | | color: #0064FF;
|
| | | }
|
| | |
|
| | | .submit {
|
| | | color: #fff;
|
| | | background: #0064FF;
|
| | | border: 2rpx solid #0064FF;
|
| | | }
|
| | | }
|
| | | }
|
| | | </style> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | æä»¶IDï¼gx-drop-down-menu
|
| | | ä¿®æ¹èªuniapp æä»¶å¸åº ãdrop-down-menu䏿èåãå¤éï¼èªå®ä¹æ¥æèå´éæ©ã
|
| | | **ä¾èµdayjsï¼è¯·npm install dayjs ã"dayjs": "^1.11.10"ã
|
| | |
|
| | | Vue2 Vue3 |
| | | â Ã |
| | | App å¿«åºç¨ 微信å°ç¨åº æ¯ä»å®å°ç¨åº ç¾åº¦å°ç¨åº åèå°ç¨åº QQå°ç¨åº |
| | | app-vue app-nvue â â â â â â |
| | | ééå°ç¨åº å¿«æå°ç¨åº é£ä¹¦å°ç¨åº 京ä¸å°ç¨åº |
| | | â â â â |
| | | H5-Safari Android Browser 微信æµè§å¨(Android) QQæµè§å¨(Android) Chrome IE Edge Firefox PC-Safari |
| | | â â â â â â â â |
| | |
| | | }) |
| | | } |
| | | |
| | | //æ¶æ¯å¤ç |
| | | mqttTool.message = function(){ |
| | | return new Promise((resolve, reject) => { |
| | | if(mqttTool.client == null){ |
| | | resolve('æªè¿æ¥') |
| | | console.log('App_text' + ":unconnect æªè¿æ¥") |
| | | return; |
| | | } |
| | | if(mqttTool.client != null && ! mqttTool.client.connected){ |
| | | mqttTool.client.reconnect() |
| | | } |
| | | |
| | | mqttTool.client.on('message', function(topic, message, buffer) { |
| | | console.info(topic) |
| | | console.info(message) |
| | | setTimeout(() => { |
| | | resolve({topic, message, buffer }) |
| | | }, 300) |
| | | }) |
| | | |
| | | }) |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | import App from './App'
|
| | | import Vue from 'vue' |
| | |
|
| | | import store from './store'; // å¼å
¥ Vuex store |
| | |
|
| | | // æ¤å¤ä¸ºå¼ç¨èªå®ä¹é¡¶é¨ |
| | | import cuCustom from './colorui/components/cu-custom.vue' |
| | | Vue.component('cu-custom',cuCustom); |
| | | import TnCustom from './components/TnCustom/TnCustom.vue' |
| | | Vue.component('tn-custom', TnCustom)
|
| | |
|
| | | import MqttView from './mqtt/MqttView.vue' |
| | | Vue.component('mqtt-view', MqttView)
|
| | |
|
| | | import uView from "uview-ui"; |
| | | Vue.use(uView); |
| | |
| | | Vue.prototype.$mqttTool = mqttTool |
| | | |
| | |
|
| | | const EventBus = new Vue(); |
| | | Vue.prototype.$eventBus = EventBus |
| | | |
| | |
|
| | | //å
¨å±çæ§å®æ¶å¨ï¼å¨é¡µé¢ä½¿ç¨å±é¨å®æ¶å¨ä¼åºç°æ æ³å
³éé®é¢ï¼
|
| | | Vue.prototype.$monitorTimer = null |
| | |
| | | App.mpType = 'app' |
| | | |
| | | const app = new Vue({ |
| | | store, // 注å
¥ store |
| | | ...App |
| | | }) |
| | | app.$mount() |
| | |
| | | { |
| | | "name" : "lbdry-uniapp", |
| | | "name" : "æºè½ä¸èè¯å¹²ç¥æº", |
| | | "appid" : "__UNI__1E83F66", |
| | | "description" : "", |
| | | "versionName" : "1.0.0", |
| | |
| | | "delay" : 0 |
| | | }, |
| | | /* 模åé
ç½® */ |
| | | "modules" : {}, |
| | | "modules" : { |
| | | "Push" : {} |
| | | }, |
| | | /* åºç¨åå¸ä¿¡æ¯ */ |
| | | "distribute" : { |
| | | /* androidæå
é
ç½® */ |
| | |
| | | "<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>", |
| | | "<uses-feature android:name=\"android.hardware.camera\"/>", |
| | | "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>" |
| | | ] |
| | | ], |
| | | "targetSdkVersion" : 30, |
| | | "minSdkVersion" : 23 |
| | | }, |
| | | /* iosæå
é
ç½® */ |
| | | "ios" : {}, |
| | | "ios" : { |
| | | "dSYMs" : false |
| | | }, |
| | | /* SDKé
ç½® */ |
| | | "sdkConfigs" : {}, |
| | | "sdkConfigs" : { |
| | | "push" : { |
| | | "unipush" : { |
| | | "icons" : { |
| | | "small" : { |
| | | "ldpi" : "static/push/push_small_18.png", |
| | | "mdpi" : "static/push/push_small_24.png", |
| | | "hdpi" : "static/push/push_small_36.png", |
| | | "xhdpi" : "static/push/push_small_48.png", |
| | | "xxhdpi" : "static/push/push_small_72.png" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "icons" : { |
| | | "android" : { |
| | | "hdpi" : "", |
| | | "xhdpi" : "", |
| | | "xxhdpi" : "", |
| | | "xxxhdpi" : "" |
| | | "hdpi" : "unpackage/res/icons/72x72.png", |
| | | "xhdpi" : "unpackage/res/icons/96x96.png", |
| | | "xxhdpi" : "unpackage/res/icons/144x144.png", |
| | | "xxxhdpi" : "unpackage/res/icons/192x192.png" |
| | | }, |
| | | "ios" : { |
| | | "appstore" : "", |
| | | "appstore" : "unpackage/res/icons/1024x1024.png", |
| | | "ipad" : { |
| | | "app" : "", |
| | | "app@2x" : "", |
| | | "notification" : "", |
| | | "notification@2x" : "", |
| | | "proapp@2x" : "", |
| | | "settings" : "", |
| | | "settings@2x" : "", |
| | | "spotlight" : "", |
| | | "spotlight@2x" : "" |
| | | "app" : "unpackage/res/icons/76x76.png", |
| | | "app@2x" : "unpackage/res/icons/152x152.png", |
| | | "notification" : "unpackage/res/icons/20x20.png", |
| | | "notification@2x" : "unpackage/res/icons/40x40.png", |
| | | "proapp@2x" : "unpackage/res/icons/167x167.png", |
| | | "settings" : "unpackage/res/icons/29x29.png", |
| | | "settings@2x" : "unpackage/res/icons/58x58.png", |
| | | "spotlight" : "unpackage/res/icons/40x40.png", |
| | | "spotlight@2x" : "unpackage/res/icons/80x80.png" |
| | | }, |
| | | "iphone" : { |
| | | "app@2x" : "", |
| | | "app@3x" : "", |
| | | "notification@2x" : "", |
| | | "notification@3x" : "", |
| | | "settings@2x" : "", |
| | | "settings@3x" : "", |
| | | "spotlight@2x" : "", |
| | | "spotlight@3x" : "" |
| | | "app@2x" : "unpackage/res/icons/120x120.png", |
| | | "app@3x" : "unpackage/res/icons/180x180.png", |
| | | "notification@2x" : "unpackage/res/icons/40x40.png", |
| | | "notification@3x" : "unpackage/res/icons/60x60.png", |
| | | "settings@2x" : "unpackage/res/icons/58x58.png", |
| | | "settings@3x" : "unpackage/res/icons/87x87.png", |
| | | "spotlight@2x" : "unpackage/res/icons/80x80.png", |
| | | "spotlight@3x" : "unpackage/res/icons/120x120.png" |
| | | } |
| | | } |
| | | }, |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template>
|
| | | <view>
|
| | | </view>
|
| | | </template>
|
| | |
|
| | | <script>
|
| | | |
| | | export default {
|
| | | name: 'MqttView',
|
| | | data() {
|
| | | return {
|
| | |
|
| | | }
|
| | | },
|
| | | onReady() {
|
| | | |
| | | },
|
| | | methods: {
|
| | | initMqtt(){
|
| | | uni.getSystemInfo({
|
| | | success: (res) => {
|
| | | let deviceId = res.deviceId
|
| | | if (!deviceId) {
|
| | | deviceId = 'mobile-' + this.tenantId + '-' + Date.parse(new Date())
|
| | | }
|
| | | uni.setStorageSync(this.$constant.DEVICE_ID, 'mobile-' + this.tenantId + '-' + res.deviceId);
|
| | | }
|
| | | })
|
| | | this.startConnect();
|
| | | },
|
| | | /* è¿æ¥MQTT */
|
| | | async startConnect() {
|
| | | var _this = this
|
| | | const account = uni.getStorageSync('account');
|
| | | const deviceid = uni.getStorageSync(this.$constant.DEVICE_ID);
|
| | | |
| | | if (!account) {
|
| | | |
| | | return false
|
| | | }
|
| | | let opts = {
|
| | | // #ifdef H5
|
| | | url: 'ws://' + this.$api.mqttBaseUrl + ':8083/mqtt',
|
| | | // #endif
|
| | | // #ifdef APP-PLUS
|
| | | url: 'wx://' + this.$api.mqttBaseUrl + ':8083/mqtt',
|
| | | // #endif
|
| | | clientId: deviceid,
|
| | | username: account.username,
|
| | | password: account.password
|
| | | }
|
| | | if (!this.$mqttTool.client) {
|
| | | var client = await this.$mqttTool.connect(opts);
|
| | | }
|
| | | //订é
æ¥è¯¢è®¾å¤ç¶æè¿åæ°æ®
|
| | | this.$mqttTool.subscribe({
|
| | | topic: this.$constant.SERVICE_DOWN + '/' + deviceid + '/#',
|
| | | qos: 0
|
| | | }).then(res => {
|
| | | console.error(res)
|
| | | })
|
| | | |
| | | //订é
è®¾å¤æ
é广æï¼å¹¿æä¸å¨ä¹å®¢æ·ç«¯idï¼åéç»ç§æ·ä¸ææå¨çº¿ç设å¤ï¼
|
| | | this.$mqttTool.subscribe({
|
| | | topic: this.$constant.SERVICE_BROADCAST_TENANT_REAL_FAULT.replace('%s', this.tenantId),
|
| | | qos: 0
|
| | | }).then(res => {
|
| | | console.error(res)
|
| | | })
|
| | | //订é
åéæä»¤è¿åç»æ
|
| | | // this.$mqttTool.subscribe({
|
| | | // topic: this.$constant.SERVICE_RES_EQU_CMD,
|
| | | // qos: 0
|
| | | // }).then(res => {
|
| | | // console.error(res)
|
| | | // })
|
| | | // if (!client) {
|
| | | // return false
|
| | | // }
|
| | | let that = this
|
| | | |
| | | client.on('connect', function(res) {
|
| | | console.error('è¿æ¥æå')
|
| | | })
|
| | | client.on('reconnect', function(res) {
|
| | | console.error('éæ°è¿æ¥')
|
| | | })
|
| | | client.on('error', function(res) {
|
| | | console.info('è¿æ¥é误')
|
| | | })
|
| | | client.on('close', function(res) {
|
| | | |
| | | console.error('å
³éæå')
|
| | | |
| | | })
|
| | | client.on('message', function(topic, message, buffer) {
|
| | | that.$eventBus.$emit(that.$constant.MQTT_TOPIC_MESSAGE, message);
|
| | | console.info(message)
|
| | | |
| | | })
|
| | | },
|
| | | },
|
| | | computed: {
|
| | | tenantId() {
|
| | | const userinfo = uni.getStorageSync('userinfo');
|
| | | const tenantid = userinfo.loginTenantId
|
| | | return tenantid;
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | | </script>
|
| | |
|
| | | <style>
|
| | |
|
| | | </style> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | /* main.js 项ç®ä¸»å
¥å£æ³¨å
¥å®ä¾ */ |
| | | // import mqttTool from './lib/mqttTool.js' |
| | | // Vue.prototype.$mqttTool = mqttTool |
| | | |
| | | /* 使ç¨èä¾è§ /pages/index/index.vue */ |
| | | // mqttåè®®ï¼H5使ç¨ws/wss APP-PLUS使ç¨wx/wxs |
| | | |
| | | var mqtt = require('mqtt/dist/mqtt.js') |
| | | |
| | | //客æ·ç«¯ |
| | | let mqttTool = { |
| | | client: null |
| | | } |
| | | |
| | | //è¿æ¥æ¯ |
| | | mqttTool.connect = function(params){ |
| | | let options = { |
| | | clientId: params.clientId, |
| | | username: params.username, |
| | | password: params.password, |
| | | clean: true, |
| | | keepalive:10, //å¿è·³ åä½ï¼s |
| | | connectTimeout: 10*1000, //è¿æ¥è¶
æ¶ åä½ï¼ms |
| | | cleanSession: true |
| | | } |
| | | let client = mqtt.connect(params.url, options); |
| | | mqttTool.client = client |
| | | return client; |
| | | } |
| | | |
| | | mqttTool.end = function(){ |
| | | return new Promise((resolve, reject) => { |
| | | if(mqttTool.client == null){ |
| | | resolve('æªè¿æ¥') |
| | | console.log('App_text' + ":end æªè¿æ¥") |
| | | return; |
| | | } |
| | | mqttTool.client.end() |
| | | mqttTool.client = null |
| | | resolve('è¿æ¥ç»æ¢') |
| | | }) |
| | | } |
| | | |
| | | mqttTool.reconnect = function(){ |
| | | return new Promise((resolve, reject) => { |
| | | if(mqttTool.client == null){ |
| | | resolve('æªè¿æ¥') |
| | | console.log('App_text' + ":reconnect æªè¿æ¥") |
| | | return; |
| | | } |
| | | mqttTool.client.reconnect() |
| | | }) |
| | | } |
| | | |
| | | mqttTool.subscribe = function(params){ |
| | | return new Promise((resolve, reject) => { |
| | | if(mqttTool.client == null){ |
| | | resolve('æªè¿æ¥') |
| | | console.log('App_text' + ":unconnect æªè¿æ¥") |
| | | return; |
| | | } |
| | | mqttTool.client.subscribe(params.topic, {qos:params.qos}, function(err,res) { |
| | | console.log(err,res) |
| | | if (!err && res.length>0) { |
| | | resolve('订é
æå') |
| | | console.log('App_text' + ":subscribe success 订é
æå") |
| | | }else{ |
| | | resolve('订é
失败') |
| | | console.log('App_text' + ":subscribe failed 订é
失败") |
| | | return; |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | mqttTool.unsubscribe = function(params){ |
| | | return new Promise((resolve, reject) => { |
| | | if(mqttTool.client == null){ |
| | | resolve('æªè¿æ¥') |
| | | console.log('App_text' + ":unconnect æªè¿æ¥") |
| | | return; |
| | | } |
| | | mqttTool.client.unsubscribe(params.topic, function(err) { |
| | | if (!err) { |
| | | resolve('åæ¶è®¢é
æå') |
| | | console.log('App_text' + ":unsubscribe success åæ¶è®¢é
æå") |
| | | }else{ |
| | | resolve('åæ¶è®¢é
失败') |
| | | console.log('App_text' + ":unsubscribe failed åæ¶è®¢é
失败") |
| | | return; |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | mqttTool.publish = function(params){ |
| | | return new Promise((resolve, reject) => { |
| | | if(mqttTool.client == null){ |
| | | resolve('æªè¿æ¥') |
| | | console.log('App_text' + ":unconnect æªè¿æ¥") |
| | | return; |
| | | } |
| | | mqttTool.client.publish(params.topic, params.message, function(err){ |
| | | if (!err) { |
| | | resolve(params.topic + '-' + params.message + '-åéæå') |
| | | console.log('App_text' + ":publish success åéæå") |
| | | }else{ |
| | | resolve(params.topic + '-' + params.message + '-åé失败') |
| | | console.log('App_text' + ":publish failed åé失败") |
| | | return; |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | export default mqttTool |
| | |
| | | "dependencies": {
|
| | | "ezuikit-js": "^0.7.2",
|
| | | "lodash.get": "^4.4.2",
|
| | | "mqtt": "^3.0.0"
|
| | | "mqtt": "^3.0.0",
|
| | | "dayjs": "^1.11.10"
|
| | | }
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | }, {
|
| | | "path": "pages/tabBar/analy",
|
| | | "path": "pages/me/analy",
|
| | | "style": {
|
| | | "navigationStyle": "custom"
|
| | | }
|
| | |
| | | } |
| | | }, |
| | | { |
| | | "path" : "pages/tabBar/warning",
|
| | | "style" : |
| | | {
|
| | | "navigationStyle": "custom",
|
| | | "app-plus": {
|
| | | "titleNView": false
|
| | | }
|
| | | }
|
| | | }, |
| | | { |
| | | "path" : "pages/device/control", |
| | | "style" : |
| | | { |
| | |
| | | } |
| | | } |
| | | }
|
| | | |
| | | ],
|
| | | "globalStyle": {
|
| | | "navigationBarTextStyle": "white",
|
| | |
| | | "selectedIconPath": "static/tabBar/shop_cur.png",
|
| | | "text": "çæ§"
|
| | | }, {
|
| | | "pagePath": "pages/tabBar/analy",
|
| | | "pagePath": "pages/tabBar/warning",
|
| | | "iconPath": "static/tabBar/analy.png",
|
| | | "selectedIconPath": "static/tabBar/analy_cur.png",
|
| | | "text": "åæ"
|
| | | "text": "æ¥è¦"
|
| | | }, {
|
| | | "pagePath": "pages/tabBar/formula",
|
| | | "iconPath": "static/tabBar/order.png",
|
| | |
| | | if (account) {
|
| | | this.model = account
|
| | | }
|
| | | let _that = this
|
| | | // uni-app客æ·ç«¯è·åpush客æ·ç«¯æ è®°
|
| | | // uni.getPushClientId({
|
| | | // success: (res) => {
|
| | | // let push_clientid = res.cid
|
| | | // _that.model.username = push_clientid
|
| | | // console.log('客æ·ç«¯æ¨éæ è¯:', push_clientid)
|
| | | // },
|
| | | // fail(err) {
|
| | | // _that.model.username = err
|
| | | // console.log(err)
|
| | | // }
|
| | | // })
|
| | |
|
| | | // uni.onPushMessage((res) => {
|
| | | // _that.model.username = JSON.stringify(res)
|
| | | // console.log("æ¶å°æ¨éæ¶æ¯ï¼", res) //ç嬿¨éæ¶æ¯
|
| | | // })
|
| | |
|
| | |
|
| | |
|
| | | },
|
| | |
|
| | | computed: {
|
| | | cid() {
|
| | | return this.$store.getters.getCid; // ä½¿ç¨ getter è·å cid
|
| | | },
|
| | | },
|
| | | methods: { |
| | |
|
| | | forget() {
|
| | |
| | | uni.setStorageSync('token', res.result.token); |
| | | |
| | |
|
| | |
|
| | | uni.switchTab({
|
| | | url: '/pages/tabBar/general'
|
| | | })
|
| ÎļþÃû´Ó pages/tabBar/analy.vue ÐÞ¸Ä |
| | |
| | | <template>
|
| | | <view>
|
| | | <cu-custom bgColor="bg-gradual-blue" :isBack="false">
|
| | | <cu-custom bgColor="bg-gradual-blue" :isBack="true">
|
| | | <block slot="content">ç产记å½åæ</block>
|
| | | </cu-custom>
|
| | |
|
| | |
| | | </view>
|
| | | <view>
|
| | | <text
|
| | | class="text-gray margin-right-lg">{{new Date().toLocaleDateString().replace(/\//g, '-')}}</text>
|
| | | class="text-gray margin-right-lg">{{curDate}}</text>
|
| | | </view>
|
| | |
|
| | | </view>
|
| | |
| | | <view class="title text-cut">{{$lget(item,'name')}}</view>
|
| | | <view class="flex title text-green text-sm">
|
| | | <u-tag v-if="item.online" size="mini" text="å¨çº¿" type="success" plain plainFill></u-tag>
|
| | | <u-tag v-else class="" size="mini" text="åæº" type="error" plain plainFill></u-tag>
|
| | | <u-tag v-else size="mini" text="离线" type="warning" plain plainFill></u-tag>
|
| | | <u-tag v-if="item.online" class="margin-left-sm" size="mini" text="å¨çº¿" type="success" plain plainFill></u-tag>
|
| | | <u-tag v-else class="margin-left-sm" size="mini" text="åæº" type="error" plain plainFill></u-tag>
|
| | | </view>
|
| | | </view>
|
| | | <view class="right" style="min-width: 240rpx;">
|
| | |
| | | loading: true,
|
| | | // v-modelç»å®çè¿ä¸ªåéä¸è¦å¨å页请æ±ç»æä¸èªå·±èµå¼ï¼ï¼ï¼
|
| | | dataList: [],
|
| | | curDate:uni.$u.timeFormat(new Date(), 'yyyy-mm-dd'),
|
| | | }
|
| | | },
|
| | | methods: {
|
| | |
| | |
|
| | | -->
|
| | | <cu-custom bgColor="bg-gradual-blue" :isBack="false">
|
| | | <block slot="content">æºè½ä¸èè¯å¹²ç¥è®¾å¤é
å¥ç³»ç»</block>
|
| | | <block slot="content">æºè½ä¸èè¯</block>
|
| | | </cu-custom>
|
| | | <mqtt-view ref="mqttView"></mqtt-view>
|
| | | <u-toast ref="uToast"></u-toast>
|
| | | <!-- <view class="card-box dynamic shadow cu-list menu">
|
| | | <view class="title-box">
|
| | |
| | | </view>
|
| | | </view>
|
| | | </view> -->
|
| | | |
| | | </view>
|
| | | </template>
|
| | |
|
| | | <script>
|
| | | |
| | |
|
| | | export default {
|
| | | |
| | | data() {
|
| | | return {
|
| | | list: [{
|
| | |
| | | },
|
| | | onShow() {
|
| | | console.info('onShow')
|
| | | uni.showTabBarRedDot({
|
| | | index: 2 // æ¾ç¤ºç¬¬2个tabbar项ï¼ç´¢å¼ä»0å¼å§ï¼ç红ç¹
|
| | | });
|
| | |
|
| | |
|
| | | },
|
| | | mounted() {
|
| | | |
| | |
|
| | |
|
| | | },
|
| | | onReady() {
|
| | | const userinfo = uni.getStorageSync('userinfo');
|
| | | const tenantid = userinfo.loginTenantId
|
| | | uni.getSystemInfo({
|
| | | success: (res) => {
|
| | | let deviceId = res.deviceId
|
| | | if (!deviceId) {
|
| | | deviceId = 'mobile-' + tenantid + '-' + Date.parse(new Date())
|
| | | }
|
| | | uni.setStorageSync(this.$constant.DEVICE_ID, 'mobile-' + tenantid + '-' + res.deviceId);
|
| | | }
|
| | | })
|
| | | this.startConnect();
|
| | | this.$refs.mqttView.initMqtt()
|
| | | |
| | | // uni.getSystemInfo({
|
| | | // success: (res) => {
|
| | | // let deviceId = res.deviceId
|
| | | // if (!deviceId) {
|
| | | // deviceId = 'mobile-' + this.tenantId + '-' + Date.parse(new Date())
|
| | | // }
|
| | | // uni.setStorageSync(this.$constant.DEVICE_ID, 'mobile-' + this.tenantId + '-' + res.deviceId);
|
| | | // }
|
| | | // })
|
| | | // this.startConnect();
|
| | |
|
| | |
|
| | |
|
| | |
| | |
|
| | |
|
| | | },
|
| | | onLoad() {
|
| | | |
| | | },
|
| | | methods: {
|
| | | |
| | | /* è¿æ¥MQTT */
|
| | | async startConnect() {
|
| | | var _this = this
|
| | |
| | | //订é
æ¥è¯¢è®¾å¤ç¶æè¿åæ°æ®
|
| | | this.$mqttTool.subscribe({
|
| | | topic: this.$constant.SERVICE_DOWN + '/' + deviceid + '/#',
|
| | | qos: 0
|
| | | }).then(res => {
|
| | | console.error(res)
|
| | | })
|
| | | |
| | | //订é
è®¾å¤æ
é广æï¼å¹¿æä¸å¨ä¹å®¢æ·ç«¯idï¼åéç»ç§æ·ä¸ææå¨çº¿ç设å¤ï¼
|
| | | this.$mqttTool.subscribe({
|
| | | topic: this.$constant.SERVICE_BROADCAST_TENANT_REAL_FAULT.replace('%s', this.tenantId),
|
| | | qos: 0
|
| | | }).then(res => {
|
| | | console.error(res)
|
| | |
| | |
|
| | |
|
| | |
|
| | | },
|
| | | computed:{
|
| | | tenantId(){
|
| | | const userinfo = uni.getStorageSync('userinfo');
|
| | | const tenantid = userinfo.loginTenantId
|
| | | return tenantid;
|
| | | }
|
| | | |
| | | }
|
| | |
|
| | | }
|
| | |
| | | </button> |
| | | </view> --> |
| | | |
| | | <view class="cu-item">
|
| | | <button class='content cu-btn' @click="itemClick('analy')">
|
| | | <image src='../../static/me/icon/diannao.png' class='png' mode='aspectFit'></image>
|
| | | <text class='text-lg margin-sm'>åæ</text>
|
| | | </button>
|
| | | </view> |
| | | |
| | | |
| | | <view class="cu-item"> |
| | | <button class='content cu-btn' @click="exit"> |
| | |
| | | uni.navigateTo({ |
| | | url:"/pages/me/video" |
| | | }) |
| | | }else if(mode == 'analy'){ |
| | | uni.navigateTo({ |
| | | url:"/pages/me/analy" |
| | | }) |
| | | }else if(mode == 'other'){ |
| | | uni.navigateTo({ |
| | | url:"/pages/tabBar/monitor" |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template>
|
| | | <view class="app">
|
| | | <cu-custom bgColor="bg-gradual-blue" :isBack="false" :isRight="true" @rightclick="rclick">
|
| | | <block slot="content">æ¥è¦</block>
|
| | |
|
| | | </cu-custom>
|
| | | <u-notice-bar text="12:20:10 1车é´GM001æºå°çµæºè¿æµ(çµæ°)æ¥è¦" mode="closable"></u-notice-bar>
|
| | |
|
| | | <!--å¼¹åºå±start-->
|
| | | <view style="width: 100%; position: absolute;z-index: 1000;top:300rpx;padding: 20rpx;" @touchmove.prevent >
|
| | | <dropdown-menu v-show="filterMenuShow"@reset='resetMenu' @change='changeMenu' :list='equList' ref='dropdownMenuRef'/>
|
| | | |
| | | </view>
|
| | | <view class="lock-page dropdown-mask" @touchmove.prevent @click.stop="1==1" v-if="filterMenuShow"></view>
|
| | | |
| | | <!--å¼¹åºå±end-->
|
| | |
|
| | | <view class="card-box dynamic shadow">
|
| | | <view class="title-box margin-bottom-sm">
|
| | | <view style="width: 100vw;" class="left justify-between">
|
| | | <view class="flex align-center">
|
| | | <uni-text class="cuIcon-titles text-blue"></uni-text>
|
| | | <view class="title">æ»è§</view>
|
| | | </view>
|
| | | <view>
|
| | | <text class="text-gray text-sm">2024-10-01 è³ 2024-12-01</text>
|
| | | </view>
|
| | |
|
| | | </view>
|
| | |
|
| | | </view>
|
| | | <view class="flex flex-direction padding-xs">
|
| | | <view class="flex">
|
| | | <view class="flex-sub flex flex-direction">
|
| | | <text class="text-df">æ¥è¦æ»æ°</text>
|
| | | <text class="text-bold text-sl margin-top-xs text-red margin-top-sm">10
|
| | | <text class="text-gray text-sm margin-left-xs">次</text></text>
|
| | |
|
| | | </view>
|
| | | <view class="flex-twice flex flex-direction justify-between">
|
| | | <view class="flex-sub flex">
|
| | | <view class="flex flex-direction flex-sub">
|
| | | <text class="text-gray text-xs">æ¥è¦ä¿¡æ¯</text>
|
| | | <text class="text-black">
|
| | | <text class="text-black">æºæ¢°æ
é:</text>
|
| | | <text class="margin-lr-xs text-orange">0</text>
|
| | | <text class="text-gray text-xs">次</text>
|
| | | </text>
|
| | |
|
| | | </view>
|
| | | <view class="flex flex-direction flex-sub">
|
| | | <text class="text-white text-xs">çµæ°æ
é</text>
|
| | | <text class="text-black">
|
| | | <text class="text-black">çµæ°æ
é:</text>
|
| | | <text class="margin-lr-xs text-orange">1</text>
|
| | | <text class="text-gray text-xs">次</text>
|
| | | </text>
|
| | |
|
| | | </view>
|
| | |
|
| | | </view>
|
| | | <view class="flex-sub flex margin-top-sm">
|
| | | <view class="flex flex-direction flex-sub">
|
| | | <text class="text-gray text-xs">æ¥è¦ä¿¡æ¯</text>
|
| | | <text>
|
| | | <text class="text-black">éä¿¡æ
é:</text>
|
| | | <text class="margin-lr-xs text-orange">4</text>
|
| | | <text class="text-gray text-xs">次</text>
|
| | | </text>
|
| | |
|
| | | </view>
|
| | | <view class="flex flex-direction flex-sub">
|
| | | <text class="text-white text-xs">å
¶ä»æ
é</text>
|
| | | <text class="text-cyan">
|
| | | <text class="text-black">å
¶ä»æ
é:</text>
|
| | | <text class="margin-lr-xs text-orange">5</text>
|
| | | <text class="text-gray text-xs">次</text>
|
| | | </text>
|
| | | </view>
|
| | |
|
| | | </view>
|
| | |
|
| | | </view>
|
| | |
|
| | | </view>
|
| | | <view class="margin-top">
|
| | | <u-scroll-list>
|
| | |
|
| | | </u-scroll-list>
|
| | |
|
| | | </view>
|
| | |
|
| | | </view>
|
| | |
|
| | |
|
| | |
|
| | | </view>
|
| | |
|
| | | <u-sticky>
|
| | | <view class="tab-box card-box top dynamic shadow">
|
| | | <z-tabs ref="tabs" :active-style="{'font-size':'30rpx','font-weight':'bold'}" :current="tabCurrent"
|
| | | :list="tabList" @change="tabsChange">
|
| | | <!-- èªå®ä¹å³ä¾§ææ§½ -->
|
| | | <!-- <template v-slot:right>
|
| | | <u-icon name="setting" ></u-icon>
|
| | | </template> -->
|
| | | </z-tabs>
|
| | | </view>
|
| | | </u-sticky>
|
| | | <!-- å¯éè¿è®¾ç½®bar-animate-mode="worm"å¼å¯æ¯æ¯è«æ¨¡å¼-->
|
| | | <swiper :style="'height:' + swiperItemHeight[tabCurrent] + 'rpx;'" :current="tabCurrent"
|
| | | @transition="swiperTransition" @animationfinish="swiperAnimationfinish">
|
| | | <swiper-item :key="0">
|
| | | <view :style="'height:' + swiperItemHeight[0] + 'rpx;'">
|
| | |
|
| | | <view class="card-box center dynamic shadow">
|
| | | <view class="title-box margin-bottom-sm">
|
| | | <view style="width: 100vw;" class="left justify-between">
|
| | | <view class="flex align-center">
|
| | | <uni-text class="cuIcon-titles text-blue"></uni-text>
|
| | | <view class="title">è®¾å¤ </view>
|
| | | </view>
|
| | | <view>
|
| | | <!-- <text class="text-blue text-sm">æ´å¤></text> -->
|
| | | </view>
|
| | |
|
| | | </view>
|
| | |
|
| | | </view>
|
| | | <view class="borderTop">
|
| | | <image style="width: 100%;border-radius: 20rpx; " src="../../static/image/pic_gz.jpg"
|
| | | mode="aspectFit"></image>
|
| | | </view>
|
| | |
|
| | | </view>
|
| | |
|
| | | <view class="card-box center dynamic shadow">
|
| | | <view class="title-box margin-bottom-sm">
|
| | | <view style="width: 100vw;" class="left justify-between">
|
| | | <view class="flex align-center">
|
| | | <uni-text class="cuIcon-titles text-blue"></uni-text>
|
| | | <view class="title">宿¶æ¥è¦ </view>
|
| | | </view>
|
| | | <view>
|
| | | <!-- <text class="text-blue text-sm">æ´å¤></text> -->
|
| | | </view>
|
| | |
|
| | | </view>
|
| | |
|
| | | </view>
|
| | | <view class="borderTop" v-for="i in 10">
|
| | | <view style="height: 180rpx;display: flex;align-items: center;">
|
| | | <view>
|
| | | <image style="width: 80rpx;height: 80rpx;margin:20rpx;border-radius: 20rpx; "
|
| | | src="../../static/image/pic_gz.jpg"></image>
|
| | | </view>
|
| | | <view
|
| | | style="display: flex;flex: 1;flex-direction: column; justify-content: space-between; ;height: 100%;padding: 20rpx;">
|
| | | <view class="text-bold">
|
| | | æ»ççµæºè¿æµæ¥è¦
|
| | | </view>
|
| | | <view class="text-gray text-sm">
|
| | | 设å¤:1å·å¹²ç¥æº
|
| | | </view>
|
| | |
|
| | | <view class="text-gray text-sm">
|
| | | æè¿°:åæµå 1å·æ»ççµæºè¿æµæ¥è¦ï¼éè¦xxxxå¤çï¼ä¸æ¹èªç©ºçæ¢å¤å¾å¿«çåå¤
|
| | | </view>
|
| | |
|
| | | </view>
|
| | | <view style="width: 100rpx;">{{i}}</view>
|
| | |
|
| | | </view>
|
| | | </view>
|
| | |
|
| | | </view>
|
| | |
|
| | | <view class="card-box bot dynamic shadow">
|
| | | <view style="height: 20rpx;"></view>
|
| | | </view>
|
| | | </view>
|
| | | </swiper-item>
|
| | | <swiper-item :key="1">
|
| | | <view :style="'height:' + swiperItemHeight[1] + 'rpx;'">
|
| | | <view class="card-box center dynamic shadow">
|
| | | <view class="title-box margin-bottom-sm">
|
| | | <view style="width: 100vw;" class="left justify-between">
|
| | | <view class="flex align-center">
|
| | | <uni-text class="cuIcon-titles text-blue"></uni-text>
|
| | | <view class="title">æè¿æ¥è¦</view>
|
| | | </view>
|
| | | <view>
|
| | | <text class="text-blue text-sm">æ´å¤></text>
|
| | | </view>
|
| | |
|
| | | </view>
|
| | |
|
| | | </view>
|
| | |
|
| | |
|
| | | <view class="borderTop">
|
| | | <view class="h-table">
|
| | | <view class="h-tr h-tr-2 ">
|
| | | <view class="h-td">车é´</view>
|
| | | <view class="h-td">æºå°</view>
|
| | | <view class="h-td">æ¶é´</view>
|
| | | <view class="h-td">ç±»å</view>
|
| | | <view class="h-td">ç级</view>
|
| | |
|
| | |
|
| | | </view>
|
| | | <view class="h-tr h-tr-2">
|
| | | <view class="h-td">001</view>
|
| | | <view class="h-td">GM001</view>
|
| | | <view class="h-td">12:00:00</view>
|
| | | <view class="h-td">æºæ¢°</view>
|
| | | <view class="h-td">é«</view>
|
| | |
|
| | | </view>
|
| | | <view class="h-tr h-tr-2">
|
| | | <view class="h-td">001</view>
|
| | | <view class="h-td">GM001</view>
|
| | | <view class="h-td">12:00:00</view>
|
| | | <view class="h-td">éä¿¡</view>
|
| | | <view class="h-td">ä¸</view>
|
| | |
|
| | | </view>
|
| | | <view class="h-tr h-tr-2">
|
| | | <view class="h-td">001</view>
|
| | | <view class="h-td">GM001</view>
|
| | | <view class="h-td">12:00:00</view>
|
| | | <view class="h-td">çµæ°</view>
|
| | | <view class="h-td">é«</view>
|
| | |
|
| | | </view>
|
| | | </view>
|
| | |
|
| | | </view>
|
| | |
|
| | |
|
| | | </view>
|
| | |
|
| | | <view class="card-box center dynamic shadow">
|
| | | <view class="title-box margin-bottom-sm">
|
| | | <view style="width: 100vw;" class="left justify-between">
|
| | | <view class="flex align-center">
|
| | | <uni-text class="cuIcon-titles text-blue"></uni-text>
|
| | | <view class="title">æ¥è¦ç»è®¡</view>
|
| | | </view>
|
| | | <view>
|
| | | <text class="text-gray text-sm"></text>
|
| | | </view>
|
| | |
|
| | | </view>
|
| | |
|
| | | </view>
|
| | |
|
| | |
|
| | | <view class="chartsMain">
|
| | | <qiun-data-charts type="mount" :opts="opts" :animation="true" :chartData="Mount" />
|
| | | </view>
|
| | | </view>
|
| | |
|
| | |
|
| | | <view class="card-box center dynamic shadow">
|
| | | <view class="title-box margin-bottom-sm">
|
| | | <view style="width: 100vw;" class="left justify-between">
|
| | | <view class="flex align-center">
|
| | | <uni-text class="cuIcon-titles text-blue"></uni-text>
|
| | | <view class="title">æ¥è¦å¯¹æ¯</view>
|
| | | </view>
|
| | | <view>
|
| | | <text class="text-gray text-sm"></text>
|
| | | </view>
|
| | |
|
| | | </view>
|
| | |
|
| | | </view>
|
| | |
|
| | | <view class="chartsMain">
|
| | |
|
| | | <qiun-data-charts type="pie" :opts="optsPie" :chartData="PieA" />
|
| | |
|
| | | </view>
|
| | | </view>
|
| | |
|
| | |
|
| | |
|
| | | <view class="card-box center dynamic shadow">
|
| | | <view class="title-box margin-bottom-sm">
|
| | | <view style="width: 100vw;" class="left justify-between">
|
| | | <view class="flex align-center">
|
| | | <uni-text class="cuIcon-titles text-blue"></uni-text>
|
| | | <view class="title">æ¥è¦é¢ç</view>
|
| | | </view>
|
| | | <view>
|
| | | <text class="text-gray text-sm"></text>
|
| | | </view>
|
| | |
|
| | | </view>
|
| | |
|
| | | </view>
|
| | |
|
| | |
|
| | | <view class="chartsMain">
|
| | | <!-- <qiun-data-charts type="mount" :opts="{extra:{mount:{type:'mount',widthRatio:1.5}}}"
|
| | | :chartData="Mount" /> -->
|
| | | <qiun-data-charts type="word" :chartData="Word" />
|
| | | </view>
|
| | | </view>
|
| | |
|
| | | <view class="card-box bot dynamic shadow">
|
| | | <view class="title-box margin-bottom-sm">
|
| | | <view style="width: 100vw;" class="left justify-between">
|
| | | <view class="flex align-center">
|
| | | <uni-text class="cuIcon-titles text-blue"></uni-text>
|
| | | <view class="title">æ¥è¦åæ</view>
|
| | | </view>
|
| | | <view>
|
| | | <text class="text-gray text-sm"></text>
|
| | | </view>
|
| | |
|
| | | </view>
|
| | |
|
| | | </view>
|
| | |
|
| | |
|
| | | <view class="chartsMain">
|
| | |
|
| | | <qiun-data-charts type="radar" :opts="optsRadar" :chartData="dataRadar" />
|
| | | </view>
|
| | | </view>
|
| | |
|
| | |
|
| | | </view>
|
| | | </swiper-item>
|
| | | </swiper>
|
| | |
|
| | |
|
| | | </view>
|
| | | </template>
|
| | |
|
| | | <script>
|
| | | import dropdownMenu from '@/components/drop-down-menu/index.vue'
|
| | | export default {
|
| | | components: {
|
| | | dropdownMenu
|
| | | },
|
| | | data() {
|
| | | return {
|
| | | equList: [{
|
| | | code: 1,
|
| | | name: '1#å¹²ç¥æº'
|
| | | },
|
| | | {
|
| | | code: 2,
|
| | | name: '2#å¹²ç¥æº'
|
| | | } |
| | | ],
|
| | | model: {},
|
| | | filterMenuShow: false,
|
| | | tabCurrent: 0,
|
| | | swiperItemHeight: [2800, 2140],
|
| | | tabList: [{
|
| | | name: '宿¶æ¥è¦',
|
| | | badge: {
|
| | | count: 6
|
| | | }
|
| | | }, {
|
| | | name: 'æ¥è¦ç»è®¡',
|
| | | }],
|
| | | PieA: {
|
| | | "series": [{
|
| | | "data": [{
|
| | | "name": "æºæ¢°",
|
| | | "value": 50,
|
| | | "labelText": "æºæ¢°:50次"
|
| | | }, {
|
| | | "name": "çµæ°",
|
| | | "value": 30,
|
| | | "labelText": "çµæ°:30次"
|
| | | }, {
|
| | | "name": "éä¿¡",
|
| | | "value": 20,
|
| | | "labelText": "éä¿¡:20次"
|
| | | }, {
|
| | | "name": "å
¶ä»",
|
| | | "value": 18,
|
| | | "labelText": "å
¶ä»:18次"
|
| | | }]
|
| | | }]
|
| | | },
|
| | | dataRadar: {
|
| | |
|
| | | categories: ["æºæ¢°", "çµæ°", "éä¿¡", "å
¶ä»"],
|
| | | series: [{
|
| | | name: "æ¥è¦å æ¯",
|
| | | data: [99, 30, 18, 73]
|
| | | }]
|
| | |
|
| | | },
|
| | |
|
| | | Mount: {
|
| | | "series": [{
|
| | |
|
| | | "data": [{
|
| | | "name": "æºæ¢°",
|
| | | "value": 82
|
| | | }, {
|
| | | "name": "çµæ°",
|
| | | "value": 63
|
| | | }, {
|
| | | "name": "éä¿¡",
|
| | | "value": 86
|
| | | }, {
|
| | | "name": "å
¶ä»",
|
| | | "value": 65
|
| | | }]
|
| | | }]
|
| | | },
|
| | | Word: {
|
| | | "series": [{
|
| | | "name": "飿ºè¿æµ",
|
| | | "textSize": 25
|
| | | }, {
|
| | | "name": "å鍿ªå
³é",
|
| | | "textSize": 20
|
| | | }, {
|
| | | "name": "é£ç®±åå¼å¸¸",
|
| | | "textSize": 20
|
| | | }, {
|
| | | "name": "çµæºè¿æµ",
|
| | | "textSize": 20
|
| | | }, {
|
| | | "name": "å çä½ä¼ æå¨",
|
| | | "textSize": 20
|
| | | }, {
|
| | | "name": "å çæ¶é´å¼å¸¸",
|
| | | "textSize": 20
|
| | | }, {
|
| | | "name": "æ»çåå¼å¸¸",
|
| | | "textSize": 20
|
| | | }, {
|
| | | "name": "é£ç®±ä¸å¨å çä½",
|
| | | "textSize": 20
|
| | | }, {
|
| | | "name": "æ»çä¸å¨å çä½",
|
| | | "textSize": 10
|
| | | }]
|
| | | },
|
| | | opts: {
|
| | | color: ["#1890FF", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4",
|
| | | "#ea7ccc"
|
| | | ],
|
| | | padding: [15, 15, 0, 5],
|
| | | enableScroll: false,
|
| | | legend: {
|
| | | show: true
|
| | | },
|
| | |
|
| | | xAxis: {
|
| | | disableGrid: true
|
| | | },
|
| | | yAxis: {
|
| | | gridColor: "rgba(230,230,230,0.6)",
|
| | |
|
| | | data: [
|
| | |
|
| | | {
|
| | | min: 0
|
| | | }
|
| | | ]
|
| | | },
|
| | | extra: {
|
| | | mount: {
|
| | | type: "bar",
|
| | | widthRatio: 0.3,
|
| | | borderWidth: 0,
|
| | | barBorderRadius: [
|
| | | 50,
|
| | | 50,
|
| | | 50,
|
| | | 50
|
| | | ],
|
| | | linearType: "custom"
|
| | | }
|
| | | }
|
| | | },
|
| | | optsPie: {
|
| | | color: ["#1890FF", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4",
|
| | | "#ea7ccc"
|
| | | ],
|
| | | padding: [5, 5, 5, 5],
|
| | | enableScroll: false,
|
| | | extra: {
|
| | | pie: {
|
| | | activeOpacity: 0.5,
|
| | | activeRadius: 10,
|
| | | offsetAngle: 0,
|
| | | labelWidth: 1,
|
| | | border: true,
|
| | | borderWidth: 3,
|
| | | borderColor: "#FFFFFF",
|
| | | linearType: "custom"
|
| | | }
|
| | | }
|
| | | },
|
| | | optsRadar: {
|
| | | color: ["#1890FF", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4",
|
| | | "#ea7ccc"
|
| | | ],
|
| | | padding: [5, 5, 5, 5],
|
| | | dataLabel: true,
|
| | | dataPointShape: false,
|
| | | enableScroll: false,
|
| | | legend: {
|
| | | show: false,
|
| | | position: "right",
|
| | | lineHeight: 25
|
| | | },
|
| | | extra: {
|
| | | radar: {
|
| | | gridType: "circle",
|
| | | gridColor: "#CCCCCC",
|
| | | gridCount: 3,
|
| | | opacity: 1,
|
| | | max: 100,
|
| | | labelShow: true,
|
| | | linearType: "custom",
|
| | | border: false
|
| | | }
|
| | | }
|
| | | },
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | }
|
| | | },
|
| | | computed: {
|
| | |
|
| | |
|
| | | },
|
| | | created() {
|
| | | |
| | | },
|
| | | beforeDestroy() {
|
| | | |
| | | },
|
| | | methods: {
|
| | | mqttTopicMessage(){
|
| | | //å¤çæ¶æ¯é»è¾
|
| | | switch(topic){
|
| | | case _this.$constant.SERVICE_BROADCAST_TENANT_REAL_FAULT.replace('%s', that.tenantId):
|
| | | console.error(that.$constant.SERVICE_BROADCAST_TENANT_REAL_FAULT.replace('%s', that.tenantId))
|
| | | console.error("æ¶å°å¹¿æ")
|
| | | |
| | | break
|
| | | } |
| | | },
|
| | | changeMenu(selectData){
|
| | | console.info(selectData)
|
| | | this.filterMenuShow = false
|
| | | |
| | | |
| | | },
|
| | | resetMenu(selectData){
|
| | | console.info(selectData)
|
| | | |
| | | },
|
| | | rclick() {
|
| | | this.filterMenuShow=!this.filterMenuShow
|
| | | },
|
| | | //tabséç¥swiper忢
|
| | | tabsChange(index) {
|
| | | this.tabCurrent = index;
|
| | | },
|
| | | //swiperæ»å¨ä¸
|
| | | swiperTransition(e) {
|
| | | this.$refs.tabs.setDx(e.detail.dx);
|
| | | },
|
| | | //swiperæ»å¨ç»æ
|
| | | swiperAnimationfinish(e) {
|
| | | this.tabCurrent = e.detail.current;
|
| | | this.$refs.tabs.unlockDx();
|
| | | },
|
| | |
|
| | | }
|
| | | }
|
| | | </script>
|
| | |
|
| | | <style lang="scss" scoped>
|
| | | @import "components/table/helang-table";
|
| | |
|
| | | .app {
|
| | | position: relative;
|
| | | }
|
| | |
|
| | | .card-box {
|
| | | margin: 20rpx;
|
| | | padding: 20rpx;
|
| | | box-sizing: border-box;
|
| | | background-color: white;
|
| | | border-radius: 20rpx;
|
| | | font-family: Helvetica Neue, Helvetica, sans-serif;
|
| | |
|
| | | }
|
| | |
|
| | |
|
| | | .top {
|
| | | margin: 0 20rpx;
|
| | | border-radius: 0;
|
| | | border-top-left-radius: 20rpx;
|
| | | border-top-right-radius: 20rpx;
|
| | | border-bot-left-radius: 0;
|
| | | border-bot-right-radius: 0;
|
| | |
|
| | | }
|
| | |
|
| | | .center {
|
| | | margin: 0 20rpx;
|
| | | border-radius: 0;
|
| | |
|
| | | }
|
| | |
|
| | | .bot {
|
| | | margin: 0 20rpx 20rpx 20rpx;
|
| | | border-top-left-radius: 0;
|
| | | border-top-right-radius: 0;
|
| | | border-bot-left-radius: 20rpx;
|
| | | border-bot-right-radius: 20rpx;
|
| | | }
|
| | |
|
| | |
|
| | | .title-box {
|
| | | display: flex;
|
| | | flex-direction: row;
|
| | | align-items: center;
|
| | |
|
| | | .left {
|
| | | display: flex;
|
| | | align-items: center;
|
| | |
|
| | | .title {
|
| | | margin: 0 10rpx;
|
| | | font-weight: bold;
|
| | | }
|
| | | }
|
| | |
|
| | | .right {
|
| | | display: flex;
|
| | | align-items: center;
|
| | |
|
| | | .title {
|
| | | margin: 0 10rpx;
|
| | | font-weight: bold;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | .info-box {
|
| | | margin-top: 20rpx;
|
| | | display: flex;
|
| | | flex-direction: row;
|
| | | align-items: center;
|
| | |
|
| | | .left {
|
| | | display: flex;
|
| | | align-items: center;
|
| | |
|
| | | .title {
|
| | | margin: 0 10rpx;
|
| | | }
|
| | | }
|
| | |
|
| | | .right {
|
| | | display: flex;
|
| | | align-items: center;
|
| | |
|
| | | .title {
|
| | | margin: 0 10rpx;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | .chartsMain {
|
| | | width: 100%;
|
| | | height: 320rpx;
|
| | | padding-top: 15rpx;
|
| | | background: #fff;
|
| | | margin-bottom: 24rpx;
|
| | | border-top: 2rpx solid #f2f2f2;
|
| | |
|
| | | .charts {
|
| | | width: 50%;
|
| | | height: 450rpx;
|
| | | box-sizing: border-box;
|
| | | }
|
| | | }
|
| | |
|
| | | .tab-box {
|
| | | display: flex;
|
| | | justify-content: center;
|
| | | /* å¼ºå¶æ°´å¹³å±
ä¸ */
|
| | | }
|
| | |
|
| | | .swiper {
|
| | | height: 2116rpx;
|
| | | }
|
| | |
|
| | | .swiper-item-view {
|
| | | height: 2116rpx;
|
| | |
|
| | |
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | .picBox {
|
| | | margin: 0 20rpx;
|
| | | background-color: white;
|
| | |
|
| | | image {
|
| | | border-radius: 8rpx;
|
| | | width: 100%;
|
| | |
|
| | | }
|
| | | }
|
| | |
|
| | | .borderTop {
|
| | | border-top: 2rpx solid #f2f2f2;
|
| | | padding-top: 20rpx;
|
| | | }
|
| | |
|
| | | // å¼¹åºå±èæ¯é®ç½©start
|
| | | .dropdown-mask {
|
| | | background: rgba(0, 0, 0, 0.5);
|
| | | }
|
| | | .lock-page {
|
| | | height: 100vh;
|
| | | width: 100vw;
|
| | | position: fixed;
|
| | | top: 0;
|
| | | left: 0;
|
| | | right: 0;
|
| | | bottom: 0;
|
| | | z-index: 998;
|
| | | }
|
| | | // å¼¹åºå±èæ¯é®ç½©end
|
| | | </style> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | import Vue from 'vue'; |
| | | import Vuex from 'vuex';
|
| | | Vue.use(Vuex);
|
| | | |
| | | const store = new Vuex.Store({ |
| | | state: {
|
| | | // å®ä¹cidé»è®¤å¼ |
| | | cid: null |
| | | }, |
| | | mutations: { |
| | | setCid(state, cid) {
|
| | | state.cid = cid;
|
| | | }, |
| | | }, |
| | | actions: { |
| | | setCid({ commit }, cid) {
|
| | | commit('setCid', cid);
|
| | | }, |
| | | }, |
| | | getters: { |
| | | getCid(state) { |
| | | return state.cid; |
| | | } |
| | | } |
| | | }); |
| | | |
| | | export default store; |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | ## 2.2.38ï¼2024-10-15ï¼ |
| | | - ä¿®å¤ å¾®ä¿¡å°ç¨åºä¸çgetSystemInfoè¦å |
| | | ## 2.2.37ï¼2024-10-12ï¼ |
| | | - ä¿®å¤ å¾®ä¿¡å°ç¨åºä¸çgetSystemInfoè¦å |
| | | ## 2.2.36ï¼2024-10-12ï¼ |
| | | - ä¿®å¤ å¾®ä¿¡å°ç¨åºä¸çgetSystemInfoè¦å |
| | | ## 2.2.35ï¼2024-09-21ï¼ |
| | | - ä¿®å¤ æ²¡æé䏿¥ææ¶ç¹å»ç¡®å®ç´æ¥æ¥éçBug [详æ
](https://ask.dcloud.net.cn/question/198168) |
| | | ## 2.2.34ï¼2024-04-24ï¼ |
| | | - æ°å¢ æ¥æç¹å»äºä»¶ï¼å¨ç¹å»æ¥ææ¶ä¼è§¦å该äºä»¶ã |
| | | ## 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ï¼ |
| | | - ä¿®å¤ h5å¹³å° å³è¾¹æ¥åçæä»½é»è®¤+1çbug [详æ
](https://github.com/dcloudio/uni-ui/issues/841) |
| | | ## 2.2.30ï¼2024-01-31ï¼ |
| | | - ä¿®å¤ éèâç§âæ¶ï¼å¨IOS15å以ä¸çæ¬æ¶åºç° ç»ææ¶é´å¨å¼å§æ¶é´ä¹å çbug [详æ
](https://github.com/dcloudio/uni-ui/issues/788) |
| | | ## 2.2.29ï¼2024-01-20ï¼ |
| | | - æ°å¢ showäºä»¶ï¼å¼¹çªå¼¹åºæ¶è§¦å该äºä»¶ [详æ
](https://github.com/dcloudio/uni-app/issues/4694) |
| | | ## 2.2.28ï¼2024-01-18ï¼ |
| | | - å»é¤ noChangeäºä»¶ï¼å½è¿è¡æ¥æèå´éæ©æ¶ï¼è¥åªéäºä¸å¤©ï¼åå¼å§ç»ææ¥æé½ä¸ºåä¸å¤© [详æ
](https://github.com/dcloudio/uni-ui/issues/815) |
| | | ## 2.2.27ï¼2024-01-10ï¼ |
| | | - ä¼å å¢å noChangeäºä»¶ï¼å½è¿è¡æ¥æèå´éæ©æ¶ï¼è¥æç©ºå¼ï¼å触å该äºä»¶ [详æ
](https://github.com/dcloudio/uni-ui/issues/815) |
| | | ## 2.2.26ï¼2024-01-08ï¼ |
| | | - ä¿®å¤ åèå°ç¨åºæ¶é´éæ©èå´å¨å¤±æé®é¢ [详æ
](https://github.com/dcloudio/uni-ui/issues/834) |
| | | ## 2.2.25ï¼2023-10-18ï¼ |
| | | - ä¿®å¤ PCç«¯åæ¬¡ä¿®æ¹æ¶é´ï¼å¼å§æ¶é´æªæ´æ°çBug [详æ
](https://github.com/dcloudio/uni-ui/issues/737) |
| | | ## 2.2.24ï¼2023-06-02ï¼ |
| | | - ä¿®å¤ é¨åæ
åµä¿®æ¹æ¶é´ï¼å¼å§ãç»ææ¶é´æ¾ç¤ºå¼å¸¸çBug [详æ
](https://ask.dcloud.net.cn/question/171146) |
| | | - ä¼å å½åæå¯ä»¥éæ©ä¸æãä¸æçæ¥æçBug |
| | | ## 2.2.23ï¼2023-05-02ï¼ |
| | | - ä¿®å¤ é¨åæ
åµä¿®æ¹æ¶é´ï¼å¼å§æ¶é´æªæ´æ°çBug [详æ
](https://github.com/dcloudio/uni-ui/issues/737) |
| | | - ä¿®å¤ é¨åå¹³å°å设å¤ç¬¬ä¸æ¬¡ç¹å»æ æ³æ¾ç¤ºå¼¹æ¡çBug |
| | | - ä¿®å¤ ios æ¥ææ ¼å¼æªè¡¥é¶æ¾ç¤ºå使ç¨å¼å¸¸çBug [详æ
](https://ask.dcloud.net.cn/question/162979) |
| | | ## 2.2.22ï¼2023-03-30ï¼ |
| | | - ä¿®å¤ æ¥å picker ä¿®æ¹å¹´æåï¼èªå¨éä¸å½æ1æ¥çBug [详æ
](https://ask.dcloud.net.cn/question/165937) |
| | | - ä¿®å¤ å°ç¨åºç«¯ ä½çæ¬ ios NaNçBug [详æ
](https://ask.dcloud.net.cn/question/162979) |
| | | ## 2.2.21ï¼2023-02-20ï¼ |
| | | - ä¿®å¤ firefox æµè§å¨æ¾ç¤ºåºåç¹å»æ æ³æèµ·æ¥åå¼¹æ¡çBug [详æ
](https://ask.dcloud.net.cn/question/163362) |
| | | ## 2.2.20ï¼2023-02-17ï¼ |
| | | - ä¼å å¼ä¸ºç©ºä¾ç¶éä¸å½å¤©é®é¢ |
| | | - ä¼å æä¾ default-value 屿§æ¯æé
ç½®éæ©å¨æå¼æ¶é»è®¤æ¾ç¤ºçæ¶é´ |
| | | - ä¼å éèå´éæ©æªéæ©æ¥ææ¶é´ï¼ç¹å»ç¡®è®¤æé®éä¸å½åæ¥ææ¶é´ |
| | | - ä¼å åèå°ç¨åºæ¥ææ¶é´èå´éæ©ï¼åºé¨æ¥ææ¢è¡çBug |
| | | ## 2.2.19ï¼2023-02-09ï¼ |
| | | - ä¿®å¤ 2.2.18 å¼èµ·èå´éæ©é
ç½® end éæ©æ æçBug [详æ
](https://github.com/dcloudio/uni-ui/issues/686) |
| | | ## 2.2.18ï¼2023-02-08ï¼ |
| | | - ä¿®å¤ ç§»å¨ç«¯èå´éæ©changeäºä»¶è§¦åå¼å¸¸çBug [详æ
](https://github.com/dcloudio/uni-ui/issues/684) |
| | | - ä¼å PC端è¾å
¥æ¥ææ ¼å¼é误æ¶è¿åå½åæ¥ææ¶é´ |
| | | - ä¼å PC端è¾å
¥æ¥ææ¶é´è¶
åº startãend éå¶çBug |
| | | - ä¼å ç§»å¨ç«¯æ¥ææ¶é´èå´ç¨æ³æ¶é´å±ç¤ºä¸å®æ´é®é¢ |
| | | ## 2.2.17ï¼2023-02-04ï¼ |
| | | - ä¿®å¤ å°ç¨åºç«¯ç»å® Date ç±»åæ¥éçBug [详æ
](https://github.com/dcloudio/uni-ui/issues/679) |
| | | - ä¿®å¤ vue3 time-picker æ æ³æ¾ç¤ºç»å®æ¶åç§çBug |
| | | ## 2.2.16ï¼2023-02-02ï¼ |
| | | - ä¿®å¤ åèå°ç¨åºæ¥éçBug |
| | | ## 2.2.15ï¼2023-02-02ï¼ |
| | | - ä¿®å¤ æäºæ
åµåæ¢æä»½é误çBug |
| | | ## 2.2.14ï¼2023-01-30ï¼ |
| | | - ä¿®å¤ æäºæ
åµåæ¢æä»½é误çBug [详æ
](https://ask.dcloud.net.cn/question/162033) |
| | | ## 2.2.13ï¼2023-01-10ï¼ |
| | | - ä¿®å¤ å¤æ¬¡å è½½ç»ä»¶é æå
åå ç¨çBug |
| | | ## 2.2.12ï¼2022-12-01ï¼ |
| | | - ä¿®å¤ vue3 ä¸ i18n å½é
ååå§å¼ä¸æ£ç¡®çBug |
| | | ## 2.2.11ï¼2022-09-19ï¼ |
| | | - ä¿®å¤ æ¯ä»å®å°ç¨åºæ ·å¼éä¹±çBug [详æ
](https://github.com/dcloudio/uni-app/issues/3861) |
| | | ## 2.2.10ï¼2022-09-19ï¼ |
| | | - ä¿®å¤ ååéæ©æ¥æèå´ï¼æ¥ææ¾ç¤ºå¼å¸¸çBug [详æ
](https://ask.dcloud.net.cn/question/153401?item_id=212892&rf=false) |
| | | ## 2.2.9ï¼2022-09-16ï¼ |
| | | - å¯ä»¥ä½¿ç¨ uni-scss æ§å¶ä¸»é¢è² |
| | | ## 2.2.8ï¼2022-09-08ï¼ |
| | | - ä¿®å¤ closeäºä»¶æ æçBug |
| | | ## 2.2.7ï¼2022-09-05ï¼ |
| | | - ä¿®å¤ ç§»å¨ç«¯ maskClick æ æçBug [详æ
](https://ask.dcloud.net.cn/question/140824) |
| | | ## 2.2.6ï¼2022-06-30ï¼ |
| | | - ä¼å ç»ä»¶æ ·å¼ï¼è°æ´äºç»ä»¶å¾æ 大å°ãé«åº¦ãé¢è²çï¼ä¸uni-ui飿 ¼ä¿æä¸è´ |
| | | ## 2.2.5ï¼2022-06-24ï¼ |
| | | - ä¿®å¤ æ¥åé¡¶é¨å¹´æååºé¨ç¡®è®¤æªå½é
åçBug |
| | | ## 2.2.4ï¼2022-03-31ï¼ |
| | | - ä¿®å¤ Vue3 ä¸å¨æèµå¼,åéç±»åæªååºçBug |
| | | ## 2.2.3ï¼2022-03-28ï¼ |
| | | - ä¿®å¤ Vue3 ä¸å¨æèµå¼æªååºçBug |
| | | ## 2.2.2ï¼2021-12-10ï¼ |
| | | - ä¿®å¤ clear-icon 屿§å¨å°ç¨åºå¹³å°ä¸çæçBug |
| | | ## 2.2.1ï¼2021-12-10ï¼ |
| | | - ä¿®å¤ æ¥æèå´éå¨å°ç¨åºå¹³å°ï¼å¿
é¡»å¤ç¹å»ä¸æ¬¡æè½åæ¶éä¸ç¶æçBug |
| | | ## 2.2.0ï¼2021-11-19ï¼ |
| | | - ä¼å ç»ä»¶UIï¼å¹¶æä¾è®¾è®¡èµæº [详æ
](https://uniapp.dcloud.io/component/uniui/resource) |
| | | - ææ¡£è¿ç§» [https://uniapp.dcloud.io/component/uniui/uni-datetime-picker](https://uniapp.dcloud.io/component/uniui/uni-datetime-picker) |
| | | ## 2.1.5ï¼2021-11-09ï¼ |
| | | - æ°å¢ æä¾ç»ä»¶è®¾è®¡èµæºï¼ç»ä»¶æ ·å¼è°æ´ |
| | | ## 2.1.4ï¼2021-09-10ï¼ |
| | | - ä¿®å¤ hide-second å¨ç§»å¨ç«¯çBug |
| | | - ä¿®å¤ åéèµé»è®¤å¼æ¶ï¼èµå¼æ¥ææªé«äº®çBug |
| | | - ä¿®å¤ èµé»è®¤å¼æ¶ï¼ç§»å¨ç«¯æªæ£ç¡®æ¾ç¤ºæ¶é´çBug |
| | | ## 2.1.3ï¼2021-09-09ï¼ |
| | | - æ°å¢ hide-second 屿§ï¼æ¯æåªä½¿ç¨æ¶åï¼éèç§ |
| | | ## 2.1.2ï¼2021-09-03ï¼ |
| | | - ä¼å åæ¶é䏿¶ï¼èå´éï¼ç´æ¥å¼å§ä¸ä¸æ¬¡éæ©, é¿å
å¤ç¹ä¸æ¬¡ |
| | | - ä¼å ç§»å¨ç«¯æ¯ææ¸
餿é®ï¼åæ¶æ¯æéè¿ ref è°ç¨ç»ä»¶ç clear æ¹æ³ |
| | | - ä¼å è°æ´åå·å¤§å°ï¼ç¾åæ¥åçé¢ |
| | | - ä¿®å¤ å å½é
å导è´ç placeholder 失æçBug |
| | | ## 2.1.1ï¼2021-08-24ï¼ |
| | | - æ°å¢ æ¯æå½é
å |
| | | - ä¼å èå´éæ©å¨å¨ pc 端è¿å®½çé®é¢ |
| | | ## 2.1.0ï¼2021-08-09ï¼ |
| | | - æ°å¢ éé
vue3 |
| | | ## 2.0.19ï¼2021-08-09ï¼ |
| | | - æ°å¢ æ¯æä½ä¸º uni-forms åç»ä»¶ç¸å
³åè½ |
| | | - ä¿®å¤ å¨ uni-forms ä¸ä½¿ç¨æ¶ï¼éæ©æ¶é´æ¥ NAN é误çBug |
| | | ## 2.0.18ï¼2021-08-05ï¼ |
| | | - ä¿®å¤ type 屿§å¨æèµå¼æ æçBug |
| | | - ä¿®å¤ â确认âæé®è¢« tabbar é®ç bug |
| | | - ä¿®å¤ ç»ä»¶æªèµå¼æ¶èå´éå·¦ã峿¥åç¸åçBug |
| | | ## 2.0.17ï¼2021-08-04ï¼ |
| | | - ä¿®å¤ èå´éæªæ£ç¡®æ¾ç¤ºå½åå¼çBug |
| | | - ä¿®å¤ h5 å¹³å°ï¼ç§»å¨ç«¯ï¼æ¥é 'cale' of undefined çBug |
| | | ## 2.0.16ï¼2021-07-21ï¼ |
| | | - æ°å¢ return-type 屿§æ¯æè¿å date æ¥æå¯¹è±¡ |
| | | ## 2.0.15ï¼2021-07-14ï¼ |
| | | - ä¿®å¤ å鿥æç±»åï¼åå§èµå¼åä¸å¨å½åæ¥åçBug |
| | | - æ°å¢ clearIcon 屿§ï¼æ¾ç¤ºæ¡çæ¸
空æé®å¯é
ç½®æ¾ç¤ºéèï¼ä»
pc ææï¼ |
| | | - ä¼å ç§»å¨ç«¯ç§»é¤æ¾ç¤ºæ¡çæ¸
空æé®ï¼æ å®é
ç¨é |
| | | ## 2.0.14ï¼2021-07-14ï¼ |
| | | - ä¿®å¤ ç»ä»¶èµå¼ä¸ºç©ºï¼ç颿ªæ´æ°çBug |
| | | - ä¿®å¤ start å end ä¸è½å¨æèµå¼çBug |
| | | - ä¿®å¤ èå´éç±»åï¼ç¨æ·éæ©å忬¡éæ©å³ä¾§æ¥åï¼ç»ææ¥æï¼æ¾ç¤ºä¸æ£ç¡®çBug |
| | | ## 2.0.13ï¼2021-07-08ï¼ |
| | | - ä¿®å¤ èå´éæ©ä¸è½å¨æèµå¼çBug |
| | | ## 2.0.12ï¼2021-07-08ï¼ |
| | | - ä¿®å¤ èå´éæ©çåå§æ¶é´å¨ä¸ä¸ªæå
æ¶ï¼é ææ æ³éæ©çbug |
| | | ## 2.0.11ï¼2021-07-08ï¼ |
| | | - ä¼å å¼¹åºå±å¨è¶
åºè§çªè¾¹ç¼å®ä½ä¸åç¡®çé®é¢ |
| | | ## 2.0.10ï¼2021-07-08ï¼ |
| | | - ä¿®å¤ èå´èµ·å§ç¹æ ·å¼çèæ¯è²ä¸ä»æ¥æ ·å¼çåä½åæ¯è²èåï¼å¯¼è´æ¥æåä½ç䏿¸
çBug |
| | | - ä¼å å¼¹åºå±å¨è¶
åºè§çªè¾¹ç¼è¢«é®ççé®é¢ |
| | | ## 2.0.9ï¼2021-07-07ï¼ |
| | | - æ°å¢ maskClick äºä»¶ |
| | | - ä¿®å¤ ç¹æ®æ
嵿¥å rpx å¸å±é误çBugï¼rpx -> px |
| | | - ä¿®å¤ èå´éæ©æ¶æ¸
空è¿åå¼ä¸åççbugï¼['', ''] -> [] |
| | | ## 2.0.8ï¼2021-07-07ï¼ |
| | | - æ°å¢ æ¥ææ¶é´æ¾ç¤ºæ¡æ¯æææ§½ |
| | | ## 2.0.7ï¼2021-07-01ï¼ |
| | | - ä¼å æ·»å uni-icons ä¾èµ |
| | | ## 2.0.6ï¼2021-05-22ï¼ |
| | | - ä¿®å¤ å¾æ å¨å°ç¨åºä¸ä¸æ¾ç¤ºçBug |
| | | - ä¼å éå½åå¼ç¨ç»ä»¶ï¼é¿å
æ½å¨ç»ä»¶å½åå²çª |
| | | ## 2.0.5ï¼2021-05-20ï¼ |
| | | - ä¼å 代ç ç®å½æå¹³å |
| | | ## 2.0.4ï¼2021-05-12ï¼ |
| | | - æ°å¢ ç»ä»¶ç¤ºä¾å°å |
| | | ## 2.0.3ï¼2021-05-10ï¼ |
| | | - ä¿®å¤ ios ä¸ä¸è¯å« '-' æ¥ææ ¼å¼çBug |
| | | - ä¼å pc ä¸å¼¹åºå±æ·»å è¾¹æ¡åé´å½± |
| | | ## 2.0.2ï¼2021-05-08ï¼ |
| | | - ä¿®å¤ å¨ admin ä¸è·åå¼¹åºå±å®ä½é误çbug |
| | | ## 2.0.1ï¼2021-05-08ï¼ |
| | | - ä¿®å¤ type 屿§åä¸å
¼å®¹ï¼é»è®¤å¼ä» date åæ´ä¸º datetime |
| | | ## 2.0.0ï¼2021-04-30ï¼ |
| | | - æ¯ææ¥åå½¢å¼çæ¥æ+æ¶é´çèå´éæ© |
| | | > 注æï¼æ¤çæ¬ä¸ååå
¼å®¹ï¼ä¸åæ¯æåç¬æ¶é´éæ©ï¼type=timeï¼åç¸å
³ç hide-second 屿§ï¼æ¶é´éå¯ä½¿ç¨å
ç½®ç»ä»¶ pickerï¼ |
| | | ## 1.0.6ï¼2021-03-18ï¼ |
| | | - æ°å¢ hide-second 屿§ï¼æ¶é´æ¯æä»
éæ©æ¶ãå |
| | | - ä¿®å¤ éæ©è·æ¾ç¤ºçæ¥æä¸ä¸æ ·çBug |
| | | - ä¿®å¤ changäºä»¶è§¦å2次çBug |
| | | - ä¿®å¤ åãç§ end èå´é误çBug |
| | | - ä¼å æ´å¥½ç nvue éé
|
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template>
|
| | | <view class="uni-calendar-item__weeks-box" :class="{
|
| | | 'uni-calendar-item--disable':weeks.disable,
|
| | | 'uni-calendar-item--before-checked-x':weeks.beforeMultiple,
|
| | | 'uni-calendar-item--multiple': weeks.multiple,
|
| | | 'uni-calendar-item--after-checked-x':weeks.afterMultiple,
|
| | | }" @click="choiceDate(weeks)" @mouseenter="handleMousemove(weeks)">
|
| | | <view class="uni-calendar-item__weeks-box-item" :class="{
|
| | | 'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && (calendar.userChecked || !checkHover),
|
| | | 'uni-calendar-item--checked-range-text': checkHover,
|
| | | 'uni-calendar-item--before-checked':weeks.beforeMultiple,
|
| | | 'uni-calendar-item--multiple': weeks.multiple,
|
| | | 'uni-calendar-item--after-checked':weeks.afterMultiple,
|
| | | 'uni-calendar-item--disable':weeks.disable,
|
| | | }">
|
| | | <text v-if="selected && weeks.extraInfo" class="uni-calendar-item__weeks-box-circle"></text>
|
| | | <text class="uni-calendar-item__weeks-box-text uni-calendar-item__weeks-box-text-disable uni-calendar-item--checked-text">{{weeks.date}}</text>
|
| | | </view>
|
| | | <view :class="{'uni-calendar-item--today': weeks.isToday}"></view>
|
| | | </view>
|
| | | </template>
|
| | |
|
| | | <script>
|
| | | export default {
|
| | | props: {
|
| | | weeks: {
|
| | | type: Object,
|
| | | default () {
|
| | | return {}
|
| | | }
|
| | | },
|
| | | calendar: {
|
| | | type: Object,
|
| | | default: () => {
|
| | | return {}
|
| | | }
|
| | | },
|
| | | selected: {
|
| | | type: Array,
|
| | | default: () => {
|
| | | return []
|
| | | }
|
| | | },
|
| | | checkHover: {
|
| | | type: Boolean,
|
| | | default: false
|
| | | }
|
| | | },
|
| | | methods: {
|
| | | choiceDate(weeks) {
|
| | | this.$emit('change', weeks)
|
| | | },
|
| | | handleMousemove(weeks) {
|
| | | this.$emit('handleMouse', weeks)
|
| | | }
|
| | | }
|
| | | }
|
| | | </script>
|
| | |
|
| | | <style lang="scss" >
|
| | | $uni-primary: #007aff !default;
|
| | |
|
| | | .uni-calendar-item__weeks-box {
|
| | | flex: 1;
|
| | | /* #ifndef APP-NVUE */
|
| | | display: flex;
|
| | | /* #endif */
|
| | | flex-direction: column;
|
| | | justify-content: center;
|
| | | align-items: center;
|
| | | margin: 1px 0;
|
| | | position: relative;
|
| | | }
|
| | |
|
| | | .uni-calendar-item__weeks-box-text {
|
| | | font-size: 14px;
|
| | | // font-family: Lato-Bold, Lato;
|
| | | font-weight: bold;
|
| | | color: darken($color: $uni-primary, $amount: 40%);
|
| | | }
|
| | |
|
| | | .uni-calendar-item__weeks-box-item {
|
| | | position: relative;
|
| | | /* #ifndef APP-NVUE */
|
| | | display: flex;
|
| | | /* #endif */
|
| | | flex-direction: column;
|
| | | justify-content: center;
|
| | | align-items: center;
|
| | | width: 40px;
|
| | | height: 40px;
|
| | | /* #ifdef H5 */
|
| | | cursor: pointer;
|
| | | /* #endif */
|
| | | }
|
| | |
|
| | |
|
| | | .uni-calendar-item__weeks-box-circle {
|
| | | position: absolute;
|
| | | top: 5px;
|
| | | right: 5px;
|
| | | width: 8px;
|
| | | height: 8px;
|
| | | border-radius: 8px;
|
| | | background-color: #dd524d;
|
| | |
|
| | | }
|
| | |
|
| | | .uni-calendar-item__weeks-box .uni-calendar-item--disable {
|
| | | cursor: default;
|
| | | }
|
| | |
|
| | | .uni-calendar-item--disable .uni-calendar-item__weeks-box-text-disable {
|
| | | color: #D1D1D1;
|
| | | }
|
| | |
|
| | | .uni-calendar-item--today {
|
| | | position: absolute;
|
| | | top: 10px;
|
| | | right: 17%;
|
| | | background-color: #dd524d;
|
| | | width:6px;
|
| | | height: 6px;
|
| | | border-radius: 50%;
|
| | | }
|
| | |
|
| | | .uni-calendar-item--extra {
|
| | | color: #dd524d;
|
| | | opacity: 0.8;
|
| | | }
|
| | |
|
| | | .uni-calendar-item__weeks-box .uni-calendar-item--checked {
|
| | | background-color: $uni-primary;
|
| | | border-radius: 50%;
|
| | | box-sizing: border-box;
|
| | | border: 3px solid #fff;
|
| | | }
|
| | |
|
| | | .uni-calendar-item--checked .uni-calendar-item--checked-text {
|
| | | color: #fff;
|
| | | }
|
| | |
|
| | | .uni-calendar-item--multiple .uni-calendar-item--checked-range-text {
|
| | | color: #333;
|
| | | }
|
| | |
|
| | | .uni-calendar-item--multiple {
|
| | | background-color: #F6F7FC;
|
| | | // color: #fff;
|
| | | }
|
| | |
|
| | | .uni-calendar-item--multiple .uni-calendar-item--before-checked,
|
| | | .uni-calendar-item--multiple .uni-calendar-item--after-checked {
|
| | | background-color: $uni-primary;
|
| | | border-radius: 50%;
|
| | | box-sizing: border-box;
|
| | | border: 3px solid #F6F7FC;
|
| | | }
|
| | |
|
| | | .uni-calendar-item--before-checked .uni-calendar-item--checked-text,
|
| | | .uni-calendar-item--after-checked .uni-calendar-item--checked-text {
|
| | | color: #fff;
|
| | | }
|
| | |
|
| | | .uni-calendar-item--before-checked-x {
|
| | | border-top-left-radius: 50px;
|
| | | border-bottom-left-radius: 50px;
|
| | | box-sizing: border-box;
|
| | | background-color: #F6F7FC;
|
| | | }
|
| | |
|
| | | .uni-calendar-item--after-checked-x {
|
| | | border-top-right-radius: 50px;
|
| | | border-bottom-right-radius: 50px;
|
| | | background-color: #F6F7FC;
|
| | | }
|
| | | </style>
|
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template>
|
| | | <view class="uni-calendar" @mouseleave="leaveCale">
|
| | |
|
| | | <view v-if="!insert && show" class="uni-calendar__mask" :class="{'uni-calendar--mask-show':aniMaskShow}"
|
| | | @click="maskClick"></view>
|
| | |
|
| | | <view v-if="insert || show" class="uni-calendar__content"
|
| | | :class="{'uni-calendar--fixed':!insert,'uni-calendar--ani-show':aniMaskShow, 'uni-calendar__content-mobile': aniMaskShow}">
|
| | | <view class="uni-calendar__header" :class="{'uni-calendar__header-mobile' :!insert}">
|
| | |
|
| | | <view class="uni-calendar__header-btn-box" @click.stop="changeMonth('pre')">
|
| | | <view class="uni-calendar__header-btn uni-calendar--left"></view>
|
| | | </view>
|
| | |
|
| | | <picker mode="date" :value="date" fields="month" @change="bindDateChange">
|
| | | <text
|
| | | class="uni-calendar__header-text">{{ (nowDate.year||'') + yearText + ( nowDate.month||'') + monthText}}</text>
|
| | | </picker>
|
| | |
|
| | | <view class="uni-calendar__header-btn-box" @click.stop="changeMonth('next')">
|
| | | <view class="uni-calendar__header-btn uni-calendar--right"></view>
|
| | | </view>
|
| | |
|
| | | <view v-if="!insert" class="dialog-close" @click="maskClick">
|
| | | <view class="dialog-close-plus" data-id="close"></view>
|
| | | <view class="dialog-close-plus dialog-close-rotate" data-id="close"></view>
|
| | | </view>
|
| | | </view>
|
| | | <view class="uni-calendar__box">
|
| | |
|
| | | <view v-if="showMonth" class="uni-calendar__box-bg">
|
| | | <text class="uni-calendar__box-bg-text">{{nowDate.month}}</text>
|
| | | </view>
|
| | |
|
| | | <view class="uni-calendar__weeks" style="padding-bottom: 7px;">
|
| | | <view class="uni-calendar__weeks-day">
|
| | | <text class="uni-calendar__weeks-day-text">{{SUNText}}</text>
|
| | | </view>
|
| | | <view class="uni-calendar__weeks-day">
|
| | | <text class="uni-calendar__weeks-day-text">{{MONText}}</text>
|
| | | </view>
|
| | | <view class="uni-calendar__weeks-day">
|
| | | <text class="uni-calendar__weeks-day-text">{{TUEText}}</text>
|
| | | </view>
|
| | | <view class="uni-calendar__weeks-day">
|
| | | <text class="uni-calendar__weeks-day-text">{{WEDText}}</text>
|
| | | </view>
|
| | | <view class="uni-calendar__weeks-day">
|
| | | <text class="uni-calendar__weeks-day-text">{{THUText}}</text>
|
| | | </view>
|
| | | <view class="uni-calendar__weeks-day">
|
| | | <text class="uni-calendar__weeks-day-text">{{FRIText}}</text>
|
| | | </view>
|
| | | <view class="uni-calendar__weeks-day">
|
| | | <text class="uni-calendar__weeks-day-text">{{SATText}}</text>
|
| | | </view>
|
| | | </view>
|
| | |
|
| | | <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>
|
| | | </view>
|
| | | </view>
|
| | | </view>
|
| | |
|
| | | <view v-if="!insert && !range && hasTime" class="uni-date-changed uni-calendar--fixed-top"
|
| | | style="padding: 0 80px;">
|
| | | <view class="uni-date-changed--time-date">{{tempSingleDate ? tempSingleDate : selectDateText}}</view>
|
| | | <time-picker type="time" :start="timepickerStartTime" :end="timepickerEndTime" v-model="time"
|
| | | :disabled="!tempSingleDate" :border="false" :hide-second="hideSecond" class="time-picker-style">
|
| | | </time-picker>
|
| | | </view>
|
| | |
|
| | | <view v-if="!insert && range && hasTime" class="uni-date-changed uni-calendar--fixed-top">
|
| | | <view class="uni-date-changed--time-start">
|
| | | <view class="uni-date-changed--time-date">{{tempRange.before ? tempRange.before : startDateText}}
|
| | | </view>
|
| | | <time-picker type="time" :start="timepickerStartTime" v-model="timeRange.startTime" :border="false"
|
| | | :hide-second="hideSecond" :disabled="!tempRange.before" class="time-picker-style">
|
| | | </time-picker>
|
| | | </view>
|
| | | <view style="line-height: 50px;">
|
| | | <uni-icons type="arrowthinright" color="#999"></uni-icons>
|
| | | </view>
|
| | | <view class="uni-date-changed--time-end">
|
| | | <view class="uni-date-changed--time-date">{{tempRange.after ? tempRange.after : endDateText}}</view>
|
| | | <time-picker type="time" :end="timepickerEndTime" v-model="timeRange.endTime" :border="false"
|
| | | :hide-second="hideSecond" :disabled="!tempRange.after" class="time-picker-style">
|
| | | </time-picker>
|
| | | </view>
|
| | | </view>
|
| | |
|
| | | <view v-if="!insert" class="uni-date-changed uni-date-btn--ok">
|
| | | <view class="uni-datetime-picker--btn" @click="confirm">{{confirmText}}</view>
|
| | | </view>
|
| | | </view>
|
| | | </view>
|
| | | </template>
|
| | |
|
| | | <script>
|
| | | 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 i18nMessages from './i18n/index.js'
|
| | | const {
|
| | | t
|
| | | } = initVueI18n(i18nMessages)
|
| | |
|
| | | /**
|
| | | * Calendar æ¥å
|
| | | * @description æ¥åç»ä»¶å¯ä»¥æ¥çæ¥æï¼éæ©ä»»æèå´å
çæ¥æï¼æç¹æä½ã常ç¨åºæ¯å¦ï¼é
åºæ¥æé¢è®¢ãç«è½¦æºç¥¨éæ©è´ä¹°æ¥æãä¸ä¸çæå¡ç
|
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=56
|
| | | * @property {String} date èªå®ä¹å½åæ¶é´ï¼é»è®¤ä¸ºä»å¤©
|
| | | * @property {String} startDate æ¥æéæ©èå´-å¼å§æ¥æ
|
| | | * @property {String} endDate æ¥æéæ©èå´-ç»ææ¥æ
|
| | | * @property {Boolean} range èå´éæ©
|
| | | * @property {Boolean} insert = [true|false] æå
¥æ¨¡å¼,é»è®¤ä¸ºfalse
|
| | | * @value true å¼¹çªæ¨¡å¼
|
| | | * @value false æå
¥æ¨¡å¼
|
| | | * @property {Boolean} clearDate = [true|false] å¼¹çªæ¨¡å¼æ¯å¦æ¸
ç©ºä¸æ¬¡éæ©å
容
|
| | | * @property {Array} selected æç¹ï¼æå¾
æ ¼å¼[{date: '2019-06-27', info: 'ç¾å°', data: { custom: 'èªå®ä¹ä¿¡æ¯', name: 'èªå®ä¹æ¶æ¯å¤´',xxx:xxx... }}]
|
| | | * @property {Boolean} showMonth æ¯å¦éæ©æä»½ä¸ºèæ¯
|
| | | * @property {[String} defaultValue 鿩卿弿¶é»è®¤æ¾ç¤ºçæ¶é´
|
| | | * @event {Function} change æ¥ææ¹åï¼`insert :ture` æ¶çæ
|
| | | * @event {Function} confirm ç¡®è®¤éæ©`insert :false` æ¶çæ
|
| | | * @event {Function} monthSwitch 忢æä»½æ¶è§¦å
|
| | | * @example <uni-calendar :insert="true" :start-date="'2019-3-2'":end-date="'2019-5-20'"@change="change" />
|
| | | */
|
| | | export default {
|
| | | components: {
|
| | | calendarItem,
|
| | | timePicker
|
| | | },
|
| | |
|
| | | options: {
|
| | | // #ifdef MP-TOUTIAO
|
| | | virtualHost: false,
|
| | | // #endif
|
| | | // #ifndef MP-TOUTIAO
|
| | | virtualHost: true
|
| | | // #endif
|
| | | },
|
| | | props: {
|
| | | date: {
|
| | | type: String,
|
| | | default: ''
|
| | | },
|
| | | defTime: {
|
| | | type: [String, Object],
|
| | | default: ''
|
| | | },
|
| | | selectableTimes: {
|
| | | type: [Object],
|
| | | default () {
|
| | | return {}
|
| | | }
|
| | | },
|
| | | selected: {
|
| | | type: Array,
|
| | | default () {
|
| | | return []
|
| | | }
|
| | | },
|
| | | startDate: {
|
| | | type: String,
|
| | | default: ''
|
| | | },
|
| | | endDate: {
|
| | | type: String,
|
| | | default: ''
|
| | | },
|
| | | startPlaceholder: {
|
| | | type: String,
|
| | | default: ''
|
| | | },
|
| | | endPlaceholder: {
|
| | | type: String,
|
| | | default: ''
|
| | | },
|
| | | range: {
|
| | | type: Boolean,
|
| | | default: false
|
| | | },
|
| | | hasTime: {
|
| | | type: Boolean,
|
| | | default: false
|
| | | },
|
| | | insert: {
|
| | | type: Boolean,
|
| | | default: true
|
| | | },
|
| | | showMonth: {
|
| | | type: Boolean,
|
| | | default: true
|
| | | },
|
| | | clearDate: {
|
| | | type: Boolean,
|
| | | default: true
|
| | | },
|
| | | checkHover: {
|
| | | type: Boolean,
|
| | | default: true
|
| | | },
|
| | | hideSecond: {
|
| | | type: [Boolean],
|
| | | default: false
|
| | | },
|
| | | pleStatus: {
|
| | | type: Object,
|
| | | default () {
|
| | | return {
|
| | | before: '',
|
| | | after: '',
|
| | | data: [],
|
| | | fulldate: ''
|
| | | }
|
| | | }
|
| | | },
|
| | | defaultValue: {
|
| | | type: [String, Object, Array],
|
| | | default: ''
|
| | | }
|
| | | },
|
| | | data() {
|
| | | return {
|
| | | show: false,
|
| | | weeks: [],
|
| | | calendar: {},
|
| | | nowDate: {},
|
| | | aniMaskShow: false,
|
| | | firstEnter: true,
|
| | | time: '',
|
| | | timeRange: {
|
| | | startTime: '',
|
| | | endTime: ''
|
| | | },
|
| | | tempSingleDate: '',
|
| | | tempRange: {
|
| | | before: '',
|
| | | after: ''
|
| | | }
|
| | | }
|
| | | },
|
| | | watch: {
|
| | | date: {
|
| | | immediate: true,
|
| | | handler(newVal) {
|
| | | if (!this.range) {
|
| | | this.tempSingleDate = newVal
|
| | | setTimeout(() => {
|
| | | this.init(newVal)
|
| | | }, 100)
|
| | | }
|
| | | }
|
| | | },
|
| | | defTime: {
|
| | | immediate: true,
|
| | | handler(newVal) {
|
| | | if (!this.range) {
|
| | | this.time = newVal
|
| | | } else {
|
| | | this.timeRange.startTime = newVal.start
|
| | | this.timeRange.endTime = newVal.end
|
| | | }
|
| | | }
|
| | | },
|
| | | startDate(val) {
|
| | | // åèå°ç¨åº watch æ©äº created
|
| | | if (!this.cale) {
|
| | | return
|
| | | }
|
| | | this.cale.setStartDate(val)
|
| | | this.cale.setDate(this.nowDate.fullDate)
|
| | | this.weeks = this.cale.weeks
|
| | | },
|
| | | endDate(val) {
|
| | | // åèå°ç¨åº watch æ©äº created
|
| | | if (!this.cale) {
|
| | | return
|
| | | }
|
| | | this.cale.setEndDate(val)
|
| | | this.cale.setDate(this.nowDate.fullDate)
|
| | | this.weeks = this.cale.weeks
|
| | | },
|
| | | selected(newVal) {
|
| | | // åèå°ç¨åº watch æ©äº created
|
| | | if (!this.cale) {
|
| | | return
|
| | | }
|
| | | this.cale.setSelectInfo(this.nowDate.fullDate, newVal)
|
| | | this.weeks = this.cale.weeks
|
| | | },
|
| | | pleStatus: {
|
| | | immediate: true,
|
| | | handler(newVal) {
|
| | | const {
|
| | | before,
|
| | | after,
|
| | | fulldate,
|
| | | which
|
| | | } = newVal
|
| | | this.tempRange.before = before
|
| | | this.tempRange.after = after
|
| | | setTimeout(() => {
|
| | | if (fulldate) {
|
| | | this.cale.setHoverMultiple(fulldate)
|
| | | if (before && after) {
|
| | | this.cale.lastHover = true
|
| | | if (this.rangeWithinMonth(after, before)) return
|
| | | this.setDate(before)
|
| | | } else {
|
| | | this.cale.setMultiple(fulldate)
|
| | | this.setDate(this.nowDate.fullDate)
|
| | | this.calendar.fullDate = ''
|
| | | this.cale.lastHover = false
|
| | | }
|
| | | } else {
|
| | | // åèå°ç¨åº 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) {
|
| | | this.setDate(after)
|
| | | this.weeks = this.cale.weeks
|
| | | }
|
| | | this.cale.lastHover = true
|
| | | }
|
| | | }, 16)
|
| | | }
|
| | | }
|
| | | },
|
| | | computed: {
|
| | | timepickerStartTime() {
|
| | | const activeDate = this.range ? this.tempRange.before : this.calendar.fullDate
|
| | | return activeDate === this.startDate ? this.selectableTimes.start : ''
|
| | | },
|
| | | timepickerEndTime() {
|
| | | const activeDate = this.range ? this.tempRange.after : this.calendar.fullDate
|
| | | return activeDate === this.endDate ? this.selectableTimes.end : ''
|
| | | },
|
| | | /**
|
| | | * for i18n
|
| | | */
|
| | | selectDateText() {
|
| | | return t("uni-datetime-picker.selectDate")
|
| | | },
|
| | | startDateText() {
|
| | | return this.startPlaceholder || t("uni-datetime-picker.startDate")
|
| | | },
|
| | | endDateText() {
|
| | | return this.endPlaceholder || t("uni-datetime-picker.endDate")
|
| | | },
|
| | | okText() {
|
| | | return t("uni-datetime-picker.ok")
|
| | | },
|
| | | yearText() {
|
| | | return t("uni-datetime-picker.year")
|
| | | },
|
| | | monthText() {
|
| | | return t("uni-datetime-picker.month")
|
| | | },
|
| | | MONText() {
|
| | | return t("uni-calender.MON")
|
| | | },
|
| | | TUEText() {
|
| | | return t("uni-calender.TUE")
|
| | | },
|
| | | WEDText() {
|
| | | return t("uni-calender.WED")
|
| | | },
|
| | | THUText() {
|
| | | return t("uni-calender.THU")
|
| | | },
|
| | | FRIText() {
|
| | | return t("uni-calender.FRI")
|
| | | },
|
| | | SATText() {
|
| | | return t("uni-calender.SAT")
|
| | | },
|
| | | SUNText() {
|
| | | return t("uni-calender.SUN")
|
| | | },
|
| | | confirmText() {
|
| | | return t("uni-calender.confirm")
|
| | | },
|
| | | },
|
| | | created() {
|
| | | // è·åæ¥åæ¹æ³å®ä¾
|
| | | this.cale = new Calendar({
|
| | | selected: this.selected,
|
| | | startDate: this.startDate,
|
| | | endDate: this.endDate,
|
| | | range: this.range,
|
| | | })
|
| | | // é䏿ä¸å¤©
|
| | | this.init(this.date)
|
| | | },
|
| | | methods: {
|
| | | leaveCale() {
|
| | | this.firstEnter = true
|
| | | },
|
| | | handleMouse(weeks) {
|
| | | if (weeks.disable) return
|
| | | if (this.cale.lastHover) return
|
| | | let {
|
| | | before,
|
| | | after
|
| | | } = this.cale.multipleStatus
|
| | | if (!before) return
|
| | | this.calendar = weeks
|
| | | // 设置èå´é
|
| | | this.cale.setHoverMultiple(this.calendar.fullDate)
|
| | | this.weeks = this.cale.weeks
|
| | | // hoveræ¶ï¼è¿å
¥ä¸ä¸ªæ¥åï¼æ´æ°å¦ä¸ä¸ª
|
| | | if (this.firstEnter) {
|
| | | this.$emit('firstEnterCale', this.cale.multipleStatus)
|
| | | this.firstEnter = false
|
| | | }
|
| | | },
|
| | | rangeWithinMonth(A, B) {
|
| | | const [yearA, monthA] = A.split('-')
|
| | | const [yearB, monthB] = B.split('-')
|
| | | return yearA === yearB && monthA === monthB
|
| | | },
|
| | | // èçç¹å»äºä»¶
|
| | | maskClick() {
|
| | | this.close()
|
| | | this.$emit('maskClose')
|
| | | },
|
| | |
|
| | | clearCalender() {
|
| | | if (this.range) {
|
| | | this.timeRange.startTime = ''
|
| | | this.timeRange.endTime = ''
|
| | | this.tempRange.before = ''
|
| | | this.tempRange.after = ''
|
| | | this.cale.multipleStatus.before = ''
|
| | | this.cale.multipleStatus.after = ''
|
| | | this.cale.multipleStatus.data = []
|
| | | this.cale.lastHover = false
|
| | | } else {
|
| | | this.time = ''
|
| | | this.tempSingleDate = ''
|
| | | }
|
| | | this.calendar.fullDate = ''
|
| | | this.setDate(new Date())
|
| | | },
|
| | |
|
| | | bindDateChange(e) {
|
| | | const value = e.detail.value + '-1'
|
| | | this.setDate(value)
|
| | | },
|
| | | /**
|
| | | * åå§åæ¥ææ¾ç¤º
|
| | | * @param {Object} date
|
| | | */
|
| | | init(date) {
|
| | | // åèå°ç¨åº 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)
|
| | | }
|
| | | }
|
| | | },
|
| | | /**
|
| | | * æå¼æ¥åå¼¹çª
|
| | | */
|
| | | open() {
|
| | | // å¼¹çªæ¨¡å¼å¹¶ä¸æ¸
çæ°æ®
|
| | | if (this.clearDate && !this.insert) {
|
| | | this.cale.cleanMultipleStatus()
|
| | | this.init(this.date)
|
| | | }
|
| | | this.show = true
|
| | | this.$nextTick(() => {
|
| | | setTimeout(() => {
|
| | | this.aniMaskShow = true
|
| | | }, 50)
|
| | | })
|
| | | },
|
| | | /**
|
| | | * å
³éæ¥åå¼¹çª
|
| | | */
|
| | | close() {
|
| | | this.aniMaskShow = false
|
| | | this.$nextTick(() => {
|
| | | setTimeout(() => {
|
| | | this.show = false
|
| | | this.$emit('close')
|
| | | }, 300)
|
| | | })
|
| | | },
|
| | | /**
|
| | | * 确认æé®
|
| | | */
|
| | | confirm() {
|
| | | this.setEmit('confirm')
|
| | | this.close()
|
| | | },
|
| | | /**
|
| | | * åå触å
|
| | | */
|
| | | change(isSingleChange) {
|
| | | if (!this.insert && !isSingleChange) return
|
| | | this.setEmit('change')
|
| | | },
|
| | | /**
|
| | | * éæ©æä»½è§¦å
|
| | | */
|
| | | monthSwitch() {
|
| | | let {
|
| | | year,
|
| | | month
|
| | | } = this.nowDate
|
| | | this.$emit('monthSwitch', {
|
| | | year,
|
| | | month: Number(month)
|
| | | })
|
| | | },
|
| | | /**
|
| | | * æ´¾åäºä»¶
|
| | | * @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.hasTime && !this.time) {
|
| | | this.time = getTime(new Date(), this.hideSecond)
|
| | | }
|
| | | }
|
| | | let {
|
| | | year,
|
| | | month,
|
| | | date,
|
| | | fullDate,
|
| | | extraInfo
|
| | | } = this.calendar
|
| | | this.$emit(name, {
|
| | | range: this.cale.multipleStatus,
|
| | | year,
|
| | | month,
|
| | | date,
|
| | | time: this.time,
|
| | | timeRange: this.timeRange,
|
| | | fulldate: fullDate,
|
| | | extraInfo: extraInfo || {}
|
| | | })
|
| | | },
|
| | | /**
|
| | | * éæ©å¤©è§¦å
|
| | | * @param {Object} weeks
|
| | | */
|
| | | choiceDate(weeks) {
|
| | | if (weeks.disable) return
|
| | | this.calendar = weeks
|
| | | this.calendar.userChecked = true
|
| | | // 设置å¤é
|
| | | this.cale.setMultiple(this.calendar.fullDate, true)
|
| | | this.weeks = this.cale.weeks
|
| | | this.tempSingleDate = this.calendar.fullDate
|
| | | const beforeDate = new Date(this.cale.multipleStatus.before).getTime()
|
| | | const afterDate = new Date(this.cale.multipleStatus.after).getTime()
|
| | | if (beforeDate > afterDate && afterDate) {
|
| | | this.tempRange.before = this.cale.multipleStatus.after
|
| | | this.tempRange.after = this.cale.multipleStatus.before
|
| | | } else {
|
| | | this.tempRange.before = this.cale.multipleStatus.before
|
| | | this.tempRange.after = this.cale.multipleStatus.after
|
| | | }
|
| | | this.change(true)
|
| | | },
|
| | | 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.monthSwitch()
|
| | | },
|
| | | /**
|
| | | * è®¾ç½®æ¥æ
|
| | | * @param {Object} date
|
| | | */
|
| | | setDate(date) {
|
| | | this.cale.setDate(date)
|
| | | this.weeks = this.cale.weeks
|
| | | this.nowDate = this.cale.getInfo(date)
|
| | | }
|
| | | }
|
| | | }
|
| | | </script>
|
| | |
|
| | | <style lang="scss">
|
| | | $uni-primary: #007aff !default;
|
| | |
|
| | | .uni-calendar {
|
| | | /* #ifndef APP-NVUE */
|
| | | display: flex;
|
| | | /* #endif */
|
| | | flex-direction: column;
|
| | | }
|
| | |
|
| | | .uni-calendar__mask {
|
| | | position: fixed;
|
| | | bottom: 0;
|
| | | top: 0;
|
| | | left: 0;
|
| | | right: 0;
|
| | | background-color: rgba(0, 0, 0, 0.4);
|
| | | transition-property: opacity;
|
| | | transition-duration: 0.3s;
|
| | | opacity: 0;
|
| | | /* #ifndef APP-NVUE */
|
| | | z-index: 99;
|
| | | /* #endif */
|
| | | }
|
| | |
|
| | | .uni-calendar--mask-show {
|
| | | opacity: 1
|
| | | }
|
| | |
|
| | | .uni-calendar--fixed {
|
| | | position: fixed;
|
| | | bottom: calc(var(--window-bottom));
|
| | | left: 0;
|
| | | right: 0;
|
| | | transition-property: transform;
|
| | | transition-duration: 0.3s;
|
| | | transform: translateY(460px);
|
| | | /* #ifndef APP-NVUE */
|
| | | z-index: 99;
|
| | | /* #endif */
|
| | | }
|
| | |
|
| | | .uni-calendar--ani-show {
|
| | | transform: translateY(0);
|
| | | }
|
| | |
|
| | | .uni-calendar__content {
|
| | | background-color: #fff;
|
| | | }
|
| | |
|
| | | .uni-calendar__content-mobile {
|
| | | border-top-left-radius: 10px;
|
| | | border-top-right-radius: 10px;
|
| | | box-shadow: 0px 0px 5px 3px rgba(0, 0, 0, 0.1);
|
| | | }
|
| | |
|
| | | .uni-calendar__header {
|
| | | position: relative;
|
| | | /* #ifndef APP-NVUE */
|
| | | display: flex;
|
| | | /* #endif */
|
| | | flex-direction: row;
|
| | | justify-content: center;
|
| | | align-items: center;
|
| | | height: 50px;
|
| | | }
|
| | |
|
| | | .uni-calendar__header-mobile {
|
| | | padding: 10px;
|
| | | padding-bottom: 0;
|
| | | }
|
| | |
|
| | | .uni-calendar--fixed-top {
|
| | | /* #ifndef APP-NVUE */
|
| | | display: flex;
|
| | | /* #endif */
|
| | | flex-direction: row;
|
| | | justify-content: space-between;
|
| | | border-top-color: rgba(0, 0, 0, 0.4);
|
| | | border-top-style: solid;
|
| | | border-top-width: 1px;
|
| | | }
|
| | |
|
| | | .uni-calendar--fixed-width {
|
| | | width: 50px;
|
| | | }
|
| | |
|
| | | .uni-calendar__backtoday {
|
| | | position: absolute;
|
| | | right: 0;
|
| | | top: 25rpx;
|
| | | padding: 0 5px;
|
| | | padding-left: 10px;
|
| | | height: 25px;
|
| | | line-height: 25px;
|
| | | font-size: 12px;
|
| | | border-top-left-radius: 25px;
|
| | | border-bottom-left-radius: 25px;
|
| | | color: #fff;
|
| | | background-color: #f1f1f1;
|
| | | }
|
| | |
|
| | | .uni-calendar__header-text {
|
| | | text-align: center;
|
| | | width: 100px;
|
| | | font-size: 15px;
|
| | | color: #666;
|
| | | }
|
| | |
|
| | | .uni-calendar__button-text {
|
| | | text-align: center;
|
| | | width: 100px;
|
| | | font-size: 14px;
|
| | | color: $uni-primary;
|
| | | /* #ifndef APP-NVUE */
|
| | | letter-spacing: 3px;
|
| | | /* #endif */
|
| | | }
|
| | |
|
| | | .uni-calendar__header-btn-box {
|
| | | /* #ifndef APP-NVUE */
|
| | | display: flex;
|
| | | /* #endif */
|
| | | flex-direction: row;
|
| | | align-items: center;
|
| | | justify-content: center;
|
| | | width: 50px;
|
| | | height: 50px;
|
| | | }
|
| | |
|
| | | .uni-calendar__header-btn {
|
| | | width: 9px;
|
| | | height: 9px;
|
| | | border-left-color: #808080;
|
| | | border-left-style: solid;
|
| | | border-left-width: 1px;
|
| | | border-top-color: #555555;
|
| | | border-top-style: solid;
|
| | | border-top-width: 1px;
|
| | | }
|
| | |
|
| | | .uni-calendar--left {
|
| | | transform: rotate(-45deg);
|
| | | }
|
| | |
|
| | | .uni-calendar--right {
|
| | | transform: rotate(135deg);
|
| | | }
|
| | |
|
| | |
|
| | | .uni-calendar__weeks {
|
| | | position: relative;
|
| | | /* #ifndef APP-NVUE */
|
| | | display: flex;
|
| | | /* #endif */
|
| | | flex-direction: row;
|
| | | }
|
| | |
|
| | | .uni-calendar__weeks-item {
|
| | | flex: 1;
|
| | | }
|
| | |
|
| | | .uni-calendar__weeks-day {
|
| | | flex: 1;
|
| | | /* #ifndef APP-NVUE */
|
| | | display: flex;
|
| | | /* #endif */
|
| | | flex-direction: column;
|
| | | justify-content: center;
|
| | | align-items: center;
|
| | | height: 40px;
|
| | | border-bottom-color: #F5F5F5;
|
| | | border-bottom-style: solid;
|
| | | border-bottom-width: 1px;
|
| | | }
|
| | |
|
| | | .uni-calendar__weeks-day-text {
|
| | | font-size: 12px;
|
| | | color: #B2B2B2;
|
| | | }
|
| | |
|
| | | .uni-calendar__box {
|
| | | position: relative;
|
| | | // padding: 0 10px;
|
| | | padding-bottom: 7px;
|
| | | }
|
| | |
|
| | | .uni-calendar__box-bg {
|
| | | /* #ifndef APP-NVUE */
|
| | | display: flex;
|
| | | /* #endif */
|
| | | justify-content: center;
|
| | | align-items: center;
|
| | | position: absolute;
|
| | | top: 0;
|
| | | left: 0;
|
| | | right: 0;
|
| | | bottom: 0;
|
| | | }
|
| | |
|
| | | .uni-calendar__box-bg-text {
|
| | | font-size: 200px;
|
| | | font-weight: bold;
|
| | | color: #999;
|
| | | opacity: 0.1;
|
| | | text-align: center;
|
| | | /* #ifndef APP-NVUE */
|
| | | line-height: 1;
|
| | | /* #endif */
|
| | | }
|
| | |
|
| | | .uni-date-changed {
|
| | | padding: 0 10px;
|
| | | // line-height: 50px;
|
| | | text-align: center;
|
| | | color: #333;
|
| | | border-top-color: #DCDCDC;
|
| | | ;
|
| | | border-top-style: solid;
|
| | | border-top-width: 1px;
|
| | | flex: 1;
|
| | | }
|
| | |
|
| | | .uni-date-btn--ok {
|
| | | padding: 20px 15px;
|
| | | }
|
| | |
|
| | | .uni-date-changed--time-start {
|
| | | /* #ifndef APP-NVUE */
|
| | | display: flex;
|
| | | /* #endif */
|
| | | align-items: center;
|
| | | }
|
| | |
|
| | | .uni-date-changed--time-end {
|
| | | /* #ifndef APP-NVUE */
|
| | | display: flex;
|
| | | /* #endif */
|
| | | align-items: center;
|
| | | }
|
| | |
|
| | | .uni-date-changed--time-date {
|
| | | color: #999;
|
| | | line-height: 50px;
|
| | | /* #ifdef MP-TOUTIAO */
|
| | | font-size: 16px;
|
| | | /* #endif */
|
| | | margin-right: 5px;
|
| | | // opacity: 0.6;
|
| | | }
|
| | |
|
| | | .time-picker-style {
|
| | | // width: 62px;
|
| | | /* #ifndef APP-NVUE */
|
| | | display: flex;
|
| | | /* #endif */
|
| | | justify-content: center;
|
| | | align-items: center
|
| | | }
|
| | |
|
| | | .mr-10 {
|
| | | margin-right: 10px;
|
| | | }
|
| | |
|
| | | .dialog-close {
|
| | | position: absolute;
|
| | | top: 0;
|
| | | right: 0;
|
| | | bottom: 0;
|
| | | /* #ifndef APP-NVUE */
|
| | | display: flex;
|
| | | /* #endif */
|
| | | flex-direction: row;
|
| | | align-items: center;
|
| | | padding: 0 25px;
|
| | | margin-top: 10px;
|
| | | }
|
| | |
|
| | | .dialog-close-plus {
|
| | | width: 16px;
|
| | | height: 2px;
|
| | | background-color: #737987;
|
| | | border-radius: 2px;
|
| | | transform: rotate(45deg);
|
| | | }
|
| | |
|
| | | .dialog-close-rotate {
|
| | | position: absolute;
|
| | | transform: rotate(-45deg);
|
| | | }
|
| | |
|
| | | .uni-datetime-picker--btn {
|
| | | border-radius: 100px;
|
| | | height: 40px;
|
| | | line-height: 40px;
|
| | | background-color: $uni-primary;
|
| | | color: #fff;
|
| | | font-size: 16px;
|
| | | letter-spacing: 2px;
|
| | | }
|
| | |
|
| | | /* #ifndef APP-NVUE */
|
| | | .uni-datetime-picker--btn:active {
|
| | | opacity: 0.7;
|
| | | }
|
| | |
|
| | | /* #endif */
|
| | | </style>
|
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | {
|
| | | "uni-datetime-picker.selectDate": "select date",
|
| | | "uni-datetime-picker.selectTime": "select time",
|
| | | "uni-datetime-picker.selectDateTime": "select date and time",
|
| | | "uni-datetime-picker.startDate": "start date",
|
| | | "uni-datetime-picker.endDate": "end date",
|
| | | "uni-datetime-picker.startTime": "start time",
|
| | | "uni-datetime-picker.endTime": "end time",
|
| | | "uni-datetime-picker.ok": "ok",
|
| | | "uni-datetime-picker.clear": "clear",
|
| | | "uni-datetime-picker.cancel": "cancel",
|
| | | "uni-datetime-picker.year": "-",
|
| | | "uni-datetime-picker.month": "",
|
| | | "uni-calender.MON": "MON",
|
| | | "uni-calender.TUE": "TUE",
|
| | | "uni-calender.WED": "WED",
|
| | | "uni-calender.THU": "THU",
|
| | | "uni-calender.FRI": "FRI",
|
| | | "uni-calender.SAT": "SAT",
|
| | | "uni-calender.SUN": "SUN",
|
| | | "uni-calender.confirm": "confirm"
|
| | | }
|
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | import en from './en.json'
|
| | | import zhHans from './zh-Hans.json'
|
| | | import zhHant from './zh-Hant.json'
|
| | | export default {
|
| | | en,
|
| | | 'zh-Hans': zhHans,
|
| | | 'zh-Hant': zhHant
|
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | { |
| | | "uni-datetime-picker.selectDate": "éæ©æ¥æ", |
| | | "uni-datetime-picker.selectTime": "éæ©æ¶é´", |
| | | "uni-datetime-picker.selectDateTime": "éæ©æ¥ææ¶é´", |
| | | "uni-datetime-picker.startDate": "å¼å§æ¥æ", |
| | | "uni-datetime-picker.endDate": "ç»ææ¥æ", |
| | | "uni-datetime-picker.startTime": "å¼å§æ¶é´", |
| | | "uni-datetime-picker.endTime": "ç»ææ¶é´", |
| | | "uni-datetime-picker.ok": "ç¡®å®", |
| | | "uni-datetime-picker.clear": "æ¸
é¤", |
| | | "uni-datetime-picker.cancel": "åæ¶", |
| | | "uni-datetime-picker.year": "å¹´", |
| | | "uni-datetime-picker.month": "æ", |
| | | "uni-calender.SUN": "æ¥", |
| | | "uni-calender.MON": "ä¸", |
| | | "uni-calender.TUE": "äº", |
| | | "uni-calender.WED": "ä¸", |
| | | "uni-calender.THU": "å", |
| | | "uni-calender.FRI": "äº", |
| | | "uni-calender.SAT": "å
", |
| | | "uni-calender.confirm": "确认" |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | { |
| | | "uni-datetime-picker.selectDate": "é¸ææ¥æ", |
| | | "uni-datetime-picker.selectTime": "鏿æé", |
| | | "uni-datetime-picker.selectDateTime": "é¸ææ¥ææé", |
| | | "uni-datetime-picker.startDate": "éå§æ¥æ", |
| | | "uni-datetime-picker.endDate": "çµææ¥æ", |
| | | "uni-datetime-picker.startTime": "éå§æ¶é´", |
| | | "uni-datetime-picker.endTime": "çµææ¶é´", |
| | | "uni-datetime-picker.ok": "確å®", |
| | | "uni-datetime-picker.clear": "æ¸
é¤", |
| | | "uni-datetime-picker.cancel": "åæ¶", |
| | | "uni-datetime-picker.year": "å¹´", |
| | | "uni-datetime-picker.month": "æ", |
| | | "uni-calender.SUN": "æ¥", |
| | | "uni-calender.MON": "ä¸", |
| | | "uni-calender.TUE": "äº", |
| | | "uni-calender.WED": "ä¸", |
| | | "uni-calender.THU": "å", |
| | | "uni-calender.FRI": "äº", |
| | | "uni-calender.SAT": "å
", |
| | | "uni-calender.confirm": "確èª" |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template>
|
| | | <view class="uni-datetime-picker">
|
| | | <view @click="initTimePicker">
|
| | | <slot>
|
| | | <view class="uni-datetime-picker-timebox-pointer"
|
| | | :class="{'uni-datetime-picker-disabled': disabled, 'uni-datetime-picker-timebox': border}">
|
| | | <text class="uni-datetime-picker-text">{{time}}</text>
|
| | | <view v-if="!time" class="uni-datetime-picker-time">
|
| | | <text class="uni-datetime-picker-text">{{selectTimeText}}</text>
|
| | | </view>
|
| | | </view>
|
| | | </slot>
|
| | | </view>
|
| | | <view v-if="visible" id="mask" class="uni-datetime-picker-mask" @click="tiggerTimePicker"></view>
|
| | | <view v-if="visible" class="uni-datetime-picker-popup" :class="[dateShow && timeShow ? '' : 'fix-nvue-height']"
|
| | | :style="fixNvueBug">
|
| | | <view class="uni-title">
|
| | | <text class="uni-datetime-picker-text">{{selectTimeText}}</text>
|
| | | </view>
|
| | | <view v-if="dateShow" class="uni-datetime-picker__container-box">
|
| | | <picker-view class="uni-datetime-picker-view" :indicator-style="indicatorStyle" :value="ymd"
|
| | | @change="bindDateChange">
|
| | | <picker-view-column>
|
| | | <view class="uni-datetime-picker-item" v-for="(item,index) in years" :key="index">
|
| | | <text class="uni-datetime-picker-item">{{lessThanTen(item)}}</text>
|
| | | </view>
|
| | | </picker-view-column>
|
| | | <picker-view-column>
|
| | | <view class="uni-datetime-picker-item" v-for="(item,index) in months" :key="index">
|
| | | <text class="uni-datetime-picker-item">{{lessThanTen(item)}}</text>
|
| | | </view>
|
| | | </picker-view-column>
|
| | | <picker-view-column>
|
| | | <view class="uni-datetime-picker-item" v-for="(item,index) in days" :key="index">
|
| | | <text class="uni-datetime-picker-item">{{lessThanTen(item)}}</text>
|
| | | </view>
|
| | | </picker-view-column>
|
| | | </picker-view>
|
| | | <!-- å
¼å®¹ nvue 䏿¯æä¼ªç±» -->
|
| | | <text class="uni-datetime-picker-sign sign-left">-</text>
|
| | | <text class="uni-datetime-picker-sign sign-right">-</text>
|
| | | </view>
|
| | | <view v-if="timeShow" class="uni-datetime-picker__container-box">
|
| | | <picker-view class="uni-datetime-picker-view" :class="[hideSecond ? 'time-hide-second' : '']"
|
| | | :indicator-style="indicatorStyle" :value="hms" @change="bindTimeChange">
|
| | | <picker-view-column>
|
| | | <view class="uni-datetime-picker-item" v-for="(item,index) in hours" :key="index">
|
| | | <text class="uni-datetime-picker-item">{{lessThanTen(item)}}</text>
|
| | | </view>
|
| | | </picker-view-column>
|
| | | <picker-view-column>
|
| | | <view class="uni-datetime-picker-item" v-for="(item,index) in minutes" :key="index">
|
| | | <text class="uni-datetime-picker-item">{{lessThanTen(item)}}</text>
|
| | | </view>
|
| | | </picker-view-column>
|
| | | <picker-view-column v-if="!hideSecond">
|
| | | <view class="uni-datetime-picker-item" v-for="(item,index) in seconds" :key="index">
|
| | | <text class="uni-datetime-picker-item">{{lessThanTen(item)}}</text>
|
| | | </view>
|
| | | </picker-view-column>
|
| | | </picker-view>
|
| | | <!-- å
¼å®¹ nvue 䏿¯æä¼ªç±» -->
|
| | | <text class="uni-datetime-picker-sign" :class="[hideSecond ? 'sign-center' : 'sign-left']">:</text>
|
| | | <text v-if="!hideSecond" class="uni-datetime-picker-sign sign-right">:</text>
|
| | | </view>
|
| | | <view class="uni-datetime-picker-btn">
|
| | | <view @click="clearTime">
|
| | | <text class="uni-datetime-picker-btn-text">{{clearText}}</text>
|
| | | </view>
|
| | | <view class="uni-datetime-picker-btn-group">
|
| | | <view class="uni-datetime-picker-cancel" @click="tiggerTimePicker">
|
| | | <text class="uni-datetime-picker-btn-text">{{cancelText}}</text>
|
| | | </view>
|
| | | <view @click="setTime">
|
| | | <text class="uni-datetime-picker-btn-text">{{okText}}</text>
|
| | | </view>
|
| | | </view>
|
| | | </view>
|
| | | </view>
|
| | | </view>
|
| | | </template>
|
| | |
|
| | | <script>
|
| | | import {
|
| | | initVueI18n
|
| | | } from '@dcloudio/uni-i18n'
|
| | | import i18nMessages from './i18n/index.js'
|
| | | const {
|
| | | t
|
| | | } = initVueI18n(i18nMessages)
|
| | | import {
|
| | | fixIosDateFormat
|
| | | } from './util'
|
| | |
|
| | | /**
|
| | | * DatetimePicker æ¶é´éæ©å¨
|
| | | * @description å¯ä»¥åæ¶éæ©æ¥æåæ¶é´çéæ©å¨
|
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=xxx
|
| | | * @property {String} type = [datetime | date | time] æ¾ç¤ºæ¨¡å¼
|
| | | * @property {Boolean} multiple = [true|false] æ¯å¦å¤é
|
| | | * @property {String|Number} value é»è®¤å¼
|
| | | * @property {String|Number} start èµ·å§æ¥æææ¶é´
|
| | | * @property {String|Number} end èµ·å§æ¥æææ¶é´
|
| | | * @property {String} return-type = [timestamp | string]
|
| | | * @event {Function} change éä¸åçåå触å
|
| | | */
|
| | |
|
| | | export default {
|
| | | name: 'UniDatetimePicker',
|
| | | data() {
|
| | | return {
|
| | | indicatorStyle: `height: 50px;`,
|
| | | visible: false,
|
| | | fixNvueBug: {},
|
| | | dateShow: true,
|
| | | timeShow: true,
|
| | | title: 'æ¥æåæ¶é´',
|
| | | // è¾å
¥æ¡å½åæ¶é´
|
| | | time: '',
|
| | | // å½åçå¹´ææ¥æ¶åç§
|
| | | year: 1920,
|
| | | month: 0,
|
| | | day: 0,
|
| | | hour: 0,
|
| | | minute: 0,
|
| | | second: 0,
|
| | | // èµ·å§æ¶é´
|
| | | startYear: 1920,
|
| | | startMonth: 1,
|
| | | startDay: 1,
|
| | | startHour: 0,
|
| | | startMinute: 0,
|
| | | startSecond: 0,
|
| | | // ç»ææ¶é´
|
| | | endYear: 2120,
|
| | | endMonth: 12,
|
| | | endDay: 31,
|
| | | endHour: 23,
|
| | | endMinute: 59,
|
| | | endSecond: 59,
|
| | | }
|
| | | },
|
| | | options: {
|
| | | // #ifdef MP-TOUTIAO
|
| | | virtualHost: false,
|
| | | // #endif
|
| | | // #ifndef MP-TOUTIAO
|
| | | virtualHost: true
|
| | | // #endif
|
| | | },
|
| | | props: {
|
| | | type: {
|
| | | type: String,
|
| | | default: 'datetime'
|
| | | },
|
| | | value: {
|
| | | type: [String, Number],
|
| | | default: ''
|
| | | },
|
| | | modelValue: {
|
| | | type: [String, Number],
|
| | | default: ''
|
| | | },
|
| | | start: {
|
| | | type: [Number, String],
|
| | | default: ''
|
| | | },
|
| | | end: {
|
| | | type: [Number, String],
|
| | | default: ''
|
| | | },
|
| | | returnType: {
|
| | | type: String,
|
| | | default: 'string'
|
| | | },
|
| | | disabled: {
|
| | | type: [Boolean, String],
|
| | | default: false
|
| | | },
|
| | | border: {
|
| | | type: [Boolean, String],
|
| | | default: true
|
| | | },
|
| | | hideSecond: {
|
| | | type: [Boolean, String],
|
| | | default: false
|
| | | }
|
| | | },
|
| | | watch: {
|
| | | // #ifndef VUE3
|
| | | value: {
|
| | | handler(newVal) {
|
| | | if (newVal) {
|
| | | this.parseValue(fixIosDateFormat(newVal))
|
| | | this.initTime(false)
|
| | | } else {
|
| | | this.time = ''
|
| | | this.parseValue(Date.now())
|
| | | }
|
| | | },
|
| | | immediate: true
|
| | | },
|
| | | // #endif
|
| | | // #ifdef VUE3
|
| | | modelValue: {
|
| | | handler(newVal) {
|
| | | if (newVal) {
|
| | | this.parseValue(fixIosDateFormat(newVal))
|
| | | this.initTime(false)
|
| | | } else {
|
| | | this.time = ''
|
| | | this.parseValue(Date.now())
|
| | | }
|
| | | },
|
| | | immediate: true
|
| | | },
|
| | | // #endif
|
| | | type: {
|
| | | handler(newValue) {
|
| | | if (newValue === 'date') {
|
| | | this.dateShow = true
|
| | | this.timeShow = false
|
| | | this.title = 'æ¥æ'
|
| | | } else if (newValue === 'time') {
|
| | | this.dateShow = false
|
| | | this.timeShow = true
|
| | | this.title = 'æ¶é´'
|
| | | } else {
|
| | | this.dateShow = true
|
| | | this.timeShow = true
|
| | | this.title = 'æ¥æåæ¶é´'
|
| | | }
|
| | | },
|
| | | immediate: true
|
| | | },
|
| | | start: {
|
| | | handler(newVal) {
|
| | | this.parseDatetimeRange(fixIosDateFormat(newVal), 'start')
|
| | | },
|
| | | immediate: true
|
| | | },
|
| | | end: {
|
| | | handler(newVal) {
|
| | | this.parseDatetimeRange(fixIosDateFormat(newVal), 'end')
|
| | | },
|
| | | immediate: true
|
| | | },
|
| | |
|
| | | // æãæ¥ãæ¶ãåãç§å¯éèå´åååï¼æ£æ¥å½å弿¯å¦å¨èå´å
ï¼ä¸å¨åå½åå¼é置为å¯éèå´ç¬¬ä¸é¡¹
|
| | | months(newVal) {
|
| | | this.checkValue('month', this.month, newVal)
|
| | | },
|
| | | days(newVal) {
|
| | | this.checkValue('day', this.day, newVal)
|
| | | },
|
| | | hours(newVal) {
|
| | | this.checkValue('hour', this.hour, newVal)
|
| | | },
|
| | | minutes(newVal) {
|
| | | this.checkValue('minute', this.minute, newVal)
|
| | | },
|
| | | seconds(newVal) {
|
| | | this.checkValue('second', this.second, newVal)
|
| | | }
|
| | | },
|
| | | computed: {
|
| | | // å½åå¹´ãæãæ¥ãæ¶ãåãç§éæ©èå´
|
| | | years() {
|
| | | return this.getCurrentRange('year')
|
| | | },
|
| | |
|
| | | months() {
|
| | | return this.getCurrentRange('month')
|
| | | },
|
| | |
|
| | | days() {
|
| | | return this.getCurrentRange('day')
|
| | | },
|
| | |
|
| | | hours() {
|
| | | return this.getCurrentRange('hour')
|
| | | },
|
| | |
|
| | | minutes() {
|
| | | return this.getCurrentRange('minute')
|
| | | },
|
| | |
|
| | | seconds() {
|
| | | return this.getCurrentRange('second')
|
| | | },
|
| | |
|
| | | // picker å½å弿°ç»
|
| | | ymd() {
|
| | | return [this.year - this.minYear, this.month - this.minMonth, this.day - this.minDay]
|
| | | },
|
| | | hms() {
|
| | | return [this.hour - this.minHour, this.minute - this.minMinute, this.second - this.minSecond]
|
| | | },
|
| | |
|
| | | // å½å date æ¯ start
|
| | | currentDateIsStart() {
|
| | | return this.year === this.startYear && this.month === this.startMonth && this.day === this.startDay
|
| | | },
|
| | |
|
| | | // å½å date æ¯ end
|
| | | currentDateIsEnd() {
|
| | | return this.year === this.endYear && this.month === this.endMonth && this.day === this.endDay
|
| | | },
|
| | |
|
| | | // å½åå¹´ãæãæ¥ãæ¶ãåãç§çæå°å¼åæå¤§å¼
|
| | | minYear() {
|
| | | return this.startYear
|
| | | },
|
| | | maxYear() {
|
| | | return this.endYear
|
| | | },
|
| | | minMonth() {
|
| | | if (this.year === this.startYear) {
|
| | | return this.startMonth
|
| | | } else {
|
| | | return 1
|
| | | }
|
| | | },
|
| | | maxMonth() {
|
| | | if (this.year === this.endYear) {
|
| | | return this.endMonth
|
| | | } else {
|
| | | return 12
|
| | | }
|
| | | },
|
| | | minDay() {
|
| | | if (this.year === this.startYear && this.month === this.startMonth) {
|
| | | return this.startDay
|
| | | } else {
|
| | | return 1
|
| | | }
|
| | | },
|
| | | maxDay() {
|
| | | if (this.year === this.endYear && this.month === this.endMonth) {
|
| | | return this.endDay
|
| | | } else {
|
| | | return this.daysInMonth(this.year, this.month)
|
| | | }
|
| | | },
|
| | | minHour() {
|
| | | if (this.type === 'datetime') {
|
| | | if (this.currentDateIsStart) {
|
| | | return this.startHour
|
| | | } else {
|
| | | return 0
|
| | | }
|
| | | }
|
| | | if (this.type === 'time') {
|
| | | return this.startHour
|
| | | }
|
| | | },
|
| | | maxHour() {
|
| | | if (this.type === 'datetime') {
|
| | | if (this.currentDateIsEnd) {
|
| | | return this.endHour
|
| | | } else {
|
| | | return 23
|
| | | }
|
| | | }
|
| | | if (this.type === 'time') {
|
| | | return this.endHour
|
| | | }
|
| | | },
|
| | | minMinute() {
|
| | | if (this.type === 'datetime') {
|
| | | if (this.currentDateIsStart && this.hour === this.startHour) {
|
| | | return this.startMinute
|
| | | } else {
|
| | | return 0
|
| | | }
|
| | | }
|
| | | if (this.type === 'time') {
|
| | | if (this.hour === this.startHour) {
|
| | | return this.startMinute
|
| | | } else {
|
| | | return 0
|
| | | }
|
| | | }
|
| | | },
|
| | | maxMinute() {
|
| | | if (this.type === 'datetime') {
|
| | | if (this.currentDateIsEnd && this.hour === this.endHour) {
|
| | | return this.endMinute
|
| | | } else {
|
| | | return 59
|
| | | }
|
| | | }
|
| | | if (this.type === 'time') {
|
| | | if (this.hour === this.endHour) {
|
| | | return this.endMinute
|
| | | } else {
|
| | | return 59
|
| | | }
|
| | | }
|
| | | },
|
| | | minSecond() {
|
| | | if (this.type === 'datetime') {
|
| | | if (this.currentDateIsStart && this.hour === this.startHour && this.minute === this.startMinute) {
|
| | | return this.startSecond
|
| | | } else {
|
| | | return 0
|
| | | }
|
| | | }
|
| | | if (this.type === 'time') {
|
| | | if (this.hour === this.startHour && this.minute === this.startMinute) {
|
| | | return this.startSecond
|
| | | } else {
|
| | | return 0
|
| | | }
|
| | | }
|
| | | },
|
| | | maxSecond() {
|
| | | if (this.type === 'datetime') {
|
| | | if (this.currentDateIsEnd && this.hour === this.endHour && this.minute === this.endMinute) {
|
| | | return this.endSecond
|
| | | } else {
|
| | | return 59
|
| | | }
|
| | | }
|
| | | if (this.type === 'time') {
|
| | | if (this.hour === this.endHour && this.minute === this.endMinute) {
|
| | | return this.endSecond
|
| | | } else {
|
| | | return 59
|
| | | }
|
| | | }
|
| | | },
|
| | |
|
| | | /**
|
| | | * for i18n
|
| | | */
|
| | | selectTimeText() {
|
| | | return t("uni-datetime-picker.selectTime")
|
| | | },
|
| | | okText() {
|
| | | return t("uni-datetime-picker.ok")
|
| | | },
|
| | | clearText() {
|
| | | return t("uni-datetime-picker.clear")
|
| | | },
|
| | | cancelText() {
|
| | | return t("uni-datetime-picker.cancel")
|
| | | }
|
| | | },
|
| | |
|
| | | mounted() {
|
| | | // #ifdef APP-NVUE
|
| | | const res = uni.getSystemInfoSync();
|
| | | this.fixNvueBug = {
|
| | | top: res.windowHeight / 2,
|
| | | left: res.windowWidth / 2
|
| | | }
|
| | | // #endif
|
| | | },
|
| | |
|
| | | methods: {
|
| | | /**
|
| | | * @param {Object} item
|
| | | * å°äº 10 å¨åé¢å 个 0
|
| | | */
|
| | |
|
| | | lessThanTen(item) {
|
| | | return item < 10 ? '0' + item : item
|
| | | },
|
| | |
|
| | | /**
|
| | | * è§£ææ¶åç§å符串ï¼ä¾å¦ï¼00:00:00
|
| | | * @param {String} timeString
|
| | | */
|
| | | parseTimeType(timeString) {
|
| | | if (timeString) {
|
| | | let timeArr = timeString.split(':')
|
| | | this.hour = Number(timeArr[0])
|
| | | this.minute = Number(timeArr[1])
|
| | | this.second = Number(timeArr[2])
|
| | | }
|
| | | },
|
| | |
|
| | | /**
|
| | | * è§£æéæ©å¨åå§å¼ï¼ç±»åå¯ä»¥æ¯åç¬¦ä¸²ãæ¶é´æ³ï¼ä¾å¦ï¼2000-10-02ã'08:30:00'ã 1610695109000
|
| | | * @param {String | Number} datetime
|
| | | */
|
| | | initPickerValue(datetime) {
|
| | | let defaultValue = null
|
| | | if (datetime) {
|
| | | defaultValue = this.compareValueWithStartAndEnd(datetime, this.start, this.end)
|
| | | } else {
|
| | | defaultValue = Date.now()
|
| | | defaultValue = this.compareValueWithStartAndEnd(defaultValue, this.start, this.end)
|
| | | }
|
| | | this.parseValue(defaultValue)
|
| | | },
|
| | |
|
| | | /**
|
| | | * åå§å¼è§åï¼
|
| | | * - ç¨æ·è®¾ç½®åå§å¼ value
|
| | | * - 设置äºèµ·å§æ¶é´ startãç»æ¢æ¶é´ endï¼å¹¶ start < value < endï¼åå§å¼ä¸º valueï¼ å¦ååå§å¼ä¸º start
|
| | | * - åªè®¾ç½®äºèµ·å§æ¶é´ startï¼å¹¶ start < valueï¼åå§å¼ä¸º valueï¼å¦ååå§å¼ä¸º start
|
| | | * - åªè®¾ç½®äºç»æ¢æ¶é´ endï¼å¹¶ value < endï¼åå§å¼ä¸º valueï¼å¦ååå§å¼ä¸º end
|
| | | * - æ èµ·å§ç»æ¢æ¶é´ï¼ååå§å¼ä¸º value
|
| | | * - æ åå§å¼ valueï¼ååå§å¼ä¸ºå½åæ¬å°æ¶é´ Date.now()
|
| | | * @param {Object} value
|
| | | * @param {Object} dateBase
|
| | | */
|
| | | compareValueWithStartAndEnd(value, start, end) {
|
| | | let winner = null
|
| | | value = this.superTimeStamp(value)
|
| | | start = this.superTimeStamp(start)
|
| | | end = this.superTimeStamp(end)
|
| | |
|
| | | if (start && end) {
|
| | | if (value < start) {
|
| | | winner = new Date(start)
|
| | | } else if (value > end) {
|
| | | winner = new Date(end)
|
| | | } else {
|
| | | winner = new Date(value)
|
| | | }
|
| | | } else if (start && !end) {
|
| | | winner = start <= value ? new Date(value) : new Date(start)
|
| | | } else if (!start && end) {
|
| | | winner = value <= end ? new Date(value) : new Date(end)
|
| | | } else {
|
| | | winner = new Date(value)
|
| | | }
|
| | |
|
| | | return winner
|
| | | },
|
| | |
|
| | | /**
|
| | | * 转æ¢ä¸ºå¯æ¯è¾çæ¶é´æ³ï¼æ¥åæ¥æãæ¶åç§ãæ¶é´æ³
|
| | | * @param {Object} value
|
| | | */
|
| | | superTimeStamp(value) {
|
| | | let dateBase = ''
|
| | | if (this.type === 'time' && value && typeof value === 'string') {
|
| | | const now = new Date()
|
| | | const year = now.getFullYear()
|
| | | const month = now.getMonth() + 1
|
| | | const day = now.getDate()
|
| | | dateBase = year + '/' + month + '/' + day + ' '
|
| | | }
|
| | | if (Number(value)) {
|
| | | value = parseInt(value)
|
| | | dateBase = 0
|
| | | }
|
| | | return this.createTimeStamp(dateBase + value)
|
| | | },
|
| | |
|
| | | /**
|
| | | * è§£æé»è®¤å¼ valueï¼åç¬¦ä¸²ãæ¶é´æ³
|
| | | * @param {Object} defaultTime
|
| | | */
|
| | | parseValue(value) {
|
| | | if (!value) {
|
| | | return
|
| | | }
|
| | | if (this.type === 'time' && typeof value === "string") {
|
| | | this.parseTimeType(value)
|
| | | } else {
|
| | | let defaultDate = null
|
| | | defaultDate = new Date(value)
|
| | | if (this.type !== 'time') {
|
| | | this.year = defaultDate.getFullYear()
|
| | | this.month = defaultDate.getMonth() + 1
|
| | | this.day = defaultDate.getDate()
|
| | | }
|
| | | if (this.type !== 'date') {
|
| | | this.hour = defaultDate.getHours()
|
| | | this.minute = defaultDate.getMinutes()
|
| | | this.second = defaultDate.getSeconds()
|
| | | }
|
| | | }
|
| | | if (this.hideSecond) {
|
| | | this.second = 0
|
| | | }
|
| | | },
|
| | |
|
| | | /**
|
| | | * è§£æå¯éæ©æ¶é´èå´ startãendï¼å¹´ææ¥åç¬¦ä¸²ãæ¶é´æ³
|
| | | * @param {Object} defaultTime
|
| | | */
|
| | | parseDatetimeRange(point, pointType) {
|
| | | // æ¶é´ä¸ºç©ºï¼åé置为åå§å¼
|
| | | if (!point) {
|
| | | if (pointType === 'start') {
|
| | | this.startYear = 1920
|
| | | this.startMonth = 1
|
| | | this.startDay = 1
|
| | | this.startHour = 0
|
| | | this.startMinute = 0
|
| | | this.startSecond = 0
|
| | | }
|
| | | if (pointType === 'end') {
|
| | | this.endYear = 2120
|
| | | this.endMonth = 12
|
| | | this.endDay = 31
|
| | | this.endHour = 23
|
| | | this.endMinute = 59
|
| | | this.endSecond = 59
|
| | | }
|
| | | return
|
| | | }
|
| | | if (this.type === 'time') {
|
| | | const pointArr = point.split(':')
|
| | | this[pointType + 'Hour'] = Number(pointArr[0])
|
| | | this[pointType + 'Minute'] = Number(pointArr[1])
|
| | | this[pointType + 'Second'] = Number(pointArr[2])
|
| | | } else {
|
| | | if (!point) {
|
| | | pointType === 'start' ? this.startYear = this.year - 60 : this.endYear = this.year + 60
|
| | | return
|
| | | }
|
| | | if (Number(point)) {
|
| | | point = parseInt(point)
|
| | | }
|
| | | // datetime ç end æ²¡ææ¶åç§, åä¸éå¶
|
| | | const hasTime = /[0-9]:[0-9]/
|
| | | if (this.type === 'datetime' && pointType === 'end' && typeof point === 'string' && !hasTime.test(
|
| | | point)) {
|
| | | point = point + ' 23:59:59'
|
| | | }
|
| | | const pointDate = new Date(point)
|
| | | this[pointType + 'Year'] = pointDate.getFullYear()
|
| | | this[pointType + 'Month'] = pointDate.getMonth() + 1
|
| | | this[pointType + 'Day'] = pointDate.getDate()
|
| | | if (this.type === 'datetime') {
|
| | | this[pointType + 'Hour'] = pointDate.getHours()
|
| | | this[pointType + 'Minute'] = pointDate.getMinutes()
|
| | | this[pointType + 'Second'] = pointDate.getSeconds()
|
| | | }
|
| | | }
|
| | | },
|
| | |
|
| | | // è·å å¹´ãæãæ¥ãæ¶ãåãç§ å½åå¯éèå´
|
| | | getCurrentRange(value) {
|
| | | const range = []
|
| | | for (let i = this['min' + this.capitalize(value)]; i <= this['max' + this.capitalize(value)]; i++) {
|
| | | range.push(i)
|
| | | }
|
| | | return range
|
| | | },
|
| | |
|
| | | // å符串é¦åæ¯å¤§å
|
| | | capitalize(str) {
|
| | | return str.charAt(0).toUpperCase() + str.slice(1)
|
| | | },
|
| | |
|
| | | // æ£æ¥å½å弿¯å¦å¨èå´å
ï¼ä¸å¨åå½åå¼é置为å¯éèå´ç¬¬ä¸é¡¹
|
| | | checkValue(name, value, values) {
|
| | | if (values.indexOf(value) === -1) {
|
| | | this[name] = values[0]
|
| | | }
|
| | | },
|
| | |
|
| | | // æ¯ä¸ªæçå®é
天æ°
|
| | | daysInMonth(year, month) { // Use 1 for January, 2 for February, etc.
|
| | | return new Date(year, month, 0).getDate();
|
| | | },
|
| | |
|
| | | /**
|
| | | * çææ¶é´æ³
|
| | | * @param {Object} time
|
| | | */
|
| | | createTimeStamp(time) {
|
| | | if (!time) return
|
| | | if (typeof time === "number") {
|
| | | return time
|
| | | } else {
|
| | | time = time.replace(/-/g, '/')
|
| | | if (this.type === 'date') {
|
| | | time = time + ' ' + '00:00:00'
|
| | | }
|
| | | return Date.parse(time)
|
| | | }
|
| | | },
|
| | |
|
| | | /**
|
| | | * çææ¥æææ¶é´çå符串
|
| | | */
|
| | | createDomSting() {
|
| | | const yymmdd = this.year +
|
| | | '-' +
|
| | | this.lessThanTen(this.month) +
|
| | | '-' +
|
| | | this.lessThanTen(this.day)
|
| | |
|
| | | let hhmmss = this.lessThanTen(this.hour) +
|
| | | ':' +
|
| | | this.lessThanTen(this.minute)
|
| | |
|
| | | if (!this.hideSecond) {
|
| | | hhmmss = hhmmss + ':' + this.lessThanTen(this.second)
|
| | | }
|
| | |
|
| | | if (this.type === 'date') {
|
| | | return yymmdd
|
| | | } else if (this.type === 'time') {
|
| | | return hhmmss
|
| | | } else {
|
| | | return yymmdd + ' ' + hhmmss
|
| | | }
|
| | | },
|
| | |
|
| | | /**
|
| | | * åå§åè¿åå¼ï¼å¹¶æåº change äºä»¶
|
| | | */
|
| | | initTime(emit = true) {
|
| | | this.time = this.createDomSting()
|
| | | if (!emit) return
|
| | | if (this.returnType === 'timestamp' && this.type !== 'time') {
|
| | | this.$emit('change', this.createTimeStamp(this.time))
|
| | | this.$emit('input', this.createTimeStamp(this.time))
|
| | | this.$emit('update:modelValue', this.createTimeStamp(this.time))
|
| | | } else {
|
| | | this.$emit('change', this.time)
|
| | | this.$emit('input', this.time)
|
| | | this.$emit('update:modelValue', this.time)
|
| | | }
|
| | | },
|
| | |
|
| | | /**
|
| | | * ç¨æ·éæ©æ¥æææ¶é´æ´æ° data
|
| | | * @param {Object} e
|
| | | */
|
| | | bindDateChange(e) {
|
| | | const val = e.detail.value
|
| | | this.year = this.years[val[0]]
|
| | | this.month = this.months[val[1]]
|
| | | this.day = this.days[val[2]]
|
| | | },
|
| | | bindTimeChange(e) {
|
| | | const val = e.detail.value
|
| | | this.hour = this.hours[val[0]]
|
| | | this.minute = this.minutes[val[1]]
|
| | | this.second = this.seconds[val[2]]
|
| | | },
|
| | |
|
| | | /**
|
| | | * åå§åå¼¹åºå±
|
| | | */
|
| | | initTimePicker() {
|
| | | if (this.disabled) return
|
| | | const value = fixIosDateFormat(this.time)
|
| | | this.initPickerValue(value)
|
| | | this.visible = !this.visible
|
| | | },
|
| | |
|
| | | /**
|
| | | * 触åæå
³éå¼¹æ¡
|
| | | */
|
| | | tiggerTimePicker(e) {
|
| | | this.visible = !this.visible
|
| | | },
|
| | |
|
| | | /**
|
| | | * ç¨æ·ç¹å»âæ¸
空âæé®ï¼æ¸
空å½åå¼
|
| | | */
|
| | | clearTime() {
|
| | | this.time = ''
|
| | | this.$emit('change', this.time)
|
| | | this.$emit('input', this.time)
|
| | | this.$emit('update:modelValue', this.time)
|
| | | this.tiggerTimePicker()
|
| | | },
|
| | |
|
| | | /**
|
| | | * ç¨æ·ç¹å»âç¡®å®âæé®
|
| | | */
|
| | | setTime() {
|
| | | this.initTime()
|
| | | this.tiggerTimePicker()
|
| | | }
|
| | | }
|
| | | }
|
| | | </script>
|
| | |
|
| | | <style lang="scss">
|
| | | $uni-primary: #007aff !default;
|
| | |
|
| | | .uni-datetime-picker {
|
| | | /* #ifndef APP-NVUE */
|
| | | /* width: 100%; */
|
| | | /* #endif */
|
| | | }
|
| | |
|
| | | .uni-datetime-picker-view {
|
| | | height: 130px;
|
| | | width: 270px;
|
| | | /* #ifndef APP-NVUE */
|
| | | cursor: pointer;
|
| | | /* #endif */
|
| | | }
|
| | |
|
| | | .uni-datetime-picker-item {
|
| | | height: 50px;
|
| | | line-height: 50px;
|
| | | text-align: center;
|
| | | font-size: 14px;
|
| | | }
|
| | |
|
| | | .uni-datetime-picker-btn {
|
| | | margin-top: 60px;
|
| | | /* #ifndef APP-NVUE */
|
| | | display: flex;
|
| | | cursor: pointer;
|
| | | /* #endif */
|
| | | flex-direction: row;
|
| | | justify-content: space-between;
|
| | | }
|
| | |
|
| | | .uni-datetime-picker-btn-text {
|
| | | font-size: 14px;
|
| | | color: $uni-primary;
|
| | | }
|
| | |
|
| | | .uni-datetime-picker-btn-group {
|
| | | /* #ifndef APP-NVUE */
|
| | | display: flex;
|
| | | /* #endif */
|
| | | flex-direction: row;
|
| | | }
|
| | |
|
| | | .uni-datetime-picker-cancel {
|
| | | margin-right: 30px;
|
| | | }
|
| | |
|
| | | .uni-datetime-picker-mask {
|
| | | position: fixed;
|
| | | bottom: 0px;
|
| | | top: 0px;
|
| | | left: 0px;
|
| | | right: 0px;
|
| | | background-color: rgba(0, 0, 0, 0.4);
|
| | | transition-duration: 0.3s;
|
| | | z-index: 998;
|
| | | }
|
| | |
|
| | | .uni-datetime-picker-popup {
|
| | | border-radius: 8px;
|
| | | padding: 30px;
|
| | | width: 270px;
|
| | | /* #ifdef APP-NVUE */
|
| | | height: 500px;
|
| | | /* #endif */
|
| | | /* #ifdef APP-NVUE */
|
| | | width: 330px;
|
| | | /* #endif */
|
| | | background-color: #fff;
|
| | | position: fixed;
|
| | | top: 50%;
|
| | | left: 50%;
|
| | | transform: translate(-50%, -50%);
|
| | | transition-duration: 0.3s;
|
| | | z-index: 999;
|
| | | }
|
| | |
|
| | | .fix-nvue-height {
|
| | | /* #ifdef APP-NVUE */
|
| | | height: 330px;
|
| | | /* #endif */
|
| | | }
|
| | |
|
| | | .uni-datetime-picker-time {
|
| | | color: grey;
|
| | | }
|
| | |
|
| | | .uni-datetime-picker-column {
|
| | | height: 50px;
|
| | | }
|
| | |
|
| | | .uni-datetime-picker-timebox {
|
| | |
|
| | | border: 1px solid #E5E5E5;
|
| | | border-radius: 5px;
|
| | | padding: 7px 10px;
|
| | | /* #ifndef APP-NVUE */
|
| | | box-sizing: border-box;
|
| | | cursor: pointer;
|
| | | /* #endif */
|
| | | }
|
| | |
|
| | | .uni-datetime-picker-timebox-pointer {
|
| | | /* #ifndef APP-NVUE */
|
| | | cursor: pointer;
|
| | | /* #endif */
|
| | | }
|
| | |
|
| | |
|
| | | .uni-datetime-picker-disabled {
|
| | | opacity: 0.4;
|
| | | /* #ifdef H5 */
|
| | | cursor: not-allowed !important;
|
| | | /* #endif */
|
| | | }
|
| | |
|
| | | .uni-datetime-picker-text {
|
| | | font-size: 14px;
|
| | | line-height: 50px
|
| | | }
|
| | |
|
| | | .uni-datetime-picker-sign {
|
| | | position: absolute;
|
| | | top: 53px;
|
| | | /* åæ 10px çå
ç´ é«åº¦ï¼å
¼å®¹nvue */
|
| | | color: #999;
|
| | | /* #ifdef APP-NVUE */
|
| | | font-size: 16px;
|
| | | /* #endif */
|
| | | }
|
| | |
|
| | | .sign-left {
|
| | | left: 86px;
|
| | | }
|
| | |
|
| | | .sign-right {
|
| | | right: 86px;
|
| | | }
|
| | |
|
| | | .sign-center {
|
| | | left: 135px;
|
| | | }
|
| | |
|
| | | .uni-datetime-picker__container-box {
|
| | | position: relative;
|
| | | display: flex;
|
| | | align-items: center;
|
| | | justify-content: center;
|
| | | margin-top: 40px;
|
| | | }
|
| | |
|
| | | .time-hide-second {
|
| | | width: 180px;
|
| | | }
|
| | | </style> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <view class="uni-date"> |
| | | <view class="uni-date-editor" @click="show"> |
| | | <slot> |
| | | <view class="uni-date-editor--x" |
| | | :class="{'uni-date-editor--x__disabled': disabled,'uni-date-x--border': border}"> |
| | | <view v-if="!isRange" class="uni-date-x uni-date-single"> |
| | | <uni-icons class="icon-calendar" type="calendar" color="#c0c4cc" size="22"></uni-icons> |
| | | <view class="uni-date__x-input">{{ displayValue || singlePlaceholderText }}</view> |
| | | </view> |
| | | |
| | | <view v-else class="uni-date-x uni-date-range"> |
| | | <uni-icons class="icon-calendar" type="calendar" color="#c0c4cc" size="22"></uni-icons> |
| | | <view class="uni-date__x-input text-center">{{ displayRangeValue.startDate || startPlaceholderText }}</view> |
| | | |
| | | <view class="range-separator">{{rangeSeparator}}</view> |
| | | |
| | | <view class="uni-date__x-input text-center">{{ displayRangeValue.endDate || endPlaceholderText }}</view> |
| | | </view> |
| | | |
| | | <view v-if="showClearIcon" class="uni-date__icon-clear" @click.stop="clear"> |
| | | <uni-icons type="clear" color="#c0c4cc" size="22"></uni-icons> |
| | | </view> |
| | | </view> |
| | | </slot> |
| | | </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="!isRange" class="uni-date-single--x" :style="pickerPositionStyle"> |
| | | <view class="uni-popper__arrow"></view> |
| | | |
| | | <view v-if="hasTime" class="uni-date-changed popup-x-header"> |
| | | <input class="uni-date__input text-center" type="text" v-model="inputDate" :placeholder="selectDateText" /> |
| | | |
| | | <time-picker type="time" v-model="pickerTime" :border="false" :disabled="!inputDate" |
| | | :start="timepickerStartTime" :end="timepickerEndTime" :hideSecond="hideSecond" style="width: 100%;"> |
| | | <input class="uni-date__input text-center" type="text" v-model="pickerTime" :placeholder="selectTimeText" |
| | | :disabled="!inputDate" /> |
| | | </time-picker> |
| | | </view> |
| | | |
| | | <Calendar ref="pcSingle" :showMonth="false" :start-date="calendarRange.startDate" |
| | | :end-date="calendarRange.endDate" :date="calendarDate" @change="singleChange" :default-value="defaultValue" |
| | | style="padding: 0 8px;" /> |
| | | |
| | | <view v-if="hasTime" class="popup-x-footer"> |
| | | <text class="confirm-text" @click="confirmSingleChange">{{okText}}</text> |
| | | </view> |
| | | </view> |
| | | |
| | | <view v-else class="uni-date-range--x" :style="pickerPositionStyle"> |
| | | <view class="uni-popper__arrow"></view> |
| | | <view v-if="hasTime" class="popup-x-header uni-date-changed"> |
| | | <view class="popup-x-header--datetime"> |
| | | <input class="uni-date__input uni-date-range__input" type="text" v-model="tempRange.startDate" |
| | | :placeholder="startDateText" /> |
| | | |
| | | <time-picker type="time" v-model="tempRange.startTime" :start="timepickerStartTime" :border="false" |
| | | :disabled="!tempRange.startDate" :hideSecond="hideSecond"> |
| | | <input class="uni-date__input uni-date-range__input" type="text" v-model="tempRange.startTime" |
| | | :placeholder="startTimeText" :disabled="!tempRange.startDate" /> |
| | | </time-picker> |
| | | </view> |
| | | |
| | | <uni-icons type="arrowthinright" color="#999" style="line-height: 40px;"></uni-icons> |
| | | |
| | | <view class="popup-x-header--datetime"> |
| | | <input class="uni-date__input uni-date-range__input" type="text" v-model="tempRange.endDate" |
| | | :placeholder="endDateText" /> |
| | | |
| | | <time-picker type="time" v-model="tempRange.endTime" :end="timepickerEndTime" :border="false" |
| | | :disabled="!tempRange.endDate" :hideSecond="hideSecond"> |
| | | <input class="uni-date__input uni-date-range__input" type="text" v-model="tempRange.endTime" |
| | | :placeholder="endTimeText" :disabled="!tempRange.endDate" /> |
| | | </time-picker> |
| | | </view> |
| | | </view> |
| | | |
| | | <view class="popup-x-body"> |
| | | <Calendar ref="left" :showMonth="false" :start-date="calendarRange.startDate" |
| | | :end-date="calendarRange.endDate" :range="true" :pleStatus="endMultipleStatus" @change="leftChange" |
| | | @firstEnterCale="updateRightCale" style="padding: 0 8px;"/> |
| | | <Calendar ref="right" :showMonth="false" :start-date="calendarRange.startDate" |
| | | :end-date="calendarRange.endDate" :range="true" @change="rightChange" :pleStatus="startMultipleStatus" |
| | | @firstEnterCale="updateLeftCale" style="padding: 0 8px;border-left: 1px solid #F1F1F1;" /> |
| | | </view> |
| | | |
| | | <view v-if="hasTime" class="popup-x-footer"> |
| | | <text @click="clear">{{clearText}}</text> |
| | | <text class="confirm-text" @click="confirmRangeChange">{{okText}}</text> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | |
| | | <Calendar v-if="isPhone" ref="mobile" :clearDate="false" :date="calendarDate" :defTime="mobileCalendarTime" |
| | | :start-date="calendarRange.startDate" :end-date="calendarRange.endDate" :selectableTimes="mobSelectableTime" |
| | | :startPlaceholder="startPlaceholder" :endPlaceholder="endPlaceholder" :default-value="defaultValue" |
| | | :pleStatus="endMultipleStatus" :showMonth="false" :range="isRange" :hasTime="hasTime" :insert="false" |
| | | :hideSecond="hideSecond" @confirm="mobileChange" @maskClose="close" @change="calendarClick"/> |
| | | </view> |
| | | </template> |
| | | <script> |
| | | /** |
| | | * DatetimePicker æ¶é´éæ©å¨ |
| | | * @description åæ¶æ¯æ PC åç§»å¨ç«¯ä½¿ç¨æ¥åéæ©æ¥æåæ¥æèå´ |
| | | * @tutorial https://ext.dcloud.net.cn/plugin?id=3962 |
| | | * @property {String} type éæ©å¨ç±»å |
| | | * @property {String|Number|Array|Date} value ç»å®å¼ |
| | | * @property {String} placeholder åéæ©æ¶çå ä½å
容 |
| | | * @property {String} start èµ·å§æ¶é´ |
| | | * @property {String} end ç»æ¢æ¶é´ |
| | | * @property {String} start-placeholder èå´éæ©æ¶å¼å§æ¥æçå ä½å
容 |
| | | * @property {String} end-placeholder èå´éæ©æ¶ç»ææ¥æçå ä½å
容 |
| | | * @property {String} range-separator éæ©èå´æ¶çåé符 |
| | | * @property {Boolean} border = [true|false] æ¯å¦æè¾¹æ¡ |
| | | * @property {Boolean} disabled = [true|false] æ¯å¦ç¦ç¨ |
| | | * @property {Boolean} clearIcon = [true|false] æ¯å¦æ¾ç¤ºæ¸
餿é®ï¼ä»
PC端éç¨ï¼ |
| | | * @property {[String} defaultValue 鿩卿弿¶é»è®¤æ¾ç¤ºçæ¶é´ |
| | | * @event {Function} change ç¡®å®æ¥ææ¶è§¦åçäºä»¶ |
| | | * @event {Function} maskClick ç¹å»é®ç½©å±è§¦åçäºä»¶ |
| | | * @event {Function} show æå¼å¼¹åºå± |
| | | * @event {Function} close å
³éå¼¹åºå± |
| | | * @event {Function} clear æ¸
é¤ä¸æ¬¡éä¸çç¶æåå¼ |
| | | **/ |
| | | import Calendar from './calendar.vue' |
| | | import TimePicker from './time-picker.vue' |
| | | import { |
| | | initVueI18n |
| | | } from '@dcloudio/uni-i18n' |
| | | import i18nMessages from './i18n/index.js' |
| | | import { |
| | | getDateTime, |
| | | getDate, |
| | | getTime, |
| | | getDefaultSecond, |
| | | dateCompare, |
| | | checkDate, |
| | | fixIosDateFormat |
| | | } from './util' |
| | | |
| | | export default { |
| | | name: 'UniDatetimePicker', |
| | | |
| | | options: { |
| | | // #ifdef MP-TOUTIAO |
| | | virtualHost: false, |
| | | // #endif |
| | | // #ifndef MP-TOUTIAO |
| | | virtualHost: true |
| | | // #endif |
| | | }, |
| | | components: { |
| | | Calendar, |
| | | TimePicker |
| | | }, |
| | | data() { |
| | | return { |
| | | isRange: false, |
| | | hasTime: false, |
| | | displayValue: '', |
| | | inputDate: '', |
| | | calendarDate: '', |
| | | pickerTime: '', |
| | | calendarRange: { |
| | | startDate: '', |
| | | startTime: '', |
| | | endDate: '', |
| | | endTime: '' |
| | | }, |
| | | displayRangeValue: { |
| | | startDate: '', |
| | | endDate: '', |
| | | }, |
| | | tempRange: { |
| | | startDate: '', |
| | | startTime: '', |
| | | endDate: '', |
| | | endTime: '' |
| | | }, |
| | | // 左峿¥ååæ¥æ°æ® |
| | | startMultipleStatus: { |
| | | before: '', |
| | | after: '', |
| | | data: [], |
| | | fulldate: '' |
| | | }, |
| | | endMultipleStatus: { |
| | | before: '', |
| | | after: '', |
| | | data: [], |
| | | fulldate: '' |
| | | }, |
| | | pickerVisible: false, |
| | | pickerPositionStyle: null, |
| | | isEmitValue: false, |
| | | isPhone: false, |
| | | isFirstShow: true, |
| | | i18nT: () => {} |
| | | } |
| | | }, |
| | | props: { |
| | | type: { |
| | | type: String, |
| | | default: 'datetime' |
| | | }, |
| | | value: { |
| | | type: [String, Number, Array, Date], |
| | | default: '' |
| | | }, |
| | | modelValue: { |
| | | type: [String, Number, Array, Date], |
| | | default: '' |
| | | }, |
| | | start: { |
| | | type: [Number, String], |
| | | default: '' |
| | | }, |
| | | end: { |
| | | type: [Number, String], |
| | | default: '' |
| | | }, |
| | | returnType: { |
| | | type: String, |
| | | default: 'string' |
| | | }, |
| | | placeholder: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | startPlaceholder: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | endPlaceholder: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | rangeSeparator: { |
| | | type: String, |
| | | default: '-' |
| | | }, |
| | | border: { |
| | | type: [Boolean], |
| | | default: true |
| | | }, |
| | | disabled: { |
| | | type: [Boolean], |
| | | default: false |
| | | }, |
| | | clearIcon: { |
| | | type: [Boolean], |
| | | default: true |
| | | }, |
| | | hideSecond: { |
| | | type: [Boolean], |
| | | default: false |
| | | }, |
| | | defaultValue: { |
| | | type: [String, Object, Array], |
| | | default: '' |
| | | } |
| | | }, |
| | | watch: { |
| | | type: { |
| | | immediate: true, |
| | | handler(newVal) { |
| | | this.hasTime = newVal.indexOf('time') !== -1 |
| | | this.isRange = newVal.indexOf('range') !== -1 |
| | | } |
| | | }, |
| | | // #ifndef VUE3 |
| | | value: { |
| | | immediate: true, |
| | | handler(newVal) { |
| | | if (this.isEmitValue) { |
| | | this.isEmitValue = false |
| | | return |
| | | } |
| | | this.initPicker(newVal) |
| | | } |
| | | }, |
| | | // #endif |
| | | // #ifdef VUE3 |
| | | modelValue: { |
| | | immediate: true, |
| | | handler(newVal) { |
| | | if (this.isEmitValue) { |
| | | this.isEmitValue = false |
| | | return |
| | | } |
| | | this.initPicker(newVal) |
| | | } |
| | | }, |
| | | // #endif |
| | | start: { |
| | | immediate: true, |
| | | handler(newVal) { |
| | | if (!newVal) return |
| | | this.calendarRange.startDate = getDate(newVal) |
| | | if (this.hasTime) { |
| | | this.calendarRange.startTime = getTime(newVal) |
| | | } |
| | | } |
| | | }, |
| | | end: { |
| | | immediate: true, |
| | | handler(newVal) { |
| | | if (!newVal) return |
| | | this.calendarRange.endDate = getDate(newVal) |
| | | if (this.hasTime) { |
| | | this.calendarRange.endTime = getTime(newVal, this.hideSecond) |
| | | } |
| | | } |
| | | }, |
| | | }, |
| | | computed: { |
| | | timepickerStartTime() { |
| | | const activeDate = this.isRange ? this.tempRange.startDate : this.inputDate |
| | | return activeDate === this.calendarRange.startDate ? this.calendarRange.startTime : '' |
| | | }, |
| | | timepickerEndTime() { |
| | | const activeDate = this.isRange ? this.tempRange.endDate : this.inputDate |
| | | return activeDate === this.calendarRange.endDate ? this.calendarRange.endTime : '' |
| | | }, |
| | | mobileCalendarTime() { |
| | | const timeRange = { |
| | | start: this.tempRange.startTime, |
| | | end: this.tempRange.endTime |
| | | } |
| | | return this.isRange ? timeRange : this.pickerTime |
| | | }, |
| | | mobSelectableTime() { |
| | | return { |
| | | start: this.calendarRange.startTime, |
| | | end: this.calendarRange.endTime |
| | | } |
| | | }, |
| | | datePopupWidth() { |
| | | // todo |
| | | return this.isRange ? 653 : 301 |
| | | }, |
| | | |
| | | /** |
| | | * for i18n |
| | | */ |
| | | singlePlaceholderText() { |
| | | return this.placeholder || (this.type === 'date' ? this.selectDateText : this.selectDateTimeText) |
| | | }, |
| | | startPlaceholderText() { |
| | | return this.startPlaceholder || this.startDateText |
| | | }, |
| | | endPlaceholderText() { |
| | | return this.endPlaceholder || this.endDateText |
| | | }, |
| | | selectDateText() { |
| | | return this.i18nT("uni-datetime-picker.selectDate") |
| | | }, |
| | | selectDateTimeText() { |
| | | return this.i18nT("uni-datetime-picker.selectDateTime") |
| | | }, |
| | | selectTimeText() { |
| | | return this.i18nT("uni-datetime-picker.selectTime") |
| | | }, |
| | | startDateText() { |
| | | return this.startPlaceholder || this.i18nT("uni-datetime-picker.startDate") |
| | | }, |
| | | startTimeText() { |
| | | return this.i18nT("uni-datetime-picker.startTime") |
| | | }, |
| | | endDateText() { |
| | | return this.endPlaceholder || this.i18nT("uni-datetime-picker.endDate") |
| | | }, |
| | | endTimeText() { |
| | | return this.i18nT("uni-datetime-picker.endTime") |
| | | }, |
| | | okText() { |
| | | return this.i18nT("uni-datetime-picker.ok") |
| | | }, |
| | | clearText() { |
| | | return this.i18nT("uni-datetime-picker.clear") |
| | | }, |
| | | showClearIcon() { |
| | | return this.clearIcon && !this.disabled && (this.displayValue || (this.displayRangeValue.startDate && this |
| | | .displayRangeValue.endDate)) |
| | | } |
| | | }, |
| | | created() { |
| | | this.initI18nT() |
| | | this.platform() |
| | | }, |
| | | methods: { |
| | | initI18nT() { |
| | | const vueI18n = initVueI18n(i18nMessages) |
| | | this.i18nT = vueI18n.t |
| | | }, |
| | | initPicker(newVal) { |
| | | if ((!newVal && !this.defaultValue) || Array.isArray(newVal) && !newVal.length) { |
| | | this.$nextTick(() => { |
| | | this.clear(false) |
| | | }) |
| | | return |
| | | } |
| | | |
| | | if (!Array.isArray(newVal) && !this.isRange) { |
| | | if (newVal) { |
| | | this.displayValue = this.inputDate = this.calendarDate = getDate(newVal) |
| | | if (this.hasTime) { |
| | | this.pickerTime = getTime(newVal, this.hideSecond) |
| | | this.displayValue = `${this.displayValue} ${this.pickerTime}` |
| | | } |
| | | } else if (this.defaultValue) { |
| | | this.inputDate = this.calendarDate = getDate(this.defaultValue) |
| | | if (this.hasTime) { |
| | | this.pickerTime = getTime(this.defaultValue, this.hideSecond) |
| | | } |
| | | } |
| | | } else { |
| | | const [before, after] = newVal |
| | | if (!before && !after) return |
| | | const beforeDate = getDate(before) |
| | | const beforeTime = getTime(before, this.hideSecond) |
| | | |
| | | const afterDate = getDate(after) |
| | | const afterTime = getTime(after, this.hideSecond) |
| | | const startDate = beforeDate |
| | | const endDate = afterDate |
| | | this.displayRangeValue.startDate = this.tempRange.startDate = startDate |
| | | this.displayRangeValue.endDate = this.tempRange.endDate = endDate |
| | | |
| | | if (this.hasTime) { |
| | | this.displayRangeValue.startDate = `${beforeDate} ${beforeTime}` |
| | | this.displayRangeValue.endDate = `${afterDate} ${afterTime}` |
| | | this.tempRange.startTime = beforeTime |
| | | this.tempRange.endTime = afterTime |
| | | } |
| | | const defaultRange = { |
| | | before: beforeDate, |
| | | after: afterDate |
| | | } |
| | | this.startMultipleStatus = Object.assign({}, this.startMultipleStatus, defaultRange, { |
| | | which: 'right' |
| | | }) |
| | | this.endMultipleStatus = Object.assign({}, this.endMultipleStatus, defaultRange, { |
| | | which: 'left' |
| | | }) |
| | | } |
| | | }, |
| | | updateLeftCale(e) { |
| | | const left = this.$refs.left |
| | | // 设置èå´é |
| | | left.cale.setHoverMultiple(e.after) |
| | | left.setDate(this.$refs.left.nowDate.fullDate) |
| | | }, |
| | | updateRightCale(e) { |
| | | const right = this.$refs.right |
| | | // 设置èå´é |
| | | right.cale.setHoverMultiple(e.after) |
| | | right.setDate(this.$refs.right.nowDate.fullDate) |
| | | }, |
| | | platform() { |
| | | if (typeof navigator !== "undefined") { |
| | | this.isPhone = navigator.userAgent.toLowerCase().indexOf('mobile') !== -1 |
| | | return |
| | | } |
| | | // #ifdef MP-WEIXIN |
| | | const { |
| | | windowWidth |
| | | } = uni.getWindowInfo() |
| | | // #endif |
| | | // #ifndef MP-WEIXIN |
| | | const { |
| | | windowWidth |
| | | } = uni.getSystemInfoSync() |
| | | // #endif |
| | | this.isPhone = windowWidth <= 500 |
| | | this.windowWidth = windowWidth |
| | | }, |
| | | show() { |
| | | this.$emit("show") |
| | | if (this.disabled) { |
| | | return |
| | | } |
| | | this.platform() |
| | | if (this.isPhone) { |
| | | setTimeout(() => { |
| | | this.$refs.mobile.open() |
| | | }, 0); |
| | | return |
| | | } |
| | | this.pickerPositionStyle = { |
| | | top: '10px' |
| | | } |
| | | const dateEditor = uni.createSelectorQuery().in(this).select(".uni-date-editor") |
| | | dateEditor.boundingClientRect(rect => { |
| | | if (this.windowWidth - rect.left < this.datePopupWidth) { |
| | | this.pickerPositionStyle.right = 0 |
| | | } |
| | | }).exec() |
| | | setTimeout(() => { |
| | | this.pickerVisible = !this.pickerVisible |
| | | if (!this.isPhone && this.isRange && this.isFirstShow) { |
| | | this.isFirstShow = false |
| | | const { |
| | | startDate, |
| | | endDate |
| | | } = this.calendarRange |
| | | if (startDate && endDate) { |
| | | if (this.diffDate(startDate, endDate) < 30) { |
| | | this.$refs.right.changeMonth('pre') |
| | | } |
| | | } else { |
| | | // this.$refs.right.changeMonth('next') |
| | | if (this.isPhone) { |
| | | this.$refs.right.cale.lastHover = false; |
| | | } |
| | | } |
| | | } |
| | | |
| | | }, 50) |
| | | }, |
| | | close() { |
| | | setTimeout(() => { |
| | | this.pickerVisible = false |
| | | this.$emit('maskClick', this.value) |
| | | this.$refs.mobile && this.$refs.mobile.close() |
| | | }, 20) |
| | | }, |
| | | setEmit(value) { |
| | | if (this.returnType === "timestamp" || this.returnType === "date") { |
| | | if (!Array.isArray(value)) { |
| | | if (!this.hasTime) { |
| | | value = value + ' ' + '00:00:00' |
| | | } |
| | | value = this.createTimestamp(value) |
| | | if (this.returnType === "date") { |
| | | value = new Date(value) |
| | | } |
| | | } else { |
| | | if (!this.hasTime) { |
| | | value[0] = value[0] + ' ' + '00:00:00' |
| | | value[1] = value[1] + ' ' + '00:00:00' |
| | | } |
| | | value[0] = this.createTimestamp(value[0]) |
| | | value[1] = this.createTimestamp(value[1]) |
| | | if (this.returnType === "date") { |
| | | value[0] = new Date(value[0]) |
| | | value[1] = new Date(value[1]) |
| | | } |
| | | } |
| | | } |
| | | |
| | | this.$emit('update:modelValue', value) |
| | | this.$emit('input', value) |
| | | this.$emit('change', value) |
| | | this.isEmitValue = true |
| | | }, |
| | | createTimestamp(date) { |
| | | date = fixIosDateFormat(date) |
| | | return Date.parse(new Date(date)) |
| | | }, |
| | | singleChange(e) { |
| | | this.calendarDate = this.inputDate = e.fulldate |
| | | if (this.hasTime) return |
| | | this.confirmSingleChange() |
| | | }, |
| | | confirmSingleChange() { |
| | | if (!checkDate(this.inputDate)) { |
| | | const now = new Date() |
| | | this.calendarDate = this.inputDate = getDate(now) |
| | | this.pickerTime = getTime(now, this.hideSecond) |
| | | } |
| | | |
| | | let startLaterInputDate = false |
| | | let startDate, startTime |
| | | if (this.start) { |
| | | let startString = this.start |
| | | if (typeof this.start === 'number') { |
| | | startString = getDateTime(this.start, this.hideSecond) |
| | | } |
| | | [startDate, startTime] = startString.split(' ') |
| | | if (this.start && !dateCompare(startDate, this.inputDate)) { |
| | | startLaterInputDate = true |
| | | this.inputDate = startDate |
| | | } |
| | | } |
| | | |
| | | let endEarlierInputDate = false |
| | | let endDate, endTime |
| | | if (this.end) { |
| | | let endString = this.end |
| | | if (typeof this.end === 'number') { |
| | | endString = getDateTime(this.end, this.hideSecond) |
| | | } |
| | | [endDate, endTime] = endString.split(' ') |
| | | if (this.end && !dateCompare(this.inputDate, endDate)) { |
| | | endEarlierInputDate = true |
| | | this.inputDate = endDate |
| | | } |
| | | } |
| | | if (this.hasTime) { |
| | | if (startLaterInputDate) { |
| | | this.pickerTime = startTime || getDefaultSecond(this.hideSecond) |
| | | } |
| | | if (endEarlierInputDate) { |
| | | this.pickerTime = endTime || getDefaultSecond(this.hideSecond) |
| | | } |
| | | if (!this.pickerTime) { |
| | | this.pickerTime = getTime(Date.now(), this.hideSecond) |
| | | } |
| | | this.displayValue = `${this.inputDate} ${this.pickerTime}` |
| | | } else { |
| | | this.displayValue = this.inputDate |
| | | } |
| | | this.setEmit(this.displayValue) |
| | | this.pickerVisible = false |
| | | }, |
| | | leftChange(e) { |
| | | const { |
| | | before, |
| | | after |
| | | } = e.range |
| | | this.rangeChange(before, after) |
| | | const obj = { |
| | | before: e.range.before, |
| | | after: e.range.after, |
| | | data: e.range.data, |
| | | fulldate: e.fulldate |
| | | } |
| | | this.startMultipleStatus = Object.assign({}, this.startMultipleStatus, obj) |
| | | this.$emit('calendarClick', e) |
| | | }, |
| | | rightChange(e) { |
| | | const { |
| | | before, |
| | | after |
| | | } = e.range |
| | | this.rangeChange(before, after) |
| | | const obj = { |
| | | before: e.range.before, |
| | | after: e.range.after, |
| | | data: e.range.data, |
| | | fulldate: e.fulldate |
| | | } |
| | | this.endMultipleStatus = Object.assign({}, this.endMultipleStatus, obj) |
| | | this.$emit('calendarClick', e) |
| | | }, |
| | | mobileChange(e) { |
| | | if (this.isRange) { |
| | | const { |
| | | before, |
| | | after |
| | | } = e.range |
| | | if (!before) { |
| | | return; |
| | | } |
| | | |
| | | this.handleStartAndEnd(before, after, true) |
| | | if (this.hasTime) { |
| | | const { |
| | | startTime, |
| | | endTime |
| | | } = e.timeRange |
| | | this.tempRange.startTime = startTime |
| | | this.tempRange.endTime = endTime |
| | | } |
| | | this.confirmRangeChange() |
| | | } else { |
| | | if (this.hasTime) { |
| | | this.displayValue = e.fulldate + ' ' + e.time |
| | | } else { |
| | | this.displayValue = e.fulldate |
| | | } |
| | | this.setEmit(this.displayValue) |
| | | } |
| | | this.$refs.mobile.close() |
| | | }, |
| | | rangeChange(before, after) { |
| | | if (!(before && after)) return |
| | | this.handleStartAndEnd(before, after, true) |
| | | if (this.hasTime) return |
| | | this.confirmRangeChange() |
| | | }, |
| | | confirmRangeChange() { |
| | | if (!this.tempRange.startDate || !this.tempRange.endDate) { |
| | | this.pickerVisible = false |
| | | return |
| | | } |
| | | if (!checkDate(this.tempRange.startDate)) { |
| | | this.tempRange.startDate = getDate(Date.now()) |
| | | } |
| | | if (!checkDate(this.tempRange.endDate)) { |
| | | this.tempRange.endDate = getDate(Date.now()) |
| | | } |
| | | |
| | | let start, end |
| | | |
| | | let startDateLaterRangeStartDate = false |
| | | let startDateLaterRangeEndDate = false |
| | | let startDate, startTime |
| | | if (this.start) { |
| | | let startString = this.start |
| | | if (typeof this.start === 'number') { |
| | | startString = getDateTime(this.start, this.hideSecond) |
| | | } |
| | | [startDate, startTime] = startString.split(' ') |
| | | if (this.start && !dateCompare(this.start, `${this.tempRange.startDate} ${this.tempRange.startTime}`)) { |
| | | startDateLaterRangeStartDate = true |
| | | this.tempRange.startDate = startDate |
| | | } |
| | | if (this.start && !dateCompare(this.start, `${this.tempRange.endDate} ${this.tempRange.endTime}`)) { |
| | | startDateLaterRangeEndDate = true |
| | | this.tempRange.endDate = startDate |
| | | } |
| | | } |
| | | let endDateEarlierRangeStartDate = false |
| | | let endDateEarlierRangeEndDate = false |
| | | let endDate, endTime |
| | | if (this.end) { |
| | | let endString = this.end |
| | | if (typeof this.end === 'number') { |
| | | endString = getDateTime(this.end, this.hideSecond) |
| | | } |
| | | [endDate, endTime] = endString.split(' ') |
| | | |
| | | if (this.end && !dateCompare(`${this.tempRange.startDate} ${this.tempRange.startTime}`, this.end)) { |
| | | endDateEarlierRangeStartDate = true |
| | | this.tempRange.startDate = endDate |
| | | } |
| | | if (this.end && !dateCompare(`${this.tempRange.endDate} ${this.tempRange.endTime}`, this.end)) { |
| | | endDateEarlierRangeEndDate = true |
| | | this.tempRange.endDate = endDate |
| | | } |
| | | } |
| | | if (!this.hasTime) { |
| | | start = this.displayRangeValue.startDate = this.tempRange.startDate |
| | | end = this.displayRangeValue.endDate = this.tempRange.endDate |
| | | } else { |
| | | if (startDateLaterRangeStartDate) { |
| | | this.tempRange.startTime = startTime || getDefaultSecond(this.hideSecond) |
| | | } else if (endDateEarlierRangeStartDate) { |
| | | this.tempRange.startTime = endTime || getDefaultSecond(this.hideSecond) |
| | | } |
| | | if (!this.tempRange.startTime) { |
| | | this.tempRange.startTime = getTime(Date.now(), this.hideSecond) |
| | | } |
| | | |
| | | if (startDateLaterRangeEndDate) { |
| | | this.tempRange.endTime = startTime || getDefaultSecond(this.hideSecond) |
| | | } else if (endDateEarlierRangeEndDate) { |
| | | this.tempRange.endTime = endTime || getDefaultSecond(this.hideSecond) |
| | | } |
| | | if (!this.tempRange.endTime) { |
| | | this.tempRange.endTime = getTime(Date.now(), this.hideSecond) |
| | | } |
| | | start = this.displayRangeValue.startDate = `${this.tempRange.startDate} ${this.tempRange.startTime}` |
| | | end = this.displayRangeValue.endDate = `${this.tempRange.endDate} ${this.tempRange.endTime}` |
| | | } |
| | | if (!dateCompare(start, end)) { |
| | | [start, end] = [end, start] |
| | | } |
| | | this.displayRangeValue.startDate = start |
| | | this.displayRangeValue.endDate = end |
| | | const displayRange = [start, end] |
| | | this.setEmit(displayRange) |
| | | this.pickerVisible = false |
| | | }, |
| | | handleStartAndEnd(before, after, temp = false) { |
| | | if (!before) return |
| | | if (!after) after = before; |
| | | const type = temp ? 'tempRange' : 'range' |
| | | const isStartEarlierEnd = dateCompare(before, after) |
| | | this[type].startDate = isStartEarlierEnd ? before : after |
| | | this[type].endDate = isStartEarlierEnd ? after : before |
| | | }, |
| | | /** |
| | | * æ¯è¾æ¶é´å¤§å° |
| | | */ |
| | | dateCompare(startDate, endDate) { |
| | | // è®¡ç®æªæ¢æ¶é´ |
| | | startDate = new Date(startDate.replace('-', '/').replace('-', '/')) |
| | | // 计ç®è¯¦ç»é¡¹çæªæ¢æ¶é´ |
| | | endDate = new Date(endDate.replace('-', '/').replace('-', '/')) |
| | | return startDate <= endDate |
| | | }, |
| | | |
| | | /** |
| | | * æ¯è¾æ¶é´å·® |
| | | */ |
| | | diffDate(startDate, endDate) { |
| | | // è®¡ç®æªæ¢æ¶é´ |
| | | startDate = new Date(startDate.replace('-', '/').replace('-', '/')) |
| | | // 计ç®è¯¦ç»é¡¹çæªæ¢æ¶é´ |
| | | endDate = new Date(endDate.replace('-', '/').replace('-', '/')) |
| | | const diff = (endDate - startDate) / (24 * 60 * 60 * 1000) |
| | | return Math.abs(diff) |
| | | }, |
| | | |
| | | clear(needEmit = true) { |
| | | if (!this.isRange) { |
| | | this.displayValue = '' |
| | | this.inputDate = '' |
| | | this.pickerTime = '' |
| | | if (this.isPhone) { |
| | | this.$refs.mobile && this.$refs.mobile.clearCalender() |
| | | } else { |
| | | this.$refs.pcSingle && this.$refs.pcSingle.clearCalender() |
| | | } |
| | | if (needEmit) { |
| | | this.$emit('change', '') |
| | | this.$emit('input', '') |
| | | this.$emit('update:modelValue', '') |
| | | } |
| | | } else { |
| | | this.displayRangeValue.startDate = '' |
| | | this.displayRangeValue.endDate = '' |
| | | this.tempRange.startDate = '' |
| | | this.tempRange.startTime = '' |
| | | this.tempRange.endDate = '' |
| | | this.tempRange.endTime = '' |
| | | if (this.isPhone) { |
| | | this.$refs.mobile && this.$refs.mobile.clearCalender() |
| | | } else { |
| | | this.$refs.left && this.$refs.left.clearCalender() |
| | | this.$refs.right && this.$refs.right.clearCalender() |
| | | this.$refs.right && this.$refs.right.changeMonth('next') |
| | | } |
| | | if (needEmit) { |
| | | this.$emit('change', []) |
| | | this.$emit('input', []) |
| | | this.$emit('update:modelValue', []) |
| | | } |
| | | } |
| | | }, |
| | | |
| | | calendarClick(e) { |
| | | this.$emit('calendarClick', e) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss"> |
| | | $uni-primary: #007aff !default; |
| | | |
| | | .uni-date { |
| | | width: 100%; |
| | | flex: 1; |
| | | } |
| | | |
| | | .uni-date-x { |
| | | display: flex; |
| | | flex-direction: row; |
| | | align-items: center; |
| | | justify-content: center; |
| | | border-radius: 4px; |
| | | background-color: #fff; |
| | | color: #666; |
| | | font-size: 14px; |
| | | flex: 1; |
| | | |
| | | .icon-calendar { |
| | | padding-left: 3px; |
| | | } |
| | | |
| | | .range-separator { |
| | | height: 35px; |
| | | /* #ifndef MP */ |
| | | padding: 0 2px; |
| | | /* #endif */ |
| | | line-height: 35px; |
| | | } |
| | | } |
| | | |
| | | .uni-date-x--border { |
| | | box-sizing: border-box; |
| | | border-radius: 4px; |
| | | border: 1px solid #e5e5e5; |
| | | } |
| | | |
| | | .uni-date-editor--x { |
| | | display: flex; |
| | | align-items: center; |
| | | position: relative; |
| | | } |
| | | |
| | | .uni-date-editor--x .uni-date__icon-clear { |
| | | padding-right: 3px; |
| | | display: flex; |
| | | align-items: center; |
| | | /* #ifdef H5 */ |
| | | cursor: pointer; |
| | | /* #endif */ |
| | | } |
| | | |
| | | .uni-date__x-input { |
| | | width: auto; |
| | | height: 35px; |
| | | /* #ifndef MP */ |
| | | padding-left: 5px; |
| | | /* #endif */ |
| | | position: relative; |
| | | flex: 1; |
| | | line-height: 35px; |
| | | font-size: 14px; |
| | | overflow: hidden; |
| | | } |
| | | |
| | | .text-center { |
| | | text-align: center; |
| | | } |
| | | |
| | | .uni-date__input { |
| | | height: 40px; |
| | | width: 100%; |
| | | line-height: 40px; |
| | | font-size: 14px; |
| | | } |
| | | |
| | | .uni-date-range__input { |
| | | text-align: center; |
| | | max-width: 142px; |
| | | } |
| | | |
| | | .uni-date-picker__container { |
| | | position: relative; |
| | | } |
| | | |
| | | .uni-date-mask--pc { |
| | | position: fixed; |
| | | bottom: 0px; |
| | | top: 0px; |
| | | left: 0px; |
| | | right: 0px; |
| | | background-color: rgba(0, 0, 0, 0); |
| | | transition-duration: 0.3s; |
| | | z-index: 996; |
| | | } |
| | | |
| | | .uni-date-single--x { |
| | | background-color: #fff; |
| | | position: absolute; |
| | | top: 0; |
| | | z-index: 999; |
| | | border: 1px solid #EBEEF5; |
| | | box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1); |
| | | border-radius: 4px; |
| | | } |
| | | |
| | | .uni-date-range--x { |
| | | background-color: #fff; |
| | | position: absolute; |
| | | top: 0; |
| | | z-index: 999; |
| | | border: 1px solid #EBEEF5; |
| | | box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1); |
| | | border-radius: 4px; |
| | | } |
| | | |
| | | .uni-date-editor--x__disabled { |
| | | opacity: 0.4; |
| | | cursor: default; |
| | | } |
| | | |
| | | .uni-date-editor--logo { |
| | | width: 16px; |
| | | height: 16px; |
| | | vertical-align: middle; |
| | | } |
| | | |
| | | /* æ·»å æ¶é´ */ |
| | | .popup-x-header { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | } |
| | | |
| | | .popup-x-header--datetime { |
| | | /* #ifndef APP-NVUE */ |
| | | display: flex; |
| | | /* #endif */ |
| | | flex-direction: row; |
| | | flex: 1; |
| | | } |
| | | |
| | | .popup-x-body { |
| | | display: flex; |
| | | } |
| | | |
| | | .popup-x-footer { |
| | | padding: 0 15px; |
| | | border-top-color: #F1F1F1; |
| | | border-top-style: solid; |
| | | border-top-width: 1px; |
| | | line-height: 40px; |
| | | text-align: right; |
| | | color: #666; |
| | | } |
| | | |
| | | .popup-x-footer text:hover { |
| | | color: $uni-primary; |
| | | cursor: pointer; |
| | | opacity: 0.8; |
| | | } |
| | | |
| | | .popup-x-footer .confirm-text { |
| | | margin-left: 20px; |
| | | color: $uni-primary; |
| | | } |
| | | |
| | | .uni-date-changed { |
| | | text-align: center; |
| | | color: #333; |
| | | border-bottom-color: #F1F1F1; |
| | | border-bottom-style: solid; |
| | | border-bottom-width: 1px; |
| | | } |
| | | |
| | | .uni-date-changed--time text { |
| | | height: 50px; |
| | | line-height: 50px; |
| | | } |
| | | |
| | | .uni-date-changed .uni-date-changed--time { |
| | | flex: 1; |
| | | } |
| | | |
| | | .uni-date-changed--time-date { |
| | | color: #333; |
| | | opacity: 0.6; |
| | | } |
| | | |
| | | .mr-50 { |
| | | margin-right: 50px; |
| | | } |
| | | |
| | | /* picker å¼¹åºå±éç¨çæç¤ºå°ä¸è§, todoï¼æ©å±è³ä¸ä¸å·¦å³æ¹åå®ä½ */ |
| | | .uni-popper__arrow, |
| | | .uni-popper__arrow::after { |
| | | position: absolute; |
| | | display: block; |
| | | width: 0; |
| | | height: 0; |
| | | border: 6px solid transparent; |
| | | border-top-width: 0; |
| | | } |
| | | |
| | | .uni-popper__arrow { |
| | | filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.03)); |
| | | top: -6px; |
| | | left: 10%; |
| | | margin-right: 3px; |
| | | border-bottom-color: #EBEEF5; |
| | | } |
| | | |
| | | .uni-popper__arrow::after { |
| | | content: " "; |
| | | top: 1px; |
| | | margin-left: -6px; |
| | | border-bottom-color: #fff; |
| | | } |
| | | </style> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | class Calendar {
|
| | | constructor({
|
| | | selected,
|
| | | startDate,
|
| | | endDate,
|
| | | range,
|
| | | } = {}) {
|
| | | // å½åæ¥æ
|
| | | this.date = this.getDateObj(new Date()) // å½ååå
¥æ¥æ
|
| | | // æç¹ä¿¡æ¯
|
| | | this.selected = selected || [];
|
| | | // èµ·å§æ¶é´
|
| | | this.startDate = startDate
|
| | | // ç»æ¢æ¶é´
|
| | | this.endDate = endDate
|
| | | // æ¯å¦èå´éæ©
|
| | | this.range = range
|
| | | // å¤éç¶æ
|
| | | this.cleanMultipleStatus()
|
| | | // æ¯å¨æ¥æ
|
| | | this.weeks = {}
|
| | | this.lastHover = false
|
| | | }
|
| | | /**
|
| | | * è®¾ç½®æ¥æ
|
| | | * @param {Object} date
|
| | | */
|
| | | setDate(date) {
|
| | | const selectDate = this.getDateObj(date)
|
| | | this.getWeeks(selectDate.fullDate)
|
| | | }
|
| | |
|
| | | /**
|
| | | * æ¸
çå¤éç¶æ
|
| | | */
|
| | | cleanMultipleStatus() {
|
| | | this.multipleStatus = {
|
| | | before: '',
|
| | | after: '',
|
| | | data: []
|
| | | }
|
| | | }
|
| | |
|
| | | setStartDate(startDate) {
|
| | | this.startDate = startDate
|
| | | }
|
| | |
|
| | | setEndDate(endDate) {
|
| | | this.endDate = endDate
|
| | | }
|
| | |
|
| | | getPreMonthObj(date) {
|
| | | date = fixIosDateFormat(date)
|
| | | date = new Date(date)
|
| | |
|
| | | const oldMonth = date.getMonth()
|
| | | date.setMonth(oldMonth - 1)
|
| | | const newMonth = date.getMonth()
|
| | | if (oldMonth !== 0 && newMonth - oldMonth === 0) {
|
| | | date.setMonth(newMonth - 1)
|
| | | }
|
| | | return this.getDateObj(date)
|
| | | }
|
| | | getNextMonthObj(date) {
|
| | | date = fixIosDateFormat(date)
|
| | | date = new Date(date)
|
| | |
|
| | | const oldMonth = date.getMonth()
|
| | | date.setMonth(oldMonth + 1)
|
| | | const newMonth = date.getMonth()
|
| | | if (newMonth - oldMonth > 1) {
|
| | | date.setMonth(newMonth - 1)
|
| | | }
|
| | | return this.getDateObj(date)
|
| | | }
|
| | |
|
| | | /**
|
| | | * è·åæå®æ ¼å¼Date对象
|
| | | */
|
| | | getDateObj(date) {
|
| | | date = fixIosDateFormat(date)
|
| | | date = new Date(date)
|
| | |
|
| | | return {
|
| | | fullDate: getDate(date),
|
| | | year: date.getFullYear(),
|
| | | month: addZero(date.getMonth() + 1),
|
| | | date: addZero(date.getDate()),
|
| | | day: date.getDay()
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * è·åä¸ä¸ä¸ªææ¥æéå
|
| | | */
|
| | | getPreMonthDays(amount, dateObj) {
|
| | | const result = []
|
| | | for (let i = amount - 1; i >= 0; i--) {
|
| | | const month = dateObj.month - 1
|
| | | result.push({
|
| | | date: new Date(dateObj.year, month, -i).getDate(),
|
| | | month,
|
| | | disable: true
|
| | | })
|
| | | }
|
| | | return result
|
| | | }
|
| | | /**
|
| | | * è·åæ¬ææ¥æéå
|
| | | */
|
| | | getCurrentMonthDays(amount, dateObj) {
|
| | | const result = []
|
| | | const fullDate = this.date.fullDate
|
| | | for (let i = 1; i <= amount; i++) {
|
| | | const currentDate = `${dateObj.year}-${dateObj.month}-${addZero(i)}`
|
| | | const isToday = fullDate === currentDate
|
| | | // è·åæç¹ä¿¡æ¯
|
| | | const info = this.selected && this.selected.find((item) => {
|
| | | if (this.dateEqual(currentDate, item.date)) {
|
| | | return item
|
| | | }
|
| | | })
|
| | |
|
| | | // æ¥æç¦ç¨
|
| | | let disableBefore = true
|
| | | let disableAfter = true
|
| | | if (this.startDate) {
|
| | | disableBefore = dateCompare(this.startDate, currentDate)
|
| | | }
|
| | |
|
| | | if (this.endDate) {
|
| | | disableAfter = dateCompare(currentDate, this.endDate)
|
| | | }
|
| | |
|
| | | let multiples = this.multipleStatus.data
|
| | | let multiplesStatus = -1
|
| | | if (this.range && multiples) {
|
| | | multiplesStatus = multiples.findIndex((item) => {
|
| | | return this.dateEqual(item, currentDate)
|
| | | })
|
| | | }
|
| | | const checked = multiplesStatus !== -1
|
| | |
|
| | | result.push({
|
| | | fullDate: currentDate,
|
| | | year: dateObj.year,
|
| | | date: i,
|
| | | multiple: this.range ? checked : false,
|
| | | beforeMultiple: this.isLogicBefore(currentDate, this.multipleStatus.before, this.multipleStatus.after),
|
| | | afterMultiple: this.isLogicAfter(currentDate, this.multipleStatus.before, this.multipleStatus.after),
|
| | | month: dateObj.month,
|
| | | disable: (this.startDate && !dateCompare(this.startDate, currentDate)) || (this.endDate && !dateCompare(
|
| | | currentDate, this.endDate)),
|
| | | isToday,
|
| | | userChecked: false,
|
| | | extraInfo: info
|
| | | })
|
| | | }
|
| | | return result
|
| | | }
|
| | | /**
|
| | | * è·åä¸ä¸ä¸ªææ¥æéå
|
| | | */
|
| | | _getNextMonthDays(amount, dateObj) {
|
| | | const result = []
|
| | | const month = dateObj.month + 1
|
| | | for (let i = 1; i <= amount; i++) {
|
| | | result.push({
|
| | | date: i,
|
| | | month,
|
| | | disable: true
|
| | | })
|
| | | }
|
| | | return result
|
| | | }
|
| | |
|
| | | /**
|
| | | * è·åå½åæ¥æè¯¦æ
|
| | | * @param {Object} date
|
| | | */
|
| | | getInfo(date) {
|
| | | if (!date) {
|
| | | date = new Date()
|
| | | }
|
| | | const res = this.calendar.find(item => item.fullDate === this.getDateObj(date).fullDate)
|
| | | return res ? res : this.getDateObj(date)
|
| | | }
|
| | |
|
| | | /**
|
| | | * æ¯è¾æ¶é´æ¯å¦ç¸ç
|
| | | */
|
| | | dateEqual(before, after) {
|
| | | before = new Date(fixIosDateFormat(before))
|
| | | after = new Date(fixIosDateFormat(after))
|
| | | return before.valueOf() === after.valueOf()
|
| | | }
|
| | |
|
| | | /**
|
| | | * æ¯è¾çå®èµ·å§æ¥æ
|
| | | */
|
| | |
|
| | | isLogicBefore(currentDate, before, after) {
|
| | | let logicBefore = before
|
| | | if (before && after) {
|
| | | logicBefore = dateCompare(before, after) ? before : after
|
| | | }
|
| | | return this.dateEqual(logicBefore, currentDate)
|
| | | }
|
| | |
|
| | | isLogicAfter(currentDate, before, after) {
|
| | | let logicAfter = after
|
| | | if (before && after) {
|
| | | logicAfter = dateCompare(before, after) ? after : before
|
| | | }
|
| | | return this.dateEqual(logicAfter, currentDate)
|
| | | }
|
| | |
|
| | | /**
|
| | | * è·åæ¥æèå´å
æææ¥æ
|
| | | * @param {Object} begin
|
| | | * @param {Object} end
|
| | | */
|
| | | geDateAll(begin, end) {
|
| | | var arr = []
|
| | | var ab = begin.split('-')
|
| | | var ae = end.split('-')
|
| | | var db = new Date()
|
| | | db.setFullYear(ab[0], ab[1] - 1, ab[2])
|
| | | var de = new Date()
|
| | | de.setFullYear(ae[0], ae[1] - 1, ae[2])
|
| | | var unixDb = db.getTime() - 24 * 60 * 60 * 1000
|
| | | var unixDe = de.getTime() - 24 * 60 * 60 * 1000
|
| | | for (var k = unixDb; k <= unixDe;) {
|
| | | k = k + 24 * 60 * 60 * 1000
|
| | | arr.push(this.getDateObj(new Date(parseInt(k))).fullDate)
|
| | | }
|
| | | return arr
|
| | | }
|
| | |
|
| | | /**
|
| | | * è·åå¤éç¶æ
|
| | | */
|
| | | setMultiple(fullDate) {
|
| | | if (!this.range) return
|
| | |
|
| | | let {
|
| | | before,
|
| | | after
|
| | | } = this.multipleStatus
|
| | | if (before && after) {
|
| | | if (!this.lastHover) {
|
| | | this.lastHover = true
|
| | | return
|
| | | }
|
| | | this.multipleStatus.before = fullDate
|
| | | this.multipleStatus.after = ''
|
| | | this.multipleStatus.data = []
|
| | | this.multipleStatus.fulldate = ''
|
| | | this.lastHover = false
|
| | | } else {
|
| | | if (!before) {
|
| | | this.multipleStatus.before = fullDate
|
| | | this.multipleStatus.after = undefined;
|
| | | this.lastHover = false
|
| | | } else {
|
| | | this.multipleStatus.after = fullDate
|
| | | if (dateCompare(this.multipleStatus.before, this.multipleStatus.after)) {
|
| | | this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus
|
| | | .after);
|
| | | } else {
|
| | | this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus
|
| | | .before);
|
| | | }
|
| | | this.lastHover = true
|
| | | }
|
| | | }
|
| | | this.getWeeks(fullDate)
|
| | | }
|
| | |
|
| | | /**
|
| | | * é¼ æ hover æ´æ°å¤éç¶æ
|
| | | */
|
| | | setHoverMultiple(fullDate) {
|
| | | //æé³å°ç¨åºç¹å»ä¼è§¦åhoveräºä»¶ï¼éè¦é¿å
ä¸ä¸
|
| | | // #ifndef MP-TOUTIAO
|
| | | if (!this.range || this.lastHover) return
|
| | | const {
|
| | | before
|
| | | } = this.multipleStatus
|
| | |
|
| | | if (!before) {
|
| | | this.multipleStatus.before = fullDate
|
| | | } else {
|
| | | this.multipleStatus.after = fullDate
|
| | | if (dateCompare(this.multipleStatus.before, this.multipleStatus.after)) {
|
| | | this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus.after);
|
| | | } else {
|
| | | this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus.before);
|
| | | }
|
| | | }
|
| | | this.getWeeks(fullDate)
|
| | | // #endif
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * æ´æ°é»è®¤å¼å¤éç¶æ
|
| | | */
|
| | | setDefaultMultiple(before, after) {
|
| | | this.multipleStatus.before = before
|
| | | this.multipleStatus.after = after
|
| | | if (before && after) {
|
| | | if (dateCompare(before, after)) {
|
| | | this.multipleStatus.data = this.geDateAll(before, after);
|
| | | this.getWeeks(after)
|
| | | } else {
|
| | | this.multipleStatus.data = this.geDateAll(after, before);
|
| | | this.getWeeks(before)
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * è·åæ¯å¨æ°æ®
|
| | | * @param {Object} dateData
|
| | | */
|
| | | getWeeks(dateData) {
|
| | | const {
|
| | | year,
|
| | | month,
|
| | | } = this.getDateObj(dateData)
|
| | |
|
| | | const preMonthDayAmount = new Date(year, month - 1, 1).getDay()
|
| | | const preMonthDays = this.getPreMonthDays(preMonthDayAmount, this.getDateObj(dateData))
|
| | |
|
| | | const currentMonthDayAmount = new Date(year, month, 0).getDate()
|
| | | const currentMonthDays = this.getCurrentMonthDays(currentMonthDayAmount, this.getDateObj(dateData))
|
| | |
|
| | | const nextMonthDayAmount = 42 - preMonthDayAmount - currentMonthDayAmount
|
| | | const nextMonthDays = this._getNextMonthDays(nextMonthDayAmount, this.getDateObj(dateData))
|
| | |
|
| | | const calendarDays = [...preMonthDays, ...currentMonthDays, ...nextMonthDays]
|
| | |
|
| | | const weeks = new Array(6)
|
| | | for (let i = 0; i < calendarDays.length; i++) {
|
| | | const index = Math.floor(i / 7)
|
| | | if (!weeks[index]) {
|
| | | weeks[index] = new Array(7)
|
| | | }
|
| | | weeks[index][i % 7] = calendarDays[i]
|
| | | }
|
| | |
|
| | | this.calendar = calendarDays
|
| | | this.weeks = weeks
|
| | | }
|
| | | }
|
| | |
|
| | | function getDateTime(date, hideSecond) {
|
| | | return `${getDate(date)} ${getTime(date, hideSecond)}`
|
| | | }
|
| | |
|
| | | function getDate(date) {
|
| | | date = fixIosDateFormat(date)
|
| | | date = new Date(date)
|
| | | const year = date.getFullYear()
|
| | | const month = date.getMonth() + 1
|
| | | const day = date.getDate()
|
| | | return `${year}-${addZero(month)}-${addZero(day)}`
|
| | | }
|
| | |
|
| | | function getTime(date, hideSecond) {
|
| | | date = fixIosDateFormat(date)
|
| | | date = new Date(date)
|
| | | const hour = date.getHours()
|
| | | const minute = date.getMinutes()
|
| | | const second = date.getSeconds()
|
| | | return hideSecond ? `${addZero(hour)}:${addZero(minute)}` : `${addZero(hour)}:${addZero(minute)}:${addZero(second)}`
|
| | | }
|
| | |
|
| | | function addZero(num) {
|
| | | if (num < 10) {
|
| | | num = `0${num}`
|
| | | }
|
| | | return num
|
| | | }
|
| | |
|
| | | function getDefaultSecond(hideSecond) {
|
| | | return hideSecond ? '00:00' : '00:00:00'
|
| | | }
|
| | |
|
| | | function dateCompare(startDate, endDate) {
|
| | | startDate = new Date(fixIosDateFormat(startDate))
|
| | | endDate = new Date(fixIosDateFormat(endDate))
|
| | | return startDate <= endDate
|
| | | }
|
| | |
|
| | | function checkDate(date) {
|
| | | const dateReg = /((19|20)\d{2})(-|\/)\d{1,2}(-|\/)\d{1,2}/g
|
| | | return date.match(dateReg)
|
| | | }
|
| | | //iosä½çæ¬15å以ä¸ï¼æ æ³å¹é
没æ âç§â æ¶çæ
åµï¼æä»¥éè¦å¨æ«å°¾ ç§ å ä¸ é®å· |
| | | const dateTimeReg = /^\d{4}-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01])( [0-5]?[0-9]:[0-5]?[0-9](:[0-5]?[0-9])?)?$/;
|
| | |
|
| | | function fixIosDateFormat(value) {
|
| | | if (typeof value === 'string' && dateTimeReg.test(value)) {
|
| | | value = value.replace(/-/g, '/')
|
| | | }
|
| | | return value
|
| | | }
|
| | |
|
| | | export {
|
| | | Calendar,
|
| | | getDateTime,
|
| | | getDate,
|
| | | getTime,
|
| | | addZero,
|
| | | getDefaultSecond,
|
| | | dateCompare,
|
| | | checkDate,
|
| | | fixIosDateFormat
|
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | { |
| | | "id": "uni-datetime-picker", |
| | | "displayName": "uni-datetime-picker æ¥æéæ©å¨", |
| | | "version": "2.2.38", |
| | | "description": "uni-datetime-picker æ¥ææ¶é´éæ©å¨ï¼æ¯ææ¥åï¼æ¯æèå´éæ©", |
| | | "keywords": [ |
| | | "uni-datetime-picker", |
| | | "uni-ui", |
| | | "uniui", |
| | | "æ¥ææ¶é´éæ©å¨", |
| | | "æ¥ææ¶é´" |
| | | ], |
| | | "repository": "https://github.com/dcloudio/uni-ui", |
| | | "engines": { |
| | | "HBuilderX": "" |
| | | }, |
| | | "directories": { |
| | | "example": "../../temps/example_temps" |
| | | }, |
| | | "dcloudext": { |
| | | "sale": { |
| | | "regular": { |
| | | "price": "0.00" |
| | | }, |
| | | "sourcecode": { |
| | | "price": "0.00" |
| | | } |
| | | }, |
| | | "contact": { |
| | | "qq": "" |
| | | }, |
| | | "declaration": { |
| | | "ads": "æ ", |
| | | "data": "æ ", |
| | | "permissions": "æ " |
| | | }, |
| | | "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui", |
| | | "type": "component-vue" |
| | | }, |
| | | "uni_modules": { |
| | | "dependencies": [ |
| | | "uni-scss", |
| | | "uni-icons" |
| | | ], |
| | | "encrypt": [], |
| | | "platforms": { |
| | | "cloud": { |
| | | "tcb": "y", |
| | | "aliyun": "y", |
| | | "alipay": "n" |
| | | }, |
| | | "client": { |
| | | "App": { |
| | | "app-vue": "y", |
| | | "app-nvue": "n" |
| | | }, |
| | | "H5-mobile": { |
| | | "Safari": "y", |
| | | "Android Browser": "y", |
| | | "微信æµè§å¨(Android)": "y", |
| | | "QQæµè§å¨(Android)": "y" |
| | | }, |
| | | "H5-pc": { |
| | | "Chrome": "y", |
| | | "IE": "y", |
| | | "Edge": "y", |
| | | "Firefox": "y", |
| | | "Safari": "y" |
| | | }, |
| | | "å°ç¨åº": { |
| | | "微信": "y", |
| | | "é¿é": "y", |
| | | "ç¾åº¦": "y", |
| | | "åèè·³å¨": "y", |
| | | "QQ": "y" |
| | | }, |
| | | "å¿«åºç¨": { |
| | | "å为": "u", |
| | | "èç": "u" |
| | | }, |
| | | "Vue": { |
| | | "vue2": "y", |
| | | "vue3": "y" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | |
| | | |
| | | > `éè¦éç¥ï¼ç»ä»¶åçº§æ´æ° 2.0.0 åï¼æ¯ææ¥æ+æ¶é´èå´éæ©ï¼ç»ä»¶ ui å°ä½¿ç¨æ¥åéæ©æ¥æï¼ui ååè¾å¤§ï¼åæ¶æ¯æ PC å ç§»å¨ç«¯ãæ¤çæ¬ä¸ååå
¼å®¹ï¼ä¸åæ¯æåç¬çæ¶é´éæ©ï¼type=timeï¼åç¸å
³ç hide-second 屿§ï¼æ¶é´éå¯ä½¿ç¨å
ç½®ç»ä»¶ pickerï¼ãè¥ä»éä½¿ç¨æ§çæ¬ï¼å¯å¨æä»¶å¸åºä¸è½½*éuni_modulesçæ¬*ï¼æ§çæ¬å°ä¸åç»´æ¤` |
| | | |
| | | ## DatetimePicker æ¶é´éæ©å¨ |
| | | |
| | | > **ç»ä»¶åï¼uni-datetime-picker** |
| | | > 代ç åï¼ `uDatetimePicker` |
| | | |
| | | |
| | | 该ç»ä»¶çä¼å¿æ¯ï¼æ¯æ**æ¶é´æ³**è¾å
¥åè¾åºï¼èµ·å§æ¶é´ãç»æ¢æ¶é´ä¹æ¯ææ¶é´æ³ï¼ï¼å¯**åæ¶éæ©**æ¥æåæ¶é´ã |
| | | |
| | | è¥åªæ¯éè¦åç¬éæ©æ¥æåæ¶é´ï¼ä¸éè¦æ¶é´æ³è¾å
¥åè¾åºï¼å¯ä½¿ç¨åçç picker ç»ä»¶ã |
| | | |
| | | **_ç¹å» picker é»è®¤å¼è§åï¼_** |
| | | |
| | | - è¥è®¾ç½®åå§å¼ value, 伿¾ç¤ºå¨ picker æ¾ç¤ºæ¡ä¸ |
| | | - è¥æ åå§å¼ valueï¼ååå§å¼ value 为å½åæ¬å°æ¶é´ Date.now()ï¼ ä½ä¸ä¼æ¾ç¤ºå¨ picker æ¾ç¤ºæ¡ä¸ |
| | | |
| | | ### [æ¥çææ¡£](https://uniapp.dcloud.io/component/uniui/uni-datetime-picker) |
| | | #### å¦ä½¿ç¨è¿ç¨ä¸æä»»ä½é®é¢ï¼æè
æ¨å¯¹uni-uiæä¸äºå¥½çå»ºè®®ï¼æ¬¢è¿å å
¥ uni-ui 交æµç¾¤ï¼871950839 |