陈鹏铭 93064e9f91 首次提交 9 months ago
..
components 93064e9f91 首次提交 9 months ago
changelog.md 93064e9f91 首次提交 9 months ago
package.json 93064e9f91 首次提交 9 months ago
readme.md 93064e9f91 首次提交 9 months ago

readme.md

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

  • 提供,日、周、月、年,时间统计
  • 开源不易,如有问题请先沟通处理,可留言,也可添加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:操作后最终选择的时间类型