弹窗
This commit is contained in:
@@ -251,6 +251,14 @@
|
|||||||
WF : "瓦利斯",
|
WF : "瓦利斯",
|
||||||
}
|
}
|
||||||
|
|
||||||
const countryNamesArray = Object.values(NationalDictionary);
|
function convertNationalDictToOptions(dict) {
|
||||||
|
return Object.entries(dict).map(([code, name]) => ({
|
||||||
|
label: name,
|
||||||
|
value: name // 将 value 改为国家名称
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
export default countryNamesArray;
|
// 使用示例
|
||||||
|
const optionsArray = convertNationalDictToOptions(NationalDictionary);
|
||||||
|
|
||||||
|
export default optionsArray;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<scroll-view scroll-y="true" class="scroll">
|
<scroll-view scroll-y="true" class="scroll" lower-threshold="100" @scrolltolower="onScrollToLower" >
|
||||||
<uni-card class="content-list" v-for="(item, index) in list">
|
<uni-card class="content-list" v-for="(item, index) in list">
|
||||||
<!-- `````````````````````````` -->
|
<!-- `````````````````````````` -->
|
||||||
<image class="headShot" src="../../static/logo.png" mode="scaleToFill" />
|
<image class="headShot" src="../../static/logo.png" mode="scaleToFill" />
|
||||||
@@ -23,11 +23,13 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import request from "../../components/request.js";
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
title: "Hello",
|
title: "Hello",
|
||||||
Gender: true,
|
Gender: true,
|
||||||
|
page: 0,
|
||||||
// 列表数据
|
// 列表数据
|
||||||
list: [
|
list: [
|
||||||
{
|
{
|
||||||
@@ -36,112 +38,45 @@ export default {
|
|||||||
gender: "男",
|
gender: "男",
|
||||||
score: 8.8,
|
score: 8.8,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
title: "极乐世界2",
|
|
||||||
id: "9089",
|
|
||||||
gender: "女",
|
|
||||||
score: 7.8,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "极乐世界3",
|
|
||||||
id: "9090",
|
|
||||||
gender: "男",
|
|
||||||
score: 9.8,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "极乐世界3",
|
|
||||||
id: "9090",
|
|
||||||
gender: "男",
|
|
||||||
score: 9.8,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "极乐世界3",
|
|
||||||
id: "9090",
|
|
||||||
gender: "男",
|
|
||||||
score: 9.8,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "极乐世界3",
|
|
||||||
id: "9090",
|
|
||||||
gender: "男",
|
|
||||||
score: 9.8,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "极乐世界3",
|
|
||||||
id: "9090",
|
|
||||||
gender: "男",
|
|
||||||
score: 9.8,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "极乐世界3",
|
|
||||||
id: "9090",
|
|
||||||
gender: "男",
|
|
||||||
score: 9.8,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "极乐世界3",
|
|
||||||
id: "9090",
|
|
||||||
gender: "男",
|
|
||||||
score: 9.8,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "极乐世界3",
|
|
||||||
id: "9090",
|
|
||||||
gender: "男",
|
|
||||||
score: 9.8,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "极乐世界3",
|
|
||||||
id: "9090",
|
|
||||||
gender: "男",
|
|
||||||
score: 9.8,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "极乐世界3",
|
|
||||||
id: "9090",
|
|
||||||
gender: "男",
|
|
||||||
score: 9.8,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "极乐世界3",
|
|
||||||
id: "9090",
|
|
||||||
gender: "男",
|
|
||||||
score: 9.8,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "极乐世界3",
|
|
||||||
id: "9090",
|
|
||||||
gender: "男",
|
|
||||||
score: 9.8,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "极乐世界3",
|
|
||||||
id: "9090",
|
|
||||||
gender: "男",
|
|
||||||
score: 9.8,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "极乐世界3",
|
|
||||||
id: "9090",
|
|
||||||
gender: "男",
|
|
||||||
score: 9.8,
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
// 列表数据结束
|
// 列表数据结束
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
onLoad() {
|
mounted() {
|
||||||
// 页面加载时执行
|
// 页面加载完成后请求数据
|
||||||
|
this.pkList()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// 方法定义
|
async pkList(){
|
||||||
|
const res = await request({
|
||||||
|
url: "pk/pkList",
|
||||||
|
method: "GET",
|
||||||
|
data: {
|
||||||
|
status: 0,
|
||||||
|
page: this.page,
|
||||||
|
Size: 10,
|
||||||
|
},
|
||||||
|
userInfo: false,
|
||||||
|
});
|
||||||
|
console.log(res);
|
||||||
|
if (res.code === 200) {
|
||||||
|
this.list.concat(res.data)
|
||||||
|
console.log(this.list)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onScrollToLower() {
|
||||||
|
this.page++;
|
||||||
|
this.pkList();
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.scroll {
|
.scroll {
|
||||||
height: 100%;
|
height: 90%;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|||||||
@@ -4,25 +4,25 @@ export default function request(urldata) {
|
|||||||
"http://192.168.0.218:8086/"
|
"http://192.168.0.218:8086/"
|
||||||
+ url;
|
+ url;
|
||||||
if (userInfo) {
|
if (userInfo) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
uni.getStorage({
|
uni.getStorage({
|
||||||
key: "userinfo",
|
key: "userinfo",
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
if (res.data) {
|
if (res.data) {
|
||||||
if (res.data.nickName) {
|
if (res.data.nickName) {
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
uni.request({
|
uni.request({
|
||||||
url: baseUrl,
|
url: baseUrl,
|
||||||
data: data,
|
data: data,
|
||||||
method: method,
|
method: method,
|
||||||
header: header,
|
header: header,
|
||||||
success: function (res) {
|
success: function (res) {
|
||||||
|
console.log("请求成功1", res.data);
|
||||||
resolve(res.data);
|
resolve(res.data);
|
||||||
},
|
},
|
||||||
fail: function (res) {
|
fail: function (res) {
|
||||||
reject(res);
|
reject(res);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
this.$global.lastPage = uni.page.route;
|
this.$global.lastPage = uni.page.route;
|
||||||
uni.reLaunch({ url: "/pages/UserInformation/UserInformation" })
|
uni.reLaunch({ url: "/pages/UserInformation/UserInformation" })
|
||||||
@@ -31,8 +31,12 @@ export default function request(urldata) {
|
|||||||
this.$global.lastPage = uni.page.route;
|
this.$global.lastPage = uni.page.route;
|
||||||
uni.navigateTo({ url: '/pages/login/login' })
|
uni.navigateTo({ url: '/pages/login/login' })
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
fail: function (res) {
|
||||||
|
reject(res);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
uni.request({
|
uni.request({
|
||||||
@@ -41,6 +45,7 @@ export default function request(urldata) {
|
|||||||
method: method,
|
method: method,
|
||||||
header: header,
|
header: header,
|
||||||
success: function (res) {
|
success: function (res) {
|
||||||
|
console.log("请求成功2", res);
|
||||||
resolve(res.data);
|
resolve(res.data);
|
||||||
},
|
},
|
||||||
fail: function (res) {
|
fail: function (res) {
|
||||||
|
|||||||
@@ -78,7 +78,8 @@ export default {
|
|||||||
position: fixed;
|
position: fixed;
|
||||||
top: 400rpx;
|
top: 400rpx;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
bottom: 50rpx;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 1300rpx;
|
/* height: 1300rpx; */
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<view v-if="Display" class="Mask" @click="open()">
|
<view v-if="Display" class="Mask" @click="open()">
|
||||||
<view @click.stop>
|
<view @click.stop>
|
||||||
<view class="container" >
|
<view class="container">
|
||||||
<image
|
<image
|
||||||
class="Fork"
|
class="Fork"
|
||||||
@click="open()"
|
@click="open()"
|
||||||
@@ -10,86 +10,131 @@
|
|||||||
/>
|
/>
|
||||||
<view class="Title">发布新PK</view>
|
<view class="Title">发布新PK</view>
|
||||||
<view class="Individual">
|
<view class="Individual">
|
||||||
|
|
||||||
<view class="NameAnchor">
|
<view class="NameAnchor">
|
||||||
<input class="NameAnchorcss" @input="NameAnchor" placeholder="主播名称" />
|
<input class="NameAnchorcss" @input="NameAnchor" placeholder="主播名称" />
|
||||||
|
<view v-if="nameAnchor === '' && Hint === true" class="Hint"
|
||||||
|
>请填写主播名称</view
|
||||||
|
>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="Gender">
|
<view class="Gender">
|
||||||
<uni-combox
|
<wht-select
|
||||||
class="Gendercss"
|
style="width: 300rpx"
|
||||||
:candidates="Gender"
|
@change="gender"
|
||||||
placeholder="请选择性别"
|
:options="Gender"
|
||||||
v-model="gender"
|
placeholder="性别"
|
||||||
></uni-combox>
|
/>
|
||||||
|
<view v-if="genders === '' && Hint === true" class="Hint">请选择性别</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
|
||||||
<view class="Accountnumber">
|
<view class="Accountnumber">
|
||||||
|
<view class="Coins">
|
||||||
<wht-select v-model="country" :options="options" placeholder="请选择国家" />
|
<wht-select
|
||||||
|
style="width: 300rpx"
|
||||||
|
@change="country"
|
||||||
|
:options="Country"
|
||||||
|
filterable
|
||||||
|
placeholder="请选择国家"
|
||||||
|
/>
|
||||||
|
<view v-if="countrys === '' && Hint === true" class="Hint">请选择国家</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
<view class="Coins">
|
<view class="Coins">
|
||||||
<uni-number-box class="number-box" v-model="numberCoins"></uni-number-box>
|
<view class="number-box">
|
||||||
|
<view class="number-box-title">金币:</view>
|
||||||
|
<uni-number-box v-model="numberCoins"></uni-number-box>
|
||||||
|
</view>
|
||||||
|
<view v-if="numberCoins === '' && Hint === true" class="Hint"
|
||||||
|
>请填写金币数量</view
|
||||||
|
>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<view class="time">
|
||||||
|
<uni-datetime-picker
|
||||||
|
type="datetime"
|
||||||
|
v-model="datetimesingle"
|
||||||
|
@change="changeLog"
|
||||||
|
/>
|
||||||
|
<view v-if="datetimesingle === '' && Hint === true" class="Hint"
|
||||||
|
>请选择日期</view
|
||||||
|
>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="Remarkscss" >
|
<view class="Remarkscss">
|
||||||
<uni-easyinput type="textarea" v-model="remarks" placeholder="备注"></uni-easyinput>
|
<uni-easyinput
|
||||||
|
type="textarea"
|
||||||
|
v-model="remarks"
|
||||||
|
placeholder="备注"
|
||||||
|
></uni-easyinput>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="Publish">
|
<view class="Publish">
|
||||||
<button @click="Publish()" class="Publishcss">发布</button>
|
<button @click="Publish()" class="Publishcss">发布</button>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import countryNamesArray from "../../components/NationalDictionary.js"
|
import optionsArray from "../../components/NationalDictionary.js";
|
||||||
|
import request from "../../components/request.js";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
gender: "",
|
genders: "", //性别
|
||||||
Gender: ["男", "女"],
|
Gender: [
|
||||||
Country:countryNamesArray,
|
{ label: "男", value: 1 },
|
||||||
country: "",
|
{ label: "女", value: 2 },
|
||||||
nameAnchor: "",
|
],
|
||||||
numberCoins: "",
|
Country: optionsArray,
|
||||||
remarks: "",
|
countrys: "", //国家
|
||||||
|
nameAnchor: "", //主播名称
|
||||||
|
numberCoins: "", //金币数量
|
||||||
|
remarks: "", //备注
|
||||||
Display: false,
|
Display: false,
|
||||||
options: [
|
Hint: false,
|
||||||
{ label: '选项一', value: '1' },
|
datetimesingle: "",//日期
|
||||||
{ label: '选项二', value: '2' },
|
id: null, //用户id
|
||||||
{ label: '选项三', value: '3' }
|
|
||||||
]
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
uni.getStorage({
|
uni.getStorage({
|
||||||
key: "userinfo",
|
key: "userinfo",
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
|
this.id = res.data.id;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
gender(item) {
|
||||||
|
this.genders = item.value;
|
||||||
|
console.log(item);
|
||||||
|
},
|
||||||
|
|
||||||
|
country(item) {
|
||||||
|
this.countrys = item.value;
|
||||||
|
console.log(item);
|
||||||
|
},
|
||||||
|
|
||||||
handleOverlayClick(event) {
|
handleOverlayClick(event) {
|
||||||
if (event.target === this.$el) {
|
if (event.target === this.$el) {
|
||||||
this.Display = false;
|
this.Display = false;
|
||||||
|
this.Hint = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
open(){
|
open() {
|
||||||
if (this.Display) {
|
if (this.Display) {
|
||||||
this.Display = false;
|
this.Display = false;
|
||||||
|
this.Hint = false;
|
||||||
|
this.nameAnchor = "";
|
||||||
|
this.genders = "";
|
||||||
|
this.numberCoins = "";
|
||||||
|
this.remarks = "";
|
||||||
|
this.datetimesingle = "";
|
||||||
|
this.countrys = "";
|
||||||
} else {
|
} else {
|
||||||
this.Display = true;
|
this.Display = true;
|
||||||
}
|
}
|
||||||
@@ -99,36 +144,102 @@ export default {
|
|||||||
this.nameAnchor = event.target.value;
|
this.nameAnchor = event.target.value;
|
||||||
},
|
},
|
||||||
|
|
||||||
Publish(){
|
async Publish() {
|
||||||
console.log( this.nameAnchor, this.gender,this.country, this.numberCoins, this.remarks);
|
//判断是否为空
|
||||||
|
if (
|
||||||
|
this.nameAnchor === "" ||
|
||||||
|
this.genders === "" ||
|
||||||
|
this.numberCoins === "" ||
|
||||||
|
this.countrys === "" ||
|
||||||
|
this.datetimesingle === ""
|
||||||
|
) {
|
||||||
|
this.Hint = true;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
//格式化日期
|
||||||
|
const isoString = this.datetimesingle.replace(" ", "T");
|
||||||
|
const timestamp = Date.parse(isoString);
|
||||||
|
if (isNaN(timestamp)) {
|
||||||
|
throw new Error(`Invalid date format: ${this.datetimesingle}`);
|
||||||
|
}
|
||||||
|
this.datetimesingle = Math.floor(timestamp / 1000);
|
||||||
|
//发送请求
|
||||||
|
uni.showLoading({
|
||||||
|
title: "发布中...",
|
||||||
|
mask: true,
|
||||||
|
});
|
||||||
|
const res = await request({
|
||||||
|
url: "pk/addPkData",
|
||||||
|
method: "POST",
|
||||||
|
data: {
|
||||||
|
anchorId: this.nameAnchor,
|
||||||
|
pk_time: this.datetimesingle,
|
||||||
|
sex: this.genders,
|
||||||
|
country: this.countrys,
|
||||||
|
coin: this.numberCoins,
|
||||||
|
remark: this.remarks,
|
||||||
|
status: 0,
|
||||||
|
sender_id: this.id,
|
||||||
|
anchorIcon: "",
|
||||||
|
},
|
||||||
|
userInfo: true,
|
||||||
|
});
|
||||||
|
if (res.code === 200) {
|
||||||
|
this.Display = false;
|
||||||
|
this.Hint = false;
|
||||||
|
this.nameAnchor = "";
|
||||||
|
this.genders = "";
|
||||||
|
this.numberCoins = "";
|
||||||
|
this.remarks = "";
|
||||||
|
this.datetimesingle = "";
|
||||||
|
uni.hideLoading();
|
||||||
|
uni.showToast({
|
||||||
|
title: "发布成功",
|
||||||
|
icon: "success",
|
||||||
|
duration: 2000,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
uni.hideLoading();
|
||||||
|
uni.showToast({
|
||||||
|
title: "发布失败",
|
||||||
|
icon: "none",
|
||||||
|
duration: 2000,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.Mask{
|
.Mask {
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
background: #00000076;
|
background: #00000076;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column-reverse;
|
flex-direction: column-reverse;
|
||||||
}
|
}
|
||||||
|
.Hint {
|
||||||
|
color: red;
|
||||||
|
font-size: 20rpx;
|
||||||
|
}
|
||||||
.container {
|
.container {
|
||||||
display: flex;
|
display: flex;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 900rpx;
|
height: 100%;
|
||||||
}
|
}
|
||||||
.Fork{
|
.Fork {
|
||||||
width: 50rpx;
|
width: 50rpx;
|
||||||
height: 50rpx;
|
height: 50rpx;
|
||||||
margin-top: 20rpx;
|
margin-top: 20rpx;
|
||||||
/* margin-bottom: 40rpx; */
|
/* margin-bottom: 40rpx; */
|
||||||
margin-left: 90%;
|
margin-left: 90%;
|
||||||
}
|
}
|
||||||
.Title{
|
.Title {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 30rpx;
|
height: 30rpx;
|
||||||
font-size: 50rpx;
|
font-size: 50rpx;
|
||||||
@@ -137,52 +248,49 @@ export default {
|
|||||||
margin-top: 40rpx;
|
margin-top: 40rpx;
|
||||||
margin-bottom: 40rpx;
|
margin-bottom: 40rpx;
|
||||||
}
|
}
|
||||||
.Individual{
|
.Individual {
|
||||||
display: flex;
|
display: flex;
|
||||||
/* justify-content: center; */
|
/* justify-content: center; */
|
||||||
}
|
}
|
||||||
.NameAnchor{
|
.NameAnchor {
|
||||||
margin: 40rpx;
|
margin: 40rpx;
|
||||||
}
|
}
|
||||||
.NameAnchorcss{
|
.time {
|
||||||
|
width: 90%;
|
||||||
|
margin-left: 5%;
|
||||||
|
}
|
||||||
|
.NameAnchorcss {
|
||||||
width: 300rpx;
|
width: 300rpx;
|
||||||
height: 85rpx;
|
height: 85rpx;
|
||||||
border: 1rpx solid #ccc;
|
border: 1rpx solid #ccc;
|
||||||
border-radius: 10rpx;
|
border-radius: 10rpx;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
.Gender{
|
.Gender {
|
||||||
margin: 40rpx;
|
|
||||||
}
|
|
||||||
.Gendercss{
|
|
||||||
width: 300rpx;
|
width: 300rpx;
|
||||||
height: 80rpx;
|
height: 80rpx;
|
||||||
text-align: center;
|
margin: 40rpx;
|
||||||
}
|
}
|
||||||
.Accountnumber{
|
.Accountnumber {
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
.Country{
|
.Coins {
|
||||||
|
|
||||||
}
|
|
||||||
.Countrycss{
|
|
||||||
margin: 40rpx;
|
|
||||||
width: 300rpx;
|
|
||||||
height: 65rpx;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
.Coins{
|
|
||||||
margin: 40rpx;
|
margin: 40rpx;
|
||||||
width: 300rpx;
|
width: 300rpx;
|
||||||
height: 65rpx;
|
height: 65rpx;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
/* align-items: center; */
|
||||||
}
|
}
|
||||||
.number-box {
|
.number-box {
|
||||||
|
display: flex;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
.Remarkscss{
|
.number-box-title {
|
||||||
|
margin-right: 20rpx;
|
||||||
|
}
|
||||||
|
.Remarkscss {
|
||||||
width: 90%;
|
width: 90%;
|
||||||
margin-top: 30rpx;
|
margin-top: 30rpx;
|
||||||
margin-left: 5%;
|
margin-left: 5%;
|
||||||
@@ -190,12 +298,12 @@ export default {
|
|||||||
margin-bottom: 50rpx;
|
margin-bottom: 50rpx;
|
||||||
border-radius: 10rpx;
|
border-radius: 10rpx;
|
||||||
}
|
}
|
||||||
.Publish{
|
.Publish {
|
||||||
margin-bottom: 50rpx;
|
margin-bottom: 50rpx;
|
||||||
width: 90%;
|
width: 90%;
|
||||||
margin-left: 5%;
|
margin-left: 5%;
|
||||||
}
|
}
|
||||||
.Publishcss{
|
.Publishcss {
|
||||||
background-color: #0048ff94;
|
background-color: #0048ff94;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
169
uni_modules/uni-datetime-picker/changelog.md
Normal file
169
uni_modules/uni-datetime-picker/changelog.md
Normal file
@@ -0,0 +1,169 @@
|
|||||||
|
## 2.2.40(2025-04-14)
|
||||||
|
- 修复 绑定字符串值的时,日历面板选中状态未重置到默认值的问题
|
||||||
|
## 2.2.39(2025-04-14)
|
||||||
|
- 修复 在 iOS 微信小程序上type='daterange'时,传入'YYYY-MM-DD'格式不生效的问题
|
||||||
|
|
||||||
|
## 2.2.38(2024-10-15)
|
||||||
|
- 修复 微信小程序中的getSystemInfo警告
|
||||||
|
## 2.2.35(2024-09-21)
|
||||||
|
- 修复 没有选中日期时点击确定直接报错的Bug [详情](https://ask.dcloud.net.cn/question/198168)
|
||||||
|
## 2.2.34(2024-04-24)
|
||||||
|
- 新增 日期点击事件,在点击日期时会触发该事件。
|
||||||
|
## 2.2.33(2024-04-15)
|
||||||
|
- 修复 抖音小程序事件传递失效bug
|
||||||
|
## 2.2.32(2024-02-20)
|
||||||
|
- 修复 日历的close事件触发异常的bug [详情](https://github.com/dcloudio/uni-ui/issues/844)
|
||||||
|
## 2.2.31(2024-02-20)
|
||||||
|
- 修复 h5平台 右边日历的月份默认+1的bug [详情](https://github.com/dcloudio/uni-ui/issues/841)
|
||||||
|
## 2.2.30(2024-01-31)
|
||||||
|
- 修复 隐藏“秒”时,在IOS15及以下版本时出现 结束时间在开始时间之前 的bug [详情](https://github.com/dcloudio/uni-ui/issues/788)
|
||||||
|
## 2.2.29(2024-01-20)
|
||||||
|
- 新增 show事件,弹窗弹出时触发该事件 [详情](https://github.com/dcloudio/uni-app/issues/4694)
|
||||||
|
## 2.2.28(2024-01-18)
|
||||||
|
- 去除 noChange事件,当进行日期范围选择时,若只选了一天,则开始结束日期都为同一天 [详情](https://github.com/dcloudio/uni-ui/issues/815)
|
||||||
|
## 2.2.27(2024-01-10)
|
||||||
|
- 优化 增加noChange事件,当进行日期范围选择时,若有空值,则触发该事件 [详情](https://github.com/dcloudio/uni-ui/issues/815)
|
||||||
|
## 2.2.26(2024-01-08)
|
||||||
|
- 修复 字节小程序时间选择范围器失效问题 [详情](https://github.com/dcloudio/uni-ui/issues/834)
|
||||||
|
## 2.2.25(2023-10-18)
|
||||||
|
- 修复 PC端初次修改时间,开始时间未更新的Bug [详情](https://github.com/dcloudio/uni-ui/issues/737)
|
||||||
|
## 2.2.24(2023-06-02)
|
||||||
|
- 修复 部分情况修改时间,开始、结束时间显示异常的Bug [详情](https://ask.dcloud.net.cn/question/171146)
|
||||||
|
- 优化 当前月可以选择上月、下月的日期的Bug
|
||||||
|
## 2.2.23(2023-05-02)
|
||||||
|
- 修复 部分情况修改时间,开始时间未更新的Bug [详情](https://github.com/dcloudio/uni-ui/issues/737)
|
||||||
|
- 修复 部分平台及设备第一次点击无法显示弹框的Bug
|
||||||
|
- 修复 ios 日期格式未补零显示及使用异常的Bug [详情](https://ask.dcloud.net.cn/question/162979)
|
||||||
|
## 2.2.22(2023-03-30)
|
||||||
|
- 修复 日历 picker 修改年月后,自动选中当月1日的Bug [详情](https://ask.dcloud.net.cn/question/165937)
|
||||||
|
- 修复 小程序端 低版本 ios NaN的Bug [详情](https://ask.dcloud.net.cn/question/162979)
|
||||||
|
## 2.2.21(2023-02-20)
|
||||||
|
- 修复 firefox 浏览器显示区域点击无法拉起日历弹框的Bug [详情](https://ask.dcloud.net.cn/question/163362)
|
||||||
|
## 2.2.20(2023-02-17)
|
||||||
|
- 优化 值为空依然选中当天问题
|
||||||
|
- 优化 提供 default-value 属性支持配置选择器打开时默认显示的时间
|
||||||
|
- 优化 非范围选择未选择日期时间,点击确认按钮选中当前日期时间
|
||||||
|
- 优化 字节小程序日期时间范围选择,底部日期换行的Bug
|
||||||
|
## 2.2.19(2023-02-09)
|
||||||
|
- 修复 2.2.18 引起范围选择配置 end 选择无效的Bug [详情](https://github.com/dcloudio/uni-ui/issues/686)
|
||||||
|
## 2.2.18(2023-02-08)
|
||||||
|
- 修复 移动端范围选择change事件触发异常的Bug [详情](https://github.com/dcloudio/uni-ui/issues/684)
|
||||||
|
- 优化 PC端输入日期格式错误时返回当前日期时间
|
||||||
|
- 优化 PC端输入日期时间超出 start、end 限制的Bug
|
||||||
|
- 优化 移动端日期时间范围用法时间展示不完整问题
|
||||||
|
## 2.2.17(2023-02-04)
|
||||||
|
- 修复 小程序端绑定 Date 类型报错的Bug [详情](https://github.com/dcloudio/uni-ui/issues/679)
|
||||||
|
- 修复 vue3 time-picker 无法显示绑定时分秒的Bug
|
||||||
|
## 2.2.16(2023-02-02)
|
||||||
|
- 修复 字节小程序报错的Bug
|
||||||
|
## 2.2.15(2023-02-02)
|
||||||
|
- 修复 某些情况切换月份错误的Bug
|
||||||
|
## 2.2.14(2023-01-30)
|
||||||
|
- 修复 某些情况切换月份错误的Bug [详情](https://ask.dcloud.net.cn/question/162033)
|
||||||
|
## 2.2.13(2023-01-10)
|
||||||
|
- 修复 多次加载组件造成内存占用的Bug
|
||||||
|
## 2.2.12(2022-12-01)
|
||||||
|
- 修复 vue3 下 i18n 国际化初始值不正确的Bug
|
||||||
|
## 2.2.11(2022-09-19)
|
||||||
|
- 修复 支付宝小程序样式错乱的Bug [详情](https://github.com/dcloudio/uni-app/issues/3861)
|
||||||
|
## 2.2.10(2022-09-19)
|
||||||
|
- 修复 反向选择日期范围,日期显示异常的Bug [详情](https://ask.dcloud.net.cn/question/153401?item_id=212892&rf=false)
|
||||||
|
## 2.2.9(2022-09-16)
|
||||||
|
- 可以使用 uni-scss 控制主题色
|
||||||
|
## 2.2.8(2022-09-08)
|
||||||
|
- 修复 close事件无效的Bug
|
||||||
|
## 2.2.7(2022-09-05)
|
||||||
|
- 修复 移动端 maskClick 无效的Bug [详情](https://ask.dcloud.net.cn/question/140824)
|
||||||
|
## 2.2.6(2022-06-30)
|
||||||
|
- 优化 组件样式,调整了组件图标大小、高度、颜色等,与uni-ui风格保持一致
|
||||||
|
## 2.2.5(2022-06-24)
|
||||||
|
- 修复 日历顶部年月及底部确认未国际化的Bug
|
||||||
|
## 2.2.4(2022-03-31)
|
||||||
|
- 修复 Vue3 下动态赋值,单选类型未响应的Bug
|
||||||
|
## 2.2.3(2022-03-28)
|
||||||
|
- 修复 Vue3 下动态赋值未响应的Bug
|
||||||
|
## 2.2.2(2021-12-10)
|
||||||
|
- 修复 clear-icon 属性在小程序平台不生效的Bug
|
||||||
|
## 2.2.1(2021-12-10)
|
||||||
|
- 修复 日期范围选在小程序平台,必须多点击一次才能取消选中状态的Bug
|
||||||
|
## 2.2.0(2021-11-19)
|
||||||
|
- 优化 组件UI,并提供设计资源 [详情](https://uniapp.dcloud.io/component/uniui/resource)
|
||||||
|
- 文档迁移 [https://uniapp.dcloud.io/component/uniui/uni-datetime-picker](https://uniapp.dcloud.io/component/uniui/uni-datetime-picker)
|
||||||
|
## 2.1.5(2021-11-09)
|
||||||
|
- 新增 提供组件设计资源,组件样式调整
|
||||||
|
## 2.1.4(2021-09-10)
|
||||||
|
- 修复 hide-second 在移动端的Bug
|
||||||
|
- 修复 单选赋默认值时,赋值日期未高亮的Bug
|
||||||
|
- 修复 赋默认值时,移动端未正确显示时间的Bug
|
||||||
|
## 2.1.3(2021-09-09)
|
||||||
|
- 新增 hide-second 属性,支持只使用时分,隐藏秒
|
||||||
|
## 2.1.2(2021-09-03)
|
||||||
|
- 优化 取消选中时(范围选)直接开始下一次选择, 避免多点一次
|
||||||
|
- 优化 移动端支持清除按钮,同时支持通过 ref 调用组件的 clear 方法
|
||||||
|
- 优化 调整字号大小,美化日历界面
|
||||||
|
- 修复 因国际化导致的 placeholder 失效的Bug
|
||||||
|
## 2.1.1(2021-08-24)
|
||||||
|
- 新增 支持国际化
|
||||||
|
- 优化 范围选择器在 pc 端过宽的问题
|
||||||
|
## 2.1.0(2021-08-09)
|
||||||
|
- 新增 适配 vue3
|
||||||
|
## 2.0.19(2021-08-09)
|
||||||
|
- 新增 支持作为 uni-forms 子组件相关功能
|
||||||
|
- 修复 在 uni-forms 中使用时,选择时间报 NAN 错误的Bug
|
||||||
|
## 2.0.18(2021-08-05)
|
||||||
|
- 修复 type 属性动态赋值无效的Bug
|
||||||
|
- 修复 ‘确认’按钮被 tabbar 遮盖 bug
|
||||||
|
- 修复 组件未赋值时范围选左、右日历相同的Bug
|
||||||
|
## 2.0.17(2021-08-04)
|
||||||
|
- 修复 范围选未正确显示当前值的Bug
|
||||||
|
- 修复 h5 平台(移动端)报错 'cale' of undefined 的Bug
|
||||||
|
## 2.0.16(2021-07-21)
|
||||||
|
- 新增 return-type 属性支持返回 date 日期对象
|
||||||
|
## 2.0.15(2021-07-14)
|
||||||
|
- 修复 单选日期类型,初始赋值后不在当前日历的Bug
|
||||||
|
- 新增 clearIcon 属性,显示框的清空按钮可配置显示隐藏(仅 pc 有效)
|
||||||
|
- 优化 移动端移除显示框的清空按钮,无实际用途
|
||||||
|
## 2.0.14(2021-07-14)
|
||||||
|
- 修复 组件赋值为空,界面未更新的Bug
|
||||||
|
- 修复 start 和 end 不能动态赋值的Bug
|
||||||
|
- 修复 范围选类型,用户选择后再次选择右侧日历(结束日期)显示不正确的Bug
|
||||||
|
## 2.0.13(2021-07-08)
|
||||||
|
- 修复 范围选择不能动态赋值的Bug
|
||||||
|
## 2.0.12(2021-07-08)
|
||||||
|
- 修复 范围选择的初始时间在一个月内时,造成无法选择的bug
|
||||||
|
## 2.0.11(2021-07-08)
|
||||||
|
- 优化 弹出层在超出视窗边缘定位不准确的问题
|
||||||
|
## 2.0.10(2021-07-08)
|
||||||
|
- 修复 范围起始点样式的背景色与今日样式的字体前景色融合,导致日期字体看不清的Bug
|
||||||
|
- 优化 弹出层在超出视窗边缘被遮盖的问题
|
||||||
|
## 2.0.9(2021-07-07)
|
||||||
|
- 新增 maskClick 事件
|
||||||
|
- 修复 特殊情况日历 rpx 布局错误的Bug,rpx -> px
|
||||||
|
- 修复 范围选择时清空返回值不合理的bug,['', ''] -> []
|
||||||
|
## 2.0.8(2021-07-07)
|
||||||
|
- 新增 日期时间显示框支持插槽
|
||||||
|
## 2.0.7(2021-07-01)
|
||||||
|
- 优化 添加 uni-icons 依赖
|
||||||
|
## 2.0.6(2021-05-22)
|
||||||
|
- 修复 图标在小程序上不显示的Bug
|
||||||
|
- 优化 重命名引用组件,避免潜在组件命名冲突
|
||||||
|
## 2.0.5(2021-05-20)
|
||||||
|
- 优化 代码目录扁平化
|
||||||
|
## 2.0.4(2021-05-12)
|
||||||
|
- 新增 组件示例地址
|
||||||
|
## 2.0.3(2021-05-10)
|
||||||
|
- 修复 ios 下不识别 '-' 日期格式的Bug
|
||||||
|
- 优化 pc 下弹出层添加边框和阴影
|
||||||
|
## 2.0.2(2021-05-08)
|
||||||
|
- 修复 在 admin 中获取弹出层定位错误的bug
|
||||||
|
## 2.0.1(2021-05-08)
|
||||||
|
- 修复 type 属性向下兼容,默认值从 date 变更为 datetime
|
||||||
|
## 2.0.0(2021-04-30)
|
||||||
|
- 支持日历形式的日期+时间的范围选择
|
||||||
|
> 注意:此版本不向后兼容,不再支持单独时间选择(type=time)及相关的 hide-second 属性(时间选可使用内置组件 picker)
|
||||||
|
## 1.0.6(2021-03-18)
|
||||||
|
- 新增 hide-second 属性,时间支持仅选择时、分
|
||||||
|
- 修复 选择跟显示的日期不一样的Bug
|
||||||
|
- 修复 chang事件触发2次的Bug
|
||||||
|
- 修复 分、秒 end 范围错误的Bug
|
||||||
|
- 优化 更好的 nvue 适配
|
||||||
@@ -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,947 @@
|
|||||||
|
<template>
|
||||||
|
<view class="uni-calendar" @mouseleave="leaveCale">
|
||||||
|
|
||||||
|
<view v-if="!insert && show" class="uni-calendar__mask" :class="{'uni-calendar--mask-show':aniMaskShow}"
|
||||||
|
@click="maskClick"></view>
|
||||||
|
|
||||||
|
<view v-if="insert || show" class="uni-calendar__content"
|
||||||
|
:class="{'uni-calendar--fixed':!insert,'uni-calendar--ani-show':aniMaskShow, 'uni-calendar__content-mobile': aniMaskShow}">
|
||||||
|
<view class="uni-calendar__header" :class="{'uni-calendar__header-mobile' :!insert}">
|
||||||
|
|
||||||
|
<view class="uni-calendar__header-btn-box" @click.stop="changeMonth('pre')">
|
||||||
|
<view class="uni-calendar__header-btn uni-calendar--left"></view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<picker mode="date" :value="date" fields="month" @change="bindDateChange">
|
||||||
|
<text
|
||||||
|
class="uni-calendar__header-text">{{ (nowDate.year||'') + yearText + ( nowDate.month||'') + monthText}}</text>
|
||||||
|
</picker>
|
||||||
|
|
||||||
|
<view class="uni-calendar__header-btn-box" @click.stop="changeMonth('next')">
|
||||||
|
<view class="uni-calendar__header-btn uni-calendar--right"></view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view v-if="!insert" class="dialog-close" @click="maskClick">
|
||||||
|
<view class="dialog-close-plus" data-id="close"></view>
|
||||||
|
<view class="dialog-close-plus dialog-close-rotate" data-id="close"></view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="uni-calendar__box">
|
||||||
|
|
||||||
|
<view v-if="showMonth" class="uni-calendar__box-bg">
|
||||||
|
<text class="uni-calendar__box-bg-text">{{nowDate.month}}</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="uni-calendar__weeks" style="padding-bottom: 7px;">
|
||||||
|
<view class="uni-calendar__weeks-day">
|
||||||
|
<text class="uni-calendar__weeks-day-text">{{SUNText}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="uni-calendar__weeks-day">
|
||||||
|
<text class="uni-calendar__weeks-day-text">{{MONText}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="uni-calendar__weeks-day">
|
||||||
|
<text class="uni-calendar__weeks-day-text">{{TUEText}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="uni-calendar__weeks-day">
|
||||||
|
<text class="uni-calendar__weeks-day-text">{{WEDText}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="uni-calendar__weeks-day">
|
||||||
|
<text class="uni-calendar__weeks-day-text">{{THUText}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="uni-calendar__weeks-day">
|
||||||
|
<text class="uni-calendar__weeks-day-text">{{FRIText}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="uni-calendar__weeks-day">
|
||||||
|
<text class="uni-calendar__weeks-day-text">{{SATText}}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="uni-calendar__weeks" v-for="(item,weekIndex) in weeks" :key="weekIndex">
|
||||||
|
<view class="uni-calendar__weeks-item" v-for="(weeks,weeksIndex) in item" :key="weeksIndex">
|
||||||
|
<calendar-item class="uni-calendar-item--hook" :weeks="weeks" :calendar="calendar" :selected="selected"
|
||||||
|
:checkHover="range" @change="choiceDate" @handleMouse="handleMouse">
|
||||||
|
</calendar-item>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view v-if="!insert && !range && hasTime" class="uni-date-changed uni-calendar--fixed-top"
|
||||||
|
style="padding: 0 80px;">
|
||||||
|
<view class="uni-date-changed--time-date">{{tempSingleDate ? tempSingleDate : selectDateText}}</view>
|
||||||
|
<time-picker type="time" :start="timepickerStartTime" :end="timepickerEndTime" v-model="time"
|
||||||
|
:disabled="!tempSingleDate" :border="false" :hide-second="hideSecond" class="time-picker-style">
|
||||||
|
</time-picker>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view v-if="!insert && range && hasTime" class="uni-date-changed uni-calendar--fixed-top">
|
||||||
|
<view class="uni-date-changed--time-start">
|
||||||
|
<view class="uni-date-changed--time-date">{{tempRange.before ? tempRange.before : startDateText}}
|
||||||
|
</view>
|
||||||
|
<time-picker type="time" :start="timepickerStartTime" v-model="timeRange.startTime" :border="false"
|
||||||
|
:hide-second="hideSecond" :disabled="!tempRange.before" class="time-picker-style">
|
||||||
|
</time-picker>
|
||||||
|
</view>
|
||||||
|
<view style="line-height: 50px;">
|
||||||
|
<uni-icons type="arrowthinright" color="#999"></uni-icons>
|
||||||
|
</view>
|
||||||
|
<view class="uni-date-changed--time-end">
|
||||||
|
<view class="uni-date-changed--time-date">{{tempRange.after ? tempRange.after : endDateText}}</view>
|
||||||
|
<time-picker type="time" :end="timepickerEndTime" v-model="timeRange.endTime" :border="false"
|
||||||
|
:hide-second="hideSecond" :disabled="!tempRange.after" class="time-picker-style">
|
||||||
|
</time-picker>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view v-if="!insert" class="uni-date-changed uni-date-btn--ok">
|
||||||
|
<view class="uni-datetime-picker--btn" @click="confirm">{{confirmText}}</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
Calendar,
|
||||||
|
getDate,
|
||||||
|
getTime
|
||||||
|
} from './util.js';
|
||||||
|
import calendarItem from './calendar-item.vue'
|
||||||
|
import timePicker from './time-picker.vue'
|
||||||
|
|
||||||
|
import {
|
||||||
|
initVueI18n
|
||||||
|
} from '@dcloudio/uni-i18n'
|
||||||
|
import i18nMessages from './i18n/index.js'
|
||||||
|
const {
|
||||||
|
t
|
||||||
|
} = initVueI18n(i18nMessages)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calendar 日历
|
||||||
|
* @description 日历组件可以查看日期,选择任意范围内的日期,打点操作。常用场景如:酒店日期预订、火车机票选择购买日期、上下班打卡等
|
||||||
|
* @tutorial https://ext.dcloud.net.cn/plugin?id=56
|
||||||
|
* @property {String} date 自定义当前时间,默认为今天
|
||||||
|
* @property {String} startDate 日期选择范围-开始日期
|
||||||
|
* @property {String} endDate 日期选择范围-结束日期
|
||||||
|
* @property {Boolean} range 范围选择
|
||||||
|
* @property {Boolean} insert = [true|false] 插入模式,默认为false
|
||||||
|
* @value true 弹窗模式
|
||||||
|
* @value false 插入模式
|
||||||
|
* @property {Boolean} clearDate = [true|false] 弹窗模式是否清空上次选择内容
|
||||||
|
* @property {Array} selected 打点,期待格式[{date: '2019-06-27', info: '签到', data: { custom: '自定义信息', name: '自定义消息头',xxx:xxx... }}]
|
||||||
|
* @property {Boolean} showMonth 是否选择月份为背景
|
||||||
|
* @property {[String} defaultValue 选择器打开时默认显示的时间
|
||||||
|
* @event {Function} change 日期改变,`insert :ture` 时生效
|
||||||
|
* @event {Function} confirm 确认选择`insert :false` 时生效
|
||||||
|
* @event {Function} monthSwitch 切换月份时触发
|
||||||
|
* @example <uni-calendar :insert="true" :start-date="'2019-3-2'":end-date="'2019-5-20'"@change="change" />
|
||||||
|
*/
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
calendarItem,
|
||||||
|
timePicker
|
||||||
|
},
|
||||||
|
|
||||||
|
options: {
|
||||||
|
// #ifdef MP-TOUTIAO
|
||||||
|
virtualHost: false,
|
||||||
|
// #endif
|
||||||
|
// #ifndef MP-TOUTIAO
|
||||||
|
virtualHost: true
|
||||||
|
// #endif
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
date: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
defTime: {
|
||||||
|
type: [String, Object],
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
selectableTimes: {
|
||||||
|
type: [Object],
|
||||||
|
default () {
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
selected: {
|
||||||
|
type: Array,
|
||||||
|
default () {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
startDate: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
endDate: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
startPlaceholder: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
endPlaceholder: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
range: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
hasTime: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
insert: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
showMonth: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
clearDate: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
checkHover: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
hideSecond: {
|
||||||
|
type: [Boolean],
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
pleStatus: {
|
||||||
|
type: Object,
|
||||||
|
default () {
|
||||||
|
return {
|
||||||
|
before: '',
|
||||||
|
after: '',
|
||||||
|
data: [],
|
||||||
|
fulldate: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
defaultValue: {
|
||||||
|
type: [String, Object, Array],
|
||||||
|
default: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
show: false,
|
||||||
|
weeks: [],
|
||||||
|
calendar: {},
|
||||||
|
nowDate: {},
|
||||||
|
aniMaskShow: false,
|
||||||
|
firstEnter: true,
|
||||||
|
time: '',
|
||||||
|
timeRange: {
|
||||||
|
startTime: '',
|
||||||
|
endTime: ''
|
||||||
|
},
|
||||||
|
tempSingleDate: '',
|
||||||
|
tempRange: {
|
||||||
|
before: '',
|
||||||
|
after: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
date: {
|
||||||
|
immediate: true,
|
||||||
|
handler(newVal) {
|
||||||
|
if (!this.range) {
|
||||||
|
this.tempSingleDate = newVal
|
||||||
|
setTimeout(() => {
|
||||||
|
this.init(newVal)
|
||||||
|
}, 100)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
defTime: {
|
||||||
|
immediate: true,
|
||||||
|
handler(newVal) {
|
||||||
|
if (!this.range) {
|
||||||
|
this.time = newVal
|
||||||
|
} else {
|
||||||
|
this.timeRange.startTime = newVal.start
|
||||||
|
this.timeRange.endTime = newVal.end
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
startDate(val) {
|
||||||
|
// 字节小程序 watch 早于 created
|
||||||
|
if (!this.cale) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.cale.setStartDate(val)
|
||||||
|
this.cale.setDate(this.nowDate.fullDate)
|
||||||
|
this.weeks = this.cale.weeks
|
||||||
|
},
|
||||||
|
endDate(val) {
|
||||||
|
// 字节小程序 watch 早于 created
|
||||||
|
if (!this.cale) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.cale.setEndDate(val)
|
||||||
|
this.cale.setDate(this.nowDate.fullDate)
|
||||||
|
this.weeks = this.cale.weeks
|
||||||
|
},
|
||||||
|
selected(newVal) {
|
||||||
|
// 字节小程序 watch 早于 created
|
||||||
|
if (!this.cale) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.cale.setSelectInfo(this.nowDate.fullDate, newVal)
|
||||||
|
this.weeks = this.cale.weeks
|
||||||
|
},
|
||||||
|
pleStatus: {
|
||||||
|
immediate: true,
|
||||||
|
handler(newVal) {
|
||||||
|
const {
|
||||||
|
before,
|
||||||
|
after,
|
||||||
|
fulldate,
|
||||||
|
which
|
||||||
|
} = newVal
|
||||||
|
this.tempRange.before = before
|
||||||
|
this.tempRange.after = after
|
||||||
|
setTimeout(() => {
|
||||||
|
if (fulldate) {
|
||||||
|
this.cale.setHoverMultiple(fulldate)
|
||||||
|
if (before && after) {
|
||||||
|
this.cale.lastHover = true
|
||||||
|
if (this.rangeWithinMonth(after, before)) return
|
||||||
|
this.setDate(before)
|
||||||
|
} else {
|
||||||
|
this.cale.setMultiple(fulldate)
|
||||||
|
this.setDate(this.nowDate.fullDate)
|
||||||
|
this.calendar.fullDate = ''
|
||||||
|
this.cale.lastHover = false
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 字节小程序 watch 早于 created
|
||||||
|
if (!this.cale) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.cale.setDefaultMultiple(before, after)
|
||||||
|
if (which === 'left' && before) {
|
||||||
|
this.setDate(before)
|
||||||
|
this.weeks = this.cale.weeks
|
||||||
|
} else if (after) {
|
||||||
|
this.setDate(after)
|
||||||
|
this.weeks = this.cale.weeks
|
||||||
|
}
|
||||||
|
this.cale.lastHover = true
|
||||||
|
}
|
||||||
|
}, 16)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
timepickerStartTime() {
|
||||||
|
const activeDate = this.range ? this.tempRange.before : this.calendar.fullDate
|
||||||
|
return activeDate === this.startDate ? this.selectableTimes.start : ''
|
||||||
|
},
|
||||||
|
timepickerEndTime() {
|
||||||
|
const activeDate = this.range ? this.tempRange.after : this.calendar.fullDate
|
||||||
|
return activeDate === this.endDate ? this.selectableTimes.end : ''
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* for i18n
|
||||||
|
*/
|
||||||
|
selectDateText() {
|
||||||
|
return t("uni-datetime-picker.selectDate")
|
||||||
|
},
|
||||||
|
startDateText() {
|
||||||
|
return this.startPlaceholder || t("uni-datetime-picker.startDate")
|
||||||
|
},
|
||||||
|
endDateText() {
|
||||||
|
return this.endPlaceholder || t("uni-datetime-picker.endDate")
|
||||||
|
},
|
||||||
|
okText() {
|
||||||
|
return t("uni-datetime-picker.ok")
|
||||||
|
},
|
||||||
|
yearText() {
|
||||||
|
return t("uni-datetime-picker.year")
|
||||||
|
},
|
||||||
|
monthText() {
|
||||||
|
return t("uni-datetime-picker.month")
|
||||||
|
},
|
||||||
|
MONText() {
|
||||||
|
return t("uni-calender.MON")
|
||||||
|
},
|
||||||
|
TUEText() {
|
||||||
|
return t("uni-calender.TUE")
|
||||||
|
},
|
||||||
|
WEDText() {
|
||||||
|
return t("uni-calender.WED")
|
||||||
|
},
|
||||||
|
THUText() {
|
||||||
|
return t("uni-calender.THU")
|
||||||
|
},
|
||||||
|
FRIText() {
|
||||||
|
return t("uni-calender.FRI")
|
||||||
|
},
|
||||||
|
SATText() {
|
||||||
|
return t("uni-calender.SAT")
|
||||||
|
},
|
||||||
|
SUNText() {
|
||||||
|
return t("uni-calender.SUN")
|
||||||
|
},
|
||||||
|
confirmText() {
|
||||||
|
return t("uni-calender.confirm")
|
||||||
|
},
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
// 获取日历方法实例
|
||||||
|
this.cale = new Calendar({
|
||||||
|
selected: this.selected,
|
||||||
|
startDate: this.startDate,
|
||||||
|
endDate: this.endDate,
|
||||||
|
range: this.range,
|
||||||
|
})
|
||||||
|
// 选中某一天
|
||||||
|
this.init(this.date)
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
leaveCale() {
|
||||||
|
this.firstEnter = true
|
||||||
|
},
|
||||||
|
handleMouse(weeks) {
|
||||||
|
if (weeks.disable) return
|
||||||
|
if (this.cale.lastHover) return
|
||||||
|
let {
|
||||||
|
before,
|
||||||
|
after
|
||||||
|
} = this.cale.multipleStatus
|
||||||
|
if (!before) return
|
||||||
|
this.calendar = weeks
|
||||||
|
// 设置范围选
|
||||||
|
this.cale.setHoverMultiple(this.calendar.fullDate)
|
||||||
|
this.weeks = this.cale.weeks
|
||||||
|
// hover时,进入一个日历,更新另一个
|
||||||
|
if (this.firstEnter) {
|
||||||
|
this.$emit('firstEnterCale', this.cale.multipleStatus)
|
||||||
|
this.firstEnter = false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
rangeWithinMonth(A, B) {
|
||||||
|
const [yearA, monthA] = A.split('-')
|
||||||
|
const [yearB, monthB] = B.split('-')
|
||||||
|
return yearA === yearB && monthA === monthB
|
||||||
|
},
|
||||||
|
// 蒙版点击事件
|
||||||
|
maskClick() {
|
||||||
|
this.close()
|
||||||
|
this.$emit('maskClose')
|
||||||
|
},
|
||||||
|
|
||||||
|
clearCalender() {
|
||||||
|
if (this.range) {
|
||||||
|
this.timeRange.startTime = ''
|
||||||
|
this.timeRange.endTime = ''
|
||||||
|
this.tempRange.before = ''
|
||||||
|
this.tempRange.after = ''
|
||||||
|
this.cale.multipleStatus.before = ''
|
||||||
|
this.cale.multipleStatus.after = ''
|
||||||
|
this.cale.multipleStatus.data = []
|
||||||
|
this.cale.lastHover = false
|
||||||
|
} else {
|
||||||
|
this.time = ''
|
||||||
|
this.tempSingleDate = ''
|
||||||
|
}
|
||||||
|
this.calendar.fullDate = ''
|
||||||
|
this.setDate(new Date())
|
||||||
|
},
|
||||||
|
|
||||||
|
bindDateChange(e) {
|
||||||
|
const value = e.detail.value + '-1'
|
||||||
|
this.setDate(value)
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 初始化日期显示
|
||||||
|
* @param {Object} date
|
||||||
|
*/
|
||||||
|
init(date) {
|
||||||
|
// 字节小程序 watch 早于 created
|
||||||
|
if (!this.cale) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.cale.setDate(date || new Date())
|
||||||
|
this.weeks = this.cale.weeks
|
||||||
|
this.nowDate = this.cale.getInfo(date)
|
||||||
|
this.calendar = {
|
||||||
|
...this.nowDate
|
||||||
|
}
|
||||||
|
if (!date) {
|
||||||
|
// 优化date为空默认不选中今天
|
||||||
|
this.calendar.fullDate = ''
|
||||||
|
if (this.defaultValue && !this.range) {
|
||||||
|
// 暂时只支持移动端非范围选择
|
||||||
|
const defaultDate = new Date(this.defaultValue)
|
||||||
|
const fullDate = getDate(defaultDate)
|
||||||
|
const year = defaultDate.getFullYear()
|
||||||
|
const month = defaultDate.getMonth() + 1
|
||||||
|
const date = defaultDate.getDate()
|
||||||
|
const day = defaultDate.getDay()
|
||||||
|
this.calendar = {
|
||||||
|
fullDate,
|
||||||
|
year,
|
||||||
|
month,
|
||||||
|
date,
|
||||||
|
day
|
||||||
|
},
|
||||||
|
this.tempSingleDate = fullDate
|
||||||
|
this.time = getTime(defaultDate, this.hideSecond)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 打开日历弹窗
|
||||||
|
*/
|
||||||
|
open() {
|
||||||
|
// 弹窗模式并且清理数据
|
||||||
|
if (this.clearDate && !this.insert) {
|
||||||
|
this.cale.cleanMultipleStatus()
|
||||||
|
this.init(this.date)
|
||||||
|
}
|
||||||
|
this.show = true
|
||||||
|
this.$nextTick(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.aniMaskShow = true
|
||||||
|
}, 50)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 关闭日历弹窗
|
||||||
|
*/
|
||||||
|
close() {
|
||||||
|
this.aniMaskShow = false
|
||||||
|
this.$nextTick(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.show = false
|
||||||
|
this.$emit('close')
|
||||||
|
}, 300)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 确认按钮
|
||||||
|
*/
|
||||||
|
confirm() {
|
||||||
|
this.setEmit('confirm')
|
||||||
|
this.close()
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 变化触发
|
||||||
|
*/
|
||||||
|
change(isSingleChange) {
|
||||||
|
if (!this.insert && !isSingleChange) return
|
||||||
|
this.setEmit('change')
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 选择月份触发
|
||||||
|
*/
|
||||||
|
monthSwitch() {
|
||||||
|
let {
|
||||||
|
year,
|
||||||
|
month
|
||||||
|
} = this.nowDate
|
||||||
|
this.$emit('monthSwitch', {
|
||||||
|
year,
|
||||||
|
month: Number(month)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 派发事件
|
||||||
|
* @param {Object} name
|
||||||
|
*/
|
||||||
|
setEmit(name) {
|
||||||
|
if (!this.range) {
|
||||||
|
if (!this.calendar.fullDate) {
|
||||||
|
this.calendar = this.cale.getInfo(new Date())
|
||||||
|
this.tempSingleDate = this.calendar.fullDate
|
||||||
|
}
|
||||||
|
if (this.hasTime && !this.time) {
|
||||||
|
this.time = getTime(new Date(), this.hideSecond)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let {
|
||||||
|
year,
|
||||||
|
month,
|
||||||
|
date,
|
||||||
|
fullDate,
|
||||||
|
extraInfo
|
||||||
|
} = this.calendar
|
||||||
|
this.$emit(name, {
|
||||||
|
range: this.cale.multipleStatus,
|
||||||
|
year,
|
||||||
|
month,
|
||||||
|
date,
|
||||||
|
time: this.time,
|
||||||
|
timeRange: this.timeRange,
|
||||||
|
fulldate: fullDate,
|
||||||
|
extraInfo: extraInfo || {}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 选择天触发
|
||||||
|
* @param {Object} weeks
|
||||||
|
*/
|
||||||
|
choiceDate(weeks) {
|
||||||
|
if (weeks.disable) return
|
||||||
|
this.calendar = weeks
|
||||||
|
this.calendar.userChecked = true
|
||||||
|
// 设置多选
|
||||||
|
this.cale.setMultiple(this.calendar.fullDate, true)
|
||||||
|
this.weeks = this.cale.weeks
|
||||||
|
this.tempSingleDate = this.calendar.fullDate
|
||||||
|
const beforeDate = new Date(this.cale.multipleStatus.before).getTime()
|
||||||
|
const afterDate = new Date(this.cale.multipleStatus.after).getTime()
|
||||||
|
if (beforeDate > afterDate && afterDate) {
|
||||||
|
this.tempRange.before = this.cale.multipleStatus.after
|
||||||
|
this.tempRange.after = this.cale.multipleStatus.before
|
||||||
|
} else {
|
||||||
|
this.tempRange.before = this.cale.multipleStatus.before
|
||||||
|
this.tempRange.after = this.cale.multipleStatus.after
|
||||||
|
}
|
||||||
|
this.change(true)
|
||||||
|
},
|
||||||
|
changeMonth(type) {
|
||||||
|
let newDate
|
||||||
|
if (type === 'pre') {
|
||||||
|
newDate = this.cale.getPreMonthObj(this.nowDate.fullDate).fullDate
|
||||||
|
} else if (type === 'next') {
|
||||||
|
newDate = this.cale.getNextMonthObj(this.nowDate.fullDate).fullDate
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setDate(newDate)
|
||||||
|
this.monthSwitch()
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 设置日期
|
||||||
|
* @param {Object} date
|
||||||
|
*/
|
||||||
|
setDate(date) {
|
||||||
|
this.cale.setDate(date)
|
||||||
|
this.weeks = this.cale.weeks
|
||||||
|
this.nowDate = this.cale.getInfo(date)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
$uni-primary: #007aff !default;
|
||||||
|
|
||||||
|
.uni-calendar {
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
display: flex;
|
||||||
|
/* #endif */
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-calendar__mask {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
background-color: rgba(0, 0, 0, 0.4);
|
||||||
|
transition-property: opacity;
|
||||||
|
transition-duration: 0.3s;
|
||||||
|
opacity: 0;
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
z-index: 99;
|
||||||
|
/* #endif */
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-calendar--mask-show {
|
||||||
|
opacity: 1
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-calendar--fixed {
|
||||||
|
position: fixed;
|
||||||
|
bottom: calc(var(--window-bottom));
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
transition-property: transform;
|
||||||
|
transition-duration: 0.3s;
|
||||||
|
transform: translateY(460px);
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
z-index: 99;
|
||||||
|
/* #endif */
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-calendar--ani-show {
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-calendar__content {
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-calendar__content-mobile {
|
||||||
|
border-top-left-radius: 10px;
|
||||||
|
border-top-right-radius: 10px;
|
||||||
|
box-shadow: 0px 0px 5px 3px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-calendar__header {
|
||||||
|
position: relative;
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
display: flex;
|
||||||
|
/* #endif */
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-calendar__header-mobile {
|
||||||
|
padding: 10px;
|
||||||
|
padding-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-calendar--fixed-top {
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
display: flex;
|
||||||
|
/* #endif */
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: space-between;
|
||||||
|
border-top-color: rgba(0, 0, 0, 0.4);
|
||||||
|
border-top-style: solid;
|
||||||
|
border-top-width: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-calendar--fixed-width {
|
||||||
|
width: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-calendar__backtoday {
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
top: 25rpx;
|
||||||
|
padding: 0 5px;
|
||||||
|
padding-left: 10px;
|
||||||
|
height: 25px;
|
||||||
|
line-height: 25px;
|
||||||
|
font-size: 12px;
|
||||||
|
border-top-left-radius: 25px;
|
||||||
|
border-bottom-left-radius: 25px;
|
||||||
|
color: #fff;
|
||||||
|
background-color: #f1f1f1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-calendar__header-text {
|
||||||
|
text-align: center;
|
||||||
|
width: 100px;
|
||||||
|
font-size: 15px;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-calendar__button-text {
|
||||||
|
text-align: center;
|
||||||
|
width: 100px;
|
||||||
|
font-size: 14px;
|
||||||
|
color: $uni-primary;
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
letter-spacing: 3px;
|
||||||
|
/* #endif */
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-calendar__header-btn-box {
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
display: flex;
|
||||||
|
/* #endif */
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 50px;
|
||||||
|
height: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-calendar__header-btn {
|
||||||
|
width: 9px;
|
||||||
|
height: 9px;
|
||||||
|
border-left-color: #808080;
|
||||||
|
border-left-style: solid;
|
||||||
|
border-left-width: 1px;
|
||||||
|
border-top-color: #555555;
|
||||||
|
border-top-style: solid;
|
||||||
|
border-top-width: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-calendar--left {
|
||||||
|
transform: rotate(-45deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-calendar--right {
|
||||||
|
transform: rotate(135deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.uni-calendar__weeks {
|
||||||
|
position: relative;
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
display: flex;
|
||||||
|
/* #endif */
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-calendar__weeks-item {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-calendar__weeks-day {
|
||||||
|
flex: 1;
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
display: flex;
|
||||||
|
/* #endif */
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 40px;
|
||||||
|
border-bottom-color: #F5F5F5;
|
||||||
|
border-bottom-style: solid;
|
||||||
|
border-bottom-width: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-calendar__weeks-day-text {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #B2B2B2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-calendar__box {
|
||||||
|
position: relative;
|
||||||
|
// padding: 0 10px;
|
||||||
|
padding-bottom: 7px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-calendar__box-bg {
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
display: flex;
|
||||||
|
/* #endif */
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-calendar__box-bg-text {
|
||||||
|
font-size: 200px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #999;
|
||||||
|
opacity: 0.1;
|
||||||
|
text-align: center;
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
line-height: 1;
|
||||||
|
/* #endif */
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-date-changed {
|
||||||
|
padding: 0 10px;
|
||||||
|
// line-height: 50px;
|
||||||
|
text-align: center;
|
||||||
|
color: #333;
|
||||||
|
border-top-color: #DCDCDC;
|
||||||
|
;
|
||||||
|
border-top-style: solid;
|
||||||
|
border-top-width: 1px;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-date-btn--ok {
|
||||||
|
padding: 20px 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-date-changed--time-start {
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
display: flex;
|
||||||
|
/* #endif */
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-date-changed--time-end {
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
display: flex;
|
||||||
|
/* #endif */
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-date-changed--time-date {
|
||||||
|
color: #999;
|
||||||
|
line-height: 50px;
|
||||||
|
/* #ifdef MP-TOUTIAO */
|
||||||
|
font-size: 16px;
|
||||||
|
/* #endif */
|
||||||
|
margin-right: 5px;
|
||||||
|
// opacity: 0.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.time-picker-style {
|
||||||
|
// width: 62px;
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
display: flex;
|
||||||
|
/* #endif */
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center
|
||||||
|
}
|
||||||
|
|
||||||
|
.mr-10 {
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dialog-close {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
display: flex;
|
||||||
|
/* #endif */
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
padding: 0 25px;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dialog-close-plus {
|
||||||
|
width: 16px;
|
||||||
|
height: 2px;
|
||||||
|
background-color: #737987;
|
||||||
|
border-radius: 2px;
|
||||||
|
transform: rotate(45deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.dialog-close-rotate {
|
||||||
|
position: absolute;
|
||||||
|
transform: rotate(-45deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-datetime-picker--btn {
|
||||||
|
border-radius: 100px;
|
||||||
|
height: 40px;
|
||||||
|
line-height: 40px;
|
||||||
|
background-color: $uni-primary;
|
||||||
|
color: #fff;
|
||||||
|
font-size: 16px;
|
||||||
|
letter-spacing: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
.uni-datetime-picker--btn:active {
|
||||||
|
opacity: 0.7;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* #endif */
|
||||||
|
</style>
|
||||||
@@ -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": "確認"
|
||||||
|
}
|
||||||
@@ -0,0 +1,940 @@
|
|||||||
|
<template>
|
||||||
|
<view class="uni-datetime-picker">
|
||||||
|
<view @click="initTimePicker">
|
||||||
|
<slot>
|
||||||
|
<view class="uni-datetime-picker-timebox-pointer"
|
||||||
|
:class="{'uni-datetime-picker-disabled': disabled, 'uni-datetime-picker-timebox': border}">
|
||||||
|
<text class="uni-datetime-picker-text">{{time}}</text>
|
||||||
|
<view v-if="!time" class="uni-datetime-picker-time">
|
||||||
|
<text class="uni-datetime-picker-text">{{selectTimeText}}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</slot>
|
||||||
|
</view>
|
||||||
|
<view v-if="visible" id="mask" class="uni-datetime-picker-mask" @click="tiggerTimePicker"></view>
|
||||||
|
<view v-if="visible" class="uni-datetime-picker-popup" :class="[dateShow && timeShow ? '' : 'fix-nvue-height']"
|
||||||
|
:style="fixNvueBug">
|
||||||
|
<view class="uni-title">
|
||||||
|
<text class="uni-datetime-picker-text">{{selectTimeText}}</text>
|
||||||
|
</view>
|
||||||
|
<view v-if="dateShow" class="uni-datetime-picker__container-box">
|
||||||
|
<picker-view class="uni-datetime-picker-view" :indicator-style="indicatorStyle" :value="ymd"
|
||||||
|
@change="bindDateChange">
|
||||||
|
<picker-view-column>
|
||||||
|
<view class="uni-datetime-picker-item" v-for="(item,index) in years" :key="index">
|
||||||
|
<text class="uni-datetime-picker-item">{{lessThanTen(item)}}</text>
|
||||||
|
</view>
|
||||||
|
</picker-view-column>
|
||||||
|
<picker-view-column>
|
||||||
|
<view class="uni-datetime-picker-item" v-for="(item,index) in months" :key="index">
|
||||||
|
<text class="uni-datetime-picker-item">{{lessThanTen(item)}}</text>
|
||||||
|
</view>
|
||||||
|
</picker-view-column>
|
||||||
|
<picker-view-column>
|
||||||
|
<view class="uni-datetime-picker-item" v-for="(item,index) in days" :key="index">
|
||||||
|
<text class="uni-datetime-picker-item">{{lessThanTen(item)}}</text>
|
||||||
|
</view>
|
||||||
|
</picker-view-column>
|
||||||
|
</picker-view>
|
||||||
|
<!-- 兼容 nvue 不支持伪类 -->
|
||||||
|
<text class="uni-datetime-picker-sign sign-left">-</text>
|
||||||
|
<text class="uni-datetime-picker-sign sign-right">-</text>
|
||||||
|
</view>
|
||||||
|
<view v-if="timeShow" class="uni-datetime-picker__container-box">
|
||||||
|
<picker-view class="uni-datetime-picker-view" :class="[hideSecond ? 'time-hide-second' : '']"
|
||||||
|
:indicator-style="indicatorStyle" :value="hms" @change="bindTimeChange">
|
||||||
|
<picker-view-column>
|
||||||
|
<view class="uni-datetime-picker-item" v-for="(item,index) in hours" :key="index">
|
||||||
|
<text class="uni-datetime-picker-item">{{lessThanTen(item)}}</text>
|
||||||
|
</view>
|
||||||
|
</picker-view-column>
|
||||||
|
<picker-view-column>
|
||||||
|
<view class="uni-datetime-picker-item" v-for="(item,index) in minutes" :key="index">
|
||||||
|
<text class="uni-datetime-picker-item">{{lessThanTen(item)}}</text>
|
||||||
|
</view>
|
||||||
|
</picker-view-column>
|
||||||
|
<picker-view-column v-if="!hideSecond">
|
||||||
|
<view class="uni-datetime-picker-item" v-for="(item,index) in seconds" :key="index">
|
||||||
|
<text class="uni-datetime-picker-item">{{lessThanTen(item)}}</text>
|
||||||
|
</view>
|
||||||
|
</picker-view-column>
|
||||||
|
</picker-view>
|
||||||
|
<!-- 兼容 nvue 不支持伪类 -->
|
||||||
|
<text class="uni-datetime-picker-sign" :class="[hideSecond ? 'sign-center' : 'sign-left']">:</text>
|
||||||
|
<text v-if="!hideSecond" class="uni-datetime-picker-sign sign-right">:</text>
|
||||||
|
</view>
|
||||||
|
<view class="uni-datetime-picker-btn">
|
||||||
|
<view @click="clearTime">
|
||||||
|
<text class="uni-datetime-picker-btn-text">{{clearText}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="uni-datetime-picker-btn-group">
|
||||||
|
<view class="uni-datetime-picker-cancel" @click="tiggerTimePicker">
|
||||||
|
<text class="uni-datetime-picker-btn-text">{{cancelText}}</text>
|
||||||
|
</view>
|
||||||
|
<view @click="setTime">
|
||||||
|
<text class="uni-datetime-picker-btn-text">{{okText}}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
initVueI18n
|
||||||
|
} from '@dcloudio/uni-i18n'
|
||||||
|
import i18nMessages from './i18n/index.js'
|
||||||
|
const {
|
||||||
|
t
|
||||||
|
} = initVueI18n(i18nMessages)
|
||||||
|
import {
|
||||||
|
fixIosDateFormat
|
||||||
|
} from './util'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DatetimePicker 时间选择器
|
||||||
|
* @description 可以同时选择日期和时间的选择器
|
||||||
|
* @tutorial https://ext.dcloud.net.cn/plugin?id=xxx
|
||||||
|
* @property {String} type = [datetime | date | time] 显示模式
|
||||||
|
* @property {Boolean} multiple = [true|false] 是否多选
|
||||||
|
* @property {String|Number} value 默认值
|
||||||
|
* @property {String|Number} start 起始日期或时间
|
||||||
|
* @property {String|Number} end 起始日期或时间
|
||||||
|
* @property {String} return-type = [timestamp | string]
|
||||||
|
* @event {Function} change 选中发生变化触发
|
||||||
|
*/
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'UniDatetimePicker',
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
indicatorStyle: `height: 50px;`,
|
||||||
|
visible: false,
|
||||||
|
fixNvueBug: {},
|
||||||
|
dateShow: true,
|
||||||
|
timeShow: true,
|
||||||
|
title: '日期和时间',
|
||||||
|
// 输入框当前时间
|
||||||
|
time: '',
|
||||||
|
// 当前的年月日时分秒
|
||||||
|
year: 1920,
|
||||||
|
month: 0,
|
||||||
|
day: 0,
|
||||||
|
hour: 0,
|
||||||
|
minute: 0,
|
||||||
|
second: 0,
|
||||||
|
// 起始时间
|
||||||
|
startYear: 1920,
|
||||||
|
startMonth: 1,
|
||||||
|
startDay: 1,
|
||||||
|
startHour: 0,
|
||||||
|
startMinute: 0,
|
||||||
|
startSecond: 0,
|
||||||
|
// 结束时间
|
||||||
|
endYear: 2120,
|
||||||
|
endMonth: 12,
|
||||||
|
endDay: 31,
|
||||||
|
endHour: 23,
|
||||||
|
endMinute: 59,
|
||||||
|
endSecond: 59,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
// #ifdef MP-TOUTIAO
|
||||||
|
virtualHost: false,
|
||||||
|
// #endif
|
||||||
|
// #ifndef MP-TOUTIAO
|
||||||
|
virtualHost: true
|
||||||
|
// #endif
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
type: {
|
||||||
|
type: String,
|
||||||
|
default: 'datetime'
|
||||||
|
},
|
||||||
|
value: {
|
||||||
|
type: [String, Number],
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
modelValue: {
|
||||||
|
type: [String, Number],
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
start: {
|
||||||
|
type: [Number, String],
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
end: {
|
||||||
|
type: [Number, String],
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
returnType: {
|
||||||
|
type: String,
|
||||||
|
default: 'string'
|
||||||
|
},
|
||||||
|
disabled: {
|
||||||
|
type: [Boolean, String],
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
border: {
|
||||||
|
type: [Boolean, String],
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
hideSecond: {
|
||||||
|
type: [Boolean, String],
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
// #ifndef VUE3
|
||||||
|
value: {
|
||||||
|
handler(newVal) {
|
||||||
|
if (newVal) {
|
||||||
|
this.parseValue(fixIosDateFormat(newVal))
|
||||||
|
this.initTime(false)
|
||||||
|
} else {
|
||||||
|
this.time = ''
|
||||||
|
this.parseValue(Date.now())
|
||||||
|
}
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
|
},
|
||||||
|
// #endif
|
||||||
|
// #ifdef VUE3
|
||||||
|
modelValue: {
|
||||||
|
handler(newVal) {
|
||||||
|
if (newVal) {
|
||||||
|
this.parseValue(fixIosDateFormat(newVal))
|
||||||
|
this.initTime(false)
|
||||||
|
} else {
|
||||||
|
this.time = ''
|
||||||
|
this.parseValue(Date.now())
|
||||||
|
}
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
|
},
|
||||||
|
// #endif
|
||||||
|
type: {
|
||||||
|
handler(newValue) {
|
||||||
|
if (newValue === 'date') {
|
||||||
|
this.dateShow = true
|
||||||
|
this.timeShow = false
|
||||||
|
this.title = '日期'
|
||||||
|
} else if (newValue === 'time') {
|
||||||
|
this.dateShow = false
|
||||||
|
this.timeShow = true
|
||||||
|
this.title = '时间'
|
||||||
|
} else {
|
||||||
|
this.dateShow = true
|
||||||
|
this.timeShow = true
|
||||||
|
this.title = '日期和时间'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
|
},
|
||||||
|
start: {
|
||||||
|
handler(newVal) {
|
||||||
|
this.parseDatetimeRange(fixIosDateFormat(newVal), 'start')
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
|
},
|
||||||
|
end: {
|
||||||
|
handler(newVal) {
|
||||||
|
this.parseDatetimeRange(fixIosDateFormat(newVal), 'end')
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
|
},
|
||||||
|
|
||||||
|
// 月、日、时、分、秒可选范围变化后,检查当前值是否在范围内,不在则当前值重置为可选范围第一项
|
||||||
|
months(newVal) {
|
||||||
|
this.checkValue('month', this.month, newVal)
|
||||||
|
},
|
||||||
|
days(newVal) {
|
||||||
|
this.checkValue('day', this.day, newVal)
|
||||||
|
},
|
||||||
|
hours(newVal) {
|
||||||
|
this.checkValue('hour', this.hour, newVal)
|
||||||
|
},
|
||||||
|
minutes(newVal) {
|
||||||
|
this.checkValue('minute', this.minute, newVal)
|
||||||
|
},
|
||||||
|
seconds(newVal) {
|
||||||
|
this.checkValue('second', this.second, newVal)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
// 当前年、月、日、时、分、秒选择范围
|
||||||
|
years() {
|
||||||
|
return this.getCurrentRange('year')
|
||||||
|
},
|
||||||
|
|
||||||
|
months() {
|
||||||
|
return this.getCurrentRange('month')
|
||||||
|
},
|
||||||
|
|
||||||
|
days() {
|
||||||
|
return this.getCurrentRange('day')
|
||||||
|
},
|
||||||
|
|
||||||
|
hours() {
|
||||||
|
return this.getCurrentRange('hour')
|
||||||
|
},
|
||||||
|
|
||||||
|
minutes() {
|
||||||
|
return this.getCurrentRange('minute')
|
||||||
|
},
|
||||||
|
|
||||||
|
seconds() {
|
||||||
|
return this.getCurrentRange('second')
|
||||||
|
},
|
||||||
|
|
||||||
|
// picker 当前值数组
|
||||||
|
ymd() {
|
||||||
|
return [this.year - this.minYear, this.month - this.minMonth, this.day - this.minDay]
|
||||||
|
},
|
||||||
|
hms() {
|
||||||
|
return [this.hour - this.minHour, this.minute - this.minMinute, this.second - this.minSecond]
|
||||||
|
},
|
||||||
|
|
||||||
|
// 当前 date 是 start
|
||||||
|
currentDateIsStart() {
|
||||||
|
return this.year === this.startYear && this.month === this.startMonth && this.day === this.startDay
|
||||||
|
},
|
||||||
|
|
||||||
|
// 当前 date 是 end
|
||||||
|
currentDateIsEnd() {
|
||||||
|
return this.year === this.endYear && this.month === this.endMonth && this.day === this.endDay
|
||||||
|
},
|
||||||
|
|
||||||
|
// 当前年、月、日、时、分、秒的最小值和最大值
|
||||||
|
minYear() {
|
||||||
|
return this.startYear
|
||||||
|
},
|
||||||
|
maxYear() {
|
||||||
|
return this.endYear
|
||||||
|
},
|
||||||
|
minMonth() {
|
||||||
|
if (this.year === this.startYear) {
|
||||||
|
return this.startMonth
|
||||||
|
} else {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
maxMonth() {
|
||||||
|
if (this.year === this.endYear) {
|
||||||
|
return this.endMonth
|
||||||
|
} else {
|
||||||
|
return 12
|
||||||
|
}
|
||||||
|
},
|
||||||
|
minDay() {
|
||||||
|
if (this.year === this.startYear && this.month === this.startMonth) {
|
||||||
|
return this.startDay
|
||||||
|
} else {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
maxDay() {
|
||||||
|
if (this.year === this.endYear && this.month === this.endMonth) {
|
||||||
|
return this.endDay
|
||||||
|
} else {
|
||||||
|
return this.daysInMonth(this.year, this.month)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
minHour() {
|
||||||
|
if (this.type === 'datetime') {
|
||||||
|
if (this.currentDateIsStart) {
|
||||||
|
return this.startHour
|
||||||
|
} else {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.type === 'time') {
|
||||||
|
return this.startHour
|
||||||
|
}
|
||||||
|
},
|
||||||
|
maxHour() {
|
||||||
|
if (this.type === 'datetime') {
|
||||||
|
if (this.currentDateIsEnd) {
|
||||||
|
return this.endHour
|
||||||
|
} else {
|
||||||
|
return 23
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.type === 'time') {
|
||||||
|
return this.endHour
|
||||||
|
}
|
||||||
|
},
|
||||||
|
minMinute() {
|
||||||
|
if (this.type === 'datetime') {
|
||||||
|
if (this.currentDateIsStart && this.hour === this.startHour) {
|
||||||
|
return this.startMinute
|
||||||
|
} else {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.type === 'time') {
|
||||||
|
if (this.hour === this.startHour) {
|
||||||
|
return this.startMinute
|
||||||
|
} else {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
maxMinute() {
|
||||||
|
if (this.type === 'datetime') {
|
||||||
|
if (this.currentDateIsEnd && this.hour === this.endHour) {
|
||||||
|
return this.endMinute
|
||||||
|
} else {
|
||||||
|
return 59
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.type === 'time') {
|
||||||
|
if (this.hour === this.endHour) {
|
||||||
|
return this.endMinute
|
||||||
|
} else {
|
||||||
|
return 59
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
minSecond() {
|
||||||
|
if (this.type === 'datetime') {
|
||||||
|
if (this.currentDateIsStart && this.hour === this.startHour && this.minute === this.startMinute) {
|
||||||
|
return this.startSecond
|
||||||
|
} else {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.type === 'time') {
|
||||||
|
if (this.hour === this.startHour && this.minute === this.startMinute) {
|
||||||
|
return this.startSecond
|
||||||
|
} else {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
maxSecond() {
|
||||||
|
if (this.type === 'datetime') {
|
||||||
|
if (this.currentDateIsEnd && this.hour === this.endHour && this.minute === this.endMinute) {
|
||||||
|
return this.endSecond
|
||||||
|
} else {
|
||||||
|
return 59
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.type === 'time') {
|
||||||
|
if (this.hour === this.endHour && this.minute === this.endMinute) {
|
||||||
|
return this.endSecond
|
||||||
|
} else {
|
||||||
|
return 59
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* for i18n
|
||||||
|
*/
|
||||||
|
selectTimeText() {
|
||||||
|
return t("uni-datetime-picker.selectTime")
|
||||||
|
},
|
||||||
|
okText() {
|
||||||
|
return t("uni-datetime-picker.ok")
|
||||||
|
},
|
||||||
|
clearText() {
|
||||||
|
return t("uni-datetime-picker.clear")
|
||||||
|
},
|
||||||
|
cancelText() {
|
||||||
|
return t("uni-datetime-picker.cancel")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
mounted() {
|
||||||
|
// #ifdef APP-NVUE
|
||||||
|
const res = uni.getSystemInfoSync();
|
||||||
|
this.fixNvueBug = {
|
||||||
|
top: res.windowHeight / 2,
|
||||||
|
left: res.windowWidth / 2
|
||||||
|
}
|
||||||
|
// #endif
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
/**
|
||||||
|
* @param {Object} item
|
||||||
|
* 小于 10 在前面加个 0
|
||||||
|
*/
|
||||||
|
|
||||||
|
lessThanTen(item) {
|
||||||
|
return item < 10 ? '0' + item : item
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析时分秒字符串,例如:00:00:00
|
||||||
|
* @param {String} timeString
|
||||||
|
*/
|
||||||
|
parseTimeType(timeString) {
|
||||||
|
if (timeString) {
|
||||||
|
let timeArr = timeString.split(':')
|
||||||
|
this.hour = Number(timeArr[0])
|
||||||
|
this.minute = Number(timeArr[1])
|
||||||
|
this.second = Number(timeArr[2])
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析选择器初始值,类型可以是字符串、时间戳,例如:2000-10-02、'08:30:00'、 1610695109000
|
||||||
|
* @param {String | Number} datetime
|
||||||
|
*/
|
||||||
|
initPickerValue(datetime) {
|
||||||
|
let defaultValue = null
|
||||||
|
if (datetime) {
|
||||||
|
defaultValue = this.compareValueWithStartAndEnd(datetime, this.start, this.end)
|
||||||
|
} else {
|
||||||
|
defaultValue = Date.now()
|
||||||
|
defaultValue = this.compareValueWithStartAndEnd(defaultValue, this.start, this.end)
|
||||||
|
}
|
||||||
|
this.parseValue(defaultValue)
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始值规则:
|
||||||
|
* - 用户设置初始值 value
|
||||||
|
* - 设置了起始时间 start、终止时间 end,并 start < value < end,初始值为 value, 否则初始值为 start
|
||||||
|
* - 只设置了起始时间 start,并 start < value,初始值为 value,否则初始值为 start
|
||||||
|
* - 只设置了终止时间 end,并 value < end,初始值为 value,否则初始值为 end
|
||||||
|
* - 无起始终止时间,则初始值为 value
|
||||||
|
* - 无初始值 value,则初始值为当前本地时间 Date.now()
|
||||||
|
* @param {Object} value
|
||||||
|
* @param {Object} dateBase
|
||||||
|
*/
|
||||||
|
compareValueWithStartAndEnd(value, start, end) {
|
||||||
|
let winner = null
|
||||||
|
value = this.superTimeStamp(value)
|
||||||
|
start = this.superTimeStamp(start)
|
||||||
|
end = this.superTimeStamp(end)
|
||||||
|
|
||||||
|
if (start && end) {
|
||||||
|
if (value < start) {
|
||||||
|
winner = new Date(start)
|
||||||
|
} else if (value > end) {
|
||||||
|
winner = new Date(end)
|
||||||
|
} else {
|
||||||
|
winner = new Date(value)
|
||||||
|
}
|
||||||
|
} else if (start && !end) {
|
||||||
|
winner = start <= value ? new Date(value) : new Date(start)
|
||||||
|
} else if (!start && end) {
|
||||||
|
winner = value <= end ? new Date(value) : new Date(end)
|
||||||
|
} else {
|
||||||
|
winner = new Date(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
return winner
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转换为可比较的时间戳,接受日期、时分秒、时间戳
|
||||||
|
* @param {Object} value
|
||||||
|
*/
|
||||||
|
superTimeStamp(value) {
|
||||||
|
let dateBase = ''
|
||||||
|
if (this.type === 'time' && value && typeof value === 'string') {
|
||||||
|
const now = new Date()
|
||||||
|
const year = now.getFullYear()
|
||||||
|
const month = now.getMonth() + 1
|
||||||
|
const day = now.getDate()
|
||||||
|
dateBase = year + '/' + month + '/' + day + ' '
|
||||||
|
}
|
||||||
|
if (Number(value)) {
|
||||||
|
value = parseInt(value)
|
||||||
|
dateBase = 0
|
||||||
|
}
|
||||||
|
return this.createTimeStamp(dateBase + value)
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析默认值 value,字符串、时间戳
|
||||||
|
* @param {Object} defaultTime
|
||||||
|
*/
|
||||||
|
parseValue(value) {
|
||||||
|
if (!value) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (this.type === 'time' && typeof value === "string") {
|
||||||
|
this.parseTimeType(value)
|
||||||
|
} else {
|
||||||
|
let defaultDate = null
|
||||||
|
defaultDate = new Date(value)
|
||||||
|
if (this.type !== 'time') {
|
||||||
|
this.year = defaultDate.getFullYear()
|
||||||
|
this.month = defaultDate.getMonth() + 1
|
||||||
|
this.day = defaultDate.getDate()
|
||||||
|
}
|
||||||
|
if (this.type !== 'date') {
|
||||||
|
this.hour = defaultDate.getHours()
|
||||||
|
this.minute = defaultDate.getMinutes()
|
||||||
|
this.second = defaultDate.getSeconds()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.hideSecond) {
|
||||||
|
this.second = 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析可选择时间范围 start、end,年月日字符串、时间戳
|
||||||
|
* @param {Object} defaultTime
|
||||||
|
*/
|
||||||
|
parseDatetimeRange(point, pointType) {
|
||||||
|
// 时间为空,则重置为初始值
|
||||||
|
if (!point) {
|
||||||
|
if (pointType === 'start') {
|
||||||
|
this.startYear = 1920
|
||||||
|
this.startMonth = 1
|
||||||
|
this.startDay = 1
|
||||||
|
this.startHour = 0
|
||||||
|
this.startMinute = 0
|
||||||
|
this.startSecond = 0
|
||||||
|
}
|
||||||
|
if (pointType === 'end') {
|
||||||
|
this.endYear = 2120
|
||||||
|
this.endMonth = 12
|
||||||
|
this.endDay = 31
|
||||||
|
this.endHour = 23
|
||||||
|
this.endMinute = 59
|
||||||
|
this.endSecond = 59
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (this.type === 'time') {
|
||||||
|
const pointArr = point.split(':')
|
||||||
|
this[pointType + 'Hour'] = Number(pointArr[0])
|
||||||
|
this[pointType + 'Minute'] = Number(pointArr[1])
|
||||||
|
this[pointType + 'Second'] = Number(pointArr[2])
|
||||||
|
} else {
|
||||||
|
if (!point) {
|
||||||
|
pointType === 'start' ? this.startYear = this.year - 60 : this.endYear = this.year + 60
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (Number(point)) {
|
||||||
|
point = parseInt(point)
|
||||||
|
}
|
||||||
|
// datetime 的 end 没有时分秒, 则不限制
|
||||||
|
const hasTime = /[0-9]:[0-9]/
|
||||||
|
if (this.type === 'datetime' && pointType === 'end' && typeof point === 'string' && !hasTime.test(
|
||||||
|
point)) {
|
||||||
|
point = point + ' 23:59:59'
|
||||||
|
}
|
||||||
|
const pointDate = new Date(point)
|
||||||
|
this[pointType + 'Year'] = pointDate.getFullYear()
|
||||||
|
this[pointType + 'Month'] = pointDate.getMonth() + 1
|
||||||
|
this[pointType + 'Day'] = pointDate.getDate()
|
||||||
|
if (this.type === 'datetime') {
|
||||||
|
this[pointType + 'Hour'] = pointDate.getHours()
|
||||||
|
this[pointType + 'Minute'] = pointDate.getMinutes()
|
||||||
|
this[pointType + 'Second'] = pointDate.getSeconds()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 获取 年、月、日、时、分、秒 当前可选范围
|
||||||
|
getCurrentRange(value) {
|
||||||
|
const range = []
|
||||||
|
for (let i = this['min' + this.capitalize(value)]; i <= this['max' + this.capitalize(value)]; i++) {
|
||||||
|
range.push(i)
|
||||||
|
}
|
||||||
|
return range
|
||||||
|
},
|
||||||
|
|
||||||
|
// 字符串首字母大写
|
||||||
|
capitalize(str) {
|
||||||
|
return str.charAt(0).toUpperCase() + str.slice(1)
|
||||||
|
},
|
||||||
|
|
||||||
|
// 检查当前值是否在范围内,不在则当前值重置为可选范围第一项
|
||||||
|
checkValue(name, value, values) {
|
||||||
|
if (values.indexOf(value) === -1) {
|
||||||
|
this[name] = values[0]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 每个月的实际天数
|
||||||
|
daysInMonth(year, month) { // Use 1 for January, 2 for February, etc.
|
||||||
|
return new Date(year, month, 0).getDate();
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成时间戳
|
||||||
|
* @param {Object} time
|
||||||
|
*/
|
||||||
|
createTimeStamp(time) {
|
||||||
|
if (!time) return
|
||||||
|
if (typeof time === "number") {
|
||||||
|
return time
|
||||||
|
} else {
|
||||||
|
time = time.replace(/-/g, '/')
|
||||||
|
if (this.type === 'date') {
|
||||||
|
time = time + ' ' + '00:00:00'
|
||||||
|
}
|
||||||
|
return Date.parse(time)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成日期或时间的字符串
|
||||||
|
*/
|
||||||
|
createDomSting() {
|
||||||
|
const yymmdd = this.year +
|
||||||
|
'-' +
|
||||||
|
this.lessThanTen(this.month) +
|
||||||
|
'-' +
|
||||||
|
this.lessThanTen(this.day)
|
||||||
|
|
||||||
|
let hhmmss = this.lessThanTen(this.hour) +
|
||||||
|
':' +
|
||||||
|
this.lessThanTen(this.minute)
|
||||||
|
|
||||||
|
if (!this.hideSecond) {
|
||||||
|
hhmmss = hhmmss + ':' + this.lessThanTen(this.second)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.type === 'date') {
|
||||||
|
return yymmdd
|
||||||
|
} else if (this.type === 'time') {
|
||||||
|
return hhmmss
|
||||||
|
} else {
|
||||||
|
return yymmdd + ' ' + hhmmss
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化返回值,并抛出 change 事件
|
||||||
|
*/
|
||||||
|
initTime(emit = true) {
|
||||||
|
this.time = this.createDomSting()
|
||||||
|
if (!emit) return
|
||||||
|
if (this.returnType === 'timestamp' && this.type !== 'time') {
|
||||||
|
this.$emit('change', this.createTimeStamp(this.time))
|
||||||
|
this.$emit('input', this.createTimeStamp(this.time))
|
||||||
|
this.$emit('update:modelValue', this.createTimeStamp(this.time))
|
||||||
|
} else {
|
||||||
|
this.$emit('change', this.time)
|
||||||
|
this.$emit('input', this.time)
|
||||||
|
this.$emit('update:modelValue', this.time)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户选择日期或时间更新 data
|
||||||
|
* @param {Object} e
|
||||||
|
*/
|
||||||
|
bindDateChange(e) {
|
||||||
|
const val = e.detail.value
|
||||||
|
this.year = this.years[val[0]]
|
||||||
|
this.month = this.months[val[1]]
|
||||||
|
this.day = this.days[val[2]]
|
||||||
|
},
|
||||||
|
bindTimeChange(e) {
|
||||||
|
const val = e.detail.value
|
||||||
|
this.hour = this.hours[val[0]]
|
||||||
|
this.minute = this.minutes[val[1]]
|
||||||
|
this.second = this.seconds[val[2]]
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化弹出层
|
||||||
|
*/
|
||||||
|
initTimePicker() {
|
||||||
|
if (this.disabled) return
|
||||||
|
const value = fixIosDateFormat(this.time)
|
||||||
|
this.initPickerValue(value)
|
||||||
|
this.visible = !this.visible
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 触发或关闭弹框
|
||||||
|
*/
|
||||||
|
tiggerTimePicker(e) {
|
||||||
|
this.visible = !this.visible
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户点击“清空”按钮,清空当前值
|
||||||
|
*/
|
||||||
|
clearTime() {
|
||||||
|
this.time = ''
|
||||||
|
this.$emit('change', this.time)
|
||||||
|
this.$emit('input', this.time)
|
||||||
|
this.$emit('update:modelValue', this.time)
|
||||||
|
this.tiggerTimePicker()
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户点击“确定”按钮
|
||||||
|
*/
|
||||||
|
setTime() {
|
||||||
|
this.initTime()
|
||||||
|
this.tiggerTimePicker()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
$uni-primary: #007aff !default;
|
||||||
|
|
||||||
|
.uni-datetime-picker {
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
/* width: 100%; */
|
||||||
|
/* #endif */
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-datetime-picker-view {
|
||||||
|
height: 130px;
|
||||||
|
width: 270px;
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
cursor: pointer;
|
||||||
|
/* #endif */
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-datetime-picker-item {
|
||||||
|
height: 50px;
|
||||||
|
line-height: 50px;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-datetime-picker-btn {
|
||||||
|
margin-top: 60px;
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
display: flex;
|
||||||
|
cursor: pointer;
|
||||||
|
/* #endif */
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-datetime-picker-btn-text {
|
||||||
|
font-size: 14px;
|
||||||
|
color: $uni-primary;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-datetime-picker-btn-group {
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
display: flex;
|
||||||
|
/* #endif */
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-datetime-picker-cancel {
|
||||||
|
margin-right: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-datetime-picker-mask {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0px;
|
||||||
|
top: 0px;
|
||||||
|
left: 0px;
|
||||||
|
right: 0px;
|
||||||
|
background-color: rgba(0, 0, 0, 0.4);
|
||||||
|
transition-duration: 0.3s;
|
||||||
|
z-index: 998;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-datetime-picker-popup {
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 30px;
|
||||||
|
width: 270px;
|
||||||
|
/* #ifdef APP-NVUE */
|
||||||
|
height: 500px;
|
||||||
|
/* #endif */
|
||||||
|
/* #ifdef APP-NVUE */
|
||||||
|
width: 330px;
|
||||||
|
/* #endif */
|
||||||
|
background-color: #fff;
|
||||||
|
position: fixed;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
transition-duration: 0.3s;
|
||||||
|
z-index: 999;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fix-nvue-height {
|
||||||
|
/* #ifdef APP-NVUE */
|
||||||
|
height: 330px;
|
||||||
|
/* #endif */
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-datetime-picker-time {
|
||||||
|
color: grey;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-datetime-picker-column {
|
||||||
|
height: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-datetime-picker-timebox {
|
||||||
|
|
||||||
|
border: 1px solid #E5E5E5;
|
||||||
|
border-radius: 5px;
|
||||||
|
padding: 7px 10px;
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
box-sizing: border-box;
|
||||||
|
cursor: pointer;
|
||||||
|
/* #endif */
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-datetime-picker-timebox-pointer {
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
cursor: pointer;
|
||||||
|
/* #endif */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.uni-datetime-picker-disabled {
|
||||||
|
opacity: 0.4;
|
||||||
|
/* #ifdef H5 */
|
||||||
|
cursor: not-allowed !important;
|
||||||
|
/* #endif */
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-datetime-picker-text {
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 50px
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-datetime-picker-sign {
|
||||||
|
position: absolute;
|
||||||
|
top: 53px;
|
||||||
|
/* 减掉 10px 的元素高度,兼容nvue */
|
||||||
|
color: #999;
|
||||||
|
/* #ifdef APP-NVUE */
|
||||||
|
font-size: 16px;
|
||||||
|
/* #endif */
|
||||||
|
}
|
||||||
|
|
||||||
|
.sign-left {
|
||||||
|
left: 86px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sign-right {
|
||||||
|
right: 86px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sign-center {
|
||||||
|
left: 135px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-datetime-picker__container-box {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin-top: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.time-hide-second {
|
||||||
|
width: 180px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,421 @@
|
|||||||
|
class Calendar {
|
||||||
|
constructor({
|
||||||
|
selected,
|
||||||
|
startDate,
|
||||||
|
endDate,
|
||||||
|
range,
|
||||||
|
} = {}) {
|
||||||
|
// 当前日期
|
||||||
|
this.date = this.getDateObj(new Date()) // 当前初入日期
|
||||||
|
// 打点信息
|
||||||
|
this.selected = selected || [];
|
||||||
|
// 起始时间
|
||||||
|
this.startDate = startDate
|
||||||
|
// 终止时间
|
||||||
|
this.endDate = endDate
|
||||||
|
// 是否范围选择
|
||||||
|
this.range = range
|
||||||
|
// 多选状态
|
||||||
|
this.cleanMultipleStatus()
|
||||||
|
// 每周日期
|
||||||
|
this.weeks = {}
|
||||||
|
this.lastHover = false
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 设置日期
|
||||||
|
* @param {Object} date
|
||||||
|
*/
|
||||||
|
setDate(date) {
|
||||||
|
const selectDate = this.getDateObj(date)
|
||||||
|
this.getWeeks(selectDate.fullDate)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清理多选状态
|
||||||
|
*/
|
||||||
|
cleanMultipleStatus() {
|
||||||
|
this.multipleStatus = {
|
||||||
|
before: '',
|
||||||
|
after: '',
|
||||||
|
data: []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setStartDate(startDate) {
|
||||||
|
this.startDate = startDate
|
||||||
|
}
|
||||||
|
|
||||||
|
setEndDate(endDate) {
|
||||||
|
this.endDate = endDate
|
||||||
|
}
|
||||||
|
|
||||||
|
getPreMonthObj(date) {
|
||||||
|
date = fixIosDateFormat(date)
|
||||||
|
date = new Date(date)
|
||||||
|
|
||||||
|
const oldMonth = date.getMonth()
|
||||||
|
date.setMonth(oldMonth - 1)
|
||||||
|
const newMonth = date.getMonth()
|
||||||
|
if (oldMonth !== 0 && newMonth - oldMonth === 0) {
|
||||||
|
date.setMonth(newMonth - 1)
|
||||||
|
}
|
||||||
|
return this.getDateObj(date)
|
||||||
|
}
|
||||||
|
getNextMonthObj(date) {
|
||||||
|
date = fixIosDateFormat(date)
|
||||||
|
date = new Date(date)
|
||||||
|
|
||||||
|
const oldMonth = date.getMonth()
|
||||||
|
date.setMonth(oldMonth + 1)
|
||||||
|
const newMonth = date.getMonth()
|
||||||
|
if (newMonth - oldMonth > 1) {
|
||||||
|
date.setMonth(newMonth - 1)
|
||||||
|
}
|
||||||
|
return this.getDateObj(date)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定格式Date对象
|
||||||
|
*/
|
||||||
|
getDateObj(date) {
|
||||||
|
date = fixIosDateFormat(date)
|
||||||
|
date = new Date(date)
|
||||||
|
|
||||||
|
return {
|
||||||
|
fullDate: getDate(date),
|
||||||
|
year: date.getFullYear(),
|
||||||
|
month: addZero(date.getMonth() + 1),
|
||||||
|
date: addZero(date.getDate()),
|
||||||
|
day: date.getDay()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取上一个月日期集合
|
||||||
|
*/
|
||||||
|
getPreMonthDays(amount, dateObj) {
|
||||||
|
const result = []
|
||||||
|
for (let i = amount - 1; i >= 0; i--) {
|
||||||
|
const month = dateObj.month - 1
|
||||||
|
result.push({
|
||||||
|
date: new Date(dateObj.year, month, -i).getDate(),
|
||||||
|
month,
|
||||||
|
disable: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取本月日期集合
|
||||||
|
*/
|
||||||
|
getCurrentMonthDays(amount, dateObj) {
|
||||||
|
const result = []
|
||||||
|
const fullDate = this.date.fullDate
|
||||||
|
for (let i = 1; i <= amount; i++) {
|
||||||
|
const currentDate = `${dateObj.year}-${dateObj.month}-${addZero(i)}`
|
||||||
|
const isToday = fullDate === currentDate
|
||||||
|
// 获取打点信息
|
||||||
|
const info = this.selected && this.selected.find((item) => {
|
||||||
|
if (this.dateEqual(currentDate, item.date)) {
|
||||||
|
return item
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// 日期禁用
|
||||||
|
let disableBefore = true
|
||||||
|
let disableAfter = true
|
||||||
|
if (this.startDate) {
|
||||||
|
disableBefore = dateCompare(this.startDate, currentDate)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.endDate) {
|
||||||
|
disableAfter = dateCompare(currentDate, this.endDate)
|
||||||
|
}
|
||||||
|
|
||||||
|
let multiples = this.multipleStatus.data
|
||||||
|
let multiplesStatus = -1
|
||||||
|
if (this.range && multiples) {
|
||||||
|
multiplesStatus = multiples.findIndex((item) => {
|
||||||
|
return this.dateEqual(item, currentDate)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const checked = multiplesStatus !== -1
|
||||||
|
|
||||||
|
result.push({
|
||||||
|
fullDate: currentDate,
|
||||||
|
year: dateObj.year,
|
||||||
|
date: i,
|
||||||
|
multiple: this.range ? checked : false,
|
||||||
|
beforeMultiple: this.isLogicBefore(currentDate, this.multipleStatus.before, this.multipleStatus.after),
|
||||||
|
afterMultiple: this.isLogicAfter(currentDate, this.multipleStatus.before, this.multipleStatus.after),
|
||||||
|
month: dateObj.month,
|
||||||
|
disable: (this.startDate && !dateCompare(this.startDate, currentDate)) || (this.endDate && !dateCompare(
|
||||||
|
currentDate, this.endDate)),
|
||||||
|
isToday,
|
||||||
|
userChecked: false,
|
||||||
|
extraInfo: info
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取下一个月日期集合
|
||||||
|
*/
|
||||||
|
_getNextMonthDays(amount, dateObj) {
|
||||||
|
const result = []
|
||||||
|
const month = dateObj.month + 1
|
||||||
|
for (let i = 1; i <= amount; i++) {
|
||||||
|
result.push({
|
||||||
|
date: i,
|
||||||
|
month,
|
||||||
|
disable: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前日期详情
|
||||||
|
* @param {Object} date
|
||||||
|
*/
|
||||||
|
getInfo(date) {
|
||||||
|
if (!date) {
|
||||||
|
date = new Date()
|
||||||
|
}
|
||||||
|
const res = this.calendar.find(item => item.fullDate === this.getDateObj(date).fullDate)
|
||||||
|
return res ? res : this.getDateObj(date)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 比较时间是否相等
|
||||||
|
*/
|
||||||
|
dateEqual(before, after) {
|
||||||
|
before = new Date(fixIosDateFormat(before))
|
||||||
|
after = new Date(fixIosDateFormat(after))
|
||||||
|
return before.valueOf() === after.valueOf()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 比较真实起始日期
|
||||||
|
*/
|
||||||
|
|
||||||
|
isLogicBefore(currentDate, before, after) {
|
||||||
|
let logicBefore = before
|
||||||
|
if (before && after) {
|
||||||
|
logicBefore = dateCompare(before, after) ? before : after
|
||||||
|
}
|
||||||
|
return this.dateEqual(logicBefore, currentDate)
|
||||||
|
}
|
||||||
|
|
||||||
|
isLogicAfter(currentDate, before, after) {
|
||||||
|
let logicAfter = after
|
||||||
|
if (before && after) {
|
||||||
|
logicAfter = dateCompare(before, after) ? after : before
|
||||||
|
}
|
||||||
|
return this.dateEqual(logicAfter, currentDate)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取日期范围内所有日期
|
||||||
|
* @param {Object} begin
|
||||||
|
* @param {Object} end
|
||||||
|
*/
|
||||||
|
geDateAll(begin, end) {
|
||||||
|
var arr = []
|
||||||
|
var ab = begin.split('-')
|
||||||
|
var ae = end.split('-')
|
||||||
|
var db = new Date()
|
||||||
|
db.setFullYear(ab[0], ab[1] - 1, ab[2])
|
||||||
|
var de = new Date()
|
||||||
|
de.setFullYear(ae[0], ae[1] - 1, ae[2])
|
||||||
|
var unixDb = db.getTime() - 24 * 60 * 60 * 1000
|
||||||
|
var unixDe = de.getTime() - 24 * 60 * 60 * 1000
|
||||||
|
for (var k = unixDb; k <= unixDe;) {
|
||||||
|
k = k + 24 * 60 * 60 * 1000
|
||||||
|
arr.push(this.getDateObj(new Date(parseInt(k))).fullDate)
|
||||||
|
}
|
||||||
|
return arr
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取多选状态
|
||||||
|
*/
|
||||||
|
setMultiple(fullDate) {
|
||||||
|
if (!this.range) return
|
||||||
|
|
||||||
|
let {
|
||||||
|
before,
|
||||||
|
after
|
||||||
|
} = this.multipleStatus
|
||||||
|
if (before && after) {
|
||||||
|
if (!this.lastHover) {
|
||||||
|
this.lastHover = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.multipleStatus.before = fullDate
|
||||||
|
this.multipleStatus.after = ''
|
||||||
|
this.multipleStatus.data = []
|
||||||
|
this.multipleStatus.fulldate = ''
|
||||||
|
this.lastHover = false
|
||||||
|
} else {
|
||||||
|
if (!before) {
|
||||||
|
this.multipleStatus.before = fullDate
|
||||||
|
this.multipleStatus.after = undefined;
|
||||||
|
this.lastHover = false
|
||||||
|
} else {
|
||||||
|
this.multipleStatus.after = fullDate
|
||||||
|
if (dateCompare(this.multipleStatus.before, this.multipleStatus.after)) {
|
||||||
|
this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus
|
||||||
|
.after);
|
||||||
|
} else {
|
||||||
|
this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus
|
||||||
|
.before);
|
||||||
|
}
|
||||||
|
this.lastHover = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.getWeeks(fullDate)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 鼠标 hover 更新多选状态
|
||||||
|
*/
|
||||||
|
setHoverMultiple(fullDate) {
|
||||||
|
//抖音小程序点击会触发hover事件,需要避免一下
|
||||||
|
// #ifndef MP-TOUTIAO
|
||||||
|
if (!this.range || this.lastHover) return
|
||||||
|
const {
|
||||||
|
before
|
||||||
|
} = this.multipleStatus
|
||||||
|
|
||||||
|
if (!before) {
|
||||||
|
this.multipleStatus.before = fullDate
|
||||||
|
} else {
|
||||||
|
this.multipleStatus.after = fullDate
|
||||||
|
if (dateCompare(this.multipleStatus.before, this.multipleStatus.after)) {
|
||||||
|
this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus.after);
|
||||||
|
} else {
|
||||||
|
this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus.before);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.getWeeks(fullDate)
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新默认值多选状态
|
||||||
|
*/
|
||||||
|
setDefaultMultiple(before, after) {
|
||||||
|
this.multipleStatus.before = before
|
||||||
|
this.multipleStatus.after = after
|
||||||
|
if (before && after) {
|
||||||
|
if (dateCompare(before, after)) {
|
||||||
|
this.multipleStatus.data = this.geDateAll(before, after);
|
||||||
|
this.getWeeks(after)
|
||||||
|
} else {
|
||||||
|
this.multipleStatus.data = this.geDateAll(after, before);
|
||||||
|
this.getWeeks(before)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取每周数据
|
||||||
|
* @param {Object} dateData
|
||||||
|
*/
|
||||||
|
getWeeks(dateData) {
|
||||||
|
const {
|
||||||
|
year,
|
||||||
|
month,
|
||||||
|
} = this.getDateObj(dateData)
|
||||||
|
|
||||||
|
const preMonthDayAmount = new Date(year, month - 1, 1).getDay()
|
||||||
|
const preMonthDays = this.getPreMonthDays(preMonthDayAmount, this.getDateObj(dateData))
|
||||||
|
|
||||||
|
const currentMonthDayAmount = new Date(year, month, 0).getDate()
|
||||||
|
const currentMonthDays = this.getCurrentMonthDays(currentMonthDayAmount, this.getDateObj(dateData))
|
||||||
|
|
||||||
|
const nextMonthDayAmount = 42 - preMonthDayAmount - currentMonthDayAmount
|
||||||
|
const nextMonthDays = this._getNextMonthDays(nextMonthDayAmount, this.getDateObj(dateData))
|
||||||
|
|
||||||
|
const calendarDays = [...preMonthDays, ...currentMonthDays, ...nextMonthDays]
|
||||||
|
|
||||||
|
const weeks = new Array(6)
|
||||||
|
for (let i = 0; i < calendarDays.length; i++) {
|
||||||
|
const index = Math.floor(i / 7)
|
||||||
|
if (!weeks[index]) {
|
||||||
|
weeks[index] = new Array(7)
|
||||||
|
}
|
||||||
|
weeks[index][i % 7] = calendarDays[i]
|
||||||
|
}
|
||||||
|
|
||||||
|
this.calendar = calendarDays
|
||||||
|
this.weeks = weeks
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDateTime(date, hideSecond) {
|
||||||
|
return `${getDate(date)} ${getTime(date, hideSecond)}`
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDate(date) {
|
||||||
|
date = fixIosDateFormat(date)
|
||||||
|
date = new Date(date)
|
||||||
|
const year = date.getFullYear()
|
||||||
|
const month = date.getMonth() + 1
|
||||||
|
const day = date.getDate()
|
||||||
|
return `${year}-${addZero(month)}-${addZero(day)}`
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTime(date, hideSecond) {
|
||||||
|
date = fixIosDateFormat(date)
|
||||||
|
date = new Date(date)
|
||||||
|
const hour = date.getHours()
|
||||||
|
const minute = date.getMinutes()
|
||||||
|
const second = date.getSeconds()
|
||||||
|
return hideSecond ? `${addZero(hour)}:${addZero(minute)}` : `${addZero(hour)}:${addZero(minute)}:${addZero(second)}`
|
||||||
|
}
|
||||||
|
|
||||||
|
function addZero(num) {
|
||||||
|
if (num < 10) {
|
||||||
|
num = `0${num}`
|
||||||
|
}
|
||||||
|
return num
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDefaultSecond(hideSecond) {
|
||||||
|
return hideSecond ? '00:00' : '00:00:00'
|
||||||
|
}
|
||||||
|
|
||||||
|
function dateCompare(startDate, endDate) {
|
||||||
|
startDate = new Date(fixIosDateFormat(startDate))
|
||||||
|
endDate = new Date(fixIosDateFormat(endDate))
|
||||||
|
return startDate <= endDate
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkDate(date) {
|
||||||
|
const dateReg = /((19|20)\d{2})(-|\/)\d{1,2}(-|\/)\d{1,2}/g
|
||||||
|
return date.match(dateReg)
|
||||||
|
}
|
||||||
|
//ios低版本15及以下,无法匹配 没有 ’秒‘ 时的情况,所以需要在末尾 秒 加上 问号
|
||||||
|
const dateTimeReg = /^\d{4}-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01])( [0-5]?[0-9]:[0-5]?[0-9](:[0-5]?[0-9])?)?$/;
|
||||||
|
|
||||||
|
function fixIosDateFormat(value) {
|
||||||
|
if (typeof value === 'string' && dateTimeReg.test(value)) {
|
||||||
|
value = value.replace(/-/g, '/')
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
Calendar,
|
||||||
|
getDateTime,
|
||||||
|
getDate,
|
||||||
|
getTime,
|
||||||
|
addZero,
|
||||||
|
getDefaultSecond,
|
||||||
|
dateCompare,
|
||||||
|
checkDate,
|
||||||
|
fixIosDateFormat
|
||||||
|
}
|
||||||
90
uni_modules/uni-datetime-picker/package.json
Normal file
90
uni_modules/uni-datetime-picker/package.json
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
{
|
||||||
|
"id": "uni-datetime-picker",
|
||||||
|
"displayName": "uni-datetime-picker 日期选择器",
|
||||||
|
"version": "2.2.40",
|
||||||
|
"description": "uni-datetime-picker 日期时间选择器,支持日历,支持范围选择",
|
||||||
|
"keywords": [
|
||||||
|
"uni-datetime-picker",
|
||||||
|
"uni-ui",
|
||||||
|
"uniui",
|
||||||
|
"日期时间选择器",
|
||||||
|
"日期时间"
|
||||||
|
],
|
||||||
|
"repository": "https://github.com/dcloudio/uni-ui",
|
||||||
|
"engines": {
|
||||||
|
"HBuilderX": ""
|
||||||
|
},
|
||||||
|
"directories": {
|
||||||
|
"example": "../../temps/example_temps"
|
||||||
|
},
|
||||||
|
"dcloudext": {
|
||||||
|
"sale": {
|
||||||
|
"regular": {
|
||||||
|
"price": "0.00"
|
||||||
|
},
|
||||||
|
"sourcecode": {
|
||||||
|
"price": "0.00"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"contact": {
|
||||||
|
"qq": ""
|
||||||
|
},
|
||||||
|
"declaration": {
|
||||||
|
"ads": "无",
|
||||||
|
"data": "无",
|
||||||
|
"permissions": "无"
|
||||||
|
},
|
||||||
|
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
|
||||||
|
"type": "component-vue"
|
||||||
|
},
|
||||||
|
"uni_modules": {
|
||||||
|
"dependencies": [
|
||||||
|
"uni-scss",
|
||||||
|
"uni-icons"
|
||||||
|
],
|
||||||
|
"encrypt": [],
|
||||||
|
"platforms": {
|
||||||
|
"cloud": {
|
||||||
|
"tcb": "y",
|
||||||
|
"aliyun": "y",
|
||||||
|
"alipay": "n"
|
||||||
|
},
|
||||||
|
"client": {
|
||||||
|
"App": {
|
||||||
|
"app-vue": "y",
|
||||||
|
"app-nvue": "n",
|
||||||
|
"app-harmony": "u",
|
||||||
|
"app-uvue": "u"
|
||||||
|
},
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
21
uni_modules/uni-datetime-picker/readme.md
Normal file
21
uni_modules/uni-datetime-picker/readme.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
|
||||||
|
|
||||||
|
> `重要通知:组件升级更新 2.0.0 后,支持日期+时间范围选择,组件 ui 将使用日历选择日期,ui 变化较大,同时支持 PC 和 移动端。此版本不向后兼容,不再支持单独的时间选择(type=time)及相关的 hide-second 属性(时间选可使用内置组件 picker)。若仍需使用旧版本,可在插件市场下载*非uni_modules版本*,旧版本将不再维护`
|
||||||
|
|
||||||
|
## DatetimePicker 时间选择器
|
||||||
|
|
||||||
|
> **组件名:uni-datetime-picker**
|
||||||
|
> 代码块: `uDatetimePicker`
|
||||||
|
|
||||||
|
|
||||||
|
该组件的优势是,支持**时间戳**输入和输出(起始时间、终止时间也支持时间戳),可**同时选择**日期和时间。
|
||||||
|
|
||||||
|
若只是需要单独选择日期和时间,不需要时间戳输入和输出,可使用原生的 picker 组件。
|
||||||
|
|
||||||
|
**_点击 picker 默认值规则:_**
|
||||||
|
|
||||||
|
- 若设置初始值 value, 会显示在 picker 显示框中
|
||||||
|
- 若无初始值 value,则初始值 value 为当前本地时间 Date.now(), 但不会显示在 picker 显示框中
|
||||||
|
|
||||||
|
### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-datetime-picker)
|
||||||
|
#### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"request.js","sources":["components/request.js"],"sourcesContent":["export default function request(urldata) {\r\n const { url, data, method, header, userInfo } = urldata;\r\n const baseUrl =\r\n \"http://192.168.0.218:8086/\"\r\n + url;\r\n if (userInfo) {\r\n uni.getStorage({\r\n key: \"userinfo\",\r\n success: (res) => {\r\n if (res.data) {\r\n if (res.data.nickName) {\r\n return new Promise((resolve, reject) => {\r\n uni.request({\r\n url: baseUrl,\r\n data: data,\r\n method: method,\r\n header: header,\r\n success: function (res) {\r\n resolve(res.data);\r\n },\r\n fail: function (res) {\r\n reject(res);\r\n }\r\n });\r\n });\r\n } else {\r\n this.$global.lastPage = uni.page.route;\r\n uni.reLaunch({ url: \"/pages/UserInformation/UserInformation\" })\r\n }\r\n } else {\r\n this.$global.lastPage = uni.page.route;\r\n uni.navigateTo({ url: '/pages/login/login' })\r\n }\r\n }\r\n });\r\n } else {\r\n return new Promise((resolve, reject) => {\r\n uni.request({\r\n url: baseUrl,\r\n data: data,\r\n method: method,\r\n header: header,\r\n success: function (res) {\r\n resolve(res.data);\r\n },\r\n fail: function (res) {\r\n reject(res);\r\n }\r\n });\r\n });\r\n }\r\n\r\n}"],"names":["uni","res"],"mappings":";;AAAe,SAAS,QAAQ,SAAS;AACrC,QAAM,EAAE,KAAK,MAAM,QAAQ,QAAQ,SAAU,IAAG;AAChD,QAAM,UACF,+BACE;AACN,MAAI,UAAU;AACVA,kBAAAA,MAAI,WAAW;AAAA,MACX,KAAK;AAAA,MACL,SAAS,CAAC,QAAQ;AACd,YAAI,IAAI,MAAM;AACV,cAAI,IAAI,KAAK,UAAU;AACnB,mBAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACpCA,4BAAAA,MAAI,QAAQ;AAAA,gBACR,KAAK;AAAA,gBACL;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA,SAAS,SAAUC,MAAK;AACpB,0BAAQA,KAAI,IAAI;AAAA,gBACnB;AAAA,gBACD,MAAM,SAAUA,MAAK;AACjB,yBAAOA,IAAG;AAAA,gBACb;AAAA,cACjC,CAA6B;AAAA,YAC7B,CAAyB;AAAA,UACzB,OAA2B;AACH,iBAAK,QAAQ,WAAWD,cAAAA,MAAI,KAAK;AACjCA,0BAAAA,MAAI,SAAS,EAAE,KAAK,yCAAwC,CAAE;AAAA,UACjE;AAAA,QACrB,OAAuB;AACH,eAAK,QAAQ,WAAWA,cAAAA,MAAI,KAAK;AACjCA,wBAAAA,MAAI,WAAW,EAAE,KAAK,qBAAoB,CAAE;AAAA,QAC/C;AAAA,MACJ;AAAA,IACb,CAAS;AAAA,EACT,OAAW;AACH,WAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACpCA,oBAAAA,MAAI,QAAQ;AAAA,QACR,KAAK;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA,SAAS,SAAU,KAAK;AACpB,kBAAQ,IAAI,IAAI;AAAA,QACnB;AAAA,QACD,MAAM,SAAU,KAAK;AACjB,iBAAO,GAAG;AAAA,QACb;AAAA,MACjB,CAAa;AAAA,IACb,CAAS;AAAA,EACJ;AAEL;;"}
|
{"version":3,"file":"request.js","sources":["components/request.js"],"sourcesContent":["export default function request(urldata) {\r\n const { url, data, method, header, userInfo } = urldata;\r\n const baseUrl =\r\n \"http://192.168.0.218:8086/\"\r\n + url;\r\n if (userInfo) {\r\n return new Promise((resolve, reject) => {\r\n uni.getStorage({\r\n key: \"userinfo\",\r\n success: (res) => {\r\n if (res.data) {\r\n if (res.data.nickName) {\r\n uni.request({\r\n url: baseUrl,\r\n data: data,\r\n method: method,\r\n header: header,\r\n success: function (res) {\r\n console.log(\"请求成功1\", res.data);\r\n resolve(res.data);\r\n },\r\n fail: function (res) {\r\n reject(res);\r\n }\r\n });\r\n } else {\r\n this.$global.lastPage = uni.page.route;\r\n uni.reLaunch({ url: \"/pages/UserInformation/UserInformation\" })\r\n }\r\n } else {\r\n this.$global.lastPage = uni.page.route;\r\n uni.navigateTo({ url: '/pages/login/login' })\r\n }\r\n },\r\n fail: function (res) {\r\n reject(res);\r\n }\r\n });\r\n });\r\n } else {\r\n return new Promise((resolve, reject) => {\r\n uni.request({\r\n url: baseUrl,\r\n data: data,\r\n method: method,\r\n header: header,\r\n success: function (res) {\r\n console.log(\"请求成功2\", res);\r\n resolve(res.data);\r\n },\r\n fail: function (res) {\r\n reject(res);\r\n }\r\n });\r\n });\r\n }\r\n\r\n}"],"names":["uni","res"],"mappings":";;AAAe,SAAS,QAAQ,SAAS;AACrC,QAAM,EAAE,KAAK,MAAM,QAAQ,QAAQ,SAAU,IAAG;AAChD,QAAM,UACF,+BACE;AACN,MAAI,UAAU;AACV,WAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACpCA,oBAAAA,MAAI,WAAW;AAAA,QACX,KAAK;AAAA,QACL,SAAS,CAAC,QAAQ;AACd,cAAI,IAAI,MAAM;AACV,gBAAI,IAAI,KAAK,UAAU;AACnBA,4BAAAA,MAAI,QAAQ;AAAA,gBACR,KAAK;AAAA,gBACL;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA,SAAS,SAAUC,MAAK;AACpBD,gCAAA,MAAA,MAAA,OAAA,+BAAY,SAASC,KAAI,IAAI;AAC7B,0BAAQA,KAAI,IAAI;AAAA,gBACnB;AAAA,gBACD,MAAM,SAAUA,MAAK;AACjB,yBAAOA,IAAG;AAAA,gBACb;AAAA,cACjC,CAA6B;AAAA,YAC7B,OAA+B;AACH,mBAAK,QAAQ,WAAWD,cAAAA,MAAI,KAAK;AACjCA,4BAAAA,MAAI,SAAS,EAAE,KAAK,yCAAwC,CAAE;AAAA,YACjE;AAAA,UACzB,OAA2B;AACH,iBAAK,QAAQ,WAAWA,cAAAA,MAAI,KAAK;AACjCA,0BAAAA,MAAI,WAAW,EAAE,KAAK,qBAAoB,CAAE;AAAA,UAC/C;AAAA,QACJ;AAAA,QACD,MAAM,SAAU,KAAK;AACjB,iBAAO,GAAG;AAAA,QACb;AAAA,MACjB,CAAa;AAAA,IACb,CAAS;AAAA,EACT,OAAW;AACH,WAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACpCA,oBAAAA,MAAI,QAAQ;AAAA,QACR,KAAK;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA,SAAS,SAAU,KAAK;AACpBA,wBAAY,MAAA,MAAA,OAAA,+BAAA,SAAS,GAAG;AACxB,kBAAQ,IAAI,IAAI;AAAA,QACnB;AAAA,QACD,MAAM,SAAU,KAAK;AACjB,iBAAO,GAAG;AAAA,QACb;AAAA,MACjB,CAAa;AAAA,IACb,CAAS;AAAA,EACJ;AAEL;;"}
|
||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"Home.js","sources":["pages/Home/Home.vue","../../HBuilderX/plugins/uniapp-cli-vite/uniPage:/cGFnZXMvSG9tZS9Ib21lLnZ1ZQ"],"sourcesContent":["<template>\r\n <view class=\"page\">\r\n <image src=\"../../static/HomeBackground.png\" class=\"HomeBackground\"></image>\r\n </view>\r\n <view class=\"top-navigation-container\">\r\n <top-navigation></top-navigation>\r\n </view>\r\n <view class=\"Advertisement\" @click=\"goAdvertisement\">\r\n <advertisement></advertisement>\r\n </view>\r\n <view class=\"contentList\">\r\n <contentList></contentList>\r\n </view>\r\n <view class=\"tabBar\">\r\n <tabBar></tabBar>\r\n </view>\r\n</template>\r\n\r\n<script>\r\nimport topNavigation from \"../../components/topNavigation/topNavigation\";\r\nimport Advertisement from \"../../components/Advertisement/Advertisement\";\r\nimport contentList from \"../../components/contentList/contentList\";\r\nimport tabBar from \"../../components/tabBar/tabBar\";\r\nexport default {\r\n inject: ['$global'],\r\n data() {\r\n return {};\r\n },\r\n onLoad() {\r\n // this.requestSomething();\r\n },\r\n methods: {\r\n goAdvertisement(){\r\n this.$global.lastPage = getCurrentPages().router;\r\n uni.navigateTo({ url: '/pages/login/login' })\r\n }\r\n },\r\n components: {\r\n topNavigation,\r\n Advertisement,\r\n contentList,\r\n tabBar,\r\n },\r\n};\r\n</script>\r\n\r\n<style scoped>\r\n.page {\r\n position: relative;\r\n width: 750rpx;\r\n height: 1620rpx;\r\n}\r\n\r\n.HomeBackground {\r\n position: absolute;\r\n top: 0;\r\n left: 0;\r\n width: 100%;\r\n height: 100%;\r\n z-index: -1;\r\n}\r\n.top-navigation-container {\r\n position: fixed;\r\n top: 160rpx;\r\n left: 0;\r\n width: 100%;\r\n height: 114.5rpx;\r\n}\r\n.Advertisement {\r\n position: fixed;\r\n top: 300rpx;\r\n left: 0;\r\n width: 100%;\r\n height: 100rpx;\r\n z-index: 100;\r\n}\r\n.contentList {\r\n position: fixed;\r\n top: 400rpx;\r\n left: 0;\r\n width: 100%;\r\n height: 1300rpx;\r\n}\r\n</style>\r\n","import MiniProgramPage from 'D:/项目/tk-mini-program/pages/Home/Home.vue'\nwx.createPage(MiniProgramPage)"],"names":["uni"],"mappings":";;;AAmBA,MAAO,gBAAe,MAAW;AACjC,MAAO,gBAAe,MAAW;AACjC,MAAO,cAAa,MAAW;AAC/B,eAAe,MAAW;AAC1B,MAAK,YAAU;AAAA,EACb,QAAQ,CAAC,SAAS;AAAA,EAClB,OAAO;AACL,WAAO;EACR;AAAA,EACD,SAAS;AAAA,EAER;AAAA,EACD,SAAS;AAAA,IACP,kBAAiB;AACf,WAAK,QAAQ,WAAW,gBAAe,EAAG;AAC1CA,oBAAAA,MAAI,WAAW,EAAE,KAAK,sBAAsB;AAAA,IAC9C;AAAA,EACD;AAAA,EACD,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACH;;;;;;;;;;;;;;;;;;;;AC1CA,GAAG,WAAW,eAAe;"}
|
{"version":3,"file":"Home.js","sources":["pages/Home/Home.vue","../../HBuilderX/plugins/uniapp-cli-vite/uniPage:/cGFnZXMvSG9tZS9Ib21lLnZ1ZQ"],"sourcesContent":["<template>\r\n <view class=\"page\">\r\n <image src=\"../../static/HomeBackground.png\" class=\"HomeBackground\"></image>\r\n </view>\r\n <view class=\"top-navigation-container\">\r\n <top-navigation></top-navigation>\r\n </view>\r\n <view class=\"Advertisement\" @click=\"goAdvertisement\">\r\n <advertisement></advertisement>\r\n </view>\r\n <view class=\"contentList\">\r\n <contentList></contentList>\r\n </view>\r\n <view class=\"tabBar\">\r\n <tabBar></tabBar>\r\n </view>\r\n</template>\r\n\r\n<script>\r\nimport topNavigation from \"../../components/topNavigation/topNavigation\";\r\nimport Advertisement from \"../../components/Advertisement/Advertisement\";\r\nimport contentList from \"../../components/contentList/contentList\";\r\nimport tabBar from \"../../components/tabBar/tabBar\";\r\nexport default {\r\n inject: ['$global'],\r\n data() {\r\n return {};\r\n },\r\n onLoad() {\r\n // this.requestSomething();\r\n },\r\n methods: {\r\n goAdvertisement(){\r\n this.$global.lastPage = getCurrentPages().router;\r\n uni.navigateTo({ url: '/pages/login/login' })\r\n }\r\n },\r\n components: {\r\n topNavigation,\r\n Advertisement,\r\n contentList,\r\n tabBar,\r\n },\r\n};\r\n</script>\r\n\r\n<style scoped>\r\n.page {\r\n position: relative;\r\n width: 750rpx;\r\n height: 1620rpx;\r\n}\r\n\r\n.HomeBackground {\r\n position: absolute;\r\n top: 0;\r\n left: 0;\r\n width: 100%;\r\n height: 100%;\r\n z-index: -1;\r\n}\r\n.top-navigation-container {\r\n position: fixed;\r\n top: 160rpx;\r\n left: 0;\r\n width: 100%;\r\n height: 114.5rpx;\r\n}\r\n.Advertisement {\r\n position: fixed;\r\n top: 300rpx;\r\n left: 0;\r\n width: 100%;\r\n height: 100rpx;\r\n z-index: 100;\r\n}\r\n.contentList {\r\n position: fixed;\r\n top: 400rpx;\r\n left: 0;\r\n bottom: 50rpx;\r\n width: 100%;\r\n /* height: 1300rpx; */\r\n}\r\n</style>\r\n","import MiniProgramPage from 'D:/项目/tk-mini-program/pages/Home/Home.vue'\nwx.createPage(MiniProgramPage)"],"names":["uni"],"mappings":";;;AAmBA,MAAO,gBAAe,MAAW;AACjC,MAAO,gBAAe,MAAW;AACjC,MAAO,cAAa,MAAW;AAC/B,eAAe,MAAW;AAC1B,MAAK,YAAU;AAAA,EACb,QAAQ,CAAC,SAAS;AAAA,EAClB,OAAO;AACL,WAAO;EACR;AAAA,EACD,SAAS;AAAA,EAER;AAAA,EACD,SAAS;AAAA,IACP,kBAAiB;AACf,WAAK,QAAQ,WAAW,gBAAe,EAAG;AAC1CA,oBAAAA,MAAI,WAAW,EAAE,KAAK,sBAAsB;AAAA,IAC9C;AAAA,EACD;AAAA,EACD,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACH;;;;;;;;;;;;;;;;;;;;AC1CA,GAAG,WAAW,eAAe;"}
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"index.js","sources":["uni_modules/uni-datetime-picker/components/uni-datetime-picker/i18n/index.js"],"sourcesContent":["import en from './en.json'\r\nimport zhHans from './zh-Hans.json'\r\nimport zhHant from './zh-Hant.json'\r\nexport default {\r\n\ten,\r\n\t'zh-Hans': zhHans,\r\n\t'zh-Hant': zhHant\r\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,MAAe,eAAA;AAAA,EACd;AAAA,EACA,WAAW;AAAA,EACX,WAAW;AACZ;;"}
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
160
unpackage/dist/dev/mp-weixin/NewAddedPk.js
vendored
160
unpackage/dist/dev/mp-weixin/NewAddedPk.js
vendored
@@ -1,41 +1,67 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
const common_vendor = require("./common/vendor.js");
|
const common_vendor = require("./common/vendor.js");
|
||||||
const components_NationalDictionary = require("./components/NationalDictionary.js");
|
const components_NationalDictionary = require("./components/NationalDictionary.js");
|
||||||
|
const components_request = require("./components/request.js");
|
||||||
const common_assets = require("./common/assets.js");
|
const common_assets = require("./common/assets.js");
|
||||||
const _sfc_main = {
|
const _sfc_main = {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
gender: "",
|
genders: "",
|
||||||
Gender: ["男", "女"],
|
//性别
|
||||||
Country: components_NationalDictionary.countryNamesArray,
|
Gender: [
|
||||||
country: "",
|
{ label: "男", value: 1 },
|
||||||
|
{ label: "女", value: 2 }
|
||||||
|
],
|
||||||
|
Country: components_NationalDictionary.optionsArray,
|
||||||
|
countrys: "",
|
||||||
|
//国家
|
||||||
nameAnchor: "",
|
nameAnchor: "",
|
||||||
|
//主播名称
|
||||||
numberCoins: "",
|
numberCoins: "",
|
||||||
|
//金币数量
|
||||||
remarks: "",
|
remarks: "",
|
||||||
|
//备注
|
||||||
Display: false,
|
Display: false,
|
||||||
options: [
|
Hint: false,
|
||||||
{ label: "选项一", value: "1" },
|
datetimesingle: "",
|
||||||
{ label: "选项二", value: "2" },
|
//日期
|
||||||
{ label: "选项三", value: "3" }
|
id: null
|
||||||
]
|
//用户id
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
common_vendor.index.getStorage({
|
common_vendor.index.getStorage({
|
||||||
key: "userinfo",
|
key: "userinfo",
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
|
this.id = res.data.id;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
gender(item) {
|
||||||
|
this.genders = item.value;
|
||||||
|
common_vendor.index.__f__("log", "at pages/NewAddedPk/NewAddedPk.vue:114", item);
|
||||||
|
},
|
||||||
|
country(item) {
|
||||||
|
this.countrys = item.value;
|
||||||
|
common_vendor.index.__f__("log", "at pages/NewAddedPk/NewAddedPk.vue:119", item);
|
||||||
|
},
|
||||||
handleOverlayClick(event) {
|
handleOverlayClick(event) {
|
||||||
if (event.target === this.$el) {
|
if (event.target === this.$el) {
|
||||||
this.Display = false;
|
this.Display = false;
|
||||||
|
this.Hint = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
open() {
|
open() {
|
||||||
if (this.Display) {
|
if (this.Display) {
|
||||||
this.Display = false;
|
this.Display = false;
|
||||||
|
this.Hint = false;
|
||||||
|
this.nameAnchor = "";
|
||||||
|
this.genders = "";
|
||||||
|
this.numberCoins = "";
|
||||||
|
this.remarks = "";
|
||||||
|
this.datetimesingle = "";
|
||||||
|
this.countrys = "";
|
||||||
} else {
|
} else {
|
||||||
this.Display = true;
|
this.Display = true;
|
||||||
}
|
}
|
||||||
@@ -44,59 +70,125 @@ const _sfc_main = {
|
|||||||
NameAnchor: function(event) {
|
NameAnchor: function(event) {
|
||||||
this.nameAnchor = event.target.value;
|
this.nameAnchor = event.target.value;
|
||||||
},
|
},
|
||||||
Publish() {
|
async Publish() {
|
||||||
common_vendor.index.__f__("log", "at pages/NewAddedPk/NewAddedPk.vue:103", this.nameAnchor, this.gender, this.country, this.numberCoins, this.remarks);
|
if (this.nameAnchor === "" || this.genders === "" || this.numberCoins === "" || this.countrys === "" || this.datetimesingle === "") {
|
||||||
|
this.Hint = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const isoString = this.datetimesingle.replace(" ", "T");
|
||||||
|
const timestamp = Date.parse(isoString);
|
||||||
|
if (isNaN(timestamp)) {
|
||||||
|
throw new Error(`Invalid date format: ${this.datetimesingle}`);
|
||||||
|
}
|
||||||
|
this.datetimesingle = Math.floor(timestamp / 1e3);
|
||||||
|
common_vendor.index.showLoading({
|
||||||
|
title: "发布中...",
|
||||||
|
mask: true
|
||||||
|
});
|
||||||
|
const res = await components_request.request({
|
||||||
|
url: "pk/addPkData",
|
||||||
|
method: "POST",
|
||||||
|
data: {
|
||||||
|
anchorId: this.nameAnchor,
|
||||||
|
pk_time: this.datetimesingle,
|
||||||
|
sex: this.genders,
|
||||||
|
country: this.countrys,
|
||||||
|
coin: this.numberCoins,
|
||||||
|
remark: this.remarks,
|
||||||
|
status: 0,
|
||||||
|
sender_id: this.id,
|
||||||
|
anchorIcon: ""
|
||||||
|
},
|
||||||
|
userInfo: true
|
||||||
|
});
|
||||||
|
if (res.code === 200) {
|
||||||
|
this.Display = false;
|
||||||
|
this.Hint = false;
|
||||||
|
this.nameAnchor = "";
|
||||||
|
this.genders = "";
|
||||||
|
this.numberCoins = "";
|
||||||
|
this.remarks = "";
|
||||||
|
this.datetimesingle = "";
|
||||||
|
common_vendor.index.hideLoading();
|
||||||
|
common_vendor.index.showToast({
|
||||||
|
title: "发布成功",
|
||||||
|
icon: "success",
|
||||||
|
duration: 2e3
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
common_vendor.index.hideLoading();
|
||||||
|
common_vendor.index.showToast({
|
||||||
|
title: "发布失败",
|
||||||
|
icon: "none",
|
||||||
|
duration: 2e3
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (!Array) {
|
if (!Array) {
|
||||||
const _easycom_uni_combox2 = common_vendor.resolveComponent("uni-combox");
|
|
||||||
const _easycom_wht_select2 = common_vendor.resolveComponent("wht-select");
|
const _easycom_wht_select2 = common_vendor.resolveComponent("wht-select");
|
||||||
const _easycom_uni_number_box2 = common_vendor.resolveComponent("uni-number-box");
|
const _easycom_uni_number_box2 = common_vendor.resolveComponent("uni-number-box");
|
||||||
|
const _easycom_uni_datetime_picker2 = common_vendor.resolveComponent("uni-datetime-picker");
|
||||||
const _easycom_uni_easyinput2 = common_vendor.resolveComponent("uni-easyinput");
|
const _easycom_uni_easyinput2 = common_vendor.resolveComponent("uni-easyinput");
|
||||||
(_easycom_uni_combox2 + _easycom_wht_select2 + _easycom_uni_number_box2 + _easycom_uni_easyinput2)();
|
(_easycom_wht_select2 + _easycom_uni_number_box2 + _easycom_uni_datetime_picker2 + _easycom_uni_easyinput2)();
|
||||||
}
|
}
|
||||||
const _easycom_uni_combox = () => "./uni_modules/uni-combox/components/uni-combox/uni-combox.js";
|
|
||||||
const _easycom_wht_select = () => "./uni_modules/wht-select/components/wht-select/wht-select.js";
|
const _easycom_wht_select = () => "./uni_modules/wht-select/components/wht-select/wht-select.js";
|
||||||
const _easycom_uni_number_box = () => "./uni_modules/uni-number-box/components/uni-number-box/uni-number-box.js";
|
const _easycom_uni_number_box = () => "./uni_modules/uni-number-box/components/uni-number-box/uni-number-box.js";
|
||||||
|
const _easycom_uni_datetime_picker = () => "./uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.js";
|
||||||
const _easycom_uni_easyinput = () => "./uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js";
|
const _easycom_uni_easyinput = () => "./uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js";
|
||||||
if (!Math) {
|
if (!Math) {
|
||||||
(_easycom_uni_combox + _easycom_wht_select + _easycom_uni_number_box + _easycom_uni_easyinput)();
|
(_easycom_wht_select + _easycom_uni_number_box + _easycom_uni_datetime_picker + _easycom_uni_easyinput)();
|
||||||
}
|
}
|
||||||
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||||
return common_vendor.e({
|
return common_vendor.e({
|
||||||
a: $data.Display
|
a: $data.Display
|
||||||
}, $data.Display ? {
|
}, $data.Display ? common_vendor.e({
|
||||||
b: common_vendor.o$1(($event) => $options.open()),
|
b: common_vendor.o$1(($event) => $options.open()),
|
||||||
c: common_assets._imports_0$5,
|
c: common_assets._imports_0$5,
|
||||||
d: common_vendor.o$1((...args) => $options.NameAnchor && $options.NameAnchor(...args)),
|
d: common_vendor.o$1((...args) => $options.NameAnchor && $options.NameAnchor(...args)),
|
||||||
e: common_vendor.o$1(($event) => $data.gender = $event),
|
e: $data.nameAnchor === "" && $data.Hint === true
|
||||||
f: common_vendor.p({
|
}, $data.nameAnchor === "" && $data.Hint === true ? {} : {}, {
|
||||||
candidates: $data.Gender,
|
f: common_vendor.o$1($options.gender),
|
||||||
placeholder: "请选择性别",
|
g: common_vendor.p({
|
||||||
modelValue: $data.gender
|
options: $data.Gender,
|
||||||
|
placeholder: "性别"
|
||||||
}),
|
}),
|
||||||
g: common_vendor.o$1(($event) => $data.country = $event),
|
h: $data.genders === "" && $data.Hint === true
|
||||||
h: common_vendor.p({
|
}, $data.genders === "" && $data.Hint === true ? {} : {}, {
|
||||||
options: $data.options,
|
i: common_vendor.o$1($options.country),
|
||||||
placeholder: "请选择国家",
|
|
||||||
modelValue: $data.country
|
|
||||||
}),
|
|
||||||
i: common_vendor.o$1(($event) => $data.numberCoins = $event),
|
|
||||||
j: common_vendor.p({
|
j: common_vendor.p({
|
||||||
|
options: $data.Country,
|
||||||
|
filterable: true,
|
||||||
|
placeholder: "请选择国家"
|
||||||
|
}),
|
||||||
|
k: $data.countrys === "" && $data.Hint === true
|
||||||
|
}, $data.countrys === "" && $data.Hint === true ? {} : {}, {
|
||||||
|
l: common_vendor.o$1(($event) => $data.numberCoins = $event),
|
||||||
|
m: common_vendor.p({
|
||||||
modelValue: $data.numberCoins
|
modelValue: $data.numberCoins
|
||||||
}),
|
}),
|
||||||
k: common_vendor.o$1(($event) => $data.remarks = $event),
|
n: $data.numberCoins === "" && $data.Hint === true
|
||||||
l: common_vendor.p({
|
}, $data.numberCoins === "" && $data.Hint === true ? {} : {}, {
|
||||||
|
o: common_vendor.o$1(_ctx.changeLog),
|
||||||
|
p: common_vendor.o$1(($event) => $data.datetimesingle = $event),
|
||||||
|
q: common_vendor.p({
|
||||||
|
type: "datetime",
|
||||||
|
modelValue: $data.datetimesingle
|
||||||
|
}),
|
||||||
|
r: $data.datetimesingle === "" && $data.Hint === true
|
||||||
|
}, $data.datetimesingle === "" && $data.Hint === true ? {} : {}, {
|
||||||
|
s: common_vendor.o$1(($event) => $data.remarks = $event),
|
||||||
|
t: common_vendor.p({
|
||||||
type: "textarea",
|
type: "textarea",
|
||||||
placeholder: "备注",
|
placeholder: "备注",
|
||||||
modelValue: $data.remarks
|
modelValue: $data.remarks
|
||||||
}),
|
}),
|
||||||
m: common_vendor.o$1(($event) => $options.Publish()),
|
v: common_vendor.o$1(($event) => $options.Publish()),
|
||||||
n: common_vendor.o$1(() => {
|
w: common_vendor.o$1(() => {
|
||||||
}),
|
}),
|
||||||
o: common_vendor.o$1(($event) => $options.open())
|
x: common_vendor.o$1(($event) => $options.open())
|
||||||
} : {});
|
}) : {});
|
||||||
}
|
}
|
||||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-96d38e2b"]]);
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-96d38e2b"]]);
|
||||||
exports.MiniProgramPage = MiniProgramPage;
|
exports.MiniProgramPage = MiniProgramPage;
|
||||||
|
|||||||
420
unpackage/dist/dev/mp-weixin/common/vendor.js
vendored
420
unpackage/dist/dev/mp-weixin/common/vendor.js
vendored
@@ -23,17 +23,17 @@ const remove = (arr, el) => {
|
|||||||
arr.splice(i3, 1);
|
arr.splice(i3, 1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
const hasOwnProperty$2 = Object.prototype.hasOwnProperty;
|
||||||
const hasOwn$1 = (val2, key) => hasOwnProperty$1.call(val2, key);
|
const hasOwn$2 = (val2, key) => hasOwnProperty$2.call(val2, key);
|
||||||
const isArray$1 = Array.isArray;
|
const isArray$1 = Array.isArray;
|
||||||
const isMap$1 = (val2) => toTypeString$1(val2) === "[object Map]";
|
const isMap$1 = (val2) => toTypeString$1(val2) === "[object Map]";
|
||||||
const isSet$1 = (val2) => toTypeString$1(val2) === "[object Set]";
|
const isSet$1 = (val2) => toTypeString$1(val2) === "[object Set]";
|
||||||
const isFunction$1 = (val2) => typeof val2 === "function";
|
const isFunction$1 = (val2) => typeof val2 === "function";
|
||||||
const isString = (val2) => typeof val2 === "string";
|
const isString = (val2) => typeof val2 === "string";
|
||||||
const isSymbol = (val2) => typeof val2 === "symbol";
|
const isSymbol = (val2) => typeof val2 === "symbol";
|
||||||
const isObject$1 = (val2) => val2 !== null && typeof val2 === "object";
|
const isObject$2 = (val2) => val2 !== null && typeof val2 === "object";
|
||||||
const isPromise = (val2) => {
|
const isPromise = (val2) => {
|
||||||
return (isObject$1(val2) || isFunction$1(val2)) && isFunction$1(val2.then) && isFunction$1(val2.catch);
|
return (isObject$2(val2) || isFunction$1(val2)) && isFunction$1(val2.then) && isFunction$1(val2.catch);
|
||||||
};
|
};
|
||||||
const objectToString$1 = Object.prototype.toString;
|
const objectToString$1 = Object.prototype.toString;
|
||||||
const toTypeString$1 = (value) => objectToString$1.call(value);
|
const toTypeString$1 = (value) => objectToString$1.call(value);
|
||||||
@@ -105,7 +105,7 @@ function normalizeStyle(value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
} else if (isString(value) || isObject$1(value)) {
|
} else if (isString(value) || isObject$2(value)) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,7 +133,7 @@ function normalizeClass(value) {
|
|||||||
res += normalized + " ";
|
res += normalized + " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (isObject$1(value)) {
|
} else if (isObject$2(value)) {
|
||||||
for (const name in value) {
|
for (const name in value) {
|
||||||
if (value[name]) {
|
if (value[name]) {
|
||||||
res += name + " ";
|
res += name + " ";
|
||||||
@@ -155,7 +155,7 @@ function normalizeProps(props) {
|
|||||||
return props;
|
return props;
|
||||||
}
|
}
|
||||||
const toDisplayString = (val2) => {
|
const toDisplayString = (val2) => {
|
||||||
return isString(val2) ? val2 : val2 == null ? "" : isArray$1(val2) || isObject$1(val2) && (val2.toString === objectToString$1 || !isFunction$1(val2.toString)) ? JSON.stringify(val2, replacer, 2) : String(val2);
|
return isString(val2) ? val2 : val2 == null ? "" : isArray$1(val2) || isObject$2(val2) && (val2.toString === objectToString$1 || !isFunction$1(val2.toString)) ? JSON.stringify(val2, replacer, 2) : String(val2);
|
||||||
};
|
};
|
||||||
const replacer = (_key, val2) => {
|
const replacer = (_key, val2) => {
|
||||||
if (val2 && val2.__v_isRef) {
|
if (val2 && val2.__v_isRef) {
|
||||||
@@ -176,7 +176,7 @@ const replacer = (_key, val2) => {
|
|||||||
};
|
};
|
||||||
} else if (isSymbol(val2)) {
|
} else if (isSymbol(val2)) {
|
||||||
return stringifySymbol(val2);
|
return stringifySymbol(val2);
|
||||||
} else if (isObject$1(val2) && !isArray$1(val2) && !isPlainObject$1(val2)) {
|
} else if (isObject$2(val2) && !isArray$1(val2) && !isPlainObject$1(val2)) {
|
||||||
return String(val2);
|
return String(val2);
|
||||||
}
|
}
|
||||||
return val2;
|
return val2;
|
||||||
@@ -185,11 +185,96 @@ const stringifySymbol = (v3, i3 = "") => {
|
|||||||
var _a;
|
var _a;
|
||||||
return isSymbol(v3) ? `Symbol(${(_a = v3.description) != null ? _a : i3})` : v3;
|
return isSymbol(v3) ? `Symbol(${(_a = v3.description) != null ? _a : i3})` : v3;
|
||||||
};
|
};
|
||||||
|
const isObject$1 = (val2) => val2 !== null && typeof val2 === "object";
|
||||||
|
const defaultDelimiters = ["{", "}"];
|
||||||
|
class BaseFormatter {
|
||||||
|
constructor() {
|
||||||
|
this._caches = /* @__PURE__ */ Object.create(null);
|
||||||
|
}
|
||||||
|
interpolate(message, values, delimiters = defaultDelimiters) {
|
||||||
|
if (!values) {
|
||||||
|
return [message];
|
||||||
|
}
|
||||||
|
let tokens = this._caches[message];
|
||||||
|
if (!tokens) {
|
||||||
|
tokens = parse(message, delimiters);
|
||||||
|
this._caches[message] = tokens;
|
||||||
|
}
|
||||||
|
return compile$1(tokens, values);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const RE_TOKEN_LIST_VALUE = /^(?:\d)+/;
|
||||||
|
const RE_TOKEN_NAMED_VALUE = /^(?:\w)+/;
|
||||||
|
function parse(format, [startDelimiter, endDelimiter]) {
|
||||||
|
const tokens = [];
|
||||||
|
let position = 0;
|
||||||
|
let text = "";
|
||||||
|
while (position < format.length) {
|
||||||
|
let char = format[position++];
|
||||||
|
if (char === startDelimiter) {
|
||||||
|
if (text) {
|
||||||
|
tokens.push({ type: "text", value: text });
|
||||||
|
}
|
||||||
|
text = "";
|
||||||
|
let sub = "";
|
||||||
|
char = format[position++];
|
||||||
|
while (char !== void 0 && char !== endDelimiter) {
|
||||||
|
sub += char;
|
||||||
|
char = format[position++];
|
||||||
|
}
|
||||||
|
const isClosed = char === endDelimiter;
|
||||||
|
const type = RE_TOKEN_LIST_VALUE.test(sub) ? "list" : isClosed && RE_TOKEN_NAMED_VALUE.test(sub) ? "named" : "unknown";
|
||||||
|
tokens.push({ value: sub, type });
|
||||||
|
} else {
|
||||||
|
text += char;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
text && tokens.push({ type: "text", value: text });
|
||||||
|
return tokens;
|
||||||
|
}
|
||||||
|
function compile$1(tokens, values) {
|
||||||
|
const compiled = [];
|
||||||
|
let index2 = 0;
|
||||||
|
const mode = Array.isArray(values) ? "list" : isObject$1(values) ? "named" : "unknown";
|
||||||
|
if (mode === "unknown") {
|
||||||
|
return compiled;
|
||||||
|
}
|
||||||
|
while (index2 < tokens.length) {
|
||||||
|
const token = tokens[index2];
|
||||||
|
switch (token.type) {
|
||||||
|
case "text":
|
||||||
|
compiled.push(token.value);
|
||||||
|
break;
|
||||||
|
case "list":
|
||||||
|
compiled.push(values[parseInt(token.value, 10)]);
|
||||||
|
break;
|
||||||
|
case "named":
|
||||||
|
if (mode === "named") {
|
||||||
|
compiled.push(values[token.value]);
|
||||||
|
} else {
|
||||||
|
{
|
||||||
|
console.warn(`Type of token '${token.type}' and format of value '${mode}' don't match!`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "unknown":
|
||||||
|
{
|
||||||
|
console.warn(`Detect 'unknown' type of token!`);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
index2++;
|
||||||
|
}
|
||||||
|
return compiled;
|
||||||
|
}
|
||||||
const LOCALE_ZH_HANS = "zh-Hans";
|
const LOCALE_ZH_HANS = "zh-Hans";
|
||||||
const LOCALE_ZH_HANT = "zh-Hant";
|
const LOCALE_ZH_HANT = "zh-Hant";
|
||||||
const LOCALE_EN = "en";
|
const LOCALE_EN = "en";
|
||||||
const LOCALE_FR = "fr";
|
const LOCALE_FR = "fr";
|
||||||
const LOCALE_ES = "es";
|
const LOCALE_ES = "es";
|
||||||
|
const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
||||||
|
const hasOwn$1 = (val2, key) => hasOwnProperty$1.call(val2, key);
|
||||||
|
const defaultFormatter = new BaseFormatter();
|
||||||
function include(str, parts) {
|
function include(str, parts) {
|
||||||
return !!parts.find((part) => str.indexOf(part) !== -1);
|
return !!parts.find((part) => str.indexOf(part) !== -1);
|
||||||
}
|
}
|
||||||
@@ -229,6 +314,163 @@ function normalizeLocale(locale, messages) {
|
|||||||
return lang;
|
return lang;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
class I18n {
|
||||||
|
constructor({ locale, fallbackLocale, messages, watcher, formater: formater2 }) {
|
||||||
|
this.locale = LOCALE_EN;
|
||||||
|
this.fallbackLocale = LOCALE_EN;
|
||||||
|
this.message = {};
|
||||||
|
this.messages = {};
|
||||||
|
this.watchers = [];
|
||||||
|
if (fallbackLocale) {
|
||||||
|
this.fallbackLocale = fallbackLocale;
|
||||||
|
}
|
||||||
|
this.formater = formater2 || defaultFormatter;
|
||||||
|
this.messages = messages || {};
|
||||||
|
this.setLocale(locale || LOCALE_EN);
|
||||||
|
if (watcher) {
|
||||||
|
this.watchLocale(watcher);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setLocale(locale) {
|
||||||
|
const oldLocale = this.locale;
|
||||||
|
this.locale = normalizeLocale(locale, this.messages) || this.fallbackLocale;
|
||||||
|
if (!this.messages[this.locale]) {
|
||||||
|
this.messages[this.locale] = {};
|
||||||
|
}
|
||||||
|
this.message = this.messages[this.locale];
|
||||||
|
if (oldLocale !== this.locale) {
|
||||||
|
this.watchers.forEach((watcher) => {
|
||||||
|
watcher(this.locale, oldLocale);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getLocale() {
|
||||||
|
return this.locale;
|
||||||
|
}
|
||||||
|
watchLocale(fn) {
|
||||||
|
const index2 = this.watchers.push(fn) - 1;
|
||||||
|
return () => {
|
||||||
|
this.watchers.splice(index2, 1);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
add(locale, message, override = true) {
|
||||||
|
const curMessages = this.messages[locale];
|
||||||
|
if (curMessages) {
|
||||||
|
if (override) {
|
||||||
|
Object.assign(curMessages, message);
|
||||||
|
} else {
|
||||||
|
Object.keys(message).forEach((key) => {
|
||||||
|
if (!hasOwn$1(curMessages, key)) {
|
||||||
|
curMessages[key] = message[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.messages[locale] = message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
f(message, values, delimiters) {
|
||||||
|
return this.formater.interpolate(message, values, delimiters).join("");
|
||||||
|
}
|
||||||
|
t(key, locale, values) {
|
||||||
|
let message = this.message;
|
||||||
|
if (typeof locale === "string") {
|
||||||
|
locale = normalizeLocale(locale, this.messages);
|
||||||
|
locale && (message = this.messages[locale]);
|
||||||
|
} else {
|
||||||
|
values = locale;
|
||||||
|
}
|
||||||
|
if (!hasOwn$1(message, key)) {
|
||||||
|
console.warn(`Cannot translate the value of keypath ${key}. Use the value of keypath as default.`);
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
return this.formater.interpolate(message[key], values).join("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function watchAppLocale(appVm, i18n) {
|
||||||
|
if (appVm.$watchLocale) {
|
||||||
|
appVm.$watchLocale((newLocale) => {
|
||||||
|
i18n.setLocale(newLocale);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
appVm.$watch(() => appVm.$locale, (newLocale) => {
|
||||||
|
i18n.setLocale(newLocale);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function getDefaultLocale() {
|
||||||
|
if (typeof index !== "undefined" && index.getLocale) {
|
||||||
|
return index.getLocale();
|
||||||
|
}
|
||||||
|
if (typeof global !== "undefined" && global.getLocale) {
|
||||||
|
return global.getLocale();
|
||||||
|
}
|
||||||
|
return LOCALE_EN;
|
||||||
|
}
|
||||||
|
function initVueI18n(locale, messages = {}, fallbackLocale, watcher) {
|
||||||
|
if (typeof locale !== "string") {
|
||||||
|
const options = [
|
||||||
|
messages,
|
||||||
|
locale
|
||||||
|
];
|
||||||
|
locale = options[0];
|
||||||
|
messages = options[1];
|
||||||
|
}
|
||||||
|
if (typeof locale !== "string") {
|
||||||
|
locale = getDefaultLocale();
|
||||||
|
}
|
||||||
|
if (typeof fallbackLocale !== "string") {
|
||||||
|
fallbackLocale = typeof __uniConfig !== "undefined" && __uniConfig.fallbackLocale || LOCALE_EN;
|
||||||
|
}
|
||||||
|
const i18n = new I18n({
|
||||||
|
locale,
|
||||||
|
fallbackLocale,
|
||||||
|
messages,
|
||||||
|
watcher
|
||||||
|
});
|
||||||
|
let t2 = (key, values) => {
|
||||||
|
if (typeof getApp !== "function") {
|
||||||
|
t2 = function(key2, values2) {
|
||||||
|
return i18n.t(key2, values2);
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
let isWatchedAppLocale = false;
|
||||||
|
t2 = function(key2, values2) {
|
||||||
|
const appVm = getApp().$vm;
|
||||||
|
if (appVm) {
|
||||||
|
appVm.$locale;
|
||||||
|
if (!isWatchedAppLocale) {
|
||||||
|
isWatchedAppLocale = true;
|
||||||
|
watchAppLocale(appVm, i18n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return i18n.t(key2, values2);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return t2(key, values);
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
i18n,
|
||||||
|
f(message, values, delimiters) {
|
||||||
|
return i18n.f(message, values, delimiters);
|
||||||
|
},
|
||||||
|
t(key, values) {
|
||||||
|
return t2(key, values);
|
||||||
|
},
|
||||||
|
add(locale2, message, override = true) {
|
||||||
|
return i18n.add(locale2, message, override);
|
||||||
|
},
|
||||||
|
watch(fn) {
|
||||||
|
return i18n.watchLocale(fn);
|
||||||
|
},
|
||||||
|
getLocale() {
|
||||||
|
return i18n.getLocale();
|
||||||
|
},
|
||||||
|
setLocale(newLocale) {
|
||||||
|
return i18n.setLocale(newLocale);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
const SLOT_DEFAULT_NAME = "d";
|
const SLOT_DEFAULT_NAME = "d";
|
||||||
const ON_SHOW = "onShow";
|
const ON_SHOW = "onShow";
|
||||||
const ON_HIDE = "onHide";
|
const ON_HIDE = "onHide";
|
||||||
@@ -904,7 +1146,7 @@ class BaseReactiveHandler {
|
|||||||
}
|
}
|
||||||
const targetIsArray = isArray$1(target);
|
const targetIsArray = isArray$1(target);
|
||||||
if (!isReadonly2) {
|
if (!isReadonly2) {
|
||||||
if (targetIsArray && hasOwn$1(arrayInstrumentations, key)) {
|
if (targetIsArray && hasOwn$2(arrayInstrumentations, key)) {
|
||||||
return Reflect.get(arrayInstrumentations, key, receiver);
|
return Reflect.get(arrayInstrumentations, key, receiver);
|
||||||
}
|
}
|
||||||
if (key === "hasOwnProperty") {
|
if (key === "hasOwnProperty") {
|
||||||
@@ -924,7 +1166,7 @@ class BaseReactiveHandler {
|
|||||||
if (isRef$1(res)) {
|
if (isRef$1(res)) {
|
||||||
return targetIsArray && isIntegerKey(key) ? res : res.value;
|
return targetIsArray && isIntegerKey(key) ? res : res.value;
|
||||||
}
|
}
|
||||||
if (isObject$1(res)) {
|
if (isObject$2(res)) {
|
||||||
return isReadonly2 ? readonly$1(res) : reactive$1(res);
|
return isReadonly2 ? readonly$1(res) : reactive$1(res);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
@@ -951,7 +1193,7 @@ class MutableReactiveHandler extends BaseReactiveHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const hadKey = isArray$1(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn$1(target, key);
|
const hadKey = isArray$1(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn$2(target, key);
|
||||||
const result = Reflect.set(target, key, value, receiver);
|
const result = Reflect.set(target, key, value, receiver);
|
||||||
if (target === toRaw$1(receiver)) {
|
if (target === toRaw$1(receiver)) {
|
||||||
if (!hadKey) {
|
if (!hadKey) {
|
||||||
@@ -963,7 +1205,7 @@ class MutableReactiveHandler extends BaseReactiveHandler {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
deleteProperty(target, key) {
|
deleteProperty(target, key) {
|
||||||
const hadKey = hasOwn$1(target, key);
|
const hadKey = hasOwn$2(target, key);
|
||||||
const oldValue = target[key];
|
const oldValue = target[key];
|
||||||
const result = Reflect.deleteProperty(target, key);
|
const result = Reflect.deleteProperty(target, key);
|
||||||
if (result && hadKey) {
|
if (result && hadKey) {
|
||||||
@@ -1268,7 +1510,7 @@ function createInstrumentationGetter(isReadonly2, shallow) {
|
|||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
return Reflect.get(
|
return Reflect.get(
|
||||||
hasOwn$1(instrumentations, key) && key in target ? instrumentations : target,
|
hasOwn$2(instrumentations, key) && key in target ? instrumentations : target,
|
||||||
key,
|
key,
|
||||||
receiver
|
receiver
|
||||||
);
|
);
|
||||||
@@ -1356,7 +1598,7 @@ function shallowReadonly$1(target) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
|
function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
|
||||||
if (!isObject$1(target)) {
|
if (!isObject$2(target)) {
|
||||||
{
|
{
|
||||||
warn$2(`value cannot be made reactive: ${String(target)}`);
|
warn$2(`value cannot be made reactive: ${String(target)}`);
|
||||||
}
|
}
|
||||||
@@ -1405,8 +1647,8 @@ function markRaw$1(value) {
|
|||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
const toReactive = (value) => isObject$1(value) ? reactive$1(value) : value;
|
const toReactive = (value) => isObject$2(value) ? reactive$1(value) : value;
|
||||||
const toReadonly = (value) => isObject$1(value) ? readonly$1(value) : value;
|
const toReadonly = (value) => isObject$2(value) ? readonly$1(value) : value;
|
||||||
const COMPUTED_SIDE_EFFECT_WARN = `Computed is still dirty after getter evaluation, likely because a computed is mutating its own dependency in its getter. State mutations in computed getters should be avoided. Check the docs for more details: https://vuejs.org/guide/essentials/computed.html#getters-should-be-side-effect-free`;
|
const COMPUTED_SIDE_EFFECT_WARN = `Computed is still dirty after getter evaluation, likely because a computed is mutating its own dependency in its getter. State mutations in computed getters should be avoided. Check the docs for more details: https://vuejs.org/guide/essentials/computed.html#getters-should-be-side-effect-free`;
|
||||||
class ComputedRefImpl {
|
class ComputedRefImpl {
|
||||||
constructor(getter, _setter, isReadonly2, isSSR) {
|
constructor(getter, _setter, isReadonly2, isSSR) {
|
||||||
@@ -1633,7 +1875,7 @@ function toRef$1(source, key, defaultValue) {
|
|||||||
return source;
|
return source;
|
||||||
} else if (isFunction$1(source)) {
|
} else if (isFunction$1(source)) {
|
||||||
return new GetterRefImpl(source);
|
return new GetterRefImpl(source);
|
||||||
} else if (isObject$1(source) && arguments.length > 1) {
|
} else if (isObject$2(source) && arguments.length > 1) {
|
||||||
return propertyToRef(source, key, defaultValue);
|
return propertyToRef(source, key, defaultValue);
|
||||||
} else {
|
} else {
|
||||||
return ref$1(source);
|
return ref$1(source);
|
||||||
@@ -2240,7 +2482,7 @@ function normalizeEmitsOptions(comp, appContext, asMixin = false) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!raw && !hasExtends) {
|
if (!raw && !hasExtends) {
|
||||||
if (isObject$1(comp)) {
|
if (isObject$2(comp)) {
|
||||||
cache.set(comp, null);
|
cache.set(comp, null);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -2250,7 +2492,7 @@ function normalizeEmitsOptions(comp, appContext, asMixin = false) {
|
|||||||
} else {
|
} else {
|
||||||
extend(normalized, raw);
|
extend(normalized, raw);
|
||||||
}
|
}
|
||||||
if (isObject$1(comp)) {
|
if (isObject$2(comp)) {
|
||||||
cache.set(comp, normalized);
|
cache.set(comp, normalized);
|
||||||
}
|
}
|
||||||
return normalized;
|
return normalized;
|
||||||
@@ -2260,7 +2502,7 @@ function isEmitListener(options, key) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
key = key.slice(2).replace(/Once$/, "");
|
key = key.slice(2).replace(/Once$/, "");
|
||||||
return hasOwn$1(options, key[0].toLowerCase() + key.slice(1)) || hasOwn$1(options, hyphenate(key)) || hasOwn$1(options, key);
|
return hasOwn$2(options, key[0].toLowerCase() + key.slice(1)) || hasOwn$2(options, hyphenate(key)) || hasOwn$2(options, key);
|
||||||
}
|
}
|
||||||
let currentRenderingInstance = null;
|
let currentRenderingInstance = null;
|
||||||
function setCurrentRenderingInstance(instance) {
|
function setCurrentRenderingInstance(instance) {
|
||||||
@@ -2573,7 +2815,7 @@ function createPathGetter(ctx, path) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
function traverse$1(value, depth, currentDepth = 0, seen) {
|
function traverse$1(value, depth, currentDepth = 0, seen) {
|
||||||
if (!isObject$1(value) || value["__v_skip"]) {
|
if (!isObject$2(value) || value["__v_skip"]) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
if (depth && depth > 0) {
|
if (depth && depth > 0) {
|
||||||
@@ -2667,7 +2909,7 @@ function createAppAPI(render, hydrate) {
|
|||||||
if (!isFunction$1(rootComponent)) {
|
if (!isFunction$1(rootComponent)) {
|
||||||
rootComponent = extend({}, rootComponent);
|
rootComponent = extend({}, rootComponent);
|
||||||
}
|
}
|
||||||
if (rootProps != null && !isObject$1(rootProps)) {
|
if (rootProps != null && !isObject$2(rootProps)) {
|
||||||
warn$1$1(`root props passed to app.mount() must be an object.`);
|
warn$1$1(`root props passed to app.mount() must be an object.`);
|
||||||
rootProps = null;
|
rootProps = null;
|
||||||
}
|
}
|
||||||
@@ -2913,7 +3155,7 @@ function onErrorCaptured$1(hook, target = currentInstance$1) {
|
|||||||
}
|
}
|
||||||
function toHandlers(obj, preserveCaseIfNecessary) {
|
function toHandlers(obj, preserveCaseIfNecessary) {
|
||||||
const ret = {};
|
const ret = {};
|
||||||
if (!isObject$1(obj)) {
|
if (!isObject$2(obj)) {
|
||||||
warn$1$1(`v-on with no argument expects an object value.`);
|
warn$1$1(`v-on with no argument expects an object value.`);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -2955,7 +3197,7 @@ const publicPropertiesMap = (
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
const isReservedPrefix = (key) => key === "_" || key === "$";
|
const isReservedPrefix = (key) => key === "_" || key === "$";
|
||||||
const hasSetupBinding = (state, key) => state !== EMPTY_OBJ$1 && !state.__isScriptSetup && hasOwn$1(state, key);
|
const hasSetupBinding = (state, key) => state !== EMPTY_OBJ$1 && !state.__isScriptSetup && hasOwn$2(state, key);
|
||||||
const PublicInstanceProxyHandlers = {
|
const PublicInstanceProxyHandlers = {
|
||||||
get({ _: instance }, key) {
|
get({ _: instance }, key) {
|
||||||
const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
|
const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
|
||||||
@@ -2979,17 +3221,17 @@ const PublicInstanceProxyHandlers = {
|
|||||||
} else if (hasSetupBinding(setupState, key)) {
|
} else if (hasSetupBinding(setupState, key)) {
|
||||||
accessCache[key] = 1;
|
accessCache[key] = 1;
|
||||||
return setupState[key];
|
return setupState[key];
|
||||||
} else if (data !== EMPTY_OBJ$1 && hasOwn$1(data, key)) {
|
} else if (data !== EMPTY_OBJ$1 && hasOwn$2(data, key)) {
|
||||||
accessCache[key] = 2;
|
accessCache[key] = 2;
|
||||||
return data[key];
|
return data[key];
|
||||||
} else if (
|
} else if (
|
||||||
// only cache other properties when instance has declared (thus stable)
|
// only cache other properties when instance has declared (thus stable)
|
||||||
// props
|
// props
|
||||||
(normalizedProps = instance.propsOptions[0]) && hasOwn$1(normalizedProps, key)
|
(normalizedProps = instance.propsOptions[0]) && hasOwn$2(normalizedProps, key)
|
||||||
) {
|
) {
|
||||||
accessCache[key] = 3;
|
accessCache[key] = 3;
|
||||||
return props[key];
|
return props[key];
|
||||||
} else if (ctx !== EMPTY_OBJ$1 && hasOwn$1(ctx, key)) {
|
} else if (ctx !== EMPTY_OBJ$1 && hasOwn$2(ctx, key)) {
|
||||||
accessCache[key] = 4;
|
accessCache[key] = 4;
|
||||||
return ctx[key];
|
return ctx[key];
|
||||||
} else if (shouldCacheAccess) {
|
} else if (shouldCacheAccess) {
|
||||||
@@ -3010,12 +3252,12 @@ const PublicInstanceProxyHandlers = {
|
|||||||
(cssModule = type.__cssModules) && (cssModule = cssModule[key])
|
(cssModule = type.__cssModules) && (cssModule = cssModule[key])
|
||||||
) {
|
) {
|
||||||
return cssModule;
|
return cssModule;
|
||||||
} else if (ctx !== EMPTY_OBJ$1 && hasOwn$1(ctx, key)) {
|
} else if (ctx !== EMPTY_OBJ$1 && hasOwn$2(ctx, key)) {
|
||||||
accessCache[key] = 4;
|
accessCache[key] = 4;
|
||||||
return ctx[key];
|
return ctx[key];
|
||||||
} else if (
|
} else if (
|
||||||
// global properties
|
// global properties
|
||||||
globalProperties = appContext.config.globalProperties, hasOwn$1(globalProperties, key)
|
globalProperties = appContext.config.globalProperties, hasOwn$2(globalProperties, key)
|
||||||
) {
|
) {
|
||||||
{
|
{
|
||||||
return globalProperties[key];
|
return globalProperties[key];
|
||||||
@@ -3023,7 +3265,7 @@ const PublicInstanceProxyHandlers = {
|
|||||||
} else if (currentRenderingInstance && (!isString(key) || // #1091 avoid internal isRef/isVNode checks on component instance leading
|
} else if (currentRenderingInstance && (!isString(key) || // #1091 avoid internal isRef/isVNode checks on component instance leading
|
||||||
// to infinite warning loop
|
// to infinite warning loop
|
||||||
key.indexOf("__v") !== 0)) {
|
key.indexOf("__v") !== 0)) {
|
||||||
if (data !== EMPTY_OBJ$1 && isReservedPrefix(key[0]) && hasOwn$1(data, key)) {
|
if (data !== EMPTY_OBJ$1 && isReservedPrefix(key[0]) && hasOwn$2(data, key)) {
|
||||||
warn$1$1(
|
warn$1$1(
|
||||||
`Property ${JSON.stringify(
|
`Property ${JSON.stringify(
|
||||||
key
|
key
|
||||||
@@ -3041,13 +3283,13 @@ const PublicInstanceProxyHandlers = {
|
|||||||
if (hasSetupBinding(setupState, key)) {
|
if (hasSetupBinding(setupState, key)) {
|
||||||
setupState[key] = value;
|
setupState[key] = value;
|
||||||
return true;
|
return true;
|
||||||
} else if (setupState.__isScriptSetup && hasOwn$1(setupState, key)) {
|
} else if (setupState.__isScriptSetup && hasOwn$2(setupState, key)) {
|
||||||
warn$1$1(`Cannot mutate <script setup> binding "${key}" from Options API.`);
|
warn$1$1(`Cannot mutate <script setup> binding "${key}" from Options API.`);
|
||||||
return false;
|
return false;
|
||||||
} else if (data !== EMPTY_OBJ$1 && hasOwn$1(data, key)) {
|
} else if (data !== EMPTY_OBJ$1 && hasOwn$2(data, key)) {
|
||||||
data[key] = value;
|
data[key] = value;
|
||||||
return true;
|
return true;
|
||||||
} else if (hasOwn$1(instance.props, key)) {
|
} else if (hasOwn$2(instance.props, key)) {
|
||||||
warn$1$1(`Attempting to mutate prop "${key}". Props are readonly.`);
|
warn$1$1(`Attempting to mutate prop "${key}". Props are readonly.`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -3073,12 +3315,12 @@ const PublicInstanceProxyHandlers = {
|
|||||||
_: { data, setupState, accessCache, ctx, appContext, propsOptions }
|
_: { data, setupState, accessCache, ctx, appContext, propsOptions }
|
||||||
}, key) {
|
}, key) {
|
||||||
let normalizedProps;
|
let normalizedProps;
|
||||||
return !!accessCache[key] || data !== EMPTY_OBJ$1 && hasOwn$1(data, key) || hasSetupBinding(setupState, key) || (normalizedProps = propsOptions[0]) && hasOwn$1(normalizedProps, key) || hasOwn$1(ctx, key) || hasOwn$1(publicPropertiesMap, key) || hasOwn$1(appContext.config.globalProperties, key);
|
return !!accessCache[key] || data !== EMPTY_OBJ$1 && hasOwn$2(data, key) || hasSetupBinding(setupState, key) || (normalizedProps = propsOptions[0]) && hasOwn$2(normalizedProps, key) || hasOwn$2(ctx, key) || hasOwn$2(publicPropertiesMap, key) || hasOwn$2(appContext.config.globalProperties, key);
|
||||||
},
|
},
|
||||||
defineProperty(target, key, descriptor) {
|
defineProperty(target, key, descriptor) {
|
||||||
if (descriptor.get != null) {
|
if (descriptor.get != null) {
|
||||||
target._.accessCache[key] = 0;
|
target._.accessCache[key] = 0;
|
||||||
} else if (hasOwn$1(descriptor, "value")) {
|
} else if (hasOwn$2(descriptor, "value")) {
|
||||||
this.set(target, key, descriptor.value, null);
|
this.set(target, key, descriptor.value, null);
|
||||||
}
|
}
|
||||||
return Reflect.defineProperty(target, key, descriptor);
|
return Reflect.defineProperty(target, key, descriptor);
|
||||||
@@ -3355,7 +3597,7 @@ function applyOptions$1(instance) {
|
|||||||
`data() returned a Promise - note data() cannot be async; If you intend to perform data fetching before component renders, use async setup() + <Suspense>.`
|
`data() returned a Promise - note data() cannot be async; If you intend to perform data fetching before component renders, use async setup() + <Suspense>.`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (!isObject$1(data)) {
|
if (!isObject$2(data)) {
|
||||||
warn$1$1(`data() should return an object.`);
|
warn$1$1(`data() should return an object.`);
|
||||||
} else {
|
} else {
|
||||||
instance.data = reactive$1(data);
|
instance.data = reactive$1(data);
|
||||||
@@ -3476,7 +3718,7 @@ function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP)
|
|||||||
for (const key in injectOptions) {
|
for (const key in injectOptions) {
|
||||||
const opt = injectOptions[key];
|
const opt = injectOptions[key];
|
||||||
let injected;
|
let injected;
|
||||||
if (isObject$1(opt)) {
|
if (isObject$2(opt)) {
|
||||||
if ("default" in opt) {
|
if ("default" in opt) {
|
||||||
injected = inject$1(
|
injected = inject$1(
|
||||||
opt.from || key,
|
opt.from || key,
|
||||||
@@ -3522,7 +3764,7 @@ function createWatcher$1(raw, ctx, publicThis, key) {
|
|||||||
}
|
}
|
||||||
} else if (isFunction$1(raw)) {
|
} else if (isFunction$1(raw)) {
|
||||||
watch$1(getter, raw.bind(publicThis));
|
watch$1(getter, raw.bind(publicThis));
|
||||||
} else if (isObject$1(raw)) {
|
} else if (isObject$2(raw)) {
|
||||||
if (isArray$1(raw)) {
|
if (isArray$1(raw)) {
|
||||||
raw.forEach((r22) => createWatcher$1(r22, ctx, publicThis, key));
|
raw.forEach((r22) => createWatcher$1(r22, ctx, publicThis, key));
|
||||||
} else {
|
} else {
|
||||||
@@ -3562,7 +3804,7 @@ function resolveMergedOptions(instance) {
|
|||||||
}
|
}
|
||||||
mergeOptions(resolved, base, optionMergeStrategies);
|
mergeOptions(resolved, base, optionMergeStrategies);
|
||||||
}
|
}
|
||||||
if (isObject$1(base)) {
|
if (isObject$2(base)) {
|
||||||
cache.set(base, resolved);
|
cache.set(base, resolved);
|
||||||
}
|
}
|
||||||
return resolved;
|
return resolved;
|
||||||
@@ -3728,7 +3970,7 @@ function updateProps(instance, rawProps, rawPrevProps, optimized) {
|
|||||||
}
|
}
|
||||||
const value = rawProps[key];
|
const value = rawProps[key];
|
||||||
if (options) {
|
if (options) {
|
||||||
if (hasOwn$1(attrs, key)) {
|
if (hasOwn$2(attrs, key)) {
|
||||||
if (value !== attrs[key]) {
|
if (value !== attrs[key]) {
|
||||||
attrs[key] = value;
|
attrs[key] = value;
|
||||||
hasAttrsChanged = true;
|
hasAttrsChanged = true;
|
||||||
@@ -3759,9 +4001,9 @@ function updateProps(instance, rawProps, rawPrevProps, optimized) {
|
|||||||
let kebabKey;
|
let kebabKey;
|
||||||
for (const key in rawCurrentProps) {
|
for (const key in rawCurrentProps) {
|
||||||
if (!rawProps || // for camelCase
|
if (!rawProps || // for camelCase
|
||||||
!hasOwn$1(rawProps, key) && // it's possible the original props was passed in as kebab-case
|
!hasOwn$2(rawProps, key) && // it's possible the original props was passed in as kebab-case
|
||||||
// and converted to camelCase (#955)
|
// and converted to camelCase (#955)
|
||||||
((kebabKey = hyphenate(key)) === key || !hasOwn$1(rawProps, kebabKey))) {
|
((kebabKey = hyphenate(key)) === key || !hasOwn$2(rawProps, kebabKey))) {
|
||||||
if (options) {
|
if (options) {
|
||||||
if (rawPrevProps && // for camelCase
|
if (rawPrevProps && // for camelCase
|
||||||
(rawPrevProps[key] !== void 0 || // for kebab-case
|
(rawPrevProps[key] !== void 0 || // for kebab-case
|
||||||
@@ -3782,7 +4024,7 @@ function updateProps(instance, rawProps, rawPrevProps, optimized) {
|
|||||||
}
|
}
|
||||||
if (attrs !== rawCurrentProps) {
|
if (attrs !== rawCurrentProps) {
|
||||||
for (const key in attrs) {
|
for (const key in attrs) {
|
||||||
if (!rawProps || !hasOwn$1(rawProps, key) && true) {
|
if (!rawProps || !hasOwn$2(rawProps, key) && true) {
|
||||||
delete attrs[key];
|
delete attrs[key];
|
||||||
hasAttrsChanged = true;
|
hasAttrsChanged = true;
|
||||||
}
|
}
|
||||||
@@ -3807,7 +4049,7 @@ function setFullProps(instance, rawProps, props, attrs) {
|
|||||||
}
|
}
|
||||||
const value = rawProps[key];
|
const value = rawProps[key];
|
||||||
let camelKey;
|
let camelKey;
|
||||||
if (options && hasOwn$1(options, camelKey = camelize(key))) {
|
if (options && hasOwn$2(options, camelKey = camelize(key))) {
|
||||||
if (!needCastKeys || !needCastKeys.includes(camelKey)) {
|
if (!needCastKeys || !needCastKeys.includes(camelKey)) {
|
||||||
props[camelKey] = value;
|
props[camelKey] = value;
|
||||||
} else {
|
} else {
|
||||||
@@ -3832,7 +4074,7 @@ function setFullProps(instance, rawProps, props, attrs) {
|
|||||||
key,
|
key,
|
||||||
castValues[key],
|
castValues[key],
|
||||||
instance,
|
instance,
|
||||||
!hasOwn$1(castValues, key)
|
!hasOwn$2(castValues, key)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3841,7 +4083,7 @@ function setFullProps(instance, rawProps, props, attrs) {
|
|||||||
function resolvePropValue$1(options, props, key, value, instance, isAbsent) {
|
function resolvePropValue$1(options, props, key, value, instance, isAbsent) {
|
||||||
const opt = options[key];
|
const opt = options[key];
|
||||||
if (opt != null) {
|
if (opt != null) {
|
||||||
const hasDefault = hasOwn$1(opt, "default");
|
const hasDefault = hasOwn$2(opt, "default");
|
||||||
if (hasDefault && value === void 0) {
|
if (hasDefault && value === void 0) {
|
||||||
const defaultValue = opt.default;
|
const defaultValue = opt.default;
|
||||||
if (opt.type !== Function && !opt.skipFactory && isFunction$1(defaultValue)) {
|
if (opt.type !== Function && !opt.skipFactory && isFunction$1(defaultValue)) {
|
||||||
@@ -3905,7 +4147,7 @@ function normalizePropsOptions(comp, appContext, asMixin = false) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!raw && !hasExtends) {
|
if (!raw && !hasExtends) {
|
||||||
if (isObject$1(comp)) {
|
if (isObject$2(comp)) {
|
||||||
cache.set(comp, EMPTY_ARR);
|
cache.set(comp, EMPTY_ARR);
|
||||||
}
|
}
|
||||||
return EMPTY_ARR;
|
return EMPTY_ARR;
|
||||||
@@ -3921,7 +4163,7 @@ function normalizePropsOptions(comp, appContext, asMixin = false) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (raw) {
|
} else if (raw) {
|
||||||
if (!isObject$1(raw)) {
|
if (!isObject$2(raw)) {
|
||||||
warn$1$1(`invalid props options`, raw);
|
warn$1$1(`invalid props options`, raw);
|
||||||
}
|
}
|
||||||
for (const key in raw) {
|
for (const key in raw) {
|
||||||
@@ -3940,7 +4182,7 @@ function normalizePropsOptions(comp, appContext, asMixin = false) {
|
|||||||
1
|
1
|
||||||
/* shouldCastTrue */
|
/* shouldCastTrue */
|
||||||
] = stringIndex < 0 || booleanIndex < stringIndex;
|
] = stringIndex < 0 || booleanIndex < stringIndex;
|
||||||
if (booleanIndex > -1 || hasOwn$1(prop, "default")) {
|
if (booleanIndex > -1 || hasOwn$2(prop, "default")) {
|
||||||
needCastKeys.push(normalizedKey);
|
needCastKeys.push(normalizedKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3948,7 +4190,7 @@ function normalizePropsOptions(comp, appContext, asMixin = false) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const res = [normalized, needCastKeys];
|
const res = [normalized, needCastKeys];
|
||||||
if (isObject$1(comp)) {
|
if (isObject$2(comp)) {
|
||||||
cache.set(comp, res);
|
cache.set(comp, res);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
@@ -3996,7 +4238,7 @@ function validateProps(rawProps, props, instance) {
|
|||||||
resolvedValues[key],
|
resolvedValues[key],
|
||||||
opt,
|
opt,
|
||||||
shallowReadonly$1(resolvedValues),
|
shallowReadonly$1(resolvedValues),
|
||||||
!hasOwn$1(rawProps, key) && !hasOwn$1(rawProps, hyphenate(key))
|
!hasOwn$2(rawProps, key) && !hasOwn$2(rawProps, hyphenate(key))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4040,7 +4282,7 @@ function assertType$1(value, type) {
|
|||||||
valid = value instanceof type;
|
valid = value instanceof type;
|
||||||
}
|
}
|
||||||
} else if (expectedType === "Object") {
|
} else if (expectedType === "Object") {
|
||||||
valid = isObject$1(value);
|
valid = isObject$2(value);
|
||||||
} else if (expectedType === "Array") {
|
} else if (expectedType === "Array") {
|
||||||
valid = isArray$1(value);
|
valid = isArray$1(value);
|
||||||
} else if (expectedType === "null") {
|
} else if (expectedType === "null") {
|
||||||
@@ -4374,7 +4616,7 @@ function handleSetupResult(instance, setupResult, isSSR) {
|
|||||||
{
|
{
|
||||||
instance.render = setupResult;
|
instance.render = setupResult;
|
||||||
}
|
}
|
||||||
} else if (isObject$1(setupResult)) {
|
} else if (isObject$2(setupResult)) {
|
||||||
if (isVNode(setupResult)) {
|
if (isVNode(setupResult)) {
|
||||||
warn$1$1(
|
warn$1$1(
|
||||||
`setup() should not return VNodes directly - return a render function instead.`
|
`setup() should not return VNodes directly - return a render function instead.`
|
||||||
@@ -4775,7 +5017,7 @@ function clone(src, seen) {
|
|||||||
copy = {};
|
copy = {};
|
||||||
seen.set(src, copy);
|
seen.set(src, copy);
|
||||||
for (const name in src) {
|
for (const name in src) {
|
||||||
if (hasOwn$1(src, name)) {
|
if (hasOwn$2(src, name)) {
|
||||||
copy[name] = clone(src[name], seen);
|
copy[name] = clone(src[name], seen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4920,7 +5162,7 @@ function setRef$1(instance, isUnmount = false) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
function toSkip(value) {
|
function toSkip(value) {
|
||||||
if (isObject$1(value)) {
|
if (isObject$2(value)) {
|
||||||
markRaw$1(value);
|
markRaw$1(value);
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
@@ -4963,7 +5205,7 @@ function setTemplateRef({ r: r22, f: f2 }, refValue, setupState) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (_isString) {
|
} else if (_isString) {
|
||||||
if (hasOwn$1(setupState, r22)) {
|
if (hasOwn$2(setupState, r22)) {
|
||||||
setupState[r22] = refValue;
|
setupState[r22] = refValue;
|
||||||
}
|
}
|
||||||
} else if (isRef$1(r22)) {
|
} else if (isRef$1(r22)) {
|
||||||
@@ -5628,14 +5870,14 @@ function patchMPEvent(event, instance) {
|
|||||||
event.preventDefault = NOOP;
|
event.preventDefault = NOOP;
|
||||||
event.stopPropagation = NOOP;
|
event.stopPropagation = NOOP;
|
||||||
event.stopImmediatePropagation = NOOP;
|
event.stopImmediatePropagation = NOOP;
|
||||||
if (!hasOwn$1(event, "detail")) {
|
if (!hasOwn$2(event, "detail")) {
|
||||||
event.detail = {};
|
event.detail = {};
|
||||||
}
|
}
|
||||||
if (hasOwn$1(event, "markerId")) {
|
if (hasOwn$2(event, "markerId")) {
|
||||||
event.detail = typeof event.detail === "object" ? event.detail : {};
|
event.detail = typeof event.detail === "object" ? event.detail : {};
|
||||||
event.detail.markerId = event.markerId;
|
event.detail.markerId = event.markerId;
|
||||||
}
|
}
|
||||||
if (isPlainObject$1(event.detail) && hasOwn$1(event.detail, "checked") && !hasOwn$1(event.detail, "value")) {
|
if (isPlainObject$1(event.detail) && hasOwn$2(event.detail, "checked") && !hasOwn$2(event.detail, "value")) {
|
||||||
event.detail.value = event.detail.checked;
|
event.detail.value = event.detail.checked;
|
||||||
}
|
}
|
||||||
if (isPlainObject$1(event.detail)) {
|
if (isPlainObject$1(event.detail)) {
|
||||||
@@ -5671,7 +5913,7 @@ function vFor(source, renderItem) {
|
|||||||
for (let i3 = 0; i3 < source; i3++) {
|
for (let i3 = 0; i3 < source; i3++) {
|
||||||
ret[i3] = renderItem(i3 + 1, i3, i3);
|
ret[i3] = renderItem(i3 + 1, i3, i3);
|
||||||
}
|
}
|
||||||
} else if (isObject$1(source)) {
|
} else if (isObject$2(source)) {
|
||||||
if (source[Symbol.iterator]) {
|
if (source[Symbol.iterator]) {
|
||||||
ret = Array.from(source, (item, i3) => renderItem(item, i3, i3));
|
ret = Array.from(source, (item, i3) => renderItem(item, i3, i3));
|
||||||
} else {
|
} else {
|
||||||
@@ -5972,7 +6214,7 @@ function validateProtocol(name, data, protocol2, onFail) {
|
|||||||
onFail = validateProtocolFail;
|
onFail = validateProtocolFail;
|
||||||
}
|
}
|
||||||
for (const key in protocol2) {
|
for (const key in protocol2) {
|
||||||
const errMsg = validateProp(key, data[key], protocol2[key], !hasOwn$1(data, key));
|
const errMsg = validateProp(key, data[key], protocol2[key], !hasOwn$2(data, key));
|
||||||
if (isString(errMsg)) {
|
if (isString(errMsg)) {
|
||||||
onFail(name, errMsg);
|
onFail(name, errMsg);
|
||||||
}
|
}
|
||||||
@@ -6035,7 +6277,7 @@ function assertType(value, type) {
|
|||||||
valid = value instanceof type;
|
valid = value instanceof type;
|
||||||
}
|
}
|
||||||
} else if (expectedType === "Object") {
|
} else if (expectedType === "Object") {
|
||||||
valid = isObject$1(value);
|
valid = isObject$2(value);
|
||||||
} else if (expectedType === "Array") {
|
} else if (expectedType === "Array") {
|
||||||
valid = isArray$1(value);
|
valid = isArray$1(value);
|
||||||
} else {
|
} else {
|
||||||
@@ -6692,7 +6934,7 @@ function initWrapper(protocols2) {
|
|||||||
argsOption = argsOption(fromArgs, toArgs) || {};
|
argsOption = argsOption(fromArgs, toArgs) || {};
|
||||||
}
|
}
|
||||||
for (const key in fromArgs) {
|
for (const key in fromArgs) {
|
||||||
if (hasOwn$1(argsOption, key)) {
|
if (hasOwn$2(argsOption, key)) {
|
||||||
let keyOption = argsOption[key];
|
let keyOption = argsOption[key];
|
||||||
if (isFunction$1(keyOption)) {
|
if (isFunction$1(keyOption)) {
|
||||||
keyOption = keyOption(fromArgs[key], fromArgs, toArgs);
|
keyOption = keyOption(fromArgs[key], fromArgs, toArgs);
|
||||||
@@ -6710,7 +6952,7 @@ function initWrapper(protocols2) {
|
|||||||
toArgs[key] = processCallback(methodName, callback, returnValue);
|
toArgs[key] = processCallback(methodName, callback, returnValue);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!keepFromArgs && !hasOwn$1(toArgs, key)) {
|
if (!keepFromArgs && !hasOwn$2(toArgs, key)) {
|
||||||
toArgs[key] = fromArgs[key];
|
toArgs[key] = fromArgs[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6732,7 +6974,7 @@ function initWrapper(protocols2) {
|
|||||||
return processArgs(methodName, res, returnValue, {}, realKeepReturnValue);
|
return processArgs(methodName, res, returnValue, {}, realKeepReturnValue);
|
||||||
}
|
}
|
||||||
return function wrapper(methodName, method) {
|
return function wrapper(methodName, method) {
|
||||||
const hasProtocol = hasOwn$1(protocols2, methodName);
|
const hasProtocol = hasOwn$2(protocols2, methodName);
|
||||||
if (!hasProtocol && typeof wx[methodName] !== "function") {
|
if (!hasProtocol && typeof wx[methodName] !== "function") {
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
@@ -7125,13 +7367,13 @@ function initUni(api, protocols2, platform = wx) {
|
|||||||
const wrapper = initWrapper(protocols2);
|
const wrapper = initWrapper(protocols2);
|
||||||
const UniProxyHandlers = {
|
const UniProxyHandlers = {
|
||||||
get(target, key) {
|
get(target, key) {
|
||||||
if (hasOwn$1(target, key)) {
|
if (hasOwn$2(target, key)) {
|
||||||
return target[key];
|
return target[key];
|
||||||
}
|
}
|
||||||
if (hasOwn$1(api, key)) {
|
if (hasOwn$2(api, key)) {
|
||||||
return promisify(key, api[key]);
|
return promisify(key, api[key]);
|
||||||
}
|
}
|
||||||
if (hasOwn$1(baseApis, key)) {
|
if (hasOwn$2(baseApis, key)) {
|
||||||
return promisify(key, baseApis[key]);
|
return promisify(key, baseApis[key]);
|
||||||
}
|
}
|
||||||
return promisify(key, wrapper(key, platform[key]));
|
return promisify(key, wrapper(key, platform[key]));
|
||||||
@@ -7770,7 +8012,7 @@ function isConsoleWritable() {
|
|||||||
function initRuntimeSocketService() {
|
function initRuntimeSocketService() {
|
||||||
const hosts = "192.168.0.111,127.0.0.1";
|
const hosts = "192.168.0.111,127.0.0.1";
|
||||||
const port = "8090";
|
const port = "8090";
|
||||||
const id = "mp-weixin_XfiXYR";
|
const id = "mp-weixin_3E_eeT";
|
||||||
const lazy = typeof swan !== "undefined";
|
const lazy = typeof swan !== "undefined";
|
||||||
let restoreError = lazy ? () => {
|
let restoreError = lazy ? () => {
|
||||||
} : initOnError();
|
} : initOnError();
|
||||||
@@ -7867,7 +8109,7 @@ function initVueIds(vueIds, mpInstance) {
|
|||||||
const EXTRAS = ["externalClasses"];
|
const EXTRAS = ["externalClasses"];
|
||||||
function initExtraOptions(miniProgramComponentOptions, vueOptions) {
|
function initExtraOptions(miniProgramComponentOptions, vueOptions) {
|
||||||
EXTRAS.forEach((name) => {
|
EXTRAS.forEach((name) => {
|
||||||
if (hasOwn$1(vueOptions, name)) {
|
if (hasOwn$2(vueOptions, name)) {
|
||||||
miniProgramComponentOptions[name] = vueOptions[name];
|
miniProgramComponentOptions[name] = vueOptions[name];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -8020,7 +8262,7 @@ function initComponentInstance(instance, options) {
|
|||||||
function initMocks(instance, mpInstance, mocks2) {
|
function initMocks(instance, mpInstance, mocks2) {
|
||||||
const ctx = instance.ctx;
|
const ctx = instance.ctx;
|
||||||
mocks2.forEach((mock) => {
|
mocks2.forEach((mock) => {
|
||||||
if (hasOwn$1(mpInstance, mock)) {
|
if (hasOwn$2(mpInstance, mock)) {
|
||||||
instance[mock] = ctx[mock] = mpInstance[mock];
|
instance[mock] = ctx[mock] = mpInstance[mock];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -8076,7 +8318,7 @@ function findHooks(vueOptions, hooks = /* @__PURE__ */ new Set()) {
|
|||||||
return hooks;
|
return hooks;
|
||||||
}
|
}
|
||||||
function initHook(mpOptions, hook, excludes) {
|
function initHook(mpOptions, hook, excludes) {
|
||||||
if (excludes.indexOf(hook) === -1 && !hasOwn$1(mpOptions, hook)) {
|
if (excludes.indexOf(hook) === -1 && !hasOwn$2(mpOptions, hook)) {
|
||||||
mpOptions[hook] = function(args) {
|
mpOptions[hook] = function(args) {
|
||||||
return this.$vm && this.$vm.$callHook(hook, args);
|
return this.$vm && this.$vm.$callHook(hook, args);
|
||||||
};
|
};
|
||||||
@@ -8109,7 +8351,7 @@ const findMixinRuntimeHooks = /* @__PURE__ */ once(() => {
|
|||||||
const hooks = Object.keys(MINI_PROGRAM_PAGE_RUNTIME_HOOKS);
|
const hooks = Object.keys(MINI_PROGRAM_PAGE_RUNTIME_HOOKS);
|
||||||
mixins.forEach((mixin2) => {
|
mixins.forEach((mixin2) => {
|
||||||
hooks.forEach((hook) => {
|
hooks.forEach((hook) => {
|
||||||
if (hasOwn$1(mixin2, hook) && !runtimeHooks.includes(hook)) {
|
if (hasOwn$2(mixin2, hook) && !runtimeHooks.includes(hook)) {
|
||||||
runtimeHooks.push(hook);
|
runtimeHooks.push(hook);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -8184,13 +8426,13 @@ function initCreateSubpackageApp(parseAppOptions) {
|
|||||||
const globalData = app.globalData;
|
const globalData = app.globalData;
|
||||||
if (globalData) {
|
if (globalData) {
|
||||||
Object.keys(appOptions.globalData).forEach((name) => {
|
Object.keys(appOptions.globalData).forEach((name) => {
|
||||||
if (!hasOwn$1(globalData, name)) {
|
if (!hasOwn$2(globalData, name)) {
|
||||||
globalData[name] = appOptions.globalData[name];
|
globalData[name] = appOptions.globalData[name];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Object.keys(appOptions).forEach((name) => {
|
Object.keys(appOptions).forEach((name) => {
|
||||||
if (!hasOwn$1(app, name)) {
|
if (!hasOwn$2(app, name)) {
|
||||||
app[name] = appOptions[name];
|
app[name] = appOptions[name];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -8474,7 +8716,7 @@ function applyOptions(componentOptions, vueOptions) {
|
|||||||
componentOptions.data = initData();
|
componentOptions.data = initData();
|
||||||
componentOptions.behaviors = initBehaviors(vueOptions);
|
componentOptions.behaviors = initBehaviors(vueOptions);
|
||||||
}
|
}
|
||||||
function parseComponent(vueOptions, { parse, mocks: mocks2, isPage: isPage2, isPageInProject, initRelation: initRelation2, handleLink: handleLink2, initLifetimes: initLifetimes2 }) {
|
function parseComponent(vueOptions, { parse: parse2, mocks: mocks2, isPage: isPage2, isPageInProject, initRelation: initRelation2, handleLink: handleLink2, initLifetimes: initLifetimes2 }) {
|
||||||
vueOptions = vueOptions.default || vueOptions;
|
vueOptions = vueOptions.default || vueOptions;
|
||||||
const options = {
|
const options = {
|
||||||
multipleSlots: true,
|
multipleSlots: true,
|
||||||
@@ -8484,7 +8726,7 @@ function parseComponent(vueOptions, { parse, mocks: mocks2, isPage: isPage2, isP
|
|||||||
};
|
};
|
||||||
if (isArray$1(vueOptions.mixins)) {
|
if (isArray$1(vueOptions.mixins)) {
|
||||||
vueOptions.mixins.forEach((item) => {
|
vueOptions.mixins.forEach((item) => {
|
||||||
if (isObject$1(item.options)) {
|
if (isObject$2(item.options)) {
|
||||||
extend(options, item.options);
|
extend(options, item.options);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -8520,8 +8762,8 @@ function parseComponent(vueOptions, { parse, mocks: mocks2, isPage: isPage2, isP
|
|||||||
{
|
{
|
||||||
initWorkletMethods(mpComponentOptions.methods, vueOptions.methods);
|
initWorkletMethods(mpComponentOptions.methods, vueOptions.methods);
|
||||||
}
|
}
|
||||||
if (parse) {
|
if (parse2) {
|
||||||
parse(mpComponentOptions, { handleLink: handleLink2 });
|
parse2(mpComponentOptions, { handleLink: handleLink2 });
|
||||||
}
|
}
|
||||||
return mpComponentOptions;
|
return mpComponentOptions;
|
||||||
}
|
}
|
||||||
@@ -8549,7 +8791,7 @@ function $destroyComponent(instance) {
|
|||||||
return $destroyComponentFn(instance);
|
return $destroyComponentFn(instance);
|
||||||
}
|
}
|
||||||
function parsePage(vueOptions, parseOptions2) {
|
function parsePage(vueOptions, parseOptions2) {
|
||||||
const { parse, mocks: mocks2, isPage: isPage2, initRelation: initRelation2, handleLink: handleLink2, initLifetimes: initLifetimes2 } = parseOptions2;
|
const { parse: parse2, mocks: mocks2, isPage: isPage2, initRelation: initRelation2, handleLink: handleLink2, initLifetimes: initLifetimes2 } = parseOptions2;
|
||||||
const miniProgramPageOptions = parseComponent(vueOptions, {
|
const miniProgramPageOptions = parseComponent(vueOptions, {
|
||||||
mocks: mocks2,
|
mocks: mocks2,
|
||||||
isPage: isPage2,
|
isPage: isPage2,
|
||||||
@@ -8575,7 +8817,7 @@ function parsePage(vueOptions, parseOptions2) {
|
|||||||
}
|
}
|
||||||
initRuntimeHooks(methods, vueOptions.__runtimeHooks);
|
initRuntimeHooks(methods, vueOptions.__runtimeHooks);
|
||||||
initMixinRuntimeHooks(methods);
|
initMixinRuntimeHooks(methods);
|
||||||
parse && parse(miniProgramPageOptions, { handleLink: handleLink2 });
|
parse2 && parse2(miniProgramPageOptions, { handleLink: handleLink2 });
|
||||||
return miniProgramPageOptions;
|
return miniProgramPageOptions;
|
||||||
}
|
}
|
||||||
function initCreatePage(parseOptions2) {
|
function initCreatePage(parseOptions2) {
|
||||||
@@ -29390,7 +29632,12 @@ const onLoad = /* @__PURE__ */ createHook(ON_LOAD);
|
|||||||
const onReady = /* @__PURE__ */ createHook(ON_READY);
|
const onReady = /* @__PURE__ */ createHook(ON_READY);
|
||||||
const onUnload = /* @__PURE__ */ createHook(ON_UNLOAD);
|
const onUnload = /* @__PURE__ */ createHook(ON_UNLOAD);
|
||||||
var dayjs_min = { exports: {} };
|
var dayjs_min = { exports: {} };
|
||||||
(function(module2, exports2) {
|
var hasRequiredDayjs_min;
|
||||||
|
function requireDayjs_min() {
|
||||||
|
if (hasRequiredDayjs_min)
|
||||||
|
return dayjs_min.exports;
|
||||||
|
hasRequiredDayjs_min = 1;
|
||||||
|
(function(module2, exports2) {
|
||||||
!function(t2, e2) {
|
!function(t2, e2) {
|
||||||
module2.exports = e2();
|
module2.exports = e2();
|
||||||
}(commonjsGlobal, function() {
|
}(commonjsGlobal, function() {
|
||||||
@@ -29678,8 +29925,10 @@ var dayjs_min = { exports: {} };
|
|||||||
return O2(1e3 * t3);
|
return O2(1e3 * t3);
|
||||||
}, O2.en = D2[g2], O2.Ls = D2, O2.p = {}, O2;
|
}, O2.en = D2[g2], O2.Ls = D2, O2.p = {}, O2;
|
||||||
});
|
});
|
||||||
})(dayjs_min);
|
})(dayjs_min);
|
||||||
var dayjs_minExports = dayjs_min.exports;
|
return dayjs_min.exports;
|
||||||
|
}
|
||||||
|
var dayjs_minExports = requireDayjs_min();
|
||||||
const dayjs = /* @__PURE__ */ getDefaultExportFromCjs(dayjs_minExports);
|
const dayjs = /* @__PURE__ */ getDefaultExportFromCjs(dayjs_minExports);
|
||||||
var localeData$1 = { exports: {} };
|
var localeData$1 = { exports: {} };
|
||||||
(function(module2, exports2) {
|
(function(module2, exports2) {
|
||||||
@@ -29791,7 +30040,7 @@ const isSameOrBefore = /* @__PURE__ */ getDefaultExportFromCjs(isSameOrBeforeExp
|
|||||||
var zhCn = { exports: {} };
|
var zhCn = { exports: {} };
|
||||||
(function(module2, exports2) {
|
(function(module2, exports2) {
|
||||||
!function(e2, _2) {
|
!function(e2, _2) {
|
||||||
module2.exports = _2(dayjs_minExports);
|
module2.exports = _2(requireDayjs_min());
|
||||||
}(commonjsGlobal, function(e2) {
|
}(commonjsGlobal, function(e2) {
|
||||||
function _2(e3) {
|
function _2(e3) {
|
||||||
return e3 && "object" == typeof e3 && "default" in e3 ? e3 : { default: e3 };
|
return e3 && "object" == typeof e3 && "default" in e3 ? e3 : { default: e3 };
|
||||||
@@ -33983,6 +34232,7 @@ exports.hasInjectionContext = hasInjectionContext;
|
|||||||
exports.hasQueueJob = hasQueueJob;
|
exports.hasQueueJob = hasQueueJob;
|
||||||
exports.i = i2;
|
exports.i = i2;
|
||||||
exports.index = index;
|
exports.index = index;
|
||||||
|
exports.initVueI18n = initVueI18n;
|
||||||
exports.inject = inject$1;
|
exports.inject = inject$1;
|
||||||
exports.injectHook = injectHook;
|
exports.injectHook = injectHook;
|
||||||
exports.invalidateJob = invalidateJob;
|
exports.invalidateJob = invalidateJob;
|
||||||
|
|||||||
@@ -251,6 +251,13 @@ const NationalDictionary = {
|
|||||||
UK: "英国",
|
UK: "英国",
|
||||||
WF: "瓦利斯"
|
WF: "瓦利斯"
|
||||||
};
|
};
|
||||||
const countryNamesArray = Object.values(NationalDictionary);
|
function convertNationalDictToOptions(dict) {
|
||||||
exports.countryNamesArray = countryNamesArray;
|
return Object.entries(dict).map(([code, name]) => ({
|
||||||
|
label: name,
|
||||||
|
value: name
|
||||||
|
// 将 value 改为国家名称
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
const optionsArray = convertNationalDictToOptions(NationalDictionary);
|
||||||
|
exports.optionsArray = optionsArray;
|
||||||
//# sourceMappingURL=../../.sourcemap/mp-weixin/components/NationalDictionary.js.map
|
//# sourceMappingURL=../../.sourcemap/mp-weixin/components/NationalDictionary.js.map
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
const common_vendor = require("../../common/vendor.js");
|
const common_vendor = require("../../common/vendor.js");
|
||||||
|
const components_request = require("../request.js");
|
||||||
const common_assets = require("../../common/assets.js");
|
const common_assets = require("../../common/assets.js");
|
||||||
const _sfc_main = {
|
const _sfc_main = {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
title: "Hello",
|
title: "Hello",
|
||||||
Gender: true,
|
Gender: true,
|
||||||
|
page: 0,
|
||||||
// 列表数据
|
// 列表数据
|
||||||
list: [
|
list: [
|
||||||
{
|
{
|
||||||
@@ -13,105 +15,36 @@ const _sfc_main = {
|
|||||||
id: "9088",
|
id: "9088",
|
||||||
gender: "男",
|
gender: "男",
|
||||||
score: 8.8
|
score: 8.8
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "极乐世界2",
|
|
||||||
id: "9089",
|
|
||||||
gender: "女",
|
|
||||||
score: 7.8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "极乐世界3",
|
|
||||||
id: "9090",
|
|
||||||
gender: "男",
|
|
||||||
score: 9.8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "极乐世界3",
|
|
||||||
id: "9090",
|
|
||||||
gender: "男",
|
|
||||||
score: 9.8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "极乐世界3",
|
|
||||||
id: "9090",
|
|
||||||
gender: "男",
|
|
||||||
score: 9.8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "极乐世界3",
|
|
||||||
id: "9090",
|
|
||||||
gender: "男",
|
|
||||||
score: 9.8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "极乐世界3",
|
|
||||||
id: "9090",
|
|
||||||
gender: "男",
|
|
||||||
score: 9.8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "极乐世界3",
|
|
||||||
id: "9090",
|
|
||||||
gender: "男",
|
|
||||||
score: 9.8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "极乐世界3",
|
|
||||||
id: "9090",
|
|
||||||
gender: "男",
|
|
||||||
score: 9.8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "极乐世界3",
|
|
||||||
id: "9090",
|
|
||||||
gender: "男",
|
|
||||||
score: 9.8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "极乐世界3",
|
|
||||||
id: "9090",
|
|
||||||
gender: "男",
|
|
||||||
score: 9.8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "极乐世界3",
|
|
||||||
id: "9090",
|
|
||||||
gender: "男",
|
|
||||||
score: 9.8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "极乐世界3",
|
|
||||||
id: "9090",
|
|
||||||
gender: "男",
|
|
||||||
score: 9.8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "极乐世界3",
|
|
||||||
id: "9090",
|
|
||||||
gender: "男",
|
|
||||||
score: 9.8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "极乐世界3",
|
|
||||||
id: "9090",
|
|
||||||
gender: "男",
|
|
||||||
score: 9.8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "极乐世界3",
|
|
||||||
id: "9090",
|
|
||||||
gender: "男",
|
|
||||||
score: 9.8
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
// 列表数据结束
|
// 列表数据结束
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
onLoad() {
|
mounted() {
|
||||||
|
this.pkList();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// 方法定义
|
async pkList() {
|
||||||
|
const res = await components_request.request({
|
||||||
|
url: "pk/pkList",
|
||||||
|
method: "GET",
|
||||||
|
data: {
|
||||||
|
status: 0,
|
||||||
|
page: this.page,
|
||||||
|
Size: 10
|
||||||
|
},
|
||||||
|
userInfo: false
|
||||||
|
});
|
||||||
|
common_vendor.index.__f__("log", "at components/contentList/contentList.vue:61", res);
|
||||||
|
if (res.code === 200) {
|
||||||
|
this.list.concat(res.data);
|
||||||
|
common_vendor.index.__f__("log", "at components/contentList/contentList.vue:64", this.list);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onScrollToLower() {
|
||||||
|
this.page++;
|
||||||
|
this.pkList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (!Array) {
|
if (!Array) {
|
||||||
@@ -137,7 +70,8 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|||||||
b: common_assets._imports_0$4,
|
b: common_assets._imports_0$4,
|
||||||
c: $data.Gender,
|
c: $data.Gender,
|
||||||
d: $data.Gender ? 1 : "",
|
d: $data.Gender ? 1 : "",
|
||||||
e: !$data.Gender ? 1 : ""
|
e: !$data.Gender ? 1 : "",
|
||||||
|
f: common_vendor.o$1((...args) => $options.onScrollToLower && $options.onScrollToLower(...args))
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-4813d59a"]]);
|
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-4813d59a"]]);
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
<scroll-view scroll-y="true" class="scroll data-v-4813d59a"><uni-card wx:for="{{a}}" wx:for-item="item" u-s="{{['d']}}" class="content-list data-v-4813d59a" u-i="{{item.g}}" bind:__l="__l"><image class="headShot data-v-4813d59a" src="{{b}}" mode="scaleToFill"/><view class="content-list-title data-v-4813d59a"><view class="cardname data-v-4813d59a">{{item.a}}</view><view class="content-list-info data-v-4813d59a"><view class="{{['data-v-4813d59a', d && 'Gendermale', e && 'Genderfemale']}}"><image wx:if="{{c}}" class="Genderimg data-v-4813d59a" src="{{item.b}}" mode="scaleToFill"/><image wx:else class="Genderimg data-v-4813d59a" src="{{item.c}}" mode="scaleToFill"/><view class="age data-v-4813d59a">{{item.d}}</view></view><view class="RoomID data-v-4813d59a">房间ID:{{item.e}}</view><view class="Charm data-v-4813d59a">魅力值</view><view class="charmValue data-v-4813d59a">{{item.f}}W</view></view></view></uni-card></scroll-view>
|
<scroll-view scroll-y="true" class="scroll data-v-4813d59a" lower-threshold="100" bindscrolltolower="{{f}}"><uni-card wx:for="{{a}}" wx:for-item="item" u-s="{{['d']}}" class="content-list data-v-4813d59a" u-i="{{item.g}}" bind:__l="__l"><image class="headShot data-v-4813d59a" src="{{b}}" mode="scaleToFill"/><view class="content-list-title data-v-4813d59a"><view class="cardname data-v-4813d59a">{{item.a}}</view><view class="content-list-info data-v-4813d59a"><view class="{{['data-v-4813d59a', d && 'Gendermale', e && 'Genderfemale']}}"><image wx:if="{{c}}" class="Genderimg data-v-4813d59a" src="{{item.b}}" mode="scaleToFill"/><image wx:else class="Genderimg data-v-4813d59a" src="{{item.c}}" mode="scaleToFill"/><view class="age data-v-4813d59a">{{item.d}}</view></view><view class="RoomID data-v-4813d59a">房间ID:{{item.e}}</view><view class="Charm data-v-4813d59a">魅力值</view><view class="charmValue data-v-4813d59a">{{item.f}}W</view></view></view></uni-card></scroll-view>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
.scroll.data-v-4813d59a {
|
.scroll.data-v-4813d59a {
|
||||||
height: 100%;
|
height: 90%;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|||||||
@@ -4,25 +4,25 @@ function request(urldata) {
|
|||||||
const { url, data, method, header, userInfo } = urldata;
|
const { url, data, method, header, userInfo } = urldata;
|
||||||
const baseUrl = "http://192.168.0.218:8086/" + url;
|
const baseUrl = "http://192.168.0.218:8086/" + url;
|
||||||
if (userInfo) {
|
if (userInfo) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
common_vendor.index.getStorage({
|
common_vendor.index.getStorage({
|
||||||
key: "userinfo",
|
key: "userinfo",
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
if (res.data) {
|
if (res.data) {
|
||||||
if (res.data.nickName) {
|
if (res.data.nickName) {
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
common_vendor.index.request({
|
common_vendor.index.request({
|
||||||
url: baseUrl,
|
url: baseUrl,
|
||||||
data,
|
data,
|
||||||
method,
|
method,
|
||||||
header,
|
header,
|
||||||
success: function(res2) {
|
success: function(res2) {
|
||||||
|
common_vendor.index.__f__("log", "at components/request.js:19", "请求成功1", res2.data);
|
||||||
resolve(res2.data);
|
resolve(res2.data);
|
||||||
},
|
},
|
||||||
fail: function(res2) {
|
fail: function(res2) {
|
||||||
reject(res2);
|
reject(res2);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
this.$global.lastPage = common_vendor.index.page.route;
|
this.$global.lastPage = common_vendor.index.page.route;
|
||||||
common_vendor.index.reLaunch({ url: "/pages/UserInformation/UserInformation" });
|
common_vendor.index.reLaunch({ url: "/pages/UserInformation/UserInformation" });
|
||||||
@@ -31,8 +31,12 @@ function request(urldata) {
|
|||||||
this.$global.lastPage = common_vendor.index.page.route;
|
this.$global.lastPage = common_vendor.index.page.route;
|
||||||
common_vendor.index.navigateTo({ url: "/pages/login/login" });
|
common_vendor.index.navigateTo({ url: "/pages/login/login" });
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
fail: function(res) {
|
||||||
|
reject(res);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
common_vendor.index.request({
|
common_vendor.index.request({
|
||||||
@@ -41,6 +45,7 @@ function request(urldata) {
|
|||||||
method,
|
method,
|
||||||
header,
|
header,
|
||||||
success: function(res) {
|
success: function(res) {
|
||||||
|
common_vendor.index.__f__("log", "at components/request.js:48", "请求成功2", res);
|
||||||
resolve(res.data);
|
resolve(res.data);
|
||||||
},
|
},
|
||||||
fail: function(res) {
|
fail: function(res) {
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
position: fixed;
|
position: fixed;
|
||||||
top: 400rpx;
|
top: 400rpx;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
bottom: 50rpx;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 1300rpx;
|
/* height: 1300rpx; */
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"navigationBarTitleText": "新增PK",
|
"navigationBarTitleText": "新增PK",
|
||||||
"usingComponents": {
|
"usingComponents": {
|
||||||
"uni-combox": "../../uni_modules/uni-combox/components/uni-combox/uni-combox",
|
|
||||||
"wht-select": "../../uni_modules/wht-select/components/wht-select/wht-select",
|
"wht-select": "../../uni_modules/wht-select/components/wht-select/wht-select",
|
||||||
"uni-number-box": "../../uni_modules/uni-number-box/components/uni-number-box/uni-number-box",
|
"uni-number-box": "../../uni_modules/uni-number-box/components/uni-number-box/uni-number-box",
|
||||||
|
"uni-datetime-picker": "../../uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker",
|
||||||
"uni-easyinput": "../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput"
|
"uni-easyinput": "../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1 +1 @@
|
|||||||
<view wx:if="{{a}}" class="Mask data-v-96d38e2b" bindtap="{{o}}"><view class="data-v-96d38e2b" catchtap="{{n}}"><view class="container data-v-96d38e2b"><image class="Fork data-v-96d38e2b" bindtap="{{b}}" src="{{c}}" mode="scaleToFill"/><view class="Title data-v-96d38e2b">发布新PK</view><view class="Individual data-v-96d38e2b"><view class="NameAnchor data-v-96d38e2b"><input class="NameAnchorcss data-v-96d38e2b" bindinput="{{d}}" placeholder="主播名称"/></view><view class="Gender data-v-96d38e2b"><uni-combox wx:if="{{f}}" class="Gendercss data-v-96d38e2b" u-i="96d38e2b-0" bind:__l="__l" bindupdateModelValue="{{e}}" u-p="{{f}}"></uni-combox></view></view><view class="Accountnumber data-v-96d38e2b"><wht-select wx:if="{{h}}" class="data-v-96d38e2b" u-i="96d38e2b-1" bind:__l="__l" bindupdateModelValue="{{g}}" u-p="{{h}}"/><view class="Coins data-v-96d38e2b"><uni-number-box wx:if="{{j}}" class="number-box data-v-96d38e2b" u-i="96d38e2b-2" bind:__l="__l" bindupdateModelValue="{{i}}" u-p="{{j}}"></uni-number-box></view></view><view class="Remarkscss data-v-96d38e2b"><uni-easyinput wx:if="{{l}}" class="data-v-96d38e2b" u-i="96d38e2b-3" bind:__l="__l" bindupdateModelValue="{{k}}" u-p="{{l}}"></uni-easyinput></view><view class="Publish data-v-96d38e2b"><button bindtap="{{m}}" class="Publishcss data-v-96d38e2b">发布</button></view></view></view></view>
|
<view wx:if="{{a}}" class="Mask data-v-96d38e2b" bindtap="{{x}}"><view class="data-v-96d38e2b" catchtap="{{w}}"><view class="container data-v-96d38e2b"><image class="Fork data-v-96d38e2b" bindtap="{{b}}" src="{{c}}" mode="scaleToFill"/><view class="Title data-v-96d38e2b">发布新PK</view><view class="Individual data-v-96d38e2b"><view class="NameAnchor data-v-96d38e2b"><input class="NameAnchorcss data-v-96d38e2b" bindinput="{{d}}" placeholder="主播名称"/><view wx:if="{{e}}" class="Hint data-v-96d38e2b">请填写主播名称</view></view><view class="Gender data-v-96d38e2b"><wht-select wx:if="{{g}}" class="data-v-96d38e2b" style="width:300rpx" bindchange="{{f}}" u-i="96d38e2b-0" bind:__l="__l" u-p="{{g}}"/><view wx:if="{{h}}" class="Hint data-v-96d38e2b">请选择性别</view></view></view><view class="Accountnumber data-v-96d38e2b"><view class="Coins data-v-96d38e2b"><wht-select wx:if="{{j}}" class="data-v-96d38e2b" style="width:300rpx" bindchange="{{i}}" u-i="96d38e2b-1" bind:__l="__l" u-p="{{j}}"/><view wx:if="{{k}}" class="Hint data-v-96d38e2b">请选择国家</view></view><view class="Coins data-v-96d38e2b"><view class="number-box data-v-96d38e2b"><view class="number-box-title data-v-96d38e2b">金币:</view><uni-number-box wx:if="{{m}}" class="data-v-96d38e2b" u-i="96d38e2b-2" bind:__l="__l" bindupdateModelValue="{{l}}" u-p="{{m}}"></uni-number-box></view><view wx:if="{{n}}" class="Hint data-v-96d38e2b">请填写金币数量</view></view></view><view class="time data-v-96d38e2b"><uni-datetime-picker wx:if="{{q}}" class="data-v-96d38e2b" bindchange="{{o}}" u-i="96d38e2b-3" bind:__l="__l" bindupdateModelValue="{{p}}" u-p="{{q}}"/><view wx:if="{{r}}" class="Hint data-v-96d38e2b">请选择日期</view></view><view class="Remarkscss data-v-96d38e2b"><uni-easyinput wx:if="{{t}}" class="data-v-96d38e2b" u-i="96d38e2b-4" bind:__l="__l" bindupdateModelValue="{{s}}" u-p="{{t}}"></uni-easyinput></view><view class="Publish data-v-96d38e2b"><button bindtap="{{v}}" class="Publishcss data-v-96d38e2b">发布</button></view></view></view></view>
|
||||||
@@ -1,26 +1,30 @@
|
|||||||
|
|
||||||
.Mask.data-v-96d38e2b{
|
.Mask.data-v-96d38e2b {
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
background: #00000076;
|
background: #00000076;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column-reverse;
|
flex-direction: column-reverse;
|
||||||
}
|
}
|
||||||
|
.Hint.data-v-96d38e2b {
|
||||||
|
color: red;
|
||||||
|
font-size: 20rpx;
|
||||||
|
}
|
||||||
.container.data-v-96d38e2b {
|
.container.data-v-96d38e2b {
|
||||||
display: flex;
|
display: flex;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 900rpx;
|
height: 100%;
|
||||||
}
|
}
|
||||||
.Fork.data-v-96d38e2b{
|
.Fork.data-v-96d38e2b {
|
||||||
width: 50rpx;
|
width: 50rpx;
|
||||||
height: 50rpx;
|
height: 50rpx;
|
||||||
margin-top: 20rpx;
|
margin-top: 20rpx;
|
||||||
/* margin-bottom: 40rpx; */
|
/* margin-bottom: 40rpx; */
|
||||||
margin-left: 90%;
|
margin-left: 90%;
|
||||||
}
|
}
|
||||||
.Title.data-v-96d38e2b{
|
.Title.data-v-96d38e2b {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 30rpx;
|
height: 30rpx;
|
||||||
font-size: 50rpx;
|
font-size: 50rpx;
|
||||||
@@ -29,51 +33,49 @@
|
|||||||
margin-top: 40rpx;
|
margin-top: 40rpx;
|
||||||
margin-bottom: 40rpx;
|
margin-bottom: 40rpx;
|
||||||
}
|
}
|
||||||
.Individual.data-v-96d38e2b{
|
.Individual.data-v-96d38e2b {
|
||||||
display: flex;
|
display: flex;
|
||||||
/* justify-content: center; */
|
/* justify-content: center; */
|
||||||
}
|
}
|
||||||
.NameAnchor.data-v-96d38e2b{
|
.NameAnchor.data-v-96d38e2b {
|
||||||
margin: 40rpx;
|
margin: 40rpx;
|
||||||
}
|
}
|
||||||
.NameAnchorcss.data-v-96d38e2b{
|
.time.data-v-96d38e2b {
|
||||||
|
width: 90%;
|
||||||
|
margin-left: 5%;
|
||||||
|
}
|
||||||
|
.NameAnchorcss.data-v-96d38e2b {
|
||||||
width: 300rpx;
|
width: 300rpx;
|
||||||
height: 85rpx;
|
height: 85rpx;
|
||||||
border: 1rpx solid #ccc;
|
border: 1rpx solid #ccc;
|
||||||
border-radius: 10rpx;
|
border-radius: 10rpx;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
.Gender.data-v-96d38e2b{
|
.Gender.data-v-96d38e2b {
|
||||||
margin: 40rpx;
|
|
||||||
}
|
|
||||||
.Gendercss.data-v-96d38e2b{
|
|
||||||
width: 300rpx;
|
width: 300rpx;
|
||||||
height: 80rpx;
|
height: 80rpx;
|
||||||
text-align: center;
|
margin: 40rpx;
|
||||||
}
|
}
|
||||||
.Accountnumber.data-v-96d38e2b{
|
.Accountnumber.data-v-96d38e2b {
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
.Country.data-v-96d38e2b{
|
.Coins.data-v-96d38e2b {
|
||||||
}
|
|
||||||
.Countrycss.data-v-96d38e2b{
|
|
||||||
margin: 40rpx;
|
|
||||||
width: 300rpx;
|
|
||||||
height: 65rpx;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
.Coins.data-v-96d38e2b{
|
|
||||||
margin: 40rpx;
|
margin: 40rpx;
|
||||||
width: 300rpx;
|
width: 300rpx;
|
||||||
height: 65rpx;
|
height: 65rpx;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
/* align-items: center; */
|
||||||
}
|
}
|
||||||
.number-box.data-v-96d38e2b {
|
.number-box.data-v-96d38e2b {
|
||||||
|
display: flex;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
.Remarkscss.data-v-96d38e2b{
|
.number-box-title.data-v-96d38e2b {
|
||||||
|
margin-right: 20rpx;
|
||||||
|
}
|
||||||
|
.Remarkscss.data-v-96d38e2b {
|
||||||
width: 90%;
|
width: 90%;
|
||||||
margin-top: 30rpx;
|
margin-top: 30rpx;
|
||||||
margin-left: 5%;
|
margin-left: 5%;
|
||||||
@@ -81,11 +83,11 @@
|
|||||||
margin-bottom: 50rpx;
|
margin-bottom: 50rpx;
|
||||||
border-radius: 10rpx;
|
border-radius: 10rpx;
|
||||||
}
|
}
|
||||||
.Publish.data-v-96d38e2b{
|
.Publish.data-v-96d38e2b {
|
||||||
margin-bottom: 50rpx;
|
margin-bottom: 50rpx;
|
||||||
width: 90%;
|
width: 90%;
|
||||||
margin-left: 5%;
|
margin-left: 5%;
|
||||||
}
|
}
|
||||||
.Publishcss.data-v-96d38e2b{
|
.Publishcss.data-v-96d38e2b {
|
||||||
background-color: #0048ff94;
|
background-color: #0048ff94;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,161 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
const common_vendor = require("../../../../common/vendor.js");
|
|
||||||
const _sfc_main = {
|
|
||||||
name: "uniCombox",
|
|
||||||
emits: ["input", "update:modelValue"],
|
|
||||||
props: {
|
|
||||||
clearAble: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false
|
|
||||||
},
|
|
||||||
border: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true
|
|
||||||
},
|
|
||||||
label: {
|
|
||||||
type: String,
|
|
||||||
default: ""
|
|
||||||
},
|
|
||||||
labelWidth: {
|
|
||||||
type: String,
|
|
||||||
default: "auto"
|
|
||||||
},
|
|
||||||
placeholder: {
|
|
||||||
type: String,
|
|
||||||
default: ""
|
|
||||||
},
|
|
||||||
candidates: {
|
|
||||||
type: Array,
|
|
||||||
default() {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
},
|
|
||||||
emptyTips: {
|
|
||||||
type: String,
|
|
||||||
default: "无匹配项"
|
|
||||||
},
|
|
||||||
modelValue: {
|
|
||||||
type: [String, Number],
|
|
||||||
default: ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
showSelector: false,
|
|
||||||
inputVal: ""
|
|
||||||
};
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
labelStyle() {
|
|
||||||
if (this.labelWidth === "auto") {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
return `width: ${this.labelWidth}`;
|
|
||||||
},
|
|
||||||
filterCandidates() {
|
|
||||||
return this.candidates.filter((item) => {
|
|
||||||
return item.toString().indexOf(this.inputVal) > -1;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
filterCandidatesLength() {
|
|
||||||
return this.filterCandidates.length;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
modelValue: {
|
|
||||||
handler(newVal) {
|
|
||||||
this.inputVal = newVal;
|
|
||||||
},
|
|
||||||
immediate: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
toggleSelector() {
|
|
||||||
this.showSelector = !this.showSelector;
|
|
||||||
},
|
|
||||||
onFocus() {
|
|
||||||
this.showSelector = true;
|
|
||||||
},
|
|
||||||
onBlur() {
|
|
||||||
setTimeout(() => {
|
|
||||||
this.showSelector = false;
|
|
||||||
}, 153);
|
|
||||||
},
|
|
||||||
onSelectorClick(index) {
|
|
||||||
this.inputVal = this.filterCandidates[index];
|
|
||||||
this.showSelector = false;
|
|
||||||
this.$emit("input", this.inputVal);
|
|
||||||
this.$emit("update:modelValue", this.inputVal);
|
|
||||||
},
|
|
||||||
onInput() {
|
|
||||||
setTimeout(() => {
|
|
||||||
this.$emit("input", this.inputVal);
|
|
||||||
this.$emit("update:modelValue", this.inputVal);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
clean() {
|
|
||||||
this.inputVal = "";
|
|
||||||
this.onInput();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if (!Array) {
|
|
||||||
const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
|
|
||||||
_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.label
|
|
||||||
}, $props.label ? {
|
|
||||||
b: common_vendor.t($props.label),
|
|
||||||
c: common_vendor.s($options.labelStyle)
|
|
||||||
} : {}, {
|
|
||||||
d: $props.placeholder,
|
|
||||||
e: common_vendor.o$1([($event) => $data.inputVal = $event.detail.value, (...args) => $options.onInput && $options.onInput(...args)]),
|
|
||||||
f: common_vendor.o$1((...args) => $options.onFocus && $options.onFocus(...args)),
|
|
||||||
g: common_vendor.o$1((...args) => $options.onBlur && $options.onBlur(...args)),
|
|
||||||
h: $data.inputVal,
|
|
||||||
i: !$data.inputVal || !$props.clearAble
|
|
||||||
}, !$data.inputVal || !$props.clearAble ? {
|
|
||||||
j: common_vendor.o$1($options.toggleSelector),
|
|
||||||
k: common_vendor.p({
|
|
||||||
type: $data.showSelector ? "top" : "bottom",
|
|
||||||
size: "30",
|
|
||||||
color: "#999"
|
|
||||||
})
|
|
||||||
} : {}, {
|
|
||||||
l: $data.inputVal && $props.clearAble
|
|
||||||
}, $data.inputVal && $props.clearAble ? {
|
|
||||||
m: common_vendor.o$1($options.clean),
|
|
||||||
n: common_vendor.p({
|
|
||||||
type: "clear",
|
|
||||||
size: "24",
|
|
||||||
color: "#999",
|
|
||||||
width: "60rpx",
|
|
||||||
height: "60rpx"
|
|
||||||
})
|
|
||||||
} : {}, {
|
|
||||||
o: $data.showSelector
|
|
||||||
}, $data.showSelector ? common_vendor.e({
|
|
||||||
p: $options.filterCandidatesLength === 0
|
|
||||||
}, $options.filterCandidatesLength === 0 ? {
|
|
||||||
q: common_vendor.t($props.emptyTips)
|
|
||||||
} : {}, {
|
|
||||||
r: common_vendor.f($options.filterCandidates, (item, index, i0) => {
|
|
||||||
return {
|
|
||||||
a: common_vendor.t(item),
|
|
||||||
b: index,
|
|
||||||
c: common_vendor.o$1(($event) => $options.onSelectorClick(index), index)
|
|
||||||
};
|
|
||||||
})
|
|
||||||
}) : {}, {
|
|
||||||
s: common_vendor.n($props.border ? "" : "uni-combox__no-border")
|
|
||||||
});
|
|
||||||
}
|
|
||||||
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-e602780e"]]);
|
|
||||||
wx.createComponent(Component);
|
|
||||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uni-combox/components/uni-combox/uni-combox.js.map
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<view class="{{['uni-combox', 'data-v-e602780e', s]}}"><view wx:if="{{a}}" class="uni-combox__label data-v-e602780e" style="{{c}}"><text class="data-v-e602780e">{{b}}</text></view><view class="uni-combox__input-box data-v-e602780e"><input class="uni-combox__input data-v-e602780e" type="text" placeholder="{{d}}" placeholder-class="uni-combox__input-plac" bindinput="{{e}}" bindfocus="{{f}}" bindblur="{{g}}" value="{{h}}"/><uni-icons wx:if="{{i}}" class="data-v-e602780e" bindclick="{{j}}" u-i="e602780e-0" bind:__l="__l" u-p="{{k}}"></uni-icons><uni-icons wx:if="{{l}}" class="data-v-e602780e" bindclick="{{m}}" u-i="e602780e-1" bind:__l="__l" u-p="{{n}}"></uni-icons></view><view wx:if="{{o}}" class="uni-combox__selector data-v-e602780e"><view class="uni-popper__arrow data-v-e602780e"></view><scroll-view scroll-y="true" class="uni-combox__selector-scroll data-v-e602780e"><view wx:if="{{p}}" class="uni-combox__selector-empty data-v-e602780e"><text class="data-v-e602780e">{{q}}</text></view><view wx:for="{{r}}" wx:for-item="item" wx:key="b" class="uni-combox__selector-item data-v-e602780e" bindtap="{{item.c}}"><text class="data-v-e602780e">{{item.a}}</text></view></scroll-view></view></view>
|
|
||||||
@@ -1,126 +0,0 @@
|
|||||||
/**
|
|
||||||
* 这里是uni-app内置的常用样式变量
|
|
||||||
*
|
|
||||||
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
|
|
||||||
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
|
|
||||||
*
|
|
||||||
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
|
|
||||||
*/
|
|
||||||
/* 颜色变量 */
|
|
||||||
/* 行为相关颜色 */
|
|
||||||
/* 文字基本颜色 */
|
|
||||||
/* 背景颜色 */
|
|
||||||
/* 边框颜色 */
|
|
||||||
/* 尺寸变量 */
|
|
||||||
/* 文字尺寸 */
|
|
||||||
/* 图片尺寸 */
|
|
||||||
/* Border Radius */
|
|
||||||
/* 水平间距 */
|
|
||||||
/* 垂直间距 */
|
|
||||||
/* 透明度 */
|
|
||||||
/* 文章场景相关 */
|
|
||||||
.uni-combox.data-v-e602780e {
|
|
||||||
font-size: 14px;
|
|
||||||
border: 1px solid #DCDFE6;
|
|
||||||
border-radius: 4px;
|
|
||||||
padding: 6px 10px;
|
|
||||||
position: relative;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
.uni-combox__icon.data-v-e602780e {
|
|
||||||
border: 1px solid #004cff;
|
|
||||||
width: 70rpx;
|
|
||||||
height: 70rpx;
|
|
||||||
}
|
|
||||||
.uni-combox__label.data-v-e602780e {
|
|
||||||
font-size: 16px;
|
|
||||||
line-height: 22px;
|
|
||||||
padding-right: 10px;
|
|
||||||
color: #999999;
|
|
||||||
}
|
|
||||||
.uni-combox__input-box.data-v-e602780e {
|
|
||||||
position: relative;
|
|
||||||
display: flex;
|
|
||||||
flex: 1;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
.uni-combox__input.data-v-e602780e {
|
|
||||||
flex: 1;
|
|
||||||
font-size: 14px;
|
|
||||||
height: 22px;
|
|
||||||
line-height: 22px;
|
|
||||||
}
|
|
||||||
.uni-combox__input-plac.data-v-e602780e {
|
|
||||||
font-size: 14px;
|
|
||||||
color: #999;
|
|
||||||
}
|
|
||||||
.uni-combox__selector.data-v-e602780e {
|
|
||||||
box-sizing: border-box;
|
|
||||||
position: absolute;
|
|
||||||
top: calc(100% + 12px);
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
background-color: #FFFFFF;
|
|
||||||
border: 1px solid #EBEEF5;
|
|
||||||
border-radius: 6px;
|
|
||||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
|
||||||
z-index: 2;
|
|
||||||
padding: 4px 0;
|
|
||||||
}
|
|
||||||
.uni-combox__selector-scroll.data-v-e602780e {
|
|
||||||
position: relative;
|
|
||||||
z-index: 999;
|
|
||||||
max-height: 200px;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
.uni-combox__selector-empty.data-v-e602780e,
|
|
||||||
.uni-combox__selector-item.data-v-e602780e {
|
|
||||||
display: flex;
|
|
||||||
cursor: pointer;
|
|
||||||
line-height: 36px;
|
|
||||||
font-size: 14px;
|
|
||||||
text-align: center;
|
|
||||||
padding: 0px 10px;
|
|
||||||
}
|
|
||||||
.uni-combox__selector-item.data-v-e602780e:hover {
|
|
||||||
background-color: #f9f9f9;
|
|
||||||
}
|
|
||||||
.uni-combox__selector-empty.data-v-e602780e:last-child,
|
|
||||||
.uni-combox__selector-item.data-v-e602780e:last-child {
|
|
||||||
border-bottom: none;
|
|
||||||
}
|
|
||||||
.uni-popper__arrow.data-v-e602780e,
|
|
||||||
.uni-popper__arrow.data-v-e602780e::after {
|
|
||||||
position: absolute;
|
|
||||||
display: block;
|
|
||||||
width: 0;
|
|
||||||
height: 0;
|
|
||||||
border-color: transparent;
|
|
||||||
border-style: solid;
|
|
||||||
border-width: 6px;
|
|
||||||
}
|
|
||||||
.uni-popper__arrow.data-v-e602780e {
|
|
||||||
filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.03));
|
|
||||||
top: -6px;
|
|
||||||
left: 10%;
|
|
||||||
margin-right: 3px;
|
|
||||||
border-top-width: 0;
|
|
||||||
border-bottom-color: #EBEEF5;
|
|
||||||
}
|
|
||||||
.uni-popper__arrow.data-v-e602780e::after {
|
|
||||||
content: " ";
|
|
||||||
top: 1px;
|
|
||||||
margin-left: -6px;
|
|
||||||
border-top-width: 0;
|
|
||||||
border-bottom-color: #fff;
|
|
||||||
}
|
|
||||||
.uni-combox__no-border.data-v-e602780e {
|
|
||||||
border: none;
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
"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$1(($event) => $options.choiceDate($props.weeks)),
|
||||||
|
o: common_vendor.o$1(($event) => $options.handleMousemove($props.weeks))
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
|
||||||
|
wx.createComponent(Component);
|
||||||
|
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uni-datetime-picker/components/uni-datetime-picker/calendar-item.js.map
|
||||||
@@ -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,113 @@
|
|||||||
|
/**
|
||||||
|
* 这里是uni-app内置的常用样式变量
|
||||||
|
*
|
||||||
|
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
|
||||||
|
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
|
||||||
|
*
|
||||||
|
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
|
||||||
|
*/
|
||||||
|
/* 颜色变量 */
|
||||||
|
/* 行为相关颜色 */
|
||||||
|
/* 文字基本颜色 */
|
||||||
|
/* 背景颜色 */
|
||||||
|
/* 边框颜色 */
|
||||||
|
/* 尺寸变量 */
|
||||||
|
/* 文字尺寸 */
|
||||||
|
/* 图片尺寸 */
|
||||||
|
/* Border Radius */
|
||||||
|
/* 水平间距 */
|
||||||
|
/* 垂直间距 */
|
||||||
|
/* 透明度 */
|
||||||
|
/* 文章场景相关 */
|
||||||
|
.uni-calendar-item__weeks-box {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
margin: 1px 0;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.uni-calendar-item__weeks-box-text {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #001833;
|
||||||
|
}
|
||||||
|
.uni-calendar-item__weeks-box-item {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
}
|
||||||
|
.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: #007aff;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
.uni-calendar-item--multiple .uni-calendar-item--before-checked,
|
||||||
|
.uni-calendar-item--multiple .uni-calendar-item--after-checked {
|
||||||
|
background-color: #007aff;
|
||||||
|
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;
|
||||||
|
}
|
||||||
@@ -0,0 +1,605 @@
|
|||||||
|
"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
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
virtualHost: true
|
||||||
|
},
|
||||||
|
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(isSingleChange) {
|
||||||
|
if (!this.insert && !isSingleChange)
|
||||||
|
return;
|
||||||
|
this.setEmit("change");
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 选择月份触发
|
||||||
|
*/
|
||||||
|
monthSwitch() {
|
||||||
|
let {
|
||||||
|
year,
|
||||||
|
month
|
||||||
|
} = this.nowDate;
|
||||||
|
this.$emit("monthSwitch", {
|
||||||
|
year,
|
||||||
|
month: Number(month)
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 派发事件
|
||||||
|
* @param {Object} name
|
||||||
|
*/
|
||||||
|
setEmit(name) {
|
||||||
|
if (!this.range) {
|
||||||
|
if (!this.calendar.fullDate) {
|
||||||
|
this.calendar = this.cale.getInfo(/* @__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(true);
|
||||||
|
},
|
||||||
|
changeMonth(type) {
|
||||||
|
let newDate;
|
||||||
|
if (type === "pre") {
|
||||||
|
newDate = this.cale.getPreMonthObj(this.nowDate.fullDate).fullDate;
|
||||||
|
} else if (type === "next") {
|
||||||
|
newDate = this.cale.getNextMonthObj(this.nowDate.fullDate).fullDate;
|
||||||
|
}
|
||||||
|
this.setDate(newDate);
|
||||||
|
this.monthSwitch();
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 设置日期
|
||||||
|
* @param {Object} date
|
||||||
|
*/
|
||||||
|
setDate(date) {
|
||||||
|
this.cale.setDate(date);
|
||||||
|
this.weeks = this.cale.weeks;
|
||||||
|
this.nowDate = this.cale.getInfo(date);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
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$1((...args) => $options.maskClick && $options.maskClick(...args))
|
||||||
|
} : {}, {
|
||||||
|
d: $props.insert || $data.show
|
||||||
|
}, $props.insert || $data.show ? common_vendor.e({
|
||||||
|
e: common_vendor.o$1(($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$1((...args) => $options.bindDateChange && $options.bindDateChange(...args)),
|
||||||
|
i: common_vendor.o$1(($event) => $options.changeMonth("next")),
|
||||||
|
j: !$props.insert
|
||||||
|
}, !$props.insert ? {
|
||||||
|
k: common_vendor.o$1((...args) => $options.maskClick && $options.maskClick(...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$1($options.choiceDate, weeksIndex),
|
||||||
|
b: common_vendor.o$1($options.handleMouse, weeksIndex),
|
||||||
|
c: "9e80a514-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$1(($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$1(($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$1(($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$1((...args) => $options.confirm && $options.confirm(...args))
|
||||||
|
} : {}, {
|
||||||
|
M: !$props.insert ? 1 : "",
|
||||||
|
N: $data.aniMaskShow ? 1 : "",
|
||||||
|
O: $data.aniMaskShow ? 1 : ""
|
||||||
|
}) : {}, {
|
||||||
|
P: common_vendor.o$1((...args) => $options.leaveCale && $options.leaveCale(...args))
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
|
||||||
|
wx.createComponent(Component);
|
||||||
|
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uni-datetime-picker/components/uni-datetime-picker/calendar.js.map
|
||||||
@@ -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="9e80a514-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="9e80a514-2" bind:__l="__l" bindupdateModelValue="{{D}}" u-p="{{E}}"></time-picker></view><view style="line-height:50px"><uni-icons wx:if="{{F}}" u-i="9e80a514-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="9e80a514-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,251 @@
|
|||||||
|
/**
|
||||||
|
* 这里是uni-app内置的常用样式变量
|
||||||
|
*
|
||||||
|
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
|
||||||
|
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
|
||||||
|
*
|
||||||
|
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
|
||||||
|
*/
|
||||||
|
/* 颜色变量 */
|
||||||
|
/* 行为相关颜色 */
|
||||||
|
/* 文字基本颜色 */
|
||||||
|
/* 背景颜色 */
|
||||||
|
/* 边框颜色 */
|
||||||
|
/* 尺寸变量 */
|
||||||
|
/* 文字尺寸 */
|
||||||
|
/* 图片尺寸 */
|
||||||
|
/* Border Radius */
|
||||||
|
/* 水平间距 */
|
||||||
|
/* 垂直间距 */
|
||||||
|
/* 透明度 */
|
||||||
|
/* 文章场景相关 */
|
||||||
|
.uni-calendar {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
.uni-calendar__mask {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
background-color: rgba(0, 0, 0, 0.4);
|
||||||
|
transition-property: opacity;
|
||||||
|
transition-duration: 0.3s;
|
||||||
|
opacity: 0;
|
||||||
|
z-index: 99;
|
||||||
|
}
|
||||||
|
.uni-calendar--mask-show {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
.uni-calendar--fixed {
|
||||||
|
position: fixed;
|
||||||
|
bottom: calc(var(--window-bottom));
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
transition-property: transform;
|
||||||
|
transition-duration: 0.3s;
|
||||||
|
transform: translateY(460px);
|
||||||
|
z-index: 99;
|
||||||
|
}
|
||||||
|
.uni-calendar--ani-show {
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
.uni-calendar__content {
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
.uni-calendar__content-mobile {
|
||||||
|
border-top-left-radius: 10px;
|
||||||
|
border-top-right-radius: 10px;
|
||||||
|
box-shadow: 0px 0px 5px 3px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
.uni-calendar__header {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 50px;
|
||||||
|
}
|
||||||
|
.uni-calendar__header-mobile {
|
||||||
|
padding: 10px;
|
||||||
|
padding-bottom: 0;
|
||||||
|
}
|
||||||
|
.uni-calendar--fixed-top {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: space-between;
|
||||||
|
border-top-color: rgba(0, 0, 0, 0.4);
|
||||||
|
border-top-style: solid;
|
||||||
|
border-top-width: 1px;
|
||||||
|
}
|
||||||
|
.uni-calendar--fixed-width {
|
||||||
|
width: 50px;
|
||||||
|
}
|
||||||
|
.uni-calendar__backtoday {
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
top: 25rpx;
|
||||||
|
padding: 0 5px;
|
||||||
|
padding-left: 10px;
|
||||||
|
height: 25px;
|
||||||
|
line-height: 25px;
|
||||||
|
font-size: 12px;
|
||||||
|
border-top-left-radius: 25px;
|
||||||
|
border-bottom-left-radius: 25px;
|
||||||
|
color: #fff;
|
||||||
|
background-color: #f1f1f1;
|
||||||
|
}
|
||||||
|
.uni-calendar__header-text {
|
||||||
|
text-align: center;
|
||||||
|
width: 100px;
|
||||||
|
font-size: 15px;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
.uni-calendar__button-text {
|
||||||
|
text-align: center;
|
||||||
|
width: 100px;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #007aff;
|
||||||
|
letter-spacing: 3px;
|
||||||
|
}
|
||||||
|
.uni-calendar__header-btn-box {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 50px;
|
||||||
|
height: 50px;
|
||||||
|
}
|
||||||
|
.uni-calendar__header-btn {
|
||||||
|
width: 9px;
|
||||||
|
height: 9px;
|
||||||
|
border-left-color: #808080;
|
||||||
|
border-left-style: solid;
|
||||||
|
border-left-width: 1px;
|
||||||
|
border-top-color: #555555;
|
||||||
|
border-top-style: solid;
|
||||||
|
border-top-width: 1px;
|
||||||
|
}
|
||||||
|
.uni-calendar--left {
|
||||||
|
transform: rotate(-45deg);
|
||||||
|
}
|
||||||
|
.uni-calendar--right {
|
||||||
|
transform: rotate(135deg);
|
||||||
|
}
|
||||||
|
.uni-calendar__weeks {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
|
.uni-calendar__weeks-item {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
.uni-calendar__weeks-day {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 40px;
|
||||||
|
border-bottom-color: #F5F5F5;
|
||||||
|
border-bottom-style: solid;
|
||||||
|
border-bottom-width: 1px;
|
||||||
|
}
|
||||||
|
.uni-calendar__weeks-day-text {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #B2B2B2;
|
||||||
|
}
|
||||||
|
.uni-calendar__box {
|
||||||
|
position: relative;
|
||||||
|
padding-bottom: 7px;
|
||||||
|
}
|
||||||
|
.uni-calendar__box-bg {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
}
|
||||||
|
.uni-calendar__box-bg-text {
|
||||||
|
font-size: 200px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #999;
|
||||||
|
opacity: 0.1;
|
||||||
|
text-align: center;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
.uni-date-changed {
|
||||||
|
padding: 0 10px;
|
||||||
|
text-align: center;
|
||||||
|
color: #333;
|
||||||
|
border-top-color: #DCDCDC;
|
||||||
|
border-top-style: solid;
|
||||||
|
border-top-width: 1px;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
.uni-date-btn--ok {
|
||||||
|
padding: 20px 15px;
|
||||||
|
}
|
||||||
|
.uni-date-changed--time-start {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.uni-date-changed--time-end {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.uni-date-changed--time-date {
|
||||||
|
color: #999;
|
||||||
|
line-height: 50px;
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
.time-picker-style {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.mr-10 {
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
.dialog-close {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
padding: 0 25px;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
.dialog-close-plus {
|
||||||
|
width: 16px;
|
||||||
|
height: 2px;
|
||||||
|
background-color: #737987;
|
||||||
|
border-radius: 2px;
|
||||||
|
transform: rotate(45deg);
|
||||||
|
}
|
||||||
|
.dialog-close-rotate {
|
||||||
|
position: absolute;
|
||||||
|
transform: rotate(-45deg);
|
||||||
|
}
|
||||||
|
.uni-datetime-picker--btn {
|
||||||
|
border-radius: 100px;
|
||||||
|
height: 40px;
|
||||||
|
line-height: 40px;
|
||||||
|
background-color: #007aff;
|
||||||
|
color: #fff;
|
||||||
|
font-size: 16px;
|
||||||
|
letter-spacing: 2px;
|
||||||
|
}
|
||||||
|
.uni-datetime-picker--btn:active {
|
||||||
|
opacity: 0.7;
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
"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;
|
||||||
|
//# sourceMappingURL=../../../../../../.sourcemap/mp-weixin/uni_modules/uni-datetime-picker/components/uni-datetime-picker/i18n/index.js.map
|
||||||
@@ -0,0 +1,695 @@
|
|||||||
|
"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 {
|
||||||
|
t
|
||||||
|
} = common_vendor.initVueI18n(uni_modules_uniDatetimePicker_components_uniDatetimePicker_i18n_index.i18nMessages);
|
||||||
|
const _sfc_main = {
|
||||||
|
name: "UniDatetimePicker",
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
indicatorStyle: `height: 50px;`,
|
||||||
|
visible: false,
|
||||||
|
fixNvueBug: {},
|
||||||
|
dateShow: true,
|
||||||
|
timeShow: true,
|
||||||
|
title: "日期和时间",
|
||||||
|
// 输入框当前时间
|
||||||
|
time: "",
|
||||||
|
// 当前的年月日时分秒
|
||||||
|
year: 1920,
|
||||||
|
month: 0,
|
||||||
|
day: 0,
|
||||||
|
hour: 0,
|
||||||
|
minute: 0,
|
||||||
|
second: 0,
|
||||||
|
// 起始时间
|
||||||
|
startYear: 1920,
|
||||||
|
startMonth: 1,
|
||||||
|
startDay: 1,
|
||||||
|
startHour: 0,
|
||||||
|
startMinute: 0,
|
||||||
|
startSecond: 0,
|
||||||
|
// 结束时间
|
||||||
|
endYear: 2120,
|
||||||
|
endMonth: 12,
|
||||||
|
endDay: 31,
|
||||||
|
endHour: 23,
|
||||||
|
endMinute: 59,
|
||||||
|
endSecond: 59
|
||||||
|
};
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
virtualHost: true
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
type: {
|
||||||
|
type: String,
|
||||||
|
default: "datetime"
|
||||||
|
},
|
||||||
|
value: {
|
||||||
|
type: [String, Number],
|
||||||
|
default: ""
|
||||||
|
},
|
||||||
|
modelValue: {
|
||||||
|
type: [String, Number],
|
||||||
|
default: ""
|
||||||
|
},
|
||||||
|
start: {
|
||||||
|
type: [Number, String],
|
||||||
|
default: ""
|
||||||
|
},
|
||||||
|
end: {
|
||||||
|
type: [Number, String],
|
||||||
|
default: ""
|
||||||
|
},
|
||||||
|
returnType: {
|
||||||
|
type: String,
|
||||||
|
default: "string"
|
||||||
|
},
|
||||||
|
disabled: {
|
||||||
|
type: [Boolean, String],
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
border: {
|
||||||
|
type: [Boolean, String],
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
hideSecond: {
|
||||||
|
type: [Boolean, String],
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
modelValue: {
|
||||||
|
handler(newVal) {
|
||||||
|
if (newVal) {
|
||||||
|
this.parseValue(uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.fixIosDateFormat(newVal));
|
||||||
|
this.initTime(false);
|
||||||
|
} else {
|
||||||
|
this.time = "";
|
||||||
|
this.parseValue(Date.now());
|
||||||
|
}
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
|
},
|
||||||
|
type: {
|
||||||
|
handler(newValue) {
|
||||||
|
if (newValue === "date") {
|
||||||
|
this.dateShow = true;
|
||||||
|
this.timeShow = false;
|
||||||
|
this.title = "日期";
|
||||||
|
} else if (newValue === "time") {
|
||||||
|
this.dateShow = false;
|
||||||
|
this.timeShow = true;
|
||||||
|
this.title = "时间";
|
||||||
|
} else {
|
||||||
|
this.dateShow = true;
|
||||||
|
this.timeShow = true;
|
||||||
|
this.title = "日期和时间";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
|
},
|
||||||
|
start: {
|
||||||
|
handler(newVal) {
|
||||||
|
this.parseDatetimeRange(uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.fixIosDateFormat(newVal), "start");
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
|
},
|
||||||
|
end: {
|
||||||
|
handler(newVal) {
|
||||||
|
this.parseDatetimeRange(uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.fixIosDateFormat(newVal), "end");
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
|
},
|
||||||
|
// 月、日、时、分、秒可选范围变化后,检查当前值是否在范围内,不在则当前值重置为可选范围第一项
|
||||||
|
months(newVal) {
|
||||||
|
this.checkValue("month", this.month, newVal);
|
||||||
|
},
|
||||||
|
days(newVal) {
|
||||||
|
this.checkValue("day", this.day, newVal);
|
||||||
|
},
|
||||||
|
hours(newVal) {
|
||||||
|
this.checkValue("hour", this.hour, newVal);
|
||||||
|
},
|
||||||
|
minutes(newVal) {
|
||||||
|
this.checkValue("minute", this.minute, newVal);
|
||||||
|
},
|
||||||
|
seconds(newVal) {
|
||||||
|
this.checkValue("second", this.second, newVal);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
// 当前年、月、日、时、分、秒选择范围
|
||||||
|
years() {
|
||||||
|
return this.getCurrentRange("year");
|
||||||
|
},
|
||||||
|
months() {
|
||||||
|
return this.getCurrentRange("month");
|
||||||
|
},
|
||||||
|
days() {
|
||||||
|
return this.getCurrentRange("day");
|
||||||
|
},
|
||||||
|
hours() {
|
||||||
|
return this.getCurrentRange("hour");
|
||||||
|
},
|
||||||
|
minutes() {
|
||||||
|
return this.getCurrentRange("minute");
|
||||||
|
},
|
||||||
|
seconds() {
|
||||||
|
return this.getCurrentRange("second");
|
||||||
|
},
|
||||||
|
// picker 当前值数组
|
||||||
|
ymd() {
|
||||||
|
return [this.year - this.minYear, this.month - this.minMonth, this.day - this.minDay];
|
||||||
|
},
|
||||||
|
hms() {
|
||||||
|
return [this.hour - this.minHour, this.minute - this.minMinute, this.second - this.minSecond];
|
||||||
|
},
|
||||||
|
// 当前 date 是 start
|
||||||
|
currentDateIsStart() {
|
||||||
|
return this.year === this.startYear && this.month === this.startMonth && this.day === this.startDay;
|
||||||
|
},
|
||||||
|
// 当前 date 是 end
|
||||||
|
currentDateIsEnd() {
|
||||||
|
return this.year === this.endYear && this.month === this.endMonth && this.day === this.endDay;
|
||||||
|
},
|
||||||
|
// 当前年、月、日、时、分、秒的最小值和最大值
|
||||||
|
minYear() {
|
||||||
|
return this.startYear;
|
||||||
|
},
|
||||||
|
maxYear() {
|
||||||
|
return this.endYear;
|
||||||
|
},
|
||||||
|
minMonth() {
|
||||||
|
if (this.year === this.startYear) {
|
||||||
|
return this.startMonth;
|
||||||
|
} else {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
maxMonth() {
|
||||||
|
if (this.year === this.endYear) {
|
||||||
|
return this.endMonth;
|
||||||
|
} else {
|
||||||
|
return 12;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
minDay() {
|
||||||
|
if (this.year === this.startYear && this.month === this.startMonth) {
|
||||||
|
return this.startDay;
|
||||||
|
} else {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
maxDay() {
|
||||||
|
if (this.year === this.endYear && this.month === this.endMonth) {
|
||||||
|
return this.endDay;
|
||||||
|
} else {
|
||||||
|
return this.daysInMonth(this.year, this.month);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
minHour() {
|
||||||
|
if (this.type === "datetime") {
|
||||||
|
if (this.currentDateIsStart) {
|
||||||
|
return this.startHour;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.type === "time") {
|
||||||
|
return this.startHour;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
maxHour() {
|
||||||
|
if (this.type === "datetime") {
|
||||||
|
if (this.currentDateIsEnd) {
|
||||||
|
return this.endHour;
|
||||||
|
} else {
|
||||||
|
return 23;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.type === "time") {
|
||||||
|
return this.endHour;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
minMinute() {
|
||||||
|
if (this.type === "datetime") {
|
||||||
|
if (this.currentDateIsStart && this.hour === this.startHour) {
|
||||||
|
return this.startMinute;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.type === "time") {
|
||||||
|
if (this.hour === this.startHour) {
|
||||||
|
return this.startMinute;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
maxMinute() {
|
||||||
|
if (this.type === "datetime") {
|
||||||
|
if (this.currentDateIsEnd && this.hour === this.endHour) {
|
||||||
|
return this.endMinute;
|
||||||
|
} else {
|
||||||
|
return 59;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.type === "time") {
|
||||||
|
if (this.hour === this.endHour) {
|
||||||
|
return this.endMinute;
|
||||||
|
} else {
|
||||||
|
return 59;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
minSecond() {
|
||||||
|
if (this.type === "datetime") {
|
||||||
|
if (this.currentDateIsStart && this.hour === this.startHour && this.minute === this.startMinute) {
|
||||||
|
return this.startSecond;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.type === "time") {
|
||||||
|
if (this.hour === this.startHour && this.minute === this.startMinute) {
|
||||||
|
return this.startSecond;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
maxSecond() {
|
||||||
|
if (this.type === "datetime") {
|
||||||
|
if (this.currentDateIsEnd && this.hour === this.endHour && this.minute === this.endMinute) {
|
||||||
|
return this.endSecond;
|
||||||
|
} else {
|
||||||
|
return 59;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.type === "time") {
|
||||||
|
if (this.hour === this.endHour && this.minute === this.endMinute) {
|
||||||
|
return this.endSecond;
|
||||||
|
} else {
|
||||||
|
return 59;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* for i18n
|
||||||
|
*/
|
||||||
|
selectTimeText() {
|
||||||
|
return t("uni-datetime-picker.selectTime");
|
||||||
|
},
|
||||||
|
okText() {
|
||||||
|
return t("uni-datetime-picker.ok");
|
||||||
|
},
|
||||||
|
clearText() {
|
||||||
|
return t("uni-datetime-picker.clear");
|
||||||
|
},
|
||||||
|
cancelText() {
|
||||||
|
return t("uni-datetime-picker.cancel");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/**
|
||||||
|
* @param {Object} item
|
||||||
|
* 小于 10 在前面加个 0
|
||||||
|
*/
|
||||||
|
lessThanTen(item) {
|
||||||
|
return item < 10 ? "0" + item : item;
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 解析时分秒字符串,例如:00:00:00
|
||||||
|
* @param {String} timeString
|
||||||
|
*/
|
||||||
|
parseTimeType(timeString) {
|
||||||
|
if (timeString) {
|
||||||
|
let timeArr = timeString.split(":");
|
||||||
|
this.hour = Number(timeArr[0]);
|
||||||
|
this.minute = Number(timeArr[1]);
|
||||||
|
this.second = Number(timeArr[2]);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 解析选择器初始值,类型可以是字符串、时间戳,例如:2000-10-02、'08:30:00'、 1610695109000
|
||||||
|
* @param {String | Number} datetime
|
||||||
|
*/
|
||||||
|
initPickerValue(datetime) {
|
||||||
|
let defaultValue = null;
|
||||||
|
if (datetime) {
|
||||||
|
defaultValue = this.compareValueWithStartAndEnd(datetime, this.start, this.end);
|
||||||
|
} else {
|
||||||
|
defaultValue = Date.now();
|
||||||
|
defaultValue = this.compareValueWithStartAndEnd(defaultValue, this.start, this.end);
|
||||||
|
}
|
||||||
|
this.parseValue(defaultValue);
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 初始值规则:
|
||||||
|
* - 用户设置初始值 value
|
||||||
|
* - 设置了起始时间 start、终止时间 end,并 start < value < end,初始值为 value, 否则初始值为 start
|
||||||
|
* - 只设置了起始时间 start,并 start < value,初始值为 value,否则初始值为 start
|
||||||
|
* - 只设置了终止时间 end,并 value < end,初始值为 value,否则初始值为 end
|
||||||
|
* - 无起始终止时间,则初始值为 value
|
||||||
|
* - 无初始值 value,则初始值为当前本地时间 Date.now()
|
||||||
|
* @param {Object} value
|
||||||
|
* @param {Object} dateBase
|
||||||
|
*/
|
||||||
|
compareValueWithStartAndEnd(value, start, end) {
|
||||||
|
let winner = null;
|
||||||
|
value = this.superTimeStamp(value);
|
||||||
|
start = this.superTimeStamp(start);
|
||||||
|
end = this.superTimeStamp(end);
|
||||||
|
if (start && end) {
|
||||||
|
if (value < start) {
|
||||||
|
winner = new Date(start);
|
||||||
|
} else if (value > end) {
|
||||||
|
winner = new Date(end);
|
||||||
|
} else {
|
||||||
|
winner = new Date(value);
|
||||||
|
}
|
||||||
|
} else if (start && !end) {
|
||||||
|
winner = start <= value ? new Date(value) : new Date(start);
|
||||||
|
} else if (!start && end) {
|
||||||
|
winner = value <= end ? new Date(value) : new Date(end);
|
||||||
|
} else {
|
||||||
|
winner = new Date(value);
|
||||||
|
}
|
||||||
|
return winner;
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 转换为可比较的时间戳,接受日期、时分秒、时间戳
|
||||||
|
* @param {Object} value
|
||||||
|
*/
|
||||||
|
superTimeStamp(value) {
|
||||||
|
let dateBase = "";
|
||||||
|
if (this.type === "time" && value && typeof value === "string") {
|
||||||
|
const now = /* @__PURE__ */ new Date();
|
||||||
|
const year = now.getFullYear();
|
||||||
|
const month = now.getMonth() + 1;
|
||||||
|
const day = now.getDate();
|
||||||
|
dateBase = year + "/" + month + "/" + day + " ";
|
||||||
|
}
|
||||||
|
if (Number(value)) {
|
||||||
|
value = parseInt(value);
|
||||||
|
dateBase = 0;
|
||||||
|
}
|
||||||
|
return this.createTimeStamp(dateBase + value);
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 解析默认值 value,字符串、时间戳
|
||||||
|
* @param {Object} defaultTime
|
||||||
|
*/
|
||||||
|
parseValue(value) {
|
||||||
|
if (!value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.type === "time" && typeof value === "string") {
|
||||||
|
this.parseTimeType(value);
|
||||||
|
} else {
|
||||||
|
let defaultDate = null;
|
||||||
|
defaultDate = new Date(value);
|
||||||
|
if (this.type !== "time") {
|
||||||
|
this.year = defaultDate.getFullYear();
|
||||||
|
this.month = defaultDate.getMonth() + 1;
|
||||||
|
this.day = defaultDate.getDate();
|
||||||
|
}
|
||||||
|
if (this.type !== "date") {
|
||||||
|
this.hour = defaultDate.getHours();
|
||||||
|
this.minute = defaultDate.getMinutes();
|
||||||
|
this.second = defaultDate.getSeconds();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.hideSecond) {
|
||||||
|
this.second = 0;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 解析可选择时间范围 start、end,年月日字符串、时间戳
|
||||||
|
* @param {Object} defaultTime
|
||||||
|
*/
|
||||||
|
parseDatetimeRange(point, pointType) {
|
||||||
|
if (!point) {
|
||||||
|
if (pointType === "start") {
|
||||||
|
this.startYear = 1920;
|
||||||
|
this.startMonth = 1;
|
||||||
|
this.startDay = 1;
|
||||||
|
this.startHour = 0;
|
||||||
|
this.startMinute = 0;
|
||||||
|
this.startSecond = 0;
|
||||||
|
}
|
||||||
|
if (pointType === "end") {
|
||||||
|
this.endYear = 2120;
|
||||||
|
this.endMonth = 12;
|
||||||
|
this.endDay = 31;
|
||||||
|
this.endHour = 23;
|
||||||
|
this.endMinute = 59;
|
||||||
|
this.endSecond = 59;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.type === "time") {
|
||||||
|
const pointArr = point.split(":");
|
||||||
|
this[pointType + "Hour"] = Number(pointArr[0]);
|
||||||
|
this[pointType + "Minute"] = Number(pointArr[1]);
|
||||||
|
this[pointType + "Second"] = Number(pointArr[2]);
|
||||||
|
} else {
|
||||||
|
if (!point) {
|
||||||
|
pointType === "start" ? this.startYear = this.year - 60 : this.endYear = this.year + 60;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Number(point)) {
|
||||||
|
point = parseInt(point);
|
||||||
|
}
|
||||||
|
const hasTime = /[0-9]:[0-9]/;
|
||||||
|
if (this.type === "datetime" && pointType === "end" && typeof point === "string" && !hasTime.test(
|
||||||
|
point
|
||||||
|
)) {
|
||||||
|
point = point + " 23:59:59";
|
||||||
|
}
|
||||||
|
const pointDate = new Date(point);
|
||||||
|
this[pointType + "Year"] = pointDate.getFullYear();
|
||||||
|
this[pointType + "Month"] = pointDate.getMonth() + 1;
|
||||||
|
this[pointType + "Day"] = pointDate.getDate();
|
||||||
|
if (this.type === "datetime") {
|
||||||
|
this[pointType + "Hour"] = pointDate.getHours();
|
||||||
|
this[pointType + "Minute"] = pointDate.getMinutes();
|
||||||
|
this[pointType + "Second"] = pointDate.getSeconds();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 获取 年、月、日、时、分、秒 当前可选范围
|
||||||
|
getCurrentRange(value) {
|
||||||
|
const range = [];
|
||||||
|
for (let i = this["min" + this.capitalize(value)]; i <= this["max" + this.capitalize(value)]; i++) {
|
||||||
|
range.push(i);
|
||||||
|
}
|
||||||
|
return range;
|
||||||
|
},
|
||||||
|
// 字符串首字母大写
|
||||||
|
capitalize(str) {
|
||||||
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||||
|
},
|
||||||
|
// 检查当前值是否在范围内,不在则当前值重置为可选范围第一项
|
||||||
|
checkValue(name, value, values) {
|
||||||
|
if (values.indexOf(value) === -1) {
|
||||||
|
this[name] = values[0];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 每个月的实际天数
|
||||||
|
daysInMonth(year, month) {
|
||||||
|
return new Date(year, month, 0).getDate();
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 生成时间戳
|
||||||
|
* @param {Object} time
|
||||||
|
*/
|
||||||
|
createTimeStamp(time) {
|
||||||
|
if (!time)
|
||||||
|
return;
|
||||||
|
if (typeof time === "number") {
|
||||||
|
return time;
|
||||||
|
} else {
|
||||||
|
time = time.replace(/-/g, "/");
|
||||||
|
if (this.type === "date") {
|
||||||
|
time = time + " 00:00:00";
|
||||||
|
}
|
||||||
|
return Date.parse(time);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 生成日期或时间的字符串
|
||||||
|
*/
|
||||||
|
createDomSting() {
|
||||||
|
const yymmdd = this.year + "-" + this.lessThanTen(this.month) + "-" + this.lessThanTen(this.day);
|
||||||
|
let hhmmss = this.lessThanTen(this.hour) + ":" + this.lessThanTen(this.minute);
|
||||||
|
if (!this.hideSecond) {
|
||||||
|
hhmmss = hhmmss + ":" + this.lessThanTen(this.second);
|
||||||
|
}
|
||||||
|
if (this.type === "date") {
|
||||||
|
return yymmdd;
|
||||||
|
} else if (this.type === "time") {
|
||||||
|
return hhmmss;
|
||||||
|
} else {
|
||||||
|
return yymmdd + " " + hhmmss;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 初始化返回值,并抛出 change 事件
|
||||||
|
*/
|
||||||
|
initTime(emit = true) {
|
||||||
|
this.time = this.createDomSting();
|
||||||
|
if (!emit)
|
||||||
|
return;
|
||||||
|
if (this.returnType === "timestamp" && this.type !== "time") {
|
||||||
|
this.$emit("change", this.createTimeStamp(this.time));
|
||||||
|
this.$emit("input", this.createTimeStamp(this.time));
|
||||||
|
this.$emit("update:modelValue", this.createTimeStamp(this.time));
|
||||||
|
} else {
|
||||||
|
this.$emit("change", this.time);
|
||||||
|
this.$emit("input", this.time);
|
||||||
|
this.$emit("update:modelValue", this.time);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 用户选择日期或时间更新 data
|
||||||
|
* @param {Object} e
|
||||||
|
*/
|
||||||
|
bindDateChange(e) {
|
||||||
|
const val = e.detail.value;
|
||||||
|
this.year = this.years[val[0]];
|
||||||
|
this.month = this.months[val[1]];
|
||||||
|
this.day = this.days[val[2]];
|
||||||
|
},
|
||||||
|
bindTimeChange(e) {
|
||||||
|
const val = e.detail.value;
|
||||||
|
this.hour = this.hours[val[0]];
|
||||||
|
this.minute = this.minutes[val[1]];
|
||||||
|
this.second = this.seconds[val[2]];
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 初始化弹出层
|
||||||
|
*/
|
||||||
|
initTimePicker() {
|
||||||
|
if (this.disabled)
|
||||||
|
return;
|
||||||
|
const value = uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.fixIosDateFormat(this.time);
|
||||||
|
this.initPickerValue(value);
|
||||||
|
this.visible = !this.visible;
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 触发或关闭弹框
|
||||||
|
*/
|
||||||
|
tiggerTimePicker(e) {
|
||||||
|
this.visible = !this.visible;
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 用户点击“清空”按钮,清空当前值
|
||||||
|
*/
|
||||||
|
clearTime() {
|
||||||
|
this.time = "";
|
||||||
|
this.$emit("change", this.time);
|
||||||
|
this.$emit("input", this.time);
|
||||||
|
this.$emit("update:modelValue", this.time);
|
||||||
|
this.tiggerTimePicker();
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 用户点击“确定”按钮
|
||||||
|
*/
|
||||||
|
setTime() {
|
||||||
|
this.initTime();
|
||||||
|
this.tiggerTimePicker();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||||
|
return common_vendor.e({
|
||||||
|
a: common_vendor.t($data.time),
|
||||||
|
b: !$data.time
|
||||||
|
}, !$data.time ? {
|
||||||
|
c: common_vendor.t($options.selectTimeText)
|
||||||
|
} : {}, {
|
||||||
|
d: $props.disabled ? 1 : "",
|
||||||
|
e: $props.border ? 1 : "",
|
||||||
|
f: common_vendor.o$1((...args) => $options.initTimePicker && $options.initTimePicker(...args)),
|
||||||
|
g: $data.visible
|
||||||
|
}, $data.visible ? {
|
||||||
|
h: common_vendor.o$1((...args) => $options.tiggerTimePicker && $options.tiggerTimePicker(...args))
|
||||||
|
} : {}, {
|
||||||
|
i: $data.visible
|
||||||
|
}, $data.visible ? common_vendor.e({
|
||||||
|
j: common_vendor.t($options.selectTimeText),
|
||||||
|
k: $data.dateShow
|
||||||
|
}, $data.dateShow ? {
|
||||||
|
l: common_vendor.f($options.years, (item, index, i0) => {
|
||||||
|
return {
|
||||||
|
a: common_vendor.t($options.lessThanTen(item)),
|
||||||
|
b: index
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
m: common_vendor.f($options.months, (item, index, i0) => {
|
||||||
|
return {
|
||||||
|
a: common_vendor.t($options.lessThanTen(item)),
|
||||||
|
b: index
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
n: common_vendor.f($options.days, (item, index, i0) => {
|
||||||
|
return {
|
||||||
|
a: common_vendor.t($options.lessThanTen(item)),
|
||||||
|
b: index
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
o: $data.indicatorStyle,
|
||||||
|
p: $options.ymd,
|
||||||
|
q: common_vendor.o$1((...args) => $options.bindDateChange && $options.bindDateChange(...args))
|
||||||
|
} : {}, {
|
||||||
|
r: $data.timeShow
|
||||||
|
}, $data.timeShow ? common_vendor.e({
|
||||||
|
s: common_vendor.f($options.hours, (item, index, i0) => {
|
||||||
|
return {
|
||||||
|
a: common_vendor.t($options.lessThanTen(item)),
|
||||||
|
b: index
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
t: common_vendor.f($options.minutes, (item, index, i0) => {
|
||||||
|
return {
|
||||||
|
a: common_vendor.t($options.lessThanTen(item)),
|
||||||
|
b: index
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
v: !$props.hideSecond
|
||||||
|
}, !$props.hideSecond ? {
|
||||||
|
w: common_vendor.f($options.seconds, (item, index, i0) => {
|
||||||
|
return {
|
||||||
|
a: common_vendor.t($options.lessThanTen(item)),
|
||||||
|
b: index
|
||||||
|
};
|
||||||
|
})
|
||||||
|
} : {}, {
|
||||||
|
x: common_vendor.n($props.hideSecond ? "time-hide-second" : ""),
|
||||||
|
y: $data.indicatorStyle,
|
||||||
|
z: $options.hms,
|
||||||
|
A: common_vendor.o$1((...args) => $options.bindTimeChange && $options.bindTimeChange(...args)),
|
||||||
|
B: common_vendor.n($props.hideSecond ? "sign-center" : "sign-left"),
|
||||||
|
C: !$props.hideSecond
|
||||||
|
}, !$props.hideSecond ? {} : {}) : {}, {
|
||||||
|
D: common_vendor.t($options.clearText),
|
||||||
|
E: common_vendor.o$1((...args) => $options.clearTime && $options.clearTime(...args)),
|
||||||
|
F: common_vendor.t($options.cancelText),
|
||||||
|
G: common_vendor.o$1((...args) => $options.tiggerTimePicker && $options.tiggerTimePicker(...args)),
|
||||||
|
H: common_vendor.t($options.okText),
|
||||||
|
I: common_vendor.o$1((...args) => $options.setTime && $options.setTime(...args)),
|
||||||
|
J: common_vendor.n($data.dateShow && $data.timeShow ? "" : "fix-nvue-height"),
|
||||||
|
K: common_vendor.s($data.fixNvueBug)
|
||||||
|
}) : {});
|
||||||
|
}
|
||||||
|
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
|
||||||
|
wx.createComponent(Component);
|
||||||
|
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uni-datetime-picker/components/uni-datetime-picker/time-picker.js.map
|
||||||
@@ -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"><block wx:if="{{r0}}"><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></block><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"><block wx:if="{{r0}}"><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></block><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,127 @@
|
|||||||
|
/**
|
||||||
|
* 这里是uni-app内置的常用样式变量
|
||||||
|
*
|
||||||
|
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
|
||||||
|
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
|
||||||
|
*
|
||||||
|
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
|
||||||
|
*/
|
||||||
|
/* 颜色变量 */
|
||||||
|
/* 行为相关颜色 */
|
||||||
|
/* 文字基本颜色 */
|
||||||
|
/* 背景颜色 */
|
||||||
|
/* 边框颜色 */
|
||||||
|
/* 尺寸变量 */
|
||||||
|
/* 文字尺寸 */
|
||||||
|
/* 图片尺寸 */
|
||||||
|
/* Border Radius */
|
||||||
|
/* 水平间距 */
|
||||||
|
/* 垂直间距 */
|
||||||
|
/* 透明度 */
|
||||||
|
/* 文章场景相关 */
|
||||||
|
.uni-datetime-picker {
|
||||||
|
/* width: 100%; */
|
||||||
|
}
|
||||||
|
.uni-datetime-picker-view {
|
||||||
|
height: 130px;
|
||||||
|
width: 270px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.uni-datetime-picker-item {
|
||||||
|
height: 50px;
|
||||||
|
line-height: 50px;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
.uni-datetime-picker-btn {
|
||||||
|
margin-top: 60px;
|
||||||
|
display: flex;
|
||||||
|
cursor: pointer;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
.uni-datetime-picker-btn-text {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #007aff;
|
||||||
|
}
|
||||||
|
.uni-datetime-picker-btn-group {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
|
.uni-datetime-picker-cancel {
|
||||||
|
margin-right: 30px;
|
||||||
|
}
|
||||||
|
.uni-datetime-picker-mask {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0px;
|
||||||
|
top: 0px;
|
||||||
|
left: 0px;
|
||||||
|
right: 0px;
|
||||||
|
background-color: rgba(0, 0, 0, 0.4);
|
||||||
|
transition-duration: 0.3s;
|
||||||
|
z-index: 998;
|
||||||
|
}
|
||||||
|
.uni-datetime-picker-popup {
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 30px;
|
||||||
|
width: 270px;
|
||||||
|
background-color: #fff;
|
||||||
|
position: fixed;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
transition-duration: 0.3s;
|
||||||
|
z-index: 999;
|
||||||
|
}
|
||||||
|
.uni-datetime-picker-time {
|
||||||
|
color: grey;
|
||||||
|
}
|
||||||
|
.uni-datetime-picker-column {
|
||||||
|
height: 50px;
|
||||||
|
}
|
||||||
|
.uni-datetime-picker-timebox {
|
||||||
|
border: 1px solid #E5E5E5;
|
||||||
|
border-radius: 5px;
|
||||||
|
padding: 7px 10px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.uni-datetime-picker-timebox-pointer {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.uni-datetime-picker-disabled {
|
||||||
|
opacity: 0.4;
|
||||||
|
}
|
||||||
|
.uni-datetime-picker-text {
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 50px;
|
||||||
|
}
|
||||||
|
.uni-datetime-picker-sign {
|
||||||
|
position: absolute;
|
||||||
|
top: 53px;
|
||||||
|
/* 减掉 10px 的元素高度,兼容nvue */
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
.sign-left {
|
||||||
|
left: 86px;
|
||||||
|
}
|
||||||
|
.sign-right {
|
||||||
|
right: 86px;
|
||||||
|
}
|
||||||
|
.sign-center {
|
||||||
|
left: 135px;
|
||||||
|
}
|
||||||
|
.uni-datetime-picker__container-box {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin-top: 40px;
|
||||||
|
}
|
||||||
|
.time-hide-second {
|
||||||
|
width: 180px;
|
||||||
|
}
|
||||||
@@ -0,0 +1,851 @@
|
|||||||
|
"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.getWindowInfo();
|
||||||
|
this.isPhone = windowWidth <= 500;
|
||||||
|
this.windowWidth = windowWidth;
|
||||||
|
},
|
||||||
|
show() {
|
||||||
|
this.$emit("show");
|
||||||
|
if (this.disabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.platform();
|
||||||
|
if (this.isPhone) {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$refs.mobile.open();
|
||||||
|
}, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.pickerPositionStyle = {
|
||||||
|
top: "10px"
|
||||||
|
};
|
||||||
|
const dateEditor = 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 {
|
||||||
|
if (this.isPhone) {
|
||||||
|
this.$refs.right.cale.lastHover = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 50);
|
||||||
|
},
|
||||||
|
close() {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.pickerVisible = false;
|
||||||
|
this.$emit("maskClick", this.value);
|
||||||
|
this.$refs.mobile && this.$refs.mobile.close();
|
||||||
|
}, 20);
|
||||||
|
},
|
||||||
|
setEmit(value) {
|
||||||
|
if (this.returnType === "timestamp" || this.returnType === "date") {
|
||||||
|
if (!Array.isArray(value)) {
|
||||||
|
if (!this.hasTime) {
|
||||||
|
value = value + " 00:00:00";
|
||||||
|
}
|
||||||
|
value = this.createTimestamp(value);
|
||||||
|
if (this.returnType === "date") {
|
||||||
|
value = new Date(value);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!this.hasTime) {
|
||||||
|
value[0] = value[0] + " 00:00:00";
|
||||||
|
value[1] = value[1] + " 00:00:00";
|
||||||
|
}
|
||||||
|
value[0] = this.createTimestamp(value[0]);
|
||||||
|
value[1] = this.createTimestamp(value[1]);
|
||||||
|
if (this.returnType === "date") {
|
||||||
|
value[0] = new Date(value[0]);
|
||||||
|
value[1] = new Date(value[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.$emit("update:modelValue", value);
|
||||||
|
this.$emit("input", value);
|
||||||
|
this.$emit("change", value);
|
||||||
|
this.isEmitValue = true;
|
||||||
|
},
|
||||||
|
createTimestamp(date) {
|
||||||
|
date = 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);
|
||||||
|
this.$emit("calendarClick", e);
|
||||||
|
},
|
||||||
|
rightChange(e) {
|
||||||
|
const {
|
||||||
|
before,
|
||||||
|
after
|
||||||
|
} = e.range;
|
||||||
|
this.rangeChange(before, after);
|
||||||
|
const obj = {
|
||||||
|
before: e.range.before,
|
||||||
|
after: e.range.after,
|
||||||
|
data: e.range.data,
|
||||||
|
fulldate: e.fulldate
|
||||||
|
};
|
||||||
|
this.endMultipleStatus = Object.assign({}, this.endMultipleStatus, obj);
|
||||||
|
this.$emit("calendarClick", e);
|
||||||
|
},
|
||||||
|
mobileChange(e) {
|
||||||
|
if (this.isRange) {
|
||||||
|
const {
|
||||||
|
before,
|
||||||
|
after
|
||||||
|
} = e.range;
|
||||||
|
if (!before) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.handleStartAndEnd(before, after, true);
|
||||||
|
if (this.hasTime) {
|
||||||
|
const {
|
||||||
|
startTime,
|
||||||
|
endTime
|
||||||
|
} = e.timeRange;
|
||||||
|
this.tempRange.startTime = startTime;
|
||||||
|
this.tempRange.endTime = endTime;
|
||||||
|
}
|
||||||
|
this.confirmRangeChange();
|
||||||
|
} else {
|
||||||
|
if (this.hasTime) {
|
||||||
|
this.displayValue = e.fulldate + " " + e.time;
|
||||||
|
} else {
|
||||||
|
this.displayValue = e.fulldate;
|
||||||
|
}
|
||||||
|
this.setEmit(this.displayValue);
|
||||||
|
this.calendarDate = 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;
|
||||||
|
let compareStartDateString = this.tempRange.startDate;
|
||||||
|
let compareEndDateString = this.tempRange.endDate;
|
||||||
|
if (this.hasTime) {
|
||||||
|
compareStartDateString = `${this.tempRange.startDate} ${this.tempRange.startTime}`;
|
||||||
|
compareEndDateString = `${this.tempRange.endDate} ${this.tempRange.endTime}`;
|
||||||
|
}
|
||||||
|
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, compareStartDateString)) {
|
||||||
|
startDateLaterRangeStartDate = true;
|
||||||
|
this.tempRange.startDate = startDate;
|
||||||
|
}
|
||||||
|
if (this.start && !uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.dateCompare(this.start, compareEndDateString)) {
|
||||||
|
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(compareStartDateString, this.end)) {
|
||||||
|
endDateEarlierRangeStartDate = true;
|
||||||
|
this.tempRange.startDate = endDate;
|
||||||
|
}
|
||||||
|
if (this.end && !uni_modules_uniDatetimePicker_components_uniDatetimePicker_util.dateCompare(compareEndDateString, 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)
|
||||||
|
return;
|
||||||
|
if (!after)
|
||||||
|
after = before;
|
||||||
|
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", []);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
calendarClick(e) {
|
||||||
|
this.$emit("calendarClick", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
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$1((...args) => $options.clear && $options.clear(...args))
|
||||||
|
} : {}, {
|
||||||
|
k: $props.disabled ? 1 : "",
|
||||||
|
l: $props.border ? 1 : "",
|
||||||
|
m: common_vendor.o$1((...args) => $options.show && $options.show(...args)),
|
||||||
|
n: $data.pickerVisible,
|
||||||
|
o: common_vendor.o$1((...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$1(($event) => $data.inputDate = $event.detail.value),
|
||||||
|
w: $options.selectTimeText,
|
||||||
|
x: !$data.inputDate,
|
||||||
|
y: $data.pickerTime,
|
||||||
|
z: common_vendor.o$1(($event) => $data.pickerTime = $event.detail.value),
|
||||||
|
A: common_vendor.o$1(($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", "347f72bb-4"),
|
||||||
|
D: common_vendor.o$1($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$1((...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$1(($event) => $data.tempRange.startDate = $event.detail.value),
|
||||||
|
N: $options.startTimeText,
|
||||||
|
O: !$data.tempRange.startDate,
|
||||||
|
P: $data.tempRange.startTime,
|
||||||
|
Q: common_vendor.o$1(($event) => $data.tempRange.startTime = $event.detail.value),
|
||||||
|
R: common_vendor.o$1(($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$1(($event) => $data.tempRange.endDate = $event.detail.value),
|
||||||
|
X: $options.endTimeText,
|
||||||
|
Y: !$data.tempRange.endDate,
|
||||||
|
Z: $data.tempRange.endTime,
|
||||||
|
aa: common_vendor.o$1(($event) => $data.tempRange.endTime = $event.detail.value),
|
||||||
|
ab: common_vendor.o$1(($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", "347f72bb-8"),
|
||||||
|
ae: common_vendor.o$1($options.leftChange),
|
||||||
|
af: common_vendor.o$1($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", "347f72bb-9"),
|
||||||
|
ai: common_vendor.o$1($options.rightChange),
|
||||||
|
aj: common_vendor.o$1($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$1((...args) => $options.clear && $options.clear(...args)),
|
||||||
|
ao: common_vendor.t($options.okText),
|
||||||
|
ap: common_vendor.o$1((...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", "347f72bb-10"),
|
||||||
|
av: common_vendor.o$1($options.mobileChange),
|
||||||
|
aw: common_vendor.o$1($options.close),
|
||||||
|
ax: common_vendor.o$1($options.calendarClick),
|
||||||
|
ay: 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]]);
|
||||||
|
wx.createComponent(Component);
|
||||||
|
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.js.map
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"component": true,
|
"component": true,
|
||||||
"usingComponents": {
|
"usingComponents": {
|
||||||
|
"calendar": "./calendar",
|
||||||
|
"time-picker": "./time-picker",
|
||||||
"uni-icons": "../../../uni-icons/components/uni-icons/uni-icons"
|
"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="347f72bb-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="347f72bb-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="347f72bb-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="347f72bb-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="347f72bb-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="347f72bb-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="347f72bb-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="347f72bb-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="347f72bb-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="347f72bb-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}}" bindchange="{{ax}}" u-i="347f72bb-10" bind:__l="__l" u-p="{{ay}}"/></view>
|
||||||
@@ -0,0 +1,201 @@
|
|||||||
|
/**
|
||||||
|
* 这里是uni-app内置的常用样式变量
|
||||||
|
*
|
||||||
|
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
|
||||||
|
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
|
||||||
|
*
|
||||||
|
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
|
||||||
|
*/
|
||||||
|
/* 颜色变量 */
|
||||||
|
/* 行为相关颜色 */
|
||||||
|
/* 文字基本颜色 */
|
||||||
|
/* 背景颜色 */
|
||||||
|
/* 边框颜色 */
|
||||||
|
/* 尺寸变量 */
|
||||||
|
/* 文字尺寸 */
|
||||||
|
/* 图片尺寸 */
|
||||||
|
/* Border Radius */
|
||||||
|
/* 水平间距 */
|
||||||
|
/* 垂直间距 */
|
||||||
|
/* 透明度 */
|
||||||
|
/* 文章场景相关 */
|
||||||
|
.uni-date {
|
||||||
|
width: 100%;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
.uni-date-x {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border-radius: 4px;
|
||||||
|
background-color: #fff;
|
||||||
|
color: #666;
|
||||||
|
font-size: 14px;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
.uni-date-x .icon-calendar {
|
||||||
|
padding-left: 3px;
|
||||||
|
}
|
||||||
|
.uni-date-x .range-separator {
|
||||||
|
height: 35px;
|
||||||
|
line-height: 35px;
|
||||||
|
}
|
||||||
|
.uni-date-x--border {
|
||||||
|
box-sizing: border-box;
|
||||||
|
border-radius: 4px;
|
||||||
|
border: 1px solid #e5e5e5;
|
||||||
|
}
|
||||||
|
.uni-date-editor--x {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.uni-date-editor--x .uni-date__icon-clear {
|
||||||
|
padding-right: 3px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.uni-date__x-input {
|
||||||
|
width: auto;
|
||||||
|
height: 35px;
|
||||||
|
position: relative;
|
||||||
|
flex: 1;
|
||||||
|
line-height: 35px;
|
||||||
|
font-size: 14px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.text-center {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.uni-date__input {
|
||||||
|
height: 40px;
|
||||||
|
width: 100%;
|
||||||
|
line-height: 40px;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
.uni-date-range__input {
|
||||||
|
text-align: center;
|
||||||
|
max-width: 142px;
|
||||||
|
}
|
||||||
|
.uni-date-picker__container {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.uni-date-mask--pc {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0px;
|
||||||
|
top: 0px;
|
||||||
|
left: 0px;
|
||||||
|
right: 0px;
|
||||||
|
background-color: rgba(0, 0, 0, 0);
|
||||||
|
transition-duration: 0.3s;
|
||||||
|
z-index: 996;
|
||||||
|
}
|
||||||
|
.uni-date-single--x {
|
||||||
|
background-color: #fff;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
z-index: 999;
|
||||||
|
border: 1px solid #EBEEF5;
|
||||||
|
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
.uni-date-range--x {
|
||||||
|
background-color: #fff;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
z-index: 999;
|
||||||
|
border: 1px solid #EBEEF5;
|
||||||
|
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
.uni-date-editor--x__disabled {
|
||||||
|
opacity: 0.4;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
.uni-date-editor--logo {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 添加时间 */
|
||||||
|
.popup-x-header {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
|
.popup-x-header--datetime {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
.popup-x-body {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
.popup-x-footer {
|
||||||
|
padding: 0 15px;
|
||||||
|
border-top-color: #F1F1F1;
|
||||||
|
border-top-style: solid;
|
||||||
|
border-top-width: 1px;
|
||||||
|
line-height: 40px;
|
||||||
|
text-align: right;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
.popup-x-footer text:hover {
|
||||||
|
color: #007aff;
|
||||||
|
cursor: pointer;
|
||||||
|
opacity: 0.8;
|
||||||
|
}
|
||||||
|
.popup-x-footer .confirm-text {
|
||||||
|
margin-left: 20px;
|
||||||
|
color: #007aff;
|
||||||
|
}
|
||||||
|
.uni-date-changed {
|
||||||
|
text-align: center;
|
||||||
|
color: #333;
|
||||||
|
border-bottom-color: #F1F1F1;
|
||||||
|
border-bottom-style: solid;
|
||||||
|
border-bottom-width: 1px;
|
||||||
|
}
|
||||||
|
.uni-date-changed--time text {
|
||||||
|
height: 50px;
|
||||||
|
line-height: 50px;
|
||||||
|
}
|
||||||
|
.uni-date-changed .uni-date-changed--time {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
.uni-date-changed--time-date {
|
||||||
|
color: #333;
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
.mr-50 {
|
||||||
|
margin-right: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* picker 弹出层通用的指示小三角, todo:扩展至上下左右方向定位 */
|
||||||
|
.uni-popper__arrow,
|
||||||
|
.uni-popper__arrow::after {
|
||||||
|
position: absolute;
|
||||||
|
display: block;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
border: 6px solid transparent;
|
||||||
|
border-top-width: 0;
|
||||||
|
}
|
||||||
|
.uni-popper__arrow {
|
||||||
|
filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.03));
|
||||||
|
top: -6px;
|
||||||
|
left: 10%;
|
||||||
|
margin-right: 3px;
|
||||||
|
border-bottom-color: #EBEEF5;
|
||||||
|
}
|
||||||
|
.uni-popper__arrow::after {
|
||||||
|
content: " ";
|
||||||
|
top: 1px;
|
||||||
|
margin-left: -6px;
|
||||||
|
border-bottom-color: #fff;
|
||||||
|
}
|
||||||
366
unpackage/dist/dev/mp-weixin/uni_modules/uni-datetime-picker/components/uni-datetime-picker/util.js
vendored
Normal file
366
unpackage/dist/dev/mp-weixin/uni_modules/uni-datetime-picker/components/uni-datetime-picker/util.js
vendored
Normal file
@@ -0,0 +1,366 @@
|
|||||||
|
"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;
|
||||||
|
result.push({
|
||||||
|
date: new Date(dateObj.year, month, -i).getDate(),
|
||||||
|
month,
|
||||||
|
disable: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取本月日期集合
|
||||||
|
*/
|
||||||
|
getCurrentMonthDays(amount, dateObj) {
|
||||||
|
const result = [];
|
||||||
|
const fullDate = this.date.fullDate;
|
||||||
|
for (let i = 1; i <= amount; i++) {
|
||||||
|
const currentDate = `${dateObj.year}-${dateObj.month}-${addZero(i)}`;
|
||||||
|
const isToday = fullDate === currentDate;
|
||||||
|
const info = this.selected && this.selected.find((item) => {
|
||||||
|
if (this.dateEqual(currentDate, item.date)) {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
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,
|
||||||
|
date: i,
|
||||||
|
multiple: this.range ? checked : false,
|
||||||
|
beforeMultiple: this.isLogicBefore(currentDate, this.multipleStatus.before, this.multipleStatus.after),
|
||||||
|
afterMultiple: this.isLogicAfter(currentDate, this.multipleStatus.before, this.multipleStatus.after),
|
||||||
|
month: dateObj.month,
|
||||||
|
disable: this.startDate && !dateCompare(this.startDate, currentDate) || this.endDate && !dateCompare(
|
||||||
|
currentDate,
|
||||||
|
this.endDate
|
||||||
|
),
|
||||||
|
isToday,
|
||||||
|
userChecked: false,
|
||||||
|
extraInfo: info
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取下一个月日期集合
|
||||||
|
*/
|
||||||
|
_getNextMonthDays(amount, dateObj) {
|
||||||
|
const result = [];
|
||||||
|
const month = dateObj.month + 1;
|
||||||
|
for (let i = 1; i <= amount; i++) {
|
||||||
|
result.push({
|
||||||
|
date: i,
|
||||||
|
month,
|
||||||
|
disable: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取当前日期详情
|
||||||
|
* @param {Object} date
|
||||||
|
*/
|
||||||
|
getInfo(date) {
|
||||||
|
if (!date) {
|
||||||
|
date = /* @__PURE__ */ new Date();
|
||||||
|
}
|
||||||
|
const res = this.calendar.find((item) => item.fullDate === this.getDateObj(date).fullDate);
|
||||||
|
return res ? res : this.getDateObj(date);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 比较时间是否相等
|
||||||
|
*/
|
||||||
|
dateEqual(before, after) {
|
||||||
|
before = new Date(fixIosDateFormat(before));
|
||||||
|
after = new Date(fixIosDateFormat(after));
|
||||||
|
return before.valueOf() === after.valueOf();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 比较真实起始日期
|
||||||
|
*/
|
||||||
|
isLogicBefore(currentDate, before, after) {
|
||||||
|
let logicBefore = before;
|
||||||
|
if (before && after) {
|
||||||
|
logicBefore = dateCompare(before, after) ? before : after;
|
||||||
|
}
|
||||||
|
return this.dateEqual(logicBefore, currentDate);
|
||||||
|
}
|
||||||
|
isLogicAfter(currentDate, before, after) {
|
||||||
|
let logicAfter = after;
|
||||||
|
if (before && after) {
|
||||||
|
logicAfter = dateCompare(before, after) ? after : before;
|
||||||
|
}
|
||||||
|
return this.dateEqual(logicAfter, currentDate);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取日期范围内所有日期
|
||||||
|
* @param {Object} begin
|
||||||
|
* @param {Object} end
|
||||||
|
*/
|
||||||
|
geDateAll(begin, end) {
|
||||||
|
var arr = [];
|
||||||
|
var ab = begin.split("-");
|
||||||
|
var ae = end.split("-");
|
||||||
|
var db = /* @__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.multipleStatus.after = void 0;
|
||||||
|
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;
|
||||||
|
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uni-datetime-picker/components/uni-datetime-picker/util.js.map
|
||||||
Reference in New Issue
Block a user