10.18前的开发
parent
4fa658db18
commit
aa47166ae7
Binary file not shown.
After Width: | Height: | Size: 7.0 KiB |
@ -0,0 +1,177 @@
|
|||||||
|
<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>
|
@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
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
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"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": "确认"
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"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": "確認"
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,453 @@
|
|||||||
|
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 ? dateObj.month -1 : 12
|
||||||
|
const year = month === 12 ? dateObj.year - 1 : dateObj.year
|
||||||
|
const date = new Date(year,month,-i).getDate()
|
||||||
|
const fullDate = `${year}-${addZero(month)}-${addZero(date)}`
|
||||||
|
let multiples = this.multipleStatus.data
|
||||||
|
let multiplesStatus = -1
|
||||||
|
if (this.range && multiples) {
|
||||||
|
multiplesStatus = multiples.findIndex((item) => {
|
||||||
|
return this.dateEqual(item, fullDate)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const checked = multiplesStatus !== -1
|
||||||
|
// 获取打点信息
|
||||||
|
const extraInfo = this.selected && this.selected.find((item) => {
|
||||||
|
if (this.dateEqual(fullDate, item.date)) {
|
||||||
|
return item
|
||||||
|
}
|
||||||
|
})
|
||||||
|
result.push({
|
||||||
|
fullDate,
|
||||||
|
year,
|
||||||
|
month,
|
||||||
|
date,
|
||||||
|
multiple: this.range ? checked : false,
|
||||||
|
beforeMultiple: this.isLogicBefore(fullDate, this.multipleStatus.before, this.multipleStatus.after),
|
||||||
|
afterMultiple: this.isLogicAfter(fullDate, this.multipleStatus.before, this.multipleStatus.after),
|
||||||
|
disable: (this.startDate && !dateCompare(this.startDate, fullDate)) || (this.endDate && !dateCompare(fullDate,this.endDate)),
|
||||||
|
isToday: fullDate === this.date.fullDate,
|
||||||
|
userChecked: false,
|
||||||
|
extraInfo
|
||||||
|
})
|
||||||
|
}
|
||||||
|
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 extraInfo = 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,
|
||||||
|
month: dateObj.month,
|
||||||
|
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),
|
||||||
|
disable: (this.startDate && !dateCompare(this.startDate, currentDate)) || (this.endDate && !dateCompare(currentDate,this.endDate)),
|
||||||
|
isToday,
|
||||||
|
userChecked: false,
|
||||||
|
extraInfo
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取下一个月日期集合
|
||||||
|
*/
|
||||||
|
_getNextMonthDays(amount, dateObj) {
|
||||||
|
const result = []
|
||||||
|
const month = dateObj.month + 1
|
||||||
|
for (let i = 1; i <= amount; i++) {
|
||||||
|
const month = dateObj.month === 12 ? 1 : dateObj.month*1 + 1
|
||||||
|
const year = month === 1 ? dateObj.year + 1 : dateObj.year
|
||||||
|
const fullDate = `${year}-${addZero(month)}-${addZero(i)}`
|
||||||
|
let multiples = this.multipleStatus.data
|
||||||
|
let multiplesStatus = -1
|
||||||
|
if (this.range && multiples) {
|
||||||
|
multiplesStatus = multiples.findIndex((item) => {
|
||||||
|
return this.dateEqual(item, fullDate)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const checked = multiplesStatus !== -1
|
||||||
|
// 获取打点信息
|
||||||
|
const extraInfo = this.selected && this.selected.find((item) => {
|
||||||
|
if (this.dateEqual(fullDate, item.date)) {
|
||||||
|
return item
|
||||||
|
}
|
||||||
|
})
|
||||||
|
result.push({
|
||||||
|
fullDate,
|
||||||
|
year,
|
||||||
|
date: i,
|
||||||
|
month,
|
||||||
|
multiple: this.range ? checked : false,
|
||||||
|
beforeMultiple: this.isLogicBefore(fullDate, this.multipleStatus.before, this.multipleStatus.after),
|
||||||
|
afterMultiple: this.isLogicAfter(fullDate, this.multipleStatus.before, this.multipleStatus.after),
|
||||||
|
disable: (this.startDate && !dateCompare(this.startDate, fullDate)) || (this.endDate && !dateCompare(fullDate,this.endDate)),
|
||||||
|
isToday: fullDate === this.date.fullDate,
|
||||||
|
userChecked: false,
|
||||||
|
extraInfo
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前日期详情
|
||||||
|
* @param {Object} date
|
||||||
|
*/
|
||||||
|
getInfo(date) {
|
||||||
|
if (!date) {
|
||||||
|
date = new Date()
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.calendar.find(item => item.fullDate === this.getDateObj(date).fullDate)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 比较时间是否相等
|
||||||
|
*/
|
||||||
|
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.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) {
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新默认值多选状态
|
||||||
|
*/
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
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}
|
@ -0,0 +1,87 @@
|
|||||||
|
{
|
||||||
|
"id": "uni-datetime-picker",
|
||||||
|
"displayName": "uni-datetime-picker 日期选择器",
|
||||||
|
"version": "2.2.24",
|
||||||
|
"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"
|
||||||
|
},
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,87 @@
|
|||||||
|
{
|
||||||
|
"id": "uni-easyinput",
|
||||||
|
"displayName": "uni-easyinput 增强输入框",
|
||||||
|
"version": "1.1.9",
|
||||||
|
"description": "Easyinput 组件是对原生input组件的增强",
|
||||||
|
"keywords": [
|
||||||
|
"uni-ui",
|
||||||
|
"uniui",
|
||||||
|
"input",
|
||||||
|
"uni-easyinput",
|
||||||
|
"输入框"
|
||||||
|
],
|
||||||
|
"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"
|
||||||
|
},
|
||||||
|
"client": {
|
||||||
|
"App": {
|
||||||
|
"app-vue": "y",
|
||||||
|
"app-nvue": "y"
|
||||||
|
},
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1 +1 @@
|
|||||||
<view class="content page-box data-v-1cf27b2a"><my-swiper wx:if="{{a}}" class="index-siwper margin-b-card data-v-1cf27b2a" style="width:100%" u-i="1cf27b2a-0" bind:__l="__l" u-p="{{a}}"/><view class="main-cards data-v-1cf27b2a"><view class="mc-part data-v-1cf27b2a" style="margin-left:0"><view class="mc-part-text data-v-1cf27b2a">已完成事项</view><image class="data-v-1cf27b2a" src="/static/done.png" mode="widthFix"></image></view><view class="mc-part mc-part2 data-v-1cf27b2a" style="margin-right:0"><view class="mc-part-text data-v-1cf27b2a">待完成事项</view><image class="data-v-1cf27b2a" style="transform:rotate(0deg)" src="/static/undone.png" mode="widthFix"></image></view></view><view class="attention-card data-v-1cf27b2a"><view class="part-title data-v-1cf27b2a"> 注意事项 </view><view class="ac-parts data-v-1cf27b2a"><view class="ac-part data-v-1cf27b2a" style="background:linear-gradient(45deg, #ffa2a2,#ffd3d3, #ffffff00)"> 术前注意事项 <uni-icons wx:if="{{b}}" class="data-v-1cf27b2a" u-i="1cf27b2a-1" bind:__l="__l" u-p="{{b}}"></uni-icons></view><view class="ac-part data-v-1cf27b2a" style="background:linear-gradient(45deg, #f9b275,#fff3e9, #ffffff00)"> 术中注意事项 <uni-icons wx:if="{{c}}" class="data-v-1cf27b2a" u-i="1cf27b2a-2" bind:__l="__l" u-p="{{c}}"></uni-icons></view><view class="ac-part data-v-1cf27b2a" style="background:linear-gradient(45deg, #8fdc8a,#fdfdfd, #ffffff00)"> 术后注意事项 <uni-icons wx:if="{{d}}" class="data-v-1cf27b2a" u-i="1cf27b2a-3" bind:__l="__l" u-p="{{d}}"></uni-icons></view></view></view><uni-popup wx:if="{{f}}" class="r data-v-1cf27b2a" u-s="{{['d']}}" u-r="inputDialog" u-i="1cf27b2a-4" bind:__l="__l" u-p="{{f}}"><view class="pop-box data-v-1cf27b2a"><view class="pb-title data-v-1cf27b2a">手术信息</view></view><view class="pop-close data-v-1cf27b2a"> 关闭 </view></uni-popup></view>
|
<view class="content page-box data-v-1cf27b2a"><my-swiper wx:if="{{a}}" class="index-siwper margin-b-card data-v-1cf27b2a" style="width:100%" u-i="1cf27b2a-0" bind:__l="__l" u-p="{{a}}"/><view class="main-cards data-v-1cf27b2a"><view class="mc-part data-v-1cf27b2a" style="margin-left:0"><view class="mc-part-text data-v-1cf27b2a">已完成事项</view><image class="data-v-1cf27b2a" src="/static/done.png" mode="widthFix"></image></view><view class="mc-part mc-part2 data-v-1cf27b2a" style="margin-right:0"><view class="mc-part-text data-v-1cf27b2a">待完成事项</view><image class="data-v-1cf27b2a" style="transform:rotate(0deg)" src="/static/undone.png" mode="widthFix"></image></view></view><view class="attention-card data-v-1cf27b2a"><view class="part-title data-v-1cf27b2a"> 注意事项 </view><view class="ac-parts data-v-1cf27b2a"><view class="ac-part data-v-1cf27b2a" style="background:linear-gradient(45deg, #ffa2a2,#ffd3d3, #ffffff00)"> 术前注意事项 <uni-icons wx:if="{{b}}" class="data-v-1cf27b2a" u-i="1cf27b2a-1" bind:__l="__l" u-p="{{b}}"></uni-icons></view><view class="ac-part data-v-1cf27b2a" style="background:linear-gradient(45deg, #f9b275,#fff3e9, #ffffff00)"> 术中注意事项 <uni-icons wx:if="{{c}}" class="data-v-1cf27b2a" u-i="1cf27b2a-2" bind:__l="__l" u-p="{{c}}"></uni-icons></view><view class="ac-part data-v-1cf27b2a" style="background:linear-gradient(45deg, #8fdc8a,#fdfdfd, #ffffff00)"> 术后注意事项 <uni-icons wx:if="{{d}}" class="data-v-1cf27b2a" u-i="1cf27b2a-3" bind:__l="__l" u-p="{{d}}"></uni-icons></view></view></view><uni-popup wx:if="{{n}}" class="r data-v-1cf27b2a" u-s="{{['d']}}" u-r="inputDialog" u-i="1cf27b2a-4" bind:__l="__l" u-p="{{n}}"><view class="pop-box data-v-1cf27b2a"><view class="pb-title data-v-1cf27b2a">完善手术信息</view><view class="pb-content data-v-1cf27b2a"><view class="pb-item data-v-1cf27b2a"><view class="pb-item-left data-v-1cf27b2a">已经手术</view><view class="pb-item-right data-v-1cf27b2a"><radio-group class="data-v-1cf27b2a" bindchange="{{e}}"><label class="radio data-v-1cf27b2a"><radio class="data-v-1cf27b2a" value="1"/>是</label><label class="radio data-v-1cf27b2a"><radio class="data-v-1cf27b2a" value="0"/>否</label></radio-group></view></view><view class="pb-item data-v-1cf27b2a"><view class="pb-item-left data-v-1cf27b2a">手术时间</view><view class="pb-item-right data-v-1cf27b2a"><uni-datetime-picker wx:if="{{h}}" class="data-v-1cf27b2a" bindmaskClick="{{f}}" u-i="1cf27b2a-5,1cf27b2a-4" bind:__l="__l" bindupdateModelValue="{{g}}" u-p="{{h}}"></uni-datetime-picker></view></view><view class="pb-item data-v-1cf27b2a"><view class="pb-item-left data-v-1cf27b2a">医院名称</view><view class="pb-item-right data-v-1cf27b2a"><uni-easyinput wx:if="{{k}}" class="data-v-1cf27b2a" bindiconClick="{{i}}" u-i="1cf27b2a-6,1cf27b2a-4" bind:__l="__l" bindupdateModelValue="{{j}}" u-p="{{k}}"></uni-easyinput></view></view></view></view><view class="pop-close data-v-1cf27b2a" bindtap="{{l}}"> 关闭 </view></uni-popup></view>
|
@ -0,0 +1,111 @@
|
|||||||
|
"use strict";
|
||||||
|
const common_vendor = require("../../common/vendor.js");
|
||||||
|
const store_index = require("../../store/index.js");
|
||||||
|
const api_index = require("../../api/index.js");
|
||||||
|
const utils_index = require("../../utils/index.js");
|
||||||
|
require("../../api/request.js");
|
||||||
|
require("../../config/index.js");
|
||||||
|
if (!Array) {
|
||||||
|
const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
|
||||||
|
_easycom_uni_icons2();
|
||||||
|
}
|
||||||
|
const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
|
||||||
|
if (!Math) {
|
||||||
|
_easycom_uni_icons();
|
||||||
|
}
|
||||||
|
const _sfc_main = {
|
||||||
|
__name: "login",
|
||||||
|
setup(__props) {
|
||||||
|
store_index.useStore();
|
||||||
|
common_vendor.onLoad(() => {
|
||||||
|
});
|
||||||
|
const avatarUrl = common_vendor.ref(null);
|
||||||
|
const nickname = common_vendor.ref("");
|
||||||
|
const res_form = common_vendor.ref(null);
|
||||||
|
common_vendor.watch(nickname, (v1, v2) => {
|
||||||
|
console.log("watch", v1);
|
||||||
|
});
|
||||||
|
function onChooseAvatar(e) {
|
||||||
|
avatarUrl.value = e.detail.avatarUrl;
|
||||||
|
}
|
||||||
|
function getPhoneNumber(e) {
|
||||||
|
getAccess_token({ code: e.detail.code });
|
||||||
|
}
|
||||||
|
async function getAccess_token(params = {}) {
|
||||||
|
const data = {
|
||||||
|
username: params.code,
|
||||||
|
//手机号按钮获取的code
|
||||||
|
type: "wechat_mini_app",
|
||||||
|
identity: "user",
|
||||||
|
password: "111",
|
||||||
|
avatarUrl: avatarUrl.value,
|
||||||
|
nickName: nickname.value
|
||||||
|
};
|
||||||
|
const res = await api_index.API.getToken(data);
|
||||||
|
if (res.code === 200) {
|
||||||
|
common_vendor.index.setStorageSync("avatarUrl", avatarUrl.value);
|
||||||
|
res_form.value = res.data;
|
||||||
|
res_form.value.access_token = "Bearer " + res.data.access_token;
|
||||||
|
let userId = res.data.userId;
|
||||||
|
common_vendor.index.setStorageSync("access_token", res_form.value.access_token);
|
||||||
|
wx_login(userId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function wx_login(userId) {
|
||||||
|
let res = await new Promise((resolve) => {
|
||||||
|
common_vendor.index.login({
|
||||||
|
provider: "weixin",
|
||||||
|
//使用微信登录
|
||||||
|
success: function(loginRes) {
|
||||||
|
resolve(loginRes);
|
||||||
|
console.log(loginRes, "微信登录返回信息");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
let res2 = await api_index.API.wx_login({ code: res.code }, userId);
|
||||||
|
if (res2.code === 0) {
|
||||||
|
common_vendor.index.setStorageSync("userInfo", JSON.stringify(res_form.value));
|
||||||
|
utils_index.custom.uploadImage(avatarUrl.value, async (file) => {
|
||||||
|
avatarUrl.value = file.data.file.url;
|
||||||
|
common_vendor.index.setStorageSync("avatarUrl", file.data.file.url);
|
||||||
|
await updateFunc();
|
||||||
|
common_vendor.index.switchTab({
|
||||||
|
url: "/pages/user/index"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
common_vendor.index.clearStorage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function updateFunc() {
|
||||||
|
let user_info = JSON.parse(common_vendor.index.getStorageSync("userInfo"));
|
||||||
|
user_info.avatar = avatarUrl.value;
|
||||||
|
user_info.id = user_info.userId;
|
||||||
|
return await api_index.API.userinfoUpdae(user_info);
|
||||||
|
}
|
||||||
|
function nameInput(e) {
|
||||||
|
nickname.value = e.detail.value;
|
||||||
|
}
|
||||||
|
return (_ctx, _cache) => {
|
||||||
|
return common_vendor.e({
|
||||||
|
a: avatarUrl.value
|
||||||
|
}, avatarUrl.value ? {
|
||||||
|
b: avatarUrl.value
|
||||||
|
} : {
|
||||||
|
c: common_vendor.p({
|
||||||
|
type: "person-filled",
|
||||||
|
color: "white",
|
||||||
|
size: "60"
|
||||||
|
})
|
||||||
|
}, {
|
||||||
|
d: common_vendor.o(onChooseAvatar),
|
||||||
|
e: common_vendor.o(nameInput),
|
||||||
|
f: nickname.value,
|
||||||
|
g: common_vendor.o(($event) => nickname.value = $event.detail.value),
|
||||||
|
h: common_vendor.o(getPhoneNumber)
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-e4e4508d"], ["__file", "F:/项目2023/视力表/vision-record/pages/login/login.vue"]]);
|
||||||
|
wx.createPage(MiniProgramPage);
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"navigationBarTitleText": "登录",
|
||||||
|
"usingComponents": {
|
||||||
|
"uni-icons": "../../uni_modules/uni-icons/components/uni-icons/uni-icons"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
<view class="loginBox page-box img-part card-part data-v-e4e4508d" style="text-align:center"><view class="base-info data-v-e4e4508d"><button class="avatar-wrapper data-v-e4e4508d" open-type="chooseAvatar" bindchooseavatar="{{d}}" style="border-radius:50%"><image wx:if="{{a}}" class="avatar data-v-e4e4508d" mode="aspectFill" src="{{b}}"></image><uni-icons wx:else class="data-v-e4e4508d" u-i="e4e4508d-0" bind:__l="__l" u-p="{{c||''}}"></uni-icons></button><input type="nickname" bindblur="{{e}}" class="weui-input data-v-e4e4508d" placeholder="请输入昵称" value="{{f}}" bindinput="{{g}}"/></view><view class="btn-part data-v-e4e4508d"><button class="buy-btn data-v-e4e4508d" open-type="getPhoneNumber" bindgetphonenumber="{{h}}">立即登录</button></view></view>
|
@ -1,48 +1,41 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
const common_vendor = require("../../common/vendor.js");
|
const common_vendor = require("../../common/vendor.js");
|
||||||
const store_index = require("../../store/index.js");
|
const store_index = require("../../store/index.js");
|
||||||
const api_index = require("../../api/index.js");
|
const utils_index = require("../../utils/index.js");
|
||||||
|
require("../../api/index.js");
|
||||||
require("../../api/request.js");
|
require("../../api/request.js");
|
||||||
require("../../config/index.js");
|
require("../../config/index.js");
|
||||||
const _sfc_main = {
|
const _sfc_main = {
|
||||||
__name: "index",
|
__name: "index",
|
||||||
setup(__props) {
|
setup(__props) {
|
||||||
store_index.useStore();
|
store_index.useStore();
|
||||||
function getPhoneNumber(e) {
|
common_vendor.onShow(() => {
|
||||||
console.log(e);
|
is_login.value = utils_index.custom.checkLogin();
|
||||||
getAccess_token({ code: e.detail.code });
|
if (is_login.value) {
|
||||||
}
|
userinfo.value = common_vendor.index.getStorageSync("userInfo");
|
||||||
async function getAccess_token(params = {}) {
|
avatar.value = common_vendor.index.getStorageSync("avatarUrl");
|
||||||
const data = {
|
userinfo.value = JSON.parse(userinfo.value);
|
||||||
username: params.code,
|
|
||||||
//手机号按钮获取的code
|
|
||||||
type: "wechat_mini_app",
|
|
||||||
identity: "user",
|
|
||||||
password: "111"
|
|
||||||
};
|
|
||||||
await api_index.API.getToken(data);
|
|
||||||
wx_login();
|
|
||||||
}
|
|
||||||
async function wx_login(token_res) {
|
|
||||||
let res = await new Promise((resolve) => {
|
|
||||||
common_vendor.index.login({
|
|
||||||
provider: "weixin",
|
|
||||||
//使用微信登录
|
|
||||||
success: function(loginRes) {
|
|
||||||
resolve(loginRes);
|
|
||||||
console.log(loginRes, "微信登录返回信息");
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const avatar = common_vendor.ref("");
|
||||||
|
common_vendor.ref(null);
|
||||||
|
const is_login = common_vendor.ref(null);
|
||||||
|
const userinfo = common_vendor.ref(null);
|
||||||
|
function toLogin() {
|
||||||
|
common_vendor.index.navigateTo({
|
||||||
|
url: "/pages/login/login"
|
||||||
});
|
});
|
||||||
let userId = "";
|
|
||||||
await api_index.API.wx_login({ code: res.code }, userId);
|
|
||||||
}
|
}
|
||||||
return (_ctx, _cache) => {
|
return (_ctx, _cache) => {
|
||||||
return {
|
return common_vendor.e({
|
||||||
a: common_vendor.o(getPhoneNumber)
|
a: is_login.value ? avatar.value : "../../static/avatar.png",
|
||||||
};
|
b: common_vendor.t(is_login.value ? userinfo.value.nickname : "未登录"),
|
||||||
|
c: !is_login.value
|
||||||
|
}, !is_login.value ? {
|
||||||
|
d: common_vendor.o(toLogin)
|
||||||
|
} : {});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "F:/项目2023/视力表/vision-record/pages/user/index.vue"]]);
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-79e6a490"], ["__file", "F:/项目2023/视力表/vision-record/pages/user/index.vue"]]);
|
||||||
wx.createPage(MiniProgramPage);
|
wx.createPage(MiniProgramPage);
|
||||||
|
@ -1 +1 @@
|
|||||||
<view class="user-box page-box"><button class="submit-btn" open-type="getPhoneNumber" bindgetphonenumber="{{a}}"><text>登录</text></button></view>
|
<view class="user-box page-box data-v-79e6a490"><view class="userinfo-box data-v-79e6a490"><image class="data-v-79e6a490" src="{{a}}" mode=""></image><view class=" data-v-79e6a490">{{b}}</view></view><view wx:if="{{c}}" class="btn-box data-v-79e6a490" bindtap="{{d}}"><view class="btn data-v-79e6a490">登录</view></view></view>
|
Binary file not shown.
After Width: | Height: | Size: 7.0 KiB |
@ -0,0 +1,58 @@
|
|||||||
|
"use strict";
|
||||||
|
const common_vendor = require("../../../../common/vendor.js");
|
||||||
|
const _sfc_main = {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||||
|
return common_vendor.e({
|
||||||
|
a: $props.selected && $props.weeks.extraInfo
|
||||||
|
}, $props.selected && $props.weeks.extraInfo ? {} : {}, {
|
||||||
|
b: common_vendor.t($props.weeks.date),
|
||||||
|
c: $props.calendar.fullDate === $props.weeks.fullDate && ($props.calendar.userChecked || !$props.checkHover) ? 1 : "",
|
||||||
|
d: $props.checkHover ? 1 : "",
|
||||||
|
e: $props.weeks.beforeMultiple ? 1 : "",
|
||||||
|
f: $props.weeks.multiple ? 1 : "",
|
||||||
|
g: $props.weeks.afterMultiple ? 1 : "",
|
||||||
|
h: $props.weeks.disable ? 1 : "",
|
||||||
|
i: $props.weeks.isToday ? 1 : "",
|
||||||
|
j: $props.weeks.disable ? 1 : "",
|
||||||
|
k: $props.weeks.beforeMultiple ? 1 : "",
|
||||||
|
l: $props.weeks.multiple ? 1 : "",
|
||||||
|
m: $props.weeks.afterMultiple ? 1 : "",
|
||||||
|
n: common_vendor.o(($event) => $options.choiceDate($props.weeks)),
|
||||||
|
o: common_vendor.o(($event) => $options.handleMousemove($props.weeks))
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "F:/项目2023/视力表/vision-record/uni_modules/uni-datetime-picker/components/uni-datetime-picker/calendar-item.vue"]]);
|
||||||
|
wx.createComponent(Component);
|
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"component": true,
|
||||||
|
"usingComponents": {}
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
<view class="{{['uni-calendar-item__weeks-box', j && 'uni-calendar-item--disable', k && 'uni-calendar-item--before-checked-x', l && 'uni-calendar-item--multiple', m && 'uni-calendar-item--after-checked-x']}}" bindtap="{{n}}" bindmouseenter="{{o}}"><view class="{{['uni-calendar-item__weeks-box-item', c && 'uni-calendar-item--checked', d && 'uni-calendar-item--checked-range-text', e && 'uni-calendar-item--before-checked', f && 'uni-calendar-item--multiple', g && 'uni-calendar-item--after-checked', h && 'uni-calendar-item--disable']}}"><text wx:if="{{a}}" 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">{{b}}</text></view><view class="{{[i && 'uni-calendar-item--today']}}"></view></view>
|
@ -0,0 +1,597 @@
|
|||||||
|
"use strict";
|
||||||
|
const uni_modules_uniDatetimePicker_components_uniDatetimePicker_util = require("./util.js");
|
||||||
|
const common_vendor = require("../../../../common/vendor.js");
|
||||||
|
const uni_modules_uniDatetimePicker_components_uniDatetimePicker_i18n_index = require("./i18n/index.js");
|
||||||
|
const calendarItem = () => "./calendar-item.js";
|
||||||
|
const timePicker = () => "./time-picker.js";
|
||||||
|
const { t } = common_vendor.initVueI18n(uni_modules_uniDatetimePicker_components_uniDatetimePicker_i18n_index.i18nMessages);
|
||||||
|
const _sfc_main = {
|
||||||
|
components: {
|
||||||
|
calendarItem,
|
||||||
|
timePicker
|
||||||
|
},
|
||||||
|
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) {
|
||||||
|
if (!this.cale) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.cale.setStartDate(val);
|
||||||
|
this.cale.setDate(this.nowDate.fullDate);
|
||||||
|
this.weeks = this.cale.weeks;
|
||||||
|
},
|
||||||
|
endDate(val) {
|
||||||
|
if (!this.cale) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.cale.setEndDate(val);
|
||||||
|
this.cale.setDate(this.nowDate.fullDate);
|
||||||
|
this.weeks = this.cale.weeks;
|
||||||
|
},
|
||||||
|
selected(newVal) {
|
||||||
|
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 {
|
||||||
|
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 uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.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;
|
||||||
|
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(/* @__PURE__ */ new Date());
|
||||||
|
},
|
||||||
|
bindDateChange(e) {
|
||||||
|
const value = e.detail.value + "-1";
|
||||||
|
this.setDate(value);
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 初始化日期显示
|
||||||
|
* @param {Object} date
|
||||||
|
*/
|
||||||
|
init(date) {
|
||||||
|
if (!this.cale) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.cale.setDate(date || /* @__PURE__ */ new Date());
|
||||||
|
this.weeks = this.cale.weeks;
|
||||||
|
this.nowDate = this.cale.getInfo(date);
|
||||||
|
this.calendar = { ...this.nowDate };
|
||||||
|
if (!date) {
|
||||||
|
this.calendar.fullDate = "";
|
||||||
|
if (this.defaultValue && !this.range) {
|
||||||
|
const defaultDate = new Date(this.defaultValue);
|
||||||
|
const fullDate = uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.getDate(defaultDate);
|
||||||
|
const year = defaultDate.getFullYear();
|
||||||
|
const month = defaultDate.getMonth() + 1;
|
||||||
|
const date2 = defaultDate.getDate();
|
||||||
|
const day = defaultDate.getDay();
|
||||||
|
this.calendar = {
|
||||||
|
fullDate,
|
||||||
|
year,
|
||||||
|
month,
|
||||||
|
date: date2,
|
||||||
|
day
|
||||||
|
}, this.tempSingleDate = fullDate;
|
||||||
|
this.time = uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.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() {
|
||||||
|
if (!this.insert)
|
||||||
|
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(/* @__PURE__ */ new Date());
|
||||||
|
this.tempSingleDate = this.calendar.fullDate;
|
||||||
|
}
|
||||||
|
if (this.hasTime && !this.time) {
|
||||||
|
this.time = uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.getTime(/* @__PURE__ */ 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();
|
||||||
|
},
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (!Array) {
|
||||||
|
const _component_calendar_item = common_vendor.resolveComponent("calendar-item");
|
||||||
|
const _component_time_picker = common_vendor.resolveComponent("time-picker");
|
||||||
|
const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
|
||||||
|
(_component_calendar_item + _component_time_picker + _easycom_uni_icons2)();
|
||||||
|
}
|
||||||
|
const _easycom_uni_icons = () => "../../../uni-icons/components/uni-icons/uni-icons.js";
|
||||||
|
if (!Math) {
|
||||||
|
_easycom_uni_icons();
|
||||||
|
}
|
||||||
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||||
|
return common_vendor.e({
|
||||||
|
a: !$props.insert && $data.show
|
||||||
|
}, !$props.insert && $data.show ? {
|
||||||
|
b: $data.aniMaskShow ? 1 : "",
|
||||||
|
c: common_vendor.o((...args) => $options.maskClick && $options.maskClick(...args))
|
||||||
|
} : {}, {
|
||||||
|
d: $props.insert || $data.show
|
||||||
|
}, $props.insert || $data.show ? common_vendor.e({
|
||||||
|
e: common_vendor.o(($event) => $options.changeMonth("pre")),
|
||||||
|
f: common_vendor.t(($data.nowDate.year || "") + $options.yearText + ($data.nowDate.month || "") + $options.monthText),
|
||||||
|
g: $props.date,
|
||||||
|
h: common_vendor.o((...args) => $options.bindDateChange && $options.bindDateChange(...args)),
|
||||||
|
i: common_vendor.o(($event) => $options.changeMonth("next")),
|
||||||
|
j: !$props.insert
|
||||||
|
}, !$props.insert ? {
|
||||||
|
k: common_vendor.o((...args) => $options.close && $options.close(...args))
|
||||||
|
} : {}, {
|
||||||
|
l: !$props.insert ? 1 : "",
|
||||||
|
m: $props.showMonth
|
||||||
|
}, $props.showMonth ? {
|
||||||
|
n: common_vendor.t($data.nowDate.month)
|
||||||
|
} : {}, {
|
||||||
|
o: common_vendor.t($options.SUNText),
|
||||||
|
p: common_vendor.t($options.MONText),
|
||||||
|
q: common_vendor.t($options.TUEText),
|
||||||
|
r: common_vendor.t($options.WEDText),
|
||||||
|
s: common_vendor.t($options.THUText),
|
||||||
|
t: common_vendor.t($options.FRIText),
|
||||||
|
v: common_vendor.t($options.SATText),
|
||||||
|
w: common_vendor.f($data.weeks, (item, weekIndex, i0) => {
|
||||||
|
return {
|
||||||
|
a: common_vendor.f(item, (weeks, weeksIndex, i1) => {
|
||||||
|
return {
|
||||||
|
a: common_vendor.o($options.choiceDate, weeksIndex),
|
||||||
|
b: common_vendor.o($options.handleMouse, weeksIndex),
|
||||||
|
c: "691a75e6-0-" + i0 + "-" + i1,
|
||||||
|
d: common_vendor.p({
|
||||||
|
weeks,
|
||||||
|
calendar: $data.calendar,
|
||||||
|
selected: $props.selected,
|
||||||
|
checkHover: $props.range
|
||||||
|
}),
|
||||||
|
e: weeksIndex
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
b: weekIndex
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
x: !$props.insert && !$props.range && $props.hasTime
|
||||||
|
}, !$props.insert && !$props.range && $props.hasTime ? {
|
||||||
|
y: common_vendor.t($data.tempSingleDate ? $data.tempSingleDate : $options.selectDateText),
|
||||||
|
z: common_vendor.o(($event) => $data.time = $event),
|
||||||
|
A: common_vendor.p({
|
||||||
|
type: "time",
|
||||||
|
start: $options.timepickerStartTime,
|
||||||
|
end: $options.timepickerEndTime,
|
||||||
|
disabled: !$data.tempSingleDate,
|
||||||
|
border: false,
|
||||||
|
["hide-second"]: $props.hideSecond,
|
||||||
|
modelValue: $data.time
|
||||||
|
})
|
||||||
|
} : {}, {
|
||||||
|
B: !$props.insert && $props.range && $props.hasTime
|
||||||
|
}, !$props.insert && $props.range && $props.hasTime ? {
|
||||||
|
C: common_vendor.t($data.tempRange.before ? $data.tempRange.before : $options.startDateText),
|
||||||
|
D: common_vendor.o(($event) => $data.timeRange.startTime = $event),
|
||||||
|
E: common_vendor.p({
|
||||||
|
type: "time",
|
||||||
|
start: $options.timepickerStartTime,
|
||||||
|
border: false,
|
||||||
|
["hide-second"]: $props.hideSecond,
|
||||||
|
disabled: !$data.tempRange.before,
|
||||||
|
modelValue: $data.timeRange.startTime
|
||||||
|
}),
|
||||||
|
F: common_vendor.p({
|
||||||
|
type: "arrowthinright",
|
||||||
|
color: "#999"
|
||||||
|
}),
|
||||||
|
G: common_vendor.t($data.tempRange.after ? $data.tempRange.after : $options.endDateText),
|
||||||
|
H: common_vendor.o(($event) => $data.timeRange.endTime = $event),
|
||||||
|
I: common_vendor.p({
|
||||||
|
type: "time",
|
||||||
|
end: $options.timepickerEndTime,
|
||||||
|
border: false,
|
||||||
|
["hide-second"]: $props.hideSecond,
|
||||||
|
disabled: !$data.tempRange.after,
|
||||||
|
modelValue: $data.timeRange.endTime
|
||||||
|
})
|
||||||
|
} : {}, {
|
||||||
|
J: !$props.insert
|
||||||
|
}, !$props.insert ? {
|
||||||
|
K: common_vendor.t($options.confirmText),
|
||||||
|
L: common_vendor.o((...args) => $options.confirm && $options.confirm(...args))
|
||||||
|
} : {}, {
|
||||||
|
M: !$props.insert ? 1 : "",
|
||||||
|
N: $data.aniMaskShow ? 1 : "",
|
||||||
|
O: $data.aniMaskShow ? 1 : ""
|
||||||
|
}) : {}, {
|
||||||
|
P: common_vendor.o((...args) => $options.leaveCale && $options.leaveCale(...args))
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "F:/项目2023/视力表/vision-record/uni_modules/uni-datetime-picker/components/uni-datetime-picker/calendar.vue"]]);
|
||||||
|
wx.createComponent(Component);
|
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"component": true,
|
||||||
|
"usingComponents": {
|
||||||
|
"calendar-item": "./calendar-item",
|
||||||
|
"time-picker": "./time-picker",
|
||||||
|
"uni-icons": "../../../uni-icons/components/uni-icons/uni-icons"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
<view class="uni-calendar" bindmouseleave="{{P}}"><view wx:if="{{a}}" class="{{['uni-calendar__mask', b && 'uni-calendar--mask-show']}}" bindtap="{{c}}"></view><view wx:if="{{d}}" class="{{['uni-calendar__content', M && 'uni-calendar--fixed', N && 'uni-calendar--ani-show', O && 'uni-calendar__content-mobile']}}"><view class="{{['uni-calendar__header', l && 'uni-calendar__header-mobile']}}"><view class="uni-calendar__header-btn-box" catchtap="{{e}}"><view class="uni-calendar__header-btn uni-calendar--left"></view></view><picker mode="date" value="{{g}}" fields="month" bindchange="{{h}}"><text class="uni-calendar__header-text">{{f}}</text></picker><view class="uni-calendar__header-btn-box" catchtap="{{i}}"><view class="uni-calendar__header-btn uni-calendar--right"></view></view><view wx:if="{{j}}" class="dialog-close" bindtap="{{k}}"><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 wx:if="{{m}}" class="uni-calendar__box-bg"><text class="uni-calendar__box-bg-text">{{n}}</text></view><view class="uni-calendar__weeks" style="padding-bottom:7px"><view class="uni-calendar__weeks-day"><text class="uni-calendar__weeks-day-text">{{o}}</text></view><view class="uni-calendar__weeks-day"><text class="uni-calendar__weeks-day-text">{{p}}</text></view><view class="uni-calendar__weeks-day"><text class="uni-calendar__weeks-day-text">{{q}}</text></view><view class="uni-calendar__weeks-day"><text class="uni-calendar__weeks-day-text">{{r}}</text></view><view class="uni-calendar__weeks-day"><text class="uni-calendar__weeks-day-text">{{s}}</text></view><view class="uni-calendar__weeks-day"><text class="uni-calendar__weeks-day-text">{{t}}</text></view><view class="uni-calendar__weeks-day"><text class="uni-calendar__weeks-day-text">{{v}}</text></view></view><view wx:for="{{w}}" wx:for-item="item" wx:key="b" class="uni-calendar__weeks"><view wx:for="{{item.a}}" wx:for-item="weeks" wx:key="e" class="uni-calendar__weeks-item"><calendar-item wx:if="{{weeks.d}}" class="uni-calendar-item--hook" bindchange="{{weeks.a}}" bindhandleMouse="{{weeks.b}}" u-i="{{weeks.c}}" bind:__l="__l" u-p="{{weeks.d}}"></calendar-item></view></view></view><view wx:if="{{x}}" class="uni-date-changed uni-calendar--fixed-top" style="padding:0 80px"><view class="uni-date-changed--time-date">{{y}}</view><time-picker wx:if="{{A}}" class="time-picker-style" u-i="691a75e6-1" bind:__l="__l" bindupdateModelValue="{{z}}" u-p="{{A}}"></time-picker></view><view wx:if="{{B}}" class="uni-date-changed uni-calendar--fixed-top"><view class="uni-date-changed--time-start"><view class="uni-date-changed--time-date">{{C}}</view><time-picker wx:if="{{E}}" class="time-picker-style" u-i="691a75e6-2" bind:__l="__l" bindupdateModelValue="{{D}}" u-p="{{E}}"></time-picker></view><view style="line-height:50px"><uni-icons wx:if="{{F}}" u-i="691a75e6-3" bind:__l="__l" u-p="{{F}}"></uni-icons></view><view class="uni-date-changed--time-end"><view class="uni-date-changed--time-date">{{G}}</view><time-picker wx:if="{{I}}" class="time-picker-style" u-i="691a75e6-4" bind:__l="__l" bindupdateModelValue="{{H}}" u-p="{{I}}"></time-picker></view></view><view wx:if="{{J}}" class="uni-date-changed uni-date-btn--ok"><view class="uni-datetime-picker--btn" bindtap="{{L}}">{{K}}</view></view></view></view>
|
@ -0,0 +1,73 @@
|
|||||||
|
"use strict";
|
||||||
|
const en = {
|
||||||
|
"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"
|
||||||
|
};
|
||||||
|
const zhHans = {
|
||||||
|
"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": "确认"
|
||||||
|
};
|
||||||
|
const 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": "確認"
|
||||||
|
};
|
||||||
|
const i18nMessages = {
|
||||||
|
en,
|
||||||
|
"zh-Hans": zhHans,
|
||||||
|
"zh-Hant": zhHant
|
||||||
|
};
|
||||||
|
exports.i18nMessages = i18nMessages;
|
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"component": true,
|
||||||
|
"usingComponents": {}
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
<view class="uni-datetime-picker"><view bindtap="{{f}}"><block wx:if="{{$slots.d}}"><slot></slot></block><block wx:else><view class="{{['uni-datetime-picker-timebox-pointer', d && 'uni-datetime-picker-disabled', e && 'uni-datetime-picker-timebox']}}"><text class="uni-datetime-picker-text">{{a}}</text><view wx:if="{{b}}" class="uni-datetime-picker-time"><text class="uni-datetime-picker-text">{{c}}</text></view></view></block></view><view wx:if="{{g}}" id="mask" class="uni-datetime-picker-mask" bindtap="{{h}}"></view><view wx:if="{{i}}" class="{{['uni-datetime-picker-popup', J]}}" style="{{K}}"><view class="uni-title"><text class="uni-datetime-picker-text">{{j}}</text></view><view wx:if="{{k}}" class="uni-datetime-picker__container-box"><picker-view class="uni-datetime-picker-view" indicator-style="{{o}}" value="{{p}}" bindchange="{{q}}"><picker-view-column><view wx:for="{{l}}" wx:for-item="item" wx:key="b" class="uni-datetime-picker-item"><text class="uni-datetime-picker-item">{{item.a}}</text></view></picker-view-column><picker-view-column><view wx:for="{{m}}" wx:for-item="item" wx:key="b" class="uni-datetime-picker-item"><text class="uni-datetime-picker-item">{{item.a}}</text></view></picker-view-column><picker-view-column><view wx:for="{{n}}" wx:for-item="item" wx:key="b" class="uni-datetime-picker-item"><text class="uni-datetime-picker-item">{{item.a}}</text></view></picker-view-column></picker-view><text class="uni-datetime-picker-sign sign-left">-</text><text class="uni-datetime-picker-sign sign-right">-</text></view><view wx:if="{{r}}" class="uni-datetime-picker__container-box"><picker-view class="{{['uni-datetime-picker-view', x]}}" indicator-style="{{y}}" value="{{z}}" bindchange="{{A}}"><picker-view-column><view wx:for="{{s}}" wx:for-item="item" wx:key="b" class="uni-datetime-picker-item"><text class="uni-datetime-picker-item">{{item.a}}</text></view></picker-view-column><picker-view-column><view wx:for="{{t}}" wx:for-item="item" wx:key="b" class="uni-datetime-picker-item"><text class="uni-datetime-picker-item">{{item.a}}</text></view></picker-view-column><picker-view-column wx:if="{{v}}"><view wx:for="{{w}}" wx:for-item="item" wx:key="b" class="uni-datetime-picker-item"><text class="uni-datetime-picker-item">{{item.a}}</text></view></picker-view-column></picker-view><text class="{{['uni-datetime-picker-sign', B]}}">:</text><text wx:if="{{C}}" class="uni-datetime-picker-sign sign-right">:</text></view><view class="uni-datetime-picker-btn"><view bindtap="{{E}}"><text class="uni-datetime-picker-btn-text">{{D}}</text></view><view class="uni-datetime-picker-btn-group"><view class="uni-datetime-picker-cancel" bindtap="{{G}}"><text class="uni-datetime-picker-btn-text">{{F}}</text></view><view bindtap="{{I}}"><text class="uni-datetime-picker-btn-text">{{H}}</text></view></view></view></view></view>
|
@ -0,0 +1,828 @@
|
|||||||
|
"use strict";
|
||||||
|
const common_vendor = require("../../../../common/vendor.js");
|
||||||
|
const uni_modules_uniDatetimePicker_components_uniDatetimePicker_i18n_index = require("./i18n/index.js");
|
||||||
|
const uni_modules_uniDatetimePicker_components_uniDatetimePicker_util = require("./util.js");
|
||||||
|
const Calendar = () => "./calendar.js";
|
||||||
|
const TimePicker = () => "./time-picker.js";
|
||||||
|
const _sfc_main = {
|
||||||
|
name: "UniDatetimePicker",
|
||||||
|
options: {
|
||||||
|
virtualHost: true
|
||||||
|
},
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
modelValue: {
|
||||||
|
immediate: true,
|
||||||
|
handler(newVal) {
|
||||||
|
if (this.isEmitValue) {
|
||||||
|
this.isEmitValue = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.initPicker(newVal);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
start: {
|
||||||
|
immediate: true,
|
||||||
|
handler(newVal) {
|
||||||
|
if (!newVal)
|
||||||
|
return;
|
||||||
|
this.calendarRange.startDate = uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.getDate(newVal);
|
||||||
|
if (this.hasTime) {
|
||||||
|
this.calendarRange.startTime = uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.getTime(newVal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
end: {
|
||||||
|
immediate: true,
|
||||||
|
handler(newVal) {
|
||||||
|
if (!newVal)
|
||||||
|
return;
|
||||||
|
this.calendarRange.endDate = uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.getDate(newVal);
|
||||||
|
if (this.hasTime) {
|
||||||
|
this.calendarRange.endTime = uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.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() {
|
||||||
|
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 = common_vendor.initVueI18n(uni_modules_uniDatetimePicker_components_uniDatetimePicker_i18n_index.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 = uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.getDate(newVal);
|
||||||
|
if (this.hasTime) {
|
||||||
|
this.pickerTime = uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.getTime(newVal, this.hideSecond);
|
||||||
|
this.displayValue = `${this.displayValue} ${this.pickerTime}`;
|
||||||
|
}
|
||||||
|
} else if (this.defaultValue) {
|
||||||
|
this.inputDate = this.calendarDate = uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.getDate(this.defaultValue);
|
||||||
|
if (this.hasTime) {
|
||||||
|
this.pickerTime = uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.getTime(this.defaultValue, this.hideSecond);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const [before, after] = newVal;
|
||||||
|
if (!before && !after)
|
||||||
|
return;
|
||||||
|
const beforeDate = uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.getDate(before);
|
||||||
|
const beforeTime = uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.getTime(before, this.hideSecond);
|
||||||
|
const afterDate = uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.getDate(after);
|
||||||
|
const afterTime = uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.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;
|
||||||
|
}
|
||||||
|
const { windowWidth } = common_vendor.index.getSystemInfoSync();
|
||||||
|
this.isPhone = windowWidth <= 500;
|
||||||
|
this.windowWidth = windowWidth;
|
||||||
|
},
|
||||||
|
show() {
|
||||||
|
if (this.disabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.platform();
|
||||||
|
if (this.isPhone) {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$refs.mobile.open();
|
||||||
|
}, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.pickerPositionStyle = {
|
||||||
|
top: "10px"
|
||||||
|
};
|
||||||
|
const dateEditor = common_vendor.index.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");
|
||||||
|
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 = uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.fixIosDateFormat(date);
|
||||||
|
return Date.parse(new Date(date));
|
||||||
|
},
|
||||||
|
singleChange(e) {
|
||||||
|
this.calendarDate = this.inputDate = e.fulldate;
|
||||||
|
if (this.hasTime)
|
||||||
|
return;
|
||||||
|
this.confirmSingleChange();
|
||||||
|
},
|
||||||
|
confirmSingleChange() {
|
||||||
|
if (!uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.checkDate(this.inputDate)) {
|
||||||
|
const now = /* @__PURE__ */ new Date();
|
||||||
|
this.calendarDate = this.inputDate = uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.getDate(now);
|
||||||
|
this.pickerTime = uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.getTime(now, this.hideSecond);
|
||||||
|
}
|
||||||
|
let startLaterInputDate = false;
|
||||||
|
let startDate, startTime;
|
||||||
|
if (this.start) {
|
||||||
|
let startString = this.start;
|
||||||
|
if (typeof this.start === "number") {
|
||||||
|
startString = uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.getDateTime(this.start, this.hideSecond);
|
||||||
|
}
|
||||||
|
[startDate, startTime] = startString.split(" ");
|
||||||
|
if (this.start && !uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.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 = uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.getDateTime(this.end, this.hideSecond);
|
||||||
|
}
|
||||||
|
[endDate, endTime] = endString.split(" ");
|
||||||
|
if (this.end && !uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.dateCompare(this.inputDate, endDate)) {
|
||||||
|
endEarlierInputDate = true;
|
||||||
|
this.inputDate = endDate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.hasTime) {
|
||||||
|
if (startLaterInputDate) {
|
||||||
|
this.pickerTime = startTime || uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.getDefaultSecond(this.hideSecond);
|
||||||
|
}
|
||||||
|
if (endEarlierInputDate) {
|
||||||
|
this.pickerTime = endTime || uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.getDefaultSecond(this.hideSecond);
|
||||||
|
}
|
||||||
|
if (!this.pickerTime) {
|
||||||
|
this.pickerTime = uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.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);
|
||||||
|
},
|
||||||
|
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);
|
||||||
|
},
|
||||||
|
mobileChange(e) {
|
||||||
|
if (this.isRange) {
|
||||||
|
const { before, after } = e.range;
|
||||||
|
if (!before || !after) {
|
||||||
|
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 (!uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.checkDate(this.tempRange.startDate)) {
|
||||||
|
this.tempRange.startDate = uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.getDate(Date.now());
|
||||||
|
}
|
||||||
|
if (!uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.checkDate(this.tempRange.endDate)) {
|
||||||
|
this.tempRange.endDate = uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.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 = uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.getDateTime(this.start, this.hideSecond);
|
||||||
|
}
|
||||||
|
[startDate, startTime] = startString.split(" ");
|
||||||
|
if (this.start && !uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.dateCompare(this.start, this.tempRange.startDate)) {
|
||||||
|
startDateLaterRangeStartDate = true;
|
||||||
|
this.tempRange.startDate = startDate;
|
||||||
|
}
|
||||||
|
if (this.start && !uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.dateCompare(this.start, this.tempRange.endDate)) {
|
||||||
|
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 = uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.getDateTime(this.end, this.hideSecond);
|
||||||
|
}
|
||||||
|
[endDate, endTime] = endString.split(" ");
|
||||||
|
if (this.end && !uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.dateCompare(this.tempRange.startDate, this.end)) {
|
||||||
|
endDateEarlierRangeStartDate = true;
|
||||||
|
this.tempRange.startDate = endDate;
|
||||||
|
}
|
||||||
|
if (this.end && !uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.dateCompare(this.tempRange.endDate, 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 || uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.getDefaultSecond(this.hideSecond);
|
||||||
|
} else if (endDateEarlierRangeStartDate) {
|
||||||
|
this.tempRange.startTime = endTime || uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.getDefaultSecond(this.hideSecond);
|
||||||
|
}
|
||||||
|
if (!this.tempRange.startTime) {
|
||||||
|
this.tempRange.startTime = uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.getTime(Date.now(), this.hideSecond);
|
||||||
|
}
|
||||||
|
if (startDateLaterRangeEndDate) {
|
||||||
|
this.tempRange.endTime = startTime || uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.getDefaultSecond(this.hideSecond);
|
||||||
|
} else if (endDateEarlierRangeEndDate) {
|
||||||
|
this.tempRange.endTime = endTime || uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.getDefaultSecond(this.hideSecond);
|
||||||
|
}
|
||||||
|
if (!this.tempRange.endTime) {
|
||||||
|
this.tempRange.endTime = uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.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 (!uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.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 && after))
|
||||||
|
return;
|
||||||
|
const type = temp ? "tempRange" : "range";
|
||||||
|
const isStartEarlierEnd = uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.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 * 1e3);
|
||||||
|
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", []);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (!Array) {
|
||||||
|
const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
|
||||||
|
const _component_time_picker = common_vendor.resolveComponent("time-picker");
|
||||||
|
const _component_Calendar = common_vendor.resolveComponent("Calendar");
|
||||||
|
(_easycom_uni_icons2 + _component_time_picker + _component_Calendar)();
|
||||||
|
}
|
||||||
|
const _easycom_uni_icons = () => "../../../uni-icons/components/uni-icons/uni-icons.js";
|
||||||
|
if (!Math) {
|
||||||
|
_easycom_uni_icons();
|
||||||
|
}
|
||||||
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||||
|
return common_vendor.e({
|
||||||
|
a: !$data.isRange
|
||||||
|
}, !$data.isRange ? {
|
||||||
|
b: common_vendor.p({
|
||||||
|
type: "calendar",
|
||||||
|
color: "#c0c4cc",
|
||||||
|
size: "22"
|
||||||
|
}),
|
||||||
|
c: common_vendor.t($data.displayValue || $options.singlePlaceholderText)
|
||||||
|
} : {
|
||||||
|
d: common_vendor.p({
|
||||||
|
type: "calendar",
|
||||||
|
color: "#c0c4cc",
|
||||||
|
size: "22"
|
||||||
|
}),
|
||||||
|
e: common_vendor.t($data.displayRangeValue.startDate || $options.startPlaceholderText),
|
||||||
|
f: common_vendor.t($props.rangeSeparator),
|
||||||
|
g: common_vendor.t($data.displayRangeValue.endDate || $options.endPlaceholderText)
|
||||||
|
}, {
|
||||||
|
h: $options.showClearIcon
|
||||||
|
}, $options.showClearIcon ? {
|
||||||
|
i: common_vendor.p({
|
||||||
|
type: "clear",
|
||||||
|
color: "#c0c4cc",
|
||||||
|
size: "22"
|
||||||
|
}),
|
||||||
|
j: common_vendor.o((...args) => $options.clear && $options.clear(...args))
|
||||||
|
} : {}, {
|
||||||
|
k: $props.disabled ? 1 : "",
|
||||||
|
l: $props.border ? 1 : "",
|
||||||
|
m: common_vendor.o((...args) => $options.show && $options.show(...args)),
|
||||||
|
n: $data.pickerVisible,
|
||||||
|
o: common_vendor.o((...args) => $options.close && $options.close(...args)),
|
||||||
|
p: !$data.isPhone
|
||||||
|
}, !$data.isPhone ? common_vendor.e({
|
||||||
|
q: !$data.isRange
|
||||||
|
}, !$data.isRange ? common_vendor.e({
|
||||||
|
r: $data.hasTime
|
||||||
|
}, $data.hasTime ? {
|
||||||
|
s: $options.selectDateText,
|
||||||
|
t: $data.inputDate,
|
||||||
|
v: common_vendor.o(($event) => $data.inputDate = $event.detail.value),
|
||||||
|
w: $options.selectTimeText,
|
||||||
|
x: !$data.inputDate,
|
||||||
|
y: $data.pickerTime,
|
||||||
|
z: common_vendor.o(($event) => $data.pickerTime = $event.detail.value),
|
||||||
|
A: common_vendor.o(($event) => $data.pickerTime = $event),
|
||||||
|
B: common_vendor.p({
|
||||||
|
type: "time",
|
||||||
|
border: false,
|
||||||
|
disabled: !$data.inputDate,
|
||||||
|
start: $options.timepickerStartTime,
|
||||||
|
end: $options.timepickerEndTime,
|
||||||
|
hideSecond: $props.hideSecond,
|
||||||
|
modelValue: $data.pickerTime
|
||||||
|
})
|
||||||
|
} : {}, {
|
||||||
|
C: common_vendor.sr("pcSingle", "08def278-4"),
|
||||||
|
D: common_vendor.o($options.singleChange),
|
||||||
|
E: common_vendor.p({
|
||||||
|
showMonth: false,
|
||||||
|
["start-date"]: $data.calendarRange.startDate,
|
||||||
|
["end-date"]: $data.calendarRange.endDate,
|
||||||
|
date: $data.calendarDate,
|
||||||
|
["default-value"]: $props.defaultValue
|
||||||
|
}),
|
||||||
|
F: $data.hasTime
|
||||||
|
}, $data.hasTime ? {
|
||||||
|
G: common_vendor.t($options.okText),
|
||||||
|
H: common_vendor.o((...args) => $options.confirmSingleChange && $options.confirmSingleChange(...args))
|
||||||
|
} : {}, {
|
||||||
|
I: common_vendor.s($data.pickerPositionStyle)
|
||||||
|
}) : common_vendor.e({
|
||||||
|
J: $data.hasTime
|
||||||
|
}, $data.hasTime ? {
|
||||||
|
K: $options.startDateText,
|
||||||
|
L: $data.tempRange.startDate,
|
||||||
|
M: common_vendor.o(($event) => $data.tempRange.startDate = $event.detail.value),
|
||||||
|
N: $options.startTimeText,
|
||||||
|
O: !$data.tempRange.startDate,
|
||||||
|
P: $data.tempRange.startTime,
|
||||||
|
Q: common_vendor.o(($event) => $data.tempRange.startTime = $event.detail.value),
|
||||||
|
R: common_vendor.o(($event) => $data.tempRange.startTime = $event),
|
||||||
|
S: common_vendor.p({
|
||||||
|
type: "time",
|
||||||
|
start: $options.timepickerStartTime,
|
||||||
|
border: false,
|
||||||
|
disabled: !$data.tempRange.startDate,
|
||||||
|
hideSecond: $props.hideSecond,
|
||||||
|
modelValue: $data.tempRange.startTime
|
||||||
|
}),
|
||||||
|
T: common_vendor.p({
|
||||||
|
type: "arrowthinright",
|
||||||
|
color: "#999"
|
||||||
|
}),
|
||||||
|
U: $options.endDateText,
|
||||||
|
V: $data.tempRange.endDate,
|
||||||
|
W: common_vendor.o(($event) => $data.tempRange.endDate = $event.detail.value),
|
||||||
|
X: $options.endTimeText,
|
||||||
|
Y: !$data.tempRange.endDate,
|
||||||
|
Z: $data.tempRange.endTime,
|
||||||
|
aa: common_vendor.o(($event) => $data.tempRange.endTime = $event.detail.value),
|
||||||
|
ab: common_vendor.o(($event) => $data.tempRange.endTime = $event),
|
||||||
|
ac: common_vendor.p({
|
||||||
|
type: "time",
|
||||||
|
end: $options.timepickerEndTime,
|
||||||
|
border: false,
|
||||||
|
disabled: !$data.tempRange.endDate,
|
||||||
|
hideSecond: $props.hideSecond,
|
||||||
|
modelValue: $data.tempRange.endTime
|
||||||
|
})
|
||||||
|
} : {}, {
|
||||||
|
ad: common_vendor.sr("left", "08def278-8"),
|
||||||
|
ae: common_vendor.o($options.leftChange),
|
||||||
|
af: common_vendor.o($options.updateRightCale),
|
||||||
|
ag: common_vendor.p({
|
||||||
|
showMonth: false,
|
||||||
|
["start-date"]: $data.calendarRange.startDate,
|
||||||
|
["end-date"]: $data.calendarRange.endDate,
|
||||||
|
range: true,
|
||||||
|
pleStatus: $data.endMultipleStatus
|
||||||
|
}),
|
||||||
|
ah: common_vendor.sr("right", "08def278-9"),
|
||||||
|
ai: common_vendor.o($options.rightChange),
|
||||||
|
aj: common_vendor.o($options.updateLeftCale),
|
||||||
|
ak: common_vendor.p({
|
||||||
|
showMonth: false,
|
||||||
|
["start-date"]: $data.calendarRange.startDate,
|
||||||
|
["end-date"]: $data.calendarRange.endDate,
|
||||||
|
range: true,
|
||||||
|
pleStatus: $data.startMultipleStatus
|
||||||
|
}),
|
||||||
|
al: $data.hasTime
|
||||||
|
}, $data.hasTime ? {
|
||||||
|
am: common_vendor.t($options.clearText),
|
||||||
|
an: common_vendor.o((...args) => $options.clear && $options.clear(...args)),
|
||||||
|
ao: common_vendor.t($options.okText),
|
||||||
|
ap: common_vendor.o((...args) => $options.confirmRangeChange && $options.confirmRangeChange(...args))
|
||||||
|
} : {}, {
|
||||||
|
aq: common_vendor.s($data.pickerPositionStyle)
|
||||||
|
}), {
|
||||||
|
ar: $data.pickerVisible
|
||||||
|
}) : {}, {
|
||||||
|
as: $data.isPhone
|
||||||
|
}, $data.isPhone ? {
|
||||||
|
at: common_vendor.sr("mobile", "08def278-10"),
|
||||||
|
av: common_vendor.o($options.mobileChange),
|
||||||
|
aw: common_vendor.o($options.close),
|
||||||
|
ax: common_vendor.p({
|
||||||
|
clearDate: false,
|
||||||
|
date: $data.calendarDate,
|
||||||
|
defTime: $options.mobileCalendarTime,
|
||||||
|
["start-date"]: $data.calendarRange.startDate,
|
||||||
|
["end-date"]: $data.calendarRange.endDate,
|
||||||
|
selectableTimes: $options.mobSelectableTime,
|
||||||
|
startPlaceholder: $props.startPlaceholder,
|
||||||
|
endPlaceholder: $props.endPlaceholder,
|
||||||
|
["default-value"]: $props.defaultValue,
|
||||||
|
pleStatus: $data.endMultipleStatus,
|
||||||
|
showMonth: false,
|
||||||
|
range: $data.isRange,
|
||||||
|
hasTime: $data.hasTime,
|
||||||
|
insert: false,
|
||||||
|
hideSecond: $props.hideSecond
|
||||||
|
})
|
||||||
|
} : {});
|
||||||
|
}
|
||||||
|
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "F:/项目2023/视力表/vision-record/uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue"]]);
|
||||||
|
wx.createComponent(Component);
|
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"component": true,
|
||||||
|
"usingComponents": {
|
||||||
|
"calendar": "./calendar",
|
||||||
|
"time-picker": "./time-picker",
|
||||||
|
"uni-icons": "../../../uni-icons/components/uni-icons/uni-icons"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
<view class="uni-date"><view class="uni-date-editor" bindtap="{{m}}"><block wx:if="{{$slots.d}}"><slot></slot></block><block wx:else><view class="{{['uni-date-editor--x', k && 'uni-date-editor--x__disabled', l && 'uni-date-x--border']}}"><view wx:if="{{a}}" class="uni-date-x uni-date-single"><uni-icons wx:if="{{b}}" class="icon-calendar" u-i="08def278-0" bind:__l="__l" u-p="{{b}}"></uni-icons><view class="uni-date__x-input">{{c}}</view></view><view wx:else class="uni-date-x uni-date-range"><uni-icons wx:if="{{d}}" class="icon-calendar" u-i="08def278-1" bind:__l="__l" u-p="{{d}}"></uni-icons><view class="uni-date__x-input text-center">{{e}}</view><view class="range-separator">{{f}}</view><view class="uni-date__x-input text-center">{{g}}</view></view><view wx:if="{{h}}" class="uni-date__icon-clear" catchtap="{{j}}"><uni-icons wx:if="{{i}}" u-i="08def278-2" bind:__l="__l" u-p="{{i}}"></uni-icons></view></view></block></view><view hidden="{{!n}}" class="uni-date-mask--pc" bindtap="{{o}}"></view><view wx:if="{{p}}" hidden="{{!ar}}" ref="datePicker" class="uni-date-picker__container"><view wx:if="{{q}}" class="uni-date-single--x" style="{{I}}"><view class="uni-popper__arrow"></view><view wx:if="{{r}}" class="uni-date-changed popup-x-header"><input class="uni-date__input text-center" type="text" placeholder="{{s}}" value="{{t}}" bindinput="{{v}}"/><time-picker wx:if="{{B}}" u-s="{{['d']}}" style="width:100%" u-i="08def278-3" bind:__l="__l" bindupdateModelValue="{{A}}" u-p="{{B}}"><input class="uni-date__input text-center" type="text" placeholder="{{w}}" disabled="{{x}}" value="{{y}}" bindinput="{{z}}"/></time-picker></view><calendar wx:if="{{E}}" class="r" u-r="pcSingle" bindchange="{{D}}" style="padding:0 8px" u-i="08def278-4" bind:__l="__l" u-p="{{E}}"/><view wx:if="{{F}}" class="popup-x-footer"><text class="confirm-text" bindtap="{{H}}">{{G}}</text></view></view><view wx:else class="uni-date-range--x" style="{{aq}}"><view class="uni-popper__arrow"></view><view wx:if="{{J}}" class="popup-x-header uni-date-changed"><view class="popup-x-header--datetime"><input class="uni-date__input uni-date-range__input" type="text" placeholder="{{K}}" value="{{L}}" bindinput="{{M}}"/><time-picker wx:if="{{S}}" u-s="{{['d']}}" u-i="08def278-5" bind:__l="__l" bindupdateModelValue="{{R}}" u-p="{{S}}"><input class="uni-date__input uni-date-range__input" type="text" placeholder="{{N}}" disabled="{{O}}" value="{{P}}" bindinput="{{Q}}"/></time-picker></view><uni-icons wx:if="{{T}}" style="line-height:40px" u-i="08def278-6" bind:__l="__l" u-p="{{T}}"></uni-icons><view class="popup-x-header--datetime"><input class="uni-date__input uni-date-range__input" type="text" placeholder="{{U}}" value="{{V}}" bindinput="{{W}}"/><time-picker wx:if="{{ac}}" u-s="{{['d']}}" u-i="08def278-7" bind:__l="__l" bindupdateModelValue="{{ab}}" u-p="{{ac}}"><input class="uni-date__input uni-date-range__input" type="text" placeholder="{{X}}" disabled="{{Y}}" value="{{Z}}" bindinput="{{aa}}"/></time-picker></view></view><view class="popup-x-body"><calendar wx:if="{{ag}}" class="r" u-r="left" bindchange="{{ae}}" bindfirstEnterCale="{{af}}" style="padding:0 8px" u-i="08def278-8" bind:__l="__l" u-p="{{ag}}"/><calendar wx:if="{{ak}}" class="r" u-r="right" bindchange="{{ai}}" bindfirstEnterCale="{{aj}}" style="padding:0 8px;border-left:1px solid #F1F1F1" u-i="08def278-9" bind:__l="__l" u-p="{{ak}}"/></view><view wx:if="{{al}}" class="popup-x-footer"><text bindtap="{{an}}">{{am}}</text><text class="confirm-text" bindtap="{{ap}}">{{ao}}</text></view></view></view><calendar wx:if="{{as}}" class="r" u-r="mobile" bindconfirm="{{av}}" bindmaskClose="{{aw}}" u-i="08def278-10" bind:__l="__l" u-p="{{ax}}"/></view>
|
@ -0,0 +1,406 @@
|
|||||||
|
"use strict";
|
||||||
|
class Calendar {
|
||||||
|
constructor({
|
||||||
|
selected,
|
||||||
|
startDate,
|
||||||
|
endDate,
|
||||||
|
range
|
||||||
|
} = {}) {
|
||||||
|
this.date = this.getDateObj(/* @__PURE__ */ 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 ? dateObj.month - 1 : 12;
|
||||||
|
const year = month === 12 ? dateObj.year - 1 : dateObj.year;
|
||||||
|
const date = new Date(year, month, -i).getDate();
|
||||||
|
const fullDate = `${year}-${addZero(month)}-${addZero(date)}`;
|
||||||
|
let multiples = this.multipleStatus.data;
|
||||||
|
let multiplesStatus = -1;
|
||||||
|
if (this.range && multiples) {
|
||||||
|
multiplesStatus = multiples.findIndex((item) => {
|
||||||
|
return this.dateEqual(item, fullDate);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const checked = multiplesStatus !== -1;
|
||||||
|
const extraInfo = this.selected && this.selected.find((item) => {
|
||||||
|
if (this.dateEqual(fullDate, item.date)) {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
result.push({
|
||||||
|
fullDate,
|
||||||
|
year,
|
||||||
|
month,
|
||||||
|
date,
|
||||||
|
multiple: this.range ? checked : false,
|
||||||
|
beforeMultiple: this.isLogicBefore(fullDate, this.multipleStatus.before, this.multipleStatus.after),
|
||||||
|
afterMultiple: this.isLogicAfter(fullDate, this.multipleStatus.before, this.multipleStatus.after),
|
||||||
|
disable: this.startDate && !dateCompare(this.startDate, fullDate) || this.endDate && !dateCompare(fullDate, this.endDate),
|
||||||
|
isToday: fullDate === this.date.fullDate,
|
||||||
|
userChecked: false,
|
||||||
|
extraInfo
|
||||||
|
});
|
||||||
|
}
|
||||||
|
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 extraInfo = this.selected && this.selected.find((item) => {
|
||||||
|
if (this.dateEqual(currentDate, item.date)) {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (this.startDate) {
|
||||||
|
dateCompare(this.startDate, currentDate);
|
||||||
|
}
|
||||||
|
if (this.endDate) {
|
||||||
|
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,
|
||||||
|
month: dateObj.month,
|
||||||
|
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),
|
||||||
|
disable: this.startDate && !dateCompare(this.startDate, currentDate) || this.endDate && !dateCompare(currentDate, this.endDate),
|
||||||
|
isToday,
|
||||||
|
userChecked: false,
|
||||||
|
extraInfo
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取下一个月日期集合
|
||||||
|
*/
|
||||||
|
_getNextMonthDays(amount, dateObj) {
|
||||||
|
const result = [];
|
||||||
|
dateObj.month + 1;
|
||||||
|
for (let i = 1; i <= amount; i++) {
|
||||||
|
const month = dateObj.month === 12 ? 1 : dateObj.month * 1 + 1;
|
||||||
|
const year = month === 1 ? dateObj.year + 1 : dateObj.year;
|
||||||
|
const fullDate = `${year}-${addZero(month)}-${addZero(i)}`;
|
||||||
|
let multiples = this.multipleStatus.data;
|
||||||
|
let multiplesStatus = -1;
|
||||||
|
if (this.range && multiples) {
|
||||||
|
multiplesStatus = multiples.findIndex((item) => {
|
||||||
|
return this.dateEqual(item, fullDate);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const checked = multiplesStatus !== -1;
|
||||||
|
const extraInfo = this.selected && this.selected.find((item) => {
|
||||||
|
if (this.dateEqual(fullDate, item.date)) {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
result.push({
|
||||||
|
fullDate,
|
||||||
|
year,
|
||||||
|
date: i,
|
||||||
|
month,
|
||||||
|
multiple: this.range ? checked : false,
|
||||||
|
beforeMultiple: this.isLogicBefore(fullDate, this.multipleStatus.before, this.multipleStatus.after),
|
||||||
|
afterMultiple: this.isLogicAfter(fullDate, this.multipleStatus.before, this.multipleStatus.after),
|
||||||
|
disable: this.startDate && !dateCompare(this.startDate, fullDate) || this.endDate && !dateCompare(fullDate, this.endDate),
|
||||||
|
isToday: fullDate === this.date.fullDate,
|
||||||
|
userChecked: false,
|
||||||
|
extraInfo
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取当前日期详情
|
||||||
|
* @param {Object} date
|
||||||
|
*/
|
||||||
|
getInfo(date) {
|
||||||
|
if (!date) {
|
||||||
|
date = /* @__PURE__ */ new Date();
|
||||||
|
}
|
||||||
|
return this.calendar.find((item) => item.fullDate === this.getDateObj(date).fullDate);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 比较时间是否相等
|
||||||
|
*/
|
||||||
|
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 = /* @__PURE__ */ new Date();
|
||||||
|
db.setFullYear(ab[0], ab[1] - 1, ab[2]);
|
||||||
|
var de = /* @__PURE__ */ new Date();
|
||||||
|
de.setFullYear(ae[0], ae[1] - 1, ae[2]);
|
||||||
|
var unixDb = db.getTime() - 24 * 60 * 60 * 1e3;
|
||||||
|
var unixDe = de.getTime() - 24 * 60 * 60 * 1e3;
|
||||||
|
for (var k = unixDb; k <= unixDe; ) {
|
||||||
|
k = k + 24 * 60 * 60 * 1e3;
|
||||||
|
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.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) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 更新默认值多选状态
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
exports.Calendar = Calendar;
|
||||||
|
exports.checkDate = checkDate;
|
||||||
|
exports.dateCompare = dateCompare;
|
||||||
|
exports.fixIosDateFormat = fixIosDateFormat;
|
||||||
|
exports.getDate = getDate;
|
||||||
|
exports.getDateTime = getDateTime;
|
||||||
|
exports.getDefaultSecond = getDefaultSecond;
|
||||||
|
exports.getTime = getTime;
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"component": true,
|
||||||
|
"usingComponents": {
|
||||||
|
"uni-icons": "../../../uni-icons/components/uni-icons/uni-icons"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
<view class="{{['uni-easyinput', aa && 'uni-easyinput-error']}}" style="{{ab}}"><view class="{{['uni-easyinput__content', Y]}}" style="{{Z}}"><uni-icons wx:if="{{a}}" class="content-clear-icon" bindclick="{{b}}" u-i="0ef993ec-0" bind:__l="__l" u-p="{{c}}"></uni-icons><textarea wx:if="{{d}}" class="{{['uni-easyinput__content-textarea', e && 'input-padding']}}" name="{{f}}" value="{{g}}" placeholder="{{h}}" placeholderStyle="{{i}}" disabled="{{j}}" placeholder-class="uni-easyinput__placeholder-class" maxlength="{{k}}" focus="{{l}}" autoHeight="{{m}}" cursor-spacing="{{n}}" bindinput="{{o}}" bindblur="{{p}}" bindfocus="{{q}}" bindconfirm="{{r}}" bindkeyboardheightchange="{{s}}"></textarea><block wx:else><input wx:if="{{r0}}" type="{{t}}" class="uni-easyinput__content-input" style="{{v}}" name="{{w}}" value="{{x}}" password="{{y}}" placeholder="{{z}}" placeholderStyle="{{A}}" placeholder-class="uni-easyinput__placeholder-class" disabled="{{B}}" maxlength="{{C}}" focus="{{D}}" confirmType="{{E}}" cursor-spacing="{{F}}" bindfocus="{{G}}" bindblur="{{H}}" bindinput="{{I}}" bindconfirm="{{J}}" bindkeyboardheightchange="{{K}}"/></block><block wx:if="{{L}}"><uni-icons wx:if="{{M}}" class="{{['content-clear-icon', N && 'is-textarea-icon']}}" bindclick="{{O}}" u-i="0ef993ec-1" bind:__l="__l" u-p="{{P}}"></uni-icons></block><block wx:elif="{{Q}}"><uni-icons wx:if="{{R}}" class="content-clear-icon" bindclick="{{S}}" u-i="0ef993ec-2" bind:__l="__l" u-p="{{T}}"></uni-icons></block><block wx:else><uni-icons wx:if="{{U}}" class="{{['content-clear-icon', V && 'is-textarea-icon']}}" bindclick="{{W}}" u-i="0ef993ec-3" bind:__l="__l" u-p="{{X}}"></uni-icons></block><slot name="right"></slot></view></view>
|
@ -0,0 +1,101 @@
|
|||||||
|
"use strict";
|
||||||
|
const common_vendor = require("../common/vendor.js");
|
||||||
|
const config_index = require("../config/index.js");
|
||||||
|
const custom = {
|
||||||
|
// 控制字符长度
|
||||||
|
controlLength: (str, len = 10) => {
|
||||||
|
if (!str)
|
||||||
|
return "";
|
||||||
|
if (str.length > len)
|
||||||
|
return str.slice(0, len) + "...";
|
||||||
|
return str;
|
||||||
|
},
|
||||||
|
uploadFile: (chooseImageRes) => {
|
||||||
|
const tempFilePaths = chooseImageRes.tempFilePaths;
|
||||||
|
common_vendor.index.uploadFile({
|
||||||
|
url: `${config_index.config.baseUrl}/user/upload`,
|
||||||
|
filePath: tempFilePaths[0],
|
||||||
|
name: "file",
|
||||||
|
header: {
|
||||||
|
"Authorization": token,
|
||||||
|
"x-token": token
|
||||||
|
},
|
||||||
|
success: (res) => {
|
||||||
|
JSON.parse(res.data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
uploadImage: (img, callfunc) => {
|
||||||
|
const token2 = common_vendor.index.getStorageSync("access_token");
|
||||||
|
const tempFilePaths = img;
|
||||||
|
common_vendor.index.uploadFile({
|
||||||
|
url: `${config_index.config.baseUrl}/user/upload`,
|
||||||
|
filePath: tempFilePaths,
|
||||||
|
name: "file",
|
||||||
|
header: {
|
||||||
|
"Authorization": token2,
|
||||||
|
"x-token": token2,
|
||||||
|
"token": token2
|
||||||
|
// 'content-type': 'multipart/form-data',
|
||||||
|
},
|
||||||
|
success: (res) => {
|
||||||
|
var f_res = JSON.parse(res.data);
|
||||||
|
callfunc(f_res);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
timestampToDate(stamp) {
|
||||||
|
var time = new Date(stamp);
|
||||||
|
var y = time.getFullYear();
|
||||||
|
var m = time.getMonth() + 1;
|
||||||
|
var d = time.getDate();
|
||||||
|
const date = `${y}-${m}-${d}`;
|
||||||
|
return date;
|
||||||
|
},
|
||||||
|
datatime(time) {
|
||||||
|
var myDate = /* @__PURE__ */ new Date();
|
||||||
|
myDate.setDate(myDate.getDate());
|
||||||
|
var dateArray = [];
|
||||||
|
var dateTemp;
|
||||||
|
var flag = 1;
|
||||||
|
for (var i = 0; i < time; i++) {
|
||||||
|
let month = 0;
|
||||||
|
if (myDate.getMonth() + 1 < 10) {
|
||||||
|
month = "0" + (myDate.getMonth() + 1);
|
||||||
|
} else {
|
||||||
|
month = myDate.getMonth() + 1;
|
||||||
|
}
|
||||||
|
let day = 0;
|
||||||
|
if (myDate.getDate() < 10) {
|
||||||
|
day = "0" + myDate.getDate();
|
||||||
|
} else {
|
||||||
|
day = myDate.getDate();
|
||||||
|
}
|
||||||
|
dateTemp = myDate.getFullYear() + "-" + month + "-" + day;
|
||||||
|
dateArray.push(dateTemp);
|
||||||
|
myDate.setDate(myDate.getDate() + flag);
|
||||||
|
}
|
||||||
|
return dateArray;
|
||||||
|
},
|
||||||
|
getDistances(lat1, lng1, lat2, lng2) {
|
||||||
|
let EARTH_RADIUS = 6378.137;
|
||||||
|
let radLat1 = lat1 * Math.PI / 180;
|
||||||
|
let radLat2 = lat2 * Math.PI / 180;
|
||||||
|
let a = radLat1 - radLat2;
|
||||||
|
let b = lng1 * Math.PI / 180 - lng2 * Math.PI / 180;
|
||||||
|
let s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
|
||||||
|
s = s * EARTH_RADIUS;
|
||||||
|
s = Math.round(s * 1e4) / 1e4;
|
||||||
|
return { m: s * 1e3, km: Number(s.toFixed(2)) };
|
||||||
|
},
|
||||||
|
checkLogin() {
|
||||||
|
let token2 = common_vendor.index.getStorageSync("access_token");
|
||||||
|
console.log(token2);
|
||||||
|
if (token2) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
exports.custom = custom;
|
Loading…
Reference in New Issue