更新记录

1.0.6(2023-08-30)

文档优化

1.0.5(2023-08-30)

文档优化

1.0.4(2023-08-21)

文档优化

查看更多

平台兼容性

Vue2 Vue3
×
App 快应用 微信小程序 支付宝小程序 百度小程序 字节小程序 QQ小程序
HBuilderX 3.1.0 app-vue × × × × × ×
钉钉小程序 快手小程序 飞书小程序 京东小程序
× × × ×
H5-Safari Android Browser 微信浏览器(Android) QQ浏览器(Android) Chrome IE Edge Firefox PC-Safari
× × × × × × × × ×

日期时间选择,提供,日、周、月、年,时间统计

  • 提供,日、周、月、年,时间统计
  • 开源不易,如有问题请先沟通处理,可留言,也可添加vx:lisir688
  • 如给您带来了方便,请给个五星好评,万分感谢

使用方法

    <!-- 组件引入 -->
    <lys-date v-if="showTimePicker" :type="type" :time="time" @cancleTime="showTimePicker = false" @submitTime="submitTime"></lys-date>
    // 返回函数处理
    submitTime(time, type, timeInt) {
      console.log(time, type, timeInt);
      this.showTimePicker = false;
      this.time = time;
      this.type = type;
      this.timeInt = timeInt;
    },

提供一个格式化的使用示例,插件地址,点击打开


  // 日
  if (this.type == 1) {
    this.timeBegin = uni.$lys.dateFormat('Y-m-d H:i:s', this.timeInt);
    this.timeEnd = uni.$lys.dateFormat('Y-m-d H:i:s', this.timeInt + 86400 * 1000 - 1000);
  }
  // 周
  if (this.type == 2) {
    this.timeBegin = uni.$lys.dateFormat('Y-m-d H:i:s', this.timeInt);
    this.timeEnd = uni.$lys.dateFormat('Y-m-d H:i:s', this.timeInt + 86400 * 1000 * 7 - 1000);
  }
  // 月
  if (this.type == 3) {
    let date = new Date(this.timeInt);
    date.setMonth(date.getMonth() + 1);
    this.timeBegin = uni.$lys.dateFormat('Y-m-d H:i:s', this.timeInt);
    this.timeEnd = uni.$lys.dateFormat('Y-m-d H:i:s', new Date(date).getTime() - 1000);
  }
  // 年
  if (this.type == 4) {
    this.timeBegin = uni.$lys.dateFormat('Y-01-01 00:00:00', this.timeInt);
    this.timeEnd = uni.$lys.dateFormat('Y-12-31 23:59:59', this.timeInt);
  }

参数说明

参数名称 参数类型 参数说明 默认值 可选值
showTimePicker Boolean 是否展示 false false\true
type Number 展示类型 1 1-日;2-周;3-月;4-年;
time String 默认时间 当天时间对应的各种类型
@cancleTime Function 取消处理
@submitTime Function 确认处理

特殊说明及注意事项

  • ①各种类型对应的传参结构
    • type = 1,time = 2023-08-21
    • type = 2,time = 2023年 37周
    • type = 3,time = 2023年 09月
    • type = 4,time = 2023年
  • ②确认按钮事件【@submitTime】返回的参数说明
    • time:格式化时间,对应的就是注意事项一的类型
    • timeInt:时间戳,对应开始时间戳
    • type:操作后最终选择的时间类型

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

插件不采集任何数据

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

许可协议

MIT协议

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问