@@ -1,16 +0,0 @@
-## 3.2.0(2024-01-07)
-组件优化
-## 3.2(2023-10-28)
-适配微信小程序
-## 3.1.0(2023-07-27)
-组件说明优化
-## 3.0.1(2023-07-14)
-组件优化 兼容vue3
-## 3.0(2023-07-11)
-优化上拉加载及使用说明
-## 2.0.2(2023-07-11)
-增加上拉加载指示
-## 2.0.1(2023-07-03)
-优化组件说明
-## 2.0.0(2023-06-21)
@@ -1,624 +0,0 @@
-<template>
- <view class="ccPullScroll" :class="customClass" :style="{height}">
- <scroll-view :id="scrollId" class="ccPullScrollview" :scroll-top="scrollTop" :scroll-with-animation="false"
- :scroll-y="scrollAble" :enable-back-to-top="true" @scroll="scroll" @touchstart="touchstart"
- @touchmove="touchmove" @touchend="touchend" :lower-threshold="upOffset" @touchcancel="touchend">
- <view :style="{'transform': translateY, 'transition': transition}">
- <view class="cc-pull-down-wrap"
- :class="[{'is-success': isShowDownTip && isDownSuccess},{'is-error': isShowDownTip && isDownError}]"
- :style="{'height':downOffset+'rpx'}">
- <view class="cc-pull-loading-icon" v-if="!isShowDownTip"
- :class="{'cc-pull-loading-rotate':isDownLoading}" :style="{'transform':downRotate}"></view>
- <view>{{downText}}</view>
- </view>
-
- <slot></slot>
- <slot name="empty" v-if="isEmpty"></slot>
- <view class="cc-pull-up-wrap">
- <slot name="up-loading" v-if="isUpLoading">
- <view class="cc-pull-loading-icon cc-pull-loading-rotate"></view>
- <view>{{upLoadingText}}</view>
- </slot>
- <slot name="up-error" v-if="isUpError && showUpError">
- <view v-if="upErrorText" @click="onUpErrorClick">{{upErrorText}}</view>
- <slot name="up-finish" v-else-if="isUpFinish && showUpFinish">
- <view v-if="upFinishText">{{upFinishText}}</view>
- </scroll-view>
- <!-- 回到顶部按钮 -->
- <view class="cc-pull-back-top" v-if="backTop" :class="{'is-show':isShowBackTop}" @click="onBackTop">
- <slot name="backtop">
- <image class="default-back-top" :src="defaultBackTopImgSrc" mode="aspectFill" />
-</template>
-<script>
- // #ifndef VUE3
- const defaultBackTopImgSrc = require('./back-top.png');
- // #endif
- // #ifdef VUE3
- // const defaultBackTopImgSrc = new URL('./back-top.png', import.meta.url).href;
- // 适配小程序
- import defaultBackTopImgSrc from './back-top.png';
- export default {
- name: 'ccPullScroll',
- data() {
- Object.assign(this, {
- pullType: '',
- scrollRealTop: 0, // 滚动条的位置
- scrollHeight: 0,
- page: 1,
- startPoint: null,
- lastPoint: null,
- startTop: 0,
- inTouchend: false,
- movetype: 0,
- startAngle: 0,
- isMoveDown: false
- });
- return {
- scrollId: 'ccPullScrollview-id-' + Math.random().toString(36).substr(2), // 随机生成mescroll的id(不能数字开头,否则找不到元素)
- defaultBackTopImgSrc,
- downHight: 0, // 下拉刷新: 容器高度
- downRotate: 0, // 下拉刷新: 圆形进度条旋转的角度
- downText: '', // 下拉刷新: 提示的文本
- isEmpty: false, // 是否显示空布局
- isShowDownTip: false, // 下拉刷新提示结果
- isDownSuccess: false, // 下拉刷新成功
- isDownError: false, // 下拉刷新失败
- isDownReset: false, // 下拉刷新: 是否显示重置的过渡动画
- isDownLoading: false, // 下拉刷新: 是否显示加载中
- isUpLoading: false, // 上拉加载: 是否显示 "加载中..."
- isUpFinish: false, // 是否加载完毕
- isUpError: false, // 是否上拉加载出错
- isShowBackTop: false, // 是否显示回到顶部按钮
- scrollAble: true, // 是否禁止下滑 (下拉时禁止,避免抖动)
- scrollTop: 0 // 滚动条的位置
- };
- },
- props: {
- // class
- customClass: {
- type: String,
- default: ''
- // 设置高度,默认继承父级高度
- height: {
- default: '100%'
- // 下拉时文案
- pullingText: {
- default: '下拉刷新'
- // 下拉释放时文案
- loosingText: {
- default: '释放刷新'
- // 下拉释放后文案
- downLoadingText: {
- default: '正在刷新 ...'
- // 上拉加载时文案
- upLoadingText: {
- default: '加载中 ...'
- // 是否显示下拉刷新成功
- showDownSuccess: {
- type: Boolean,
- default: false
- // 下拉刷新成功文案
- downSuccessText: {
- default: '刷新成功'
- // 是否显示下拉刷新失败
- showDownError: {
- // 下拉刷新失败文案
- downErrorText: {
- default: '刷新失败'
- // 是否显示上拉加载时失败
- showUpError: {
- default: true
- // 上拉加载失败文案
- upErrorText: {
- default: '加载失败,点击重新加载'
- // 是否显示上拉加载数据全部完成
- showUpFinish: {
- // 上拉加载完毕文案
- upFinishText: {
- default: '暂无更多了'
- // 下拉配置
- // 下拉回掉,参数为vm
- pullDown: Function,
- // 是否允许下拉刷新
- enablePullDown: {
- downOffset: {
- type: Number,
- default: 100
- downMinAngle: {
- default: 45
- downInOffsetRate: {
- default: 1
- downOutOffsetRate: {
- default: 0.2
- downStartTop: {
- // 下拉释放失效高度
- downTouchHeight: {
- default: 1200
- upOffset: {
- // 回到顶部
- backTop: Boolean,
- // 滚动距离大于多少rpx时触发
- backTopOffset: {
- default: 1000
- }
- computed: {
- numBackTopOffset() {
- return uni.upx2px(this.backTopOffset);
- numDownStartTop() {
- return uni.upx2px(this.downStartTop);
- numDownOffset() {
- return uni.upx2px(this.downOffset);
- numDownTouchHeight() {
- return uni.upx2px(this.downTouchHeight);
- transition() {
- return this.isDownReset ? 'transform 300ms' : '';
- translateY() {
- return this.downHight > 0 ? 'translateY(' + this.downHight + 'px)' : '';
- methods: {
- // 注册列表滚动事件,用于下拉刷新
- scroll(e) {
- e = e.detail;
- // 更新滚动条的位置
- this.scrollRealTop = e.scrollTop;
- // 更新滚动内容高度
- this.scrollHeight = e.scrollHeight;
- // 回到顶部功能
- if (this.backTop) {
- // 返回顶部按钮的显示隐藏
- if (e.scrollTop >= this.numBackTopOffset) {
- this.isShowBackTop = true;
- } else {
- this.isShowBackTop = false;
- // 注册列表touchstart事件,用于下拉刷新
- touchstart(e) {
- if (!this.pullDown || !this.enablePullDown) return;
- this.startPoint = this.getPoint(e); // 记录起点
- this.startTop = this.scrollRealTop; // 记录此时的滚动条位置
- this.startAngle = 0; // 初始角度
- this.lastPoint = this.startPoint; // 重置上次move的点
- this.inTouchend = false; // 标记不是touchend
- // 注册列表touchmove事件,用于下拉刷新
- touchmove(e) {
- const scrollTop = this.scrollRealTop; // 当前滚动条的距离
- const curPoint = this.getPoint(e); // 当前点
- const moveY = curPoint.y - this.startPoint.y; // 和起点比,移动的距离,大于0向下拉,小于0向上拉
- // (向下拉&&在顶部) scroll-view在滚动时不会触发touchmove,当触顶/底/左/右时,才会触发touchmove
- // scroll-view滚动到顶部时,scrollTop不一定为0; 在iOS的APP中scrollTop可能为负数,不一定和startTop相等
- if (moveY > 0 && (scrollTop <= 0 || (scrollTop <= this.numDownStartTop && scrollTop === this.startTop))) {
- // 可下拉的条件
- if (this.pullDown && this.enablePullDown && !this.inTouchend && !this.isDownLoading && !this
- .isUpLoading) {
- // 下拉的初始角度是否在配置的范围内
- if (!this.startAngle) this.startAngle = this.getAngle(this.lastPoint,
- curPoint); // 两点之间的角度,区间 [0,90]
- if (this.startAngle < this.downMinAngle) return; // 如果小于配置的角度,则不往下执行下拉刷新
- // 如果手指的位置超过配置的距离,则提前结束下拉,避免Webview嵌套导致touchend无法触发
- if (this.numDownTouchHeight > 0 && curPoint.y >= this.numDownTouchHeight) {
- this.inTouchend = true; // 标记执行touchend
- this.touchend(); // 提前触发touchend
- return;
- this.preventDefault(e); // 阻止默认事件
- const diff = curPoint.y - this.lastPoint.y; // 和上次比,移动的距离 (大于0向下,小于0向上)
- // 下拉距离 < 指定距离
- if (this.downHight < this.numDownOffset) {
- if (this.movetype !== 1) {
- this.movetype = 1; // 加入标记,保证只执行一次
- // 下拉的距离进入offset范围内那一刻的回调
- this.scrollAble = false; // 禁止下拉,避免抖动
- this.isDownReset = false; // 不重置高度
- this.isDownLoading = false; // 不显示加载中
- this.downText = this.pullingText; // 设置文本
- this.isMoveDown = true; // 标记下拉区域高度改变,在touchend重置回来
- this.downHight += diff * this.downInOffsetRate; // 越往下,高度变化越小
- // 指定距离 <= 下拉距离
- if (this.movetype !== 2) {
- this.movetype = 2; // 加入标记,保证只执行一次
- // 下拉的距离大于offset那一刻的回调
- this.downText = this.loosingText; // 设置文本
- if (diff > 0) { // 向下拉
- this.downHight += Math.round(diff * this.downOutOffsetRate); // 越往下,高度变化越小
- } else { // 向上收
- this.downHight += diff; // 向上收回高度,则向上滑多少收多少高度
- // 设置旋转角度
- this.downRotate = 'rotate(' + 360 * (this.downHight / this.numDownOffset) + 'deg)';
- // 记录本次移动的点
- this.lastPoint = curPoint;
- // 注册列表touchend事件,用于下拉刷新
- touchend(e) {
- // 如果下拉区域高度已改变,则需重置回来
- if (this.isMoveDown) {
- if (this.downHight >= this.numDownOffset) {
- // 符合触发刷新的条件
- this.triggerPullDown();
- // 不符合的话 则重置
- this.downHight = 0;
- this.scrollAble = true; // 开启下拉
- this.isDownReset = true; // 重置高度
- this.scrollTo(0);
- this.movetype = 0;
- this.isMoveDown = false;
- /* 计算两点之间的角度: 区间 [0,90] */
- getAngle(p1, p2) {
- const x = Math.abs(p1.x - p2.x);
- const y = Math.abs(p1.y - p2.y);
- const z = Math.sqrt(x * x + y * y);
- let angle = 0;
- if (z !== 0) {
- angle = Math.asin(y / z) / Math.PI * 180;
- return angle;
- preventDefault(e) {
- // 小程序不支持e.preventDefault
- // app的bounce只能通过配置pages.json的style.app-plus.bounce为"none"来禁止
- // cancelable:是否可以被禁用; defaultPrevented:是否已经被禁用
- if (e && e.cancelable && !e.defaultPrevented) e.preventDefault();
- // 点击回到顶部的按钮回调
- onBackTop() {
- this.isShowBackTop = false; // 回到顶部按钮需要先隐藏,再执行回到顶部,避免闪动
- this.scrollTo(0); // 执行回到顶部
- // 点击失败重新加载
- onUpErrorClick() {
- this.isUpError = false;
- scrollTo(y) {
- this.scrollTop = this.scrollRealTop;
- this.$nextTick(() => {
- this.scrollTop = y;
- /* 根据点击滑动事件获取第一个手指的坐标 */
- getPoint(e) {
- if (!e) {
- x: 0,
- y: 0
- if (e.touches && e.touches[0]) {
- x: e.touches[0].pageX,
- y: e.touches[0].pageY
- } else if (e.changedTouches && e.changedTouches[0]) {
- x: e.changedTouches[0].pageX,
- y: e.changedTouches[0].pageY
- x: e.clientX,
- y: e.clientY
- /* 显示上拉加载中 */
- showUpLoading() {
- this.isEmpty = false;
- this.isUpFinish = false;
- this.isUpLoading = true;
- /* 显示下拉进度布局 */
- showDownLoading() {
- this.isUpLoading = false;
- this.isShowDownTip = false;
- this.isDownSuccess = false;
- this.isDownError = false;
- this.isDownLoading = true; // 显示加载中
- this.downHight = this.numDownOffset; // 更新下拉区域高度
- this.downText = this.downLoadingText; // 设置文本
- /* 结束下拉刷新 */
- hideDownLoading() {
- if (this.isDownLoading) {
- if (this.isDownSuccess && this.showDownSuccess) {
- this.downText = this.downSuccessText;
- this.isShowDownTip = true;
- } else if (this.isDownError && this.showDownError) {
- this.downText = this.downErrorText;
- if (this.isShowDownTip) {
- setTimeout(() => {
- this.scrollHeight = 0; // 重置滚动区域,使数据不满屏时仍可检查触发翻页
- }, 300);
- }, 1000);
- /* 结束上拉加载 */
- hideUpLoading() {
- if (this.isUpLoading) {
- /* 触发下拉刷新 */
- triggerPullDown() {
- if (this.pullDown && this.enablePullDown && !this.isDownLoading && !this.isUpLoading) {
- // 下拉加载中...
- this.showDownLoading(); // 下拉刷新中...
- this.page = 1; // 预先加一页
- this.pullType = 'down';
- this.pullDown && this.pullDown.call(this.$parent, this);
- refresh() {
- this.page = 1;
- this.isDownLoading = false;
- if (this.pullDown && this.enablePullDown) {
- /* 正常加载成功 */
- success() {
- this.page++;
- this.isDownSuccess = true;
- this.hideDownLoading();
- this.hideUpLoading();
- /* 加载失败 */
- error() {
- this.isDownError = true;
- } else if (this.isUpLoading) {
- this.isUpError = true;
- /* 没有数据 */
- empty() {
- this.isEmpty = true;
- this.isUpFinish = true;
- /* 全部数据加载完毕 */
- finish() {
-</script>
-<style lang="scss" scoped>
- .ccPullScroll {
- height: 100%;
- position: relative;
- .ccPullScrollview {
- width: 100%;
- overflow-y: auto;
- box-sizing: border-box;
- /* 定位的方式固定高度 */
- .is-fixed {
- z-index: 1;
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- width: auto;
- height: auto;
- .cc-pull-down-wrap,
- .cc-pull-up-wrap {
- display: flex;
- justify-content: center;
- align-items: center;
- font-size: 28rpx;
- color: gray;
- .cc-pull-down-wrap {
- position: absolute;
- transform: translateY(-100%);
- min-height: 100rpx;
- /* 旋转loading */
- .cc-pull-loading-icon {
- width: 28rpx;
- height: 28rpx;
- border-radius: 50%;
- margin-right: 16rpx;
- border: 2rpx solid currentColor;
- border-bottom-color: transparent !important;
- /* 旋转动画 */
- .cc-pull-loading-rotate {
- animation: cc-pull-loading-rotate 0.6s linear infinite;
- @keyframes cc-pull-loading-rotate {
- 0% {
- transform: rotate(0deg);
- 100% {
- transform: rotate(360deg);
- /* 回到顶部的按钮 */
- .cc-pull-back-top {
- opacity: 0;
- pointer-events: none;
- transition: opacity 0.3s linear;
- &.is-show {
- opacity: 1;
- pointer-events: auto;
- .default-back-top {
- right: 20rpx;
- width: 72rpx;
- height: 72rpx;
- bottom: 30rpx;
- z-index: 99;
-</style>
@@ -1,85 +0,0 @@
-{
- "id": "cc-pullScroolView",
- "displayName": "简单好用的滚动列表【自动加载,上拉加载,下拉刷新,可自定义】",
- "version": "3.2.0",
- "description": "简单好用的滚动列表【自动加载,上拉加载,下拉刷新,可自定义】,支持列表分页 本地分页",
- "keywords": [
- "下拉刷新",
- "上拉加载",
- "分页器",
- "加载器",
- "虚拟列表"
-],
- "repository": "",
- "engines": {
- "HBuilderX": "^3.8.0"
- "dcloudext": {
- "type": "component-vue",
- "sale": {
- "regular": {
- "price": "0.00"
- "sourcecode": {
- "contact": {
- "qq": ""
- "declaration": {
- "ads": "无",
- "data": "无",
- "permissions": "无"
- "npmurl": ""
- "uni_modules": {
- "dependencies": [],
- "encrypt": [],
- "platforms": {
- "cloud": {
- "tcb": "y",
- "aliyun": "y"
- "client": {
- "Vue": {
- "vue2": "y",
- "vue3": "y"
- "App": {
- "app-vue": "y",
- "app-nvue": "y"
- "H5-mobile": {
- "Safari": "y",
- "Android Browser": "y",
- "微信浏览器(Android)": "y",
- "QQ浏览器(Android)": "y"
- "H5-pc": {
- "Chrome": "y",
- "IE": "y",
- "Edge": "y",
- "Firefox": "y",
- "Safari": "y"
- "小程序": {
- "微信": "y",
- "阿里": "y",
- "百度": "y",
- "字节跳动": "y",
- "QQ": "y",
- "钉钉": "y",
- "快手": "y",
- "飞书": "y",
- "京东": "y"
- "快应用": {
- "华为": "y",
- "联盟": "y"
-}
@@ -1,197 +0,0 @@
-### 我的技术微信公众号
-查看更多前端组件和框架信息,请关注我的技术微信公众号【前端组件开发】
-
-# cc-pullScroolView
-#### 使用方法
-```使用方法
-<!-- ref:唯一ref pullDown:下拉刷新事件 上拉加载方法写在生命周期onReachBottom方法内 -->
-<cc-pullScroolView class="pullScrollView" ref="pullScroll" :pullDown="pullDown">
-</cc-pullScroolView>
-<!-- 注意: 上拉加载方法写在onReachBottom方法内 -->
-onReachBottom() {
- // 数据全部加载完
- if (this.curPageNum * 10 >= this.totalNum) {
- // 显示加载中
- this.$refs.pullScroll.showUpLoading();
- this.curPageNum++;
- this.requestData();
-```
-#### HTML代码实现部分
-```html
- <view class="content">
- <div class="mui-content-padded">
- <!-- ref:唯一ref pullDown:下拉刷新事件 onReachBottom:上拉加载事件 -->
- <cc-pullScroolView class="pullScrollView" ref="pullScroll" :back-top="true" :pullDown="pullDown">
- <!-- 列表组件 -->
- <CCBProjectList :productList="projectList" @click="goProDetail"></CCBProjectList>
- </cc-pullScroolView>
- </div>
- import CCBProjectList from '../../components/ccPageView/CCProjectList.vue';
- components: {
- CCBProjectList,
- // 列表总数量
- totalNum: 60,
- // 页码 默认1开始
- curPageNum: 1,
- // 列表数组
- projectList: []
- onLoad() {
- // 页面刷新方法 会自动调用pulldown一次
- this.pageRefresh();
- // 上拉加载
- onReachBottom() {
- pageRefresh() {
- let myThis = this;
- myThis.$refs.pullScroll.refresh();
- // 下拉刷新
- pullDown(pullScroll) {
- console.log('下拉刷新');
- this.projectList = [];
- this.curPageNum = 1;
- this.requestData(pullScroll);
- // 列表条目点击事件
- goProDetail(item) {
- requestData() {
- // 模拟请求参数设置
- let reqData = {
- 'area': '',
- "pageSize": 10,
- "pageNo": this.curPageNum
- setTimeout(function() {
- // 模拟请求接口
- for (let i = 0; i < 10; i++) {
- myThis.projectList.push({
- 'proName': '产品名称' + i,
- 'proUnit': '公司名称' + i,
- 'area': '广东省',
- 'proType': '省级项目',
- 'stage': '已开工',
- 'id': 10 * (myThis.curPageNum + i) + myThis.curPageNum + ''
- myThis.totalNum = 60;
- // 如果是最后一页
- if (myThis.curPageNum * 10 >= myThis.totalNum) {
- myThis.$refs.pullScroll.finish();
- // 不是最后一页
- myThis.$refs.pullScroll.success();
- }, 600);
-<style>
- page {
- background-color: #f2f2f2;
- .content {
- flex-direction: column;
- .mui-content-padded {
- margin: 0px 14px;
- /* background-color: #ffffff; */
- .pullScrollView {
@@ -1,193 +0,0 @@
-## 为减小组件包的大小,默认组件包中不包含编辑、latex 公式等扩展功能,需要使用扩展功能的请参考下方的 插件扩展 栏的说明
-## 功能介绍
-- 全端支持(含 `v3、NVUE`)
-- 支持丰富的标签(包括 `table`、`video`、`svg` 等)
-- 支持丰富的事件效果(自动预览图片、链接处理等)
-- 支持设置占位图(加载中、出错时、预览时)
-- 支持锚点跳转、长按复制等丰富功能
-- 支持大部分 *html* 实体
-- 丰富的插件(关键词搜索、内容编辑、`latex` 公式等)
-- 效率高、容错性强且轻量化
-查看 [功能介绍](https://jin-yufeng.gitee.io/mp-html/#/overview/feature) 了解更多
-## 使用方法
-- `uni_modules` 方式
- 1. 点击右上角的 `使用 HBuilder X 导入插件` 按钮直接导入项目或点击 `下载插件 ZIP` 按钮下载插件包并解压到项目的 `uni_modules/mp-html` 目录下
- 2. 在需要使用页面的 `(n)vue` 文件中添加
- ```html
- <!-- 不需要引入,可直接使用 -->
- <mp-html :content="html" />
- ```
- ```javascript
- html: '<div>Hello World!</div>'
- 3. 需要更新版本时在 `HBuilder X` 中右键 `uni_modules/mp-html` 目录选择 `从插件市场更新` 即可
-- 源码方式
- 1. 从 [github](https://github.com/jin-yufeng/mp-html/tree/master/dist/uni-app) 或 [gitee](https://gitee.com/jin-yufeng/mp-html/tree/master/dist/uni-app) 下载源码
- 插件市场的 **非 uni_modules 版本** 无法更新,不建议从插件市场获取
- import mpHtml from '@/components/mp-html/mp-html'
- // HBuilderX 2.5.5+ 可以通过 easycom 自动引入
- mpHtml
-- npm 方式
- 1. 在项目根目录下执行
- ```bash
- npm install mp-html
- import mpHtml from 'mp-html/dist/uni-app/components/mp-html/mp-html'
- // 不可省略
- 3. 需要更新版本时执行以下命令即可
- npm update mp-html
- 使用 *cli* 方式运行的项目,通过 *npm* 方式引入时,需要在 *vue.config.js* 中配置 *transpileDependencies*,详情可见 [#330](https://github.com/jin-yufeng/mp-html/issues/330#issuecomment-913617687)
- 如果在 **nvue** 中使用还要将 `dist/uni-app/static` 目录下的内容拷贝到项目的 `static` 目录下,否则无法运行
-查看 [快速开始](https://jin-yufeng.gitee.io/mp-html/#/overview/quickstart) 了解更多
-## 组件属性
-| 属性 | 类型 | 默认值 | 说明 |
-|:---:|:---:|:---:|---|
-| container-style | String | | 容器的样式([2.1.0+](https://jin-yufeng.gitee.io/mp-html/#/changelog/changelog#v210)) |
-| content | String | | 用于渲染的 html 字符串 |
-| copy-link | Boolean | true | 是否允许外部链接被点击时自动复制 |
-| domain | String | | 主域名(用于链接拼接) |
-| error-img | String | | 图片出错时的占位图链接 |
-| lazy-load | Boolean | false | 是否开启图片懒加载 |
-| loading-img | String | | 图片加载过程中的占位图链接 |
-| pause-video | Boolean | true | 是否在播放一个视频时自动暂停其他视频 |
-| preview-img | Boolean | true | 是否允许图片被点击时自动预览 |
-| scroll-table | Boolean | false | 是否给每个表格添加一个滚动层使其能单独横向滚动 |
-| selectable | Boolean | false | 是否开启文本长按复制 |
-| set-title | Boolean | true | 是否将 title 标签的内容设置到页面标题 |
-| show-img-menu | Boolean | true | 是否允许图片被长按时显示菜单 |
-| tag-style | Object | | 设置标签的默认样式 |
-| use-anchor | Boolean | false | 是否使用锚点链接 |
-查看 [属性](https://jin-yufeng.gitee.io/mp-html/#/basic/prop) 了解更多
-## 组件事件
-| 名称 | 触发时机 |
-|:---:|---|
-| load | dom 树加载完毕时 |
-| ready | 图片加载完毕时 |
-| error | 发生渲染错误时 |
-| imgtap | 图片被点击时 |
-| linktap | 链接被点击时 |
-| play | 音视频播放时 |
-查看 [事件](https://jin-yufeng.gitee.io/mp-html/#/basic/event) 了解更多
-## api
-组件实例上提供了一些 `api` 方法可供调用
-| 名称 | 作用 |
-| in | 将锚点跳转的范围限定在一个 scroll-view 内 |
-| navigateTo | 锚点跳转 |
-| getText | 获取文本内容 |
-| getRect | 获取富文本内容的位置和大小 |
-| setContent | 设置富文本内容 |
-| imgList | 获取所有图片的数组 |
-| pauseMedia | 暂停播放音视频([2.2.2+](https://jin-yufeng.gitee.io/mp-html/#/changelog/changelog#v222)) |
-| setPlaybackRate | 设置音视频播放速率([2.4.0+](https://jin-yufeng.gitee.io/mp-html/#/changelog/changelog#v240)) |
-查看 [api](https://jin-yufeng.gitee.io/mp-html/#/advanced/api) 了解更多
-## 插件扩展
-除基本功能外,本组件还提供了丰富的扩展,可按照需要选用
-| audio | 音乐播放器 |
-| editable | 富文本 **编辑**([示例项目](https://mp-html.oss-cn-hangzhou.aliyuncs.com/editable.zip)) |
-| emoji | 解析 emoji |
-| highlight | 代码块高亮显示 |
-| markdown | 渲染 markdown |
-| search | 关键词搜索 |
-| style | 匹配 style 标签中的样式 |
-| txv-video | 使用腾讯视频 |
-| img-cache | 图片缓存 by [@PentaTea](https://github.com/PentaTea) |
-| latex | 渲染 latex 公式 by [@Zeng-J](https://github.com/Zeng-J) |
-从插件市场导入的包中 **不含有** 扩展插件,使用插件需通过微信小程序 `富文本插件` 获取或参考以下方法进行打包:
-1. 获取完整组件包
-2. 编辑 `tools/config.js` 中的 `plugins` 项,选择需要的插件
-3. 生成新的组件包
- 在 `node_modules/mp-html` 目录下执行
- npm install
- npm run build:uni-app
-4. 拷贝 `dist/uni-app` 中的内容到项目根目录
-查看 [插件](https://jin-yufeng.gitee.io/mp-html/#/advanced/plugin) 了解更多
-## 关于 nvue
-`nvue` 使用原生渲染,不支持部分 `css` 样式,为实现和 `html` 相同的效果,组件内部通过 `web-view` 进行渲染,性能上差于原生,根据 `weex` 官方建议,`web` 标签仅应用在非常规的降级场景。因此,如果通过原生的方式(如 `richtext`)能够满足需要,则不建议使用本组件,如果有较多的富文本内容,则可以直接使用 `vue` 页面
-由于渲染方式与其他端不同,有以下限制:
-1. 不支持 `lazy-load` 属性
-2. 视频不支持全屏播放
-3. 如果在 `flex-direction: row` 的容器中使用,需要给组件设置宽度或设置 `flex: 1` 占满剩余宽度
-纯 `nvue` 模式下,[此问题](https://ask.dcloud.net.cn/question/119678) 修复前,不支持通过 `uni_modules` 引入,需要本地引入(将 [dist/uni-app](https://github.com/jin-yufeng/mp-html/tree/master/dist/uni-app) 中的内容拷贝到项目根目录下)
-## 立即体验
-
-## 问题反馈
-遇到问题时,请先查阅 [常见问题](https://jin-yufeng.gitee.io/mp-html/#/question/faq) 和 [issue](https://github.com/jin-yufeng/mp-html/issues) 中是否已有相同的问题
-可通过 [issue](https://github.com/jin-yufeng/mp-html/issues/new/choose) 、插件问答或发送邮件到 [mp_html@126.com](mailto:mp_html@126.com) 提问,不建议在评论区提问(不方便回复)
-提问请严格按照 [issue 模板](https://github.com/jin-yufeng/mp-html/issues/new/choose) ,描述清楚使用环境、`html` 内容或可复现的 `demo` 项目以及复现方式,对于 **描述不清**、**无法复现** 或重复的问题将不予回复
-欢迎加入 `QQ` 交流群:
-群1(已满):`699734691`
-群2:`778239129`
-查看 [问题反馈](https://jin-yufeng.gitee.io/mp-html/#/question/feedback) 了解更多
@@ -1,129 +0,0 @@
-## v2.4.2(2023-05-14)
-1. `A` `editable` 插件支持修改文字颜色 [详细](https://github.com/jin-yufeng/mp-html/issues/254)
-2. `F` 修复了 `svg` 中有 `style` 不生效的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/505)
-3. `F` 修复了使用旧版编译器可能报错 `Bad attr nodes` 的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/472)
-4. `F` 修复了 `app` 端可能出现无法读取 `lazyLoad` 的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/513)
-5. `F` 修复了 `editable` 插件在点击换图时未拼接 `domain` 的问题 [详细](https://github.com/jin-yufeng/mp-html/pull/497) by [@TwoKe945](https://github.com/TwoKe945)
-6. `F` 修复了 `latex` 插件部分情况下不显示的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/515)
-7. `F` 修复了 `editable` 插件点击音视频时其他标签框不消失的问题
-## v2.4.1(2022-12-25)
-1. `F` 修复了没有图片时 `ready` 事件可能不触发的问题
-2. `F` 修复了加载过程中可能出现 `Root label not found` 错误的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/470)
-3. `F` 修复了 `audio` 插件退出页面可能会报错的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/457)
-4. `F` 修复了 `vue3` 运行到 `app` 在 `HBuilder X 3.6.10` 以上报错的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/480)
-5. `F` 修复了 `nvue` 端链接中包含 `%22` 时可能无法显示的问题
-6. `F` 修复了 `vue3` 使用 `highlight` 插件可能报错的问题
-## v2.4.0(2022-08-27)
-1. `A` 增加了 [setPlaybackRate](https://jin-yufeng.gitee.io/mp-html/#/advanced/api#setPlaybackRate) 的 `api`,可以设置音视频的播放速率 [详细](https://github.com/jin-yufeng/mp-html/issues/452)
-2. `A` 示例小程序代码开源 [详细](https://github.com/jin-yufeng/mp-html-demo)
-3. `U` 优化 `ready` 事件触发时机,未设置懒加载的情况下基本可以准确触发 [详细](https://github.com/jin-yufeng/mp-html/issues/195)
-4. `U` `highlight` 插件在编辑状态下不进行高亮处理,便于编辑
-5. `F` 修复了 `flex` 布局下图片大小可能不正确的问题
-6. `F` 修复了 `selectable` 属性没有设置 `force` 也可能出现渲染异常的问题
-7. `F` 修复了表格中的图片大小可能不正确的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/448)
-8. `F` 修复了含有合并单元格的表格可能无法设置竖直对齐的问题
-9. `F` 修复了 `editable` 插件在 `scroll-view` 中使用时工具条位置可能不正确的问题
-10. `F` 修复了 `vue3` 使用 [search](advanced/plugin#search) 插件可能导致错误换行的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/449)
-## v2.3.2(2022-08-13)
-1. `A` 增加 [latex](https://jin-yufeng.gitee.io/mp-html/#/advanced/plugin#latex) 插件,可以渲染数学公式 [详细](https://github.com/jin-yufeng/mp-html/pull/447) by [@Zeng-J](https://github.com/Zeng-J)
-2. `U` 优化根节点下有很多标签的长内容渲染速度
-3. `U` `highlight` 插件适配 `lang-xxx` 格式
-4. `F` 修复了 `table` 标签设置 `border` 属性后可能无法修改边框样式的问题 [详细](https://github.com/jin-yufeng/mp-html/pull/439) by [@zouxingjie](https://github.com/zouxingjie)
-5. `F` 修复了 `editable` 插件输入连续空格无效的问题
-6. `F` 修复了 `vue3` 图片设置 `inline` 会报错的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/438)
-7. `F` 修复了 `vue3` 使用 `table` 可能报错的问题
-## v2.3.1(2022-05-20)
-1. `U` `app` 端支持使用本地图片
-2. `U` 优化了微信小程序 `selectable` 属性在 `ios` 端的处理 [详细](https://jin-yufeng.gitee.io/mp-html/#/basic/prop#selectable)
-3. `F` 修复了 `editable` 插件不在顶部时 `tooltip` 位置可能错误的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/430)
-4. `F` 修复了 `vue3` 运行到微信小程序可能报错丢失内容的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/414)
-5. `F` 修复了 `vue3` 部分标签可能被错误换行的问题
-6. `F` 修复了 `editable` 插件 `app` 端插入视频无法预览的问题
-## v2.3.0(2022-04-01)
-1. `A` 增加了 `play` 事件,音视频播放时触发,可用于与页面其他音视频进行互斥播放 [详细](basic/event#play)
-2. `U` `show-img-menu` 属性支持控制预览时是否长按弹出菜单
-3. `U` 优化 `wxs` 处理,提高渲染性能 [详细](https://developers.weixin.qq.com/community/develop/article/doc/0006cc2b204740f601bd43fa25a413)
-4. `U` `video` 标签支持 `object-fit` 属性
-5. `U` 增加支持一些常用实体编码 [详细](https://github.com/jin-yufeng/mp-html/issues/418)
-6. `F` 修复了图片仅设置高度可能不显示的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/410)
-7. `F` 修复了 `video` 标签高度设置为 `auto` 不显示的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/411)
-8. `F` 修复了使用 `grid` 布局时可能样式错误的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/413)
-9. `F` 修复了含有合并单元格的表格部分情况下显示异常的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/417)
-10. `F` 修复了 `editable` 插件连续插入内容时顺序不正确的问题
-11. `F` 修复了 `uni-app` 包 `vue3` 使用 `audio` 插件报错的问题
-12. `F` 修复了 `uni-app` 包 `highlight` 插件使用自定义的 `prism.min.js` 报错的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/416)
-## v2.2.2(2022-02-26)
-1. `A` 增加了 [pauseMedia](https://jin-yufeng.gitee.io/mp-html/#/advanced/api#pauseMedia) 的 `api`,可用于暂停播放音视频 [详细](https://github.com/jin-yufeng/mp-html/issues/317)
-2. `U` 优化了长内容的加载速度
-3. `U` 适配 `vue3` [#389](https://github.com/jin-yufeng/mp-html/issues/389)、[#398](https://github.com/jin-yufeng/mp-html/pull/398) by [@zhouhuafei](https://github.com/zhouhuafei)、[#400](https://github.com/jin-yufeng/mp-html/issues/400)
-4. `F` 修复了小程序端图片高度设置为百分比时可能不显示的问题
-5. `F` 修复了 `highlight` 插件部分情况下可能显示不完整的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/403)
-## v2.2.1(2021-12-24)
-1. `A` `editable` 插件增加上下移动标签功能
-2. `U` `editable` 插件支持在文本中间光标处插入内容
-3. `F` 修复了 `nvue` 端设置 `margin` 后可能导致高度不正确的问题
-4. `F` 修复了 `highlight` 插件使用压缩版的 `prism.css` 可能导致背景失效的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/367)
-5. `F` 修复了编辑状态下使用 `emoji` 插件内容为空时可能报错的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/371)
-6. `F` 修复了使用 `editable` 插件后将 `selectable` 属性设置为 `force` 不生效的问题
-## v2.2.0(2021-10-12)
-1. `A` 增加 `customElements` 配置项,便于添加自定义功能性标签 [详细](https://github.com/jin-yufeng/mp-html/issues/350)
-2. `A` `editable` 插件增加切换音视频自动播放状态的功能 [详细](https://github.com/jin-yufeng/mp-html/pull/341) by [@leeseett](https://github.com/leeseett)
-3. `A` `editable` 插件删除媒体标签时触发 `remove` 事件,便于删除已上传的文件
-4. `U` `editable` 插件 `insertImg` 方法支持同时插入多张图片 [详细](https://github.com/jin-yufeng/mp-html/issues/342)
-5. `U` `editable` 插入图片和音视频时支持拼接 `domian` 主域名
-6. `F` 修复了内部链接参数中包含 `://` 时被认为是外部链接的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/356)
-7. `F` 修复了部分 `svg` 标签名或属性名大小写不正确时不生效的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/351)
-8. `F` 修复了 `nvue` 页面运行到非 `app` 平台时可能样式错误的问题
-## v2.1.5(2021-08-13)
-1. `A` 增加支持标签的 `dir` 属性
-2. `F` 修复了 `ruby` 标签文字与拼音没有居中对齐的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/325)
-3. `F` 修复了音视频标签内有 `a` 标签时可能无法播放的问题
-4. `F` 修复了 `externStyle` 中的 `class` 名包含下划线或数字时可能失效的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/326)
-5. `F` 修复了 `h5` 端引入 `externStyle` 可能不生效的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/326)
-## v2.1.4(2021-07-14)
-1. `F` 修复了 `rt` 标签无法设置样式的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/318)
-2. `F` 修复了表格中有单元格同时合并行和列时可能显示不正确的问题
-3. `F` 修复了 `app` 端无法关闭图片长按菜单的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/322)
-4. `F` 修复了 `editable` 插件只能添加图片链接不能修改的问题 [详细](https://github.com/jin-yufeng/mp-html/pull/312) by [@leeseett](https://github.com/leeseett)
-## v2.1.3(2021-06-12)
-1. `A` `editable` 插件增加 `insertTable` 方法
-2. `U` `editable` 插件支持编辑表格中的空白单元格 [详细](https://github.com/jin-yufeng/mp-html/issues/310)
-3. `F` 修复了 `externStyle` 中使用伪类可能失效的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/298)
-4. `F` 修复了多个组件同时使用时 `tag-style` 属性时可能互相影响的问题 [详细](https://github.com/jin-yufeng/mp-html/pull/305) by [@woodguoyu](https://github.com/woodguoyu)
-5. `F` 修复了包含 `linearGradient` 的 `svg` 可能无法显示的问题
-6. `F` 修复了编译到头条小程序时可能报错的问题
-7. `F` 修复了 `nvue` 端不触发 `click` 事件的问题
-8. `F` 修复了 `editable` 插件尾部插入时无法撤销的问题
-9. `F` 修复了 `editable` 插件的 `insertHtml` 方法只能在末尾插入的问题
-10. `F` 修复了 `editable` 插件插入音频不显示的问题
-## v2.1.2(2021-04-24)
-1. `A` 增加了 [img-cache](https://jin-yufeng.gitee.io/mp-html/#/advanced/plugin#img-cache) 插件,可以在 `app` 端缓存图片 [详细](https://github.com/jin-yufeng/mp-html/issues/292) by [@PentaTea](https://github.com/PentaTea)
-2. `U` 支持通过 `container-style` 属性设置 `white-space` 来保留连续空格和换行符 [详细](https://jin-yufeng.gitee.io/mp-html/#/question/faq#space)
-3. `U` 代码风格符合 [standard](https://standardjs.com) 标准
-4. `U` `editable` 插件编辑状态下支持预览视频 [详细](https://github.com/jin-yufeng/mp-html/issues/286)
-5. `F` 修复了 `svg` 标签内嵌 `svg` 时无法显示的问题
-6. `F` 修复了编译到支付宝和头条小程序时部分区域不可复制的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/291)
-## v2.1.1(2021-04-09)
-1. 修复了对 `p` 标签设置 `tag-style` 可能不生效的问题
-2. 修复了 `svg` 标签中的文本无法显示的问题
-3. 修复了使用 `editable` 插件编辑表格时可能报错的问题
-4. 修复了使用 `highlight` 插件运行到头条小程序时可能没有样式的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/280)
-5. 修复了使用 `editable` 插件 `editable` 属性为 `false` 时会报错的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/284)
-6. 修复了 `style` 插件连续子选择器失效的问题
-7. 修复了 `editable` 插件无法修改图片和字体大小的问题
-## v2.1.0.2(2021-03-21)
-修复了 `nvue` 端使用可能报错的问题
-## v2.1.0(2021-03-20)
-1. `A` 增加了 [container-style](https://jin-yufeng.gitee.io/mp-html/#/basic/prop#container-style) 属性 [详细](https://gitee.com/jin-yufeng/mp-html/pulls/1)
-2. `A` 增加支持 `strike` 标签
-3. `A` `editable` 插件增加 `placeholder` 属性 [详细](https://jin-yufeng.gitee.io/mp-html/#/advanced/plugin#editable)
-4. `A` `editable` 插件增加 `insertHtml` 方法 [详细](https://jin-yufeng.gitee.io/mp-html/#/advanced/plugin#editable)
-5. `U` 外部样式支持标签名选择器 [详细](https://jin-yufeng.gitee.io/mp-html/#/overview/quickstart#setting)
-6. `F` 修复了 `nvue` 端部分情况下可能不显示的问题
-## v2.0.5(2021-03-12)
-1. `U` [linktap](https://jin-yufeng.gitee.io/mp-html/#/basic/event#linktap) 事件增加返回内部文本内容 `innerText` [详细](https://github.com/jin-yufeng/mp-html/issues/271)
-2. `U` [selectable](https://jin-yufeng.gitee.io/mp-html/#/basic/prop#selectable) 属性设置为 `force` 时能够在微信 `iOS` 端生效(文本块会变成 `inline-block`) [详细](https://github.com/jin-yufeng/mp-html/issues/267)
-3. `F` 修复了部分情况下竖向无法滚动的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/182)
-4. `F` 修复了多次修改富文本数据时部分内容可能不显示的问题
-5. `F` 修复了 [腾讯视频](https://jin-yufeng.gitee.io/mp-html/#/advanced/plugin#txv-video) 插件可能无法播放的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/265)
-6. `F` 修复了 [highlight](https://jin-yufeng.gitee.io/mp-html/#/advanced/plugin#highlight) 插件没有设置高亮语言时没有应用默认样式的问题 [详细](https://github.com/jin-yufeng/mp-html/issues/276) by [@fuzui](https://github.com/fuzui)
@@ -1,498 +0,0 @@
- <view id="_root" :class="(selectable?'_select ':'')+'_root'" :style="containerStyle">
- <slot v-if="!nodes[0]" />
- <!-- #ifndef APP-PLUS-NVUE -->
- <node v-else :childs="nodes" :opts="[lazyLoad,loadingImg,errorImg,showImgMenu,selectable]" name="span" />
- <!-- #endif -->
- <!-- #ifdef APP-PLUS-NVUE -->
- <web-view ref="web" src="/uni_modules/mp-html/static/app-plus/mp-html/local.html" :style="'margin-top:-2px;height:' + height + 'px'" @onPostMessage="_onMessage" />
-/**
- * mp-html v2.4.2
- * @description 富文本组件
- * @tutorial https://github.com/jin-yufeng/mp-html
- * @property {String} container-style 容器的样式
- * @property {String} content 用于渲染的 html 字符串
- * @property {Boolean} copy-link 是否允许外部链接被点击时自动复制
- * @property {String} domain 主域名,用于拼接链接
- * @property {String} error-img 图片出错时的占位图链接
- * @property {Boolean} lazy-load 是否开启图片懒加载
- * @property {string} loading-img 图片加载过程中的占位图链接
- * @property {Boolean} pause-video 是否在播放一个视频时自动暂停其他视频
- * @property {Boolean} preview-img 是否允许图片被点击时自动预览
- * @property {Boolean} scroll-table 是否给每个表格添加一个滚动层使其能单独横向滚动
- * @property {Boolean | String} selectable 是否开启长按复制
- * @property {Boolean} set-title 是否将 title 标签的内容设置到页面标题
- * @property {Boolean} show-img-menu 是否允许图片被长按时显示菜单
- * @property {Object} tag-style 标签的默认样式
- * @property {Boolean | Number} use-anchor 是否使用锚点链接
- * @event {Function} load dom 结构加载完毕时触发
- * @event {Function} ready 所有图片加载完毕时触发
- * @event {Function} imgtap 图片被点击时触发
- * @event {Function} linktap 链接被点击时触发
- * @event {Function} play 音视频播放时触发
- * @event {Function} error 媒体加载出错时触发
- */
-// #ifndef APP-PLUS-NVUE
-import node from './node/node'
-// #endif
-import Parser from './parser'
-const plugins=[]
-// #ifdef APP-PLUS-NVUE
-const dom = weex.requireModule('dom')
-export default {
- name: 'mp-html',
- data () {
- nodes: [],
- // #ifdef APP-PLUS-NVUE
- height: 3
- containerStyle: {
- content: {
- copyLink: {
- type: [Boolean, String],
- domain: String,
- errorImg: {
- lazyLoad: {
- loadingImg: {
- pauseVideo: {
- previewImg: {
- scrollTable: [Boolean, String],
- selectable: [Boolean, String],
- setTitle: {
- showImgMenu: {
- tagStyle: Object,
- useAnchor: [Boolean, Number]
- emits: ['load', 'ready', 'imgtap', 'linktap', 'play', 'error'],
- // #ifndef APP-PLUS-NVUE
- node
- watch: {
- content (content) {
- this.setContent(content)
- created () {
- this.plugins = []
- for (let i = plugins.length; i--;) {
- this.plugins.push(new plugins[i](this))
- mounted () {
- if (this.content && !this.nodes.length) {
- this.setContent(this.content)
- beforeDestroy () {
- this._hook('onDetached')
- /**
- * @description 将锚点跳转的范围限定在一个 scroll-view 内
- * @param {Object} page scroll-view 所在页面的示例
- * @param {String} selector scroll-view 的选择器
- * @param {String} scrollTop scroll-view scroll-top 属性绑定的变量名
- in (page, selector, scrollTop) {
- if (page && selector && scrollTop) {
- this._in = {
- page,
- selector,
- scrollTop
- * @description 锚点跳转
- * @param {String} id 要跳转的锚点 id
- * @param {Number} offset 跳转位置的偏移量
- * @returns {Promise}
- navigateTo (id, offset) {
- return new Promise((resolve, reject) => {
- if (!this.useAnchor) {
- reject(Error('Anchor is disabled'))
- return
- offset = offset || parseInt(this.useAnchor) || 0
- if (!id) {
- dom.scrollToElement(this.$refs.web, {
- offset
- })
- resolve()
- this._navigateTo = {
- resolve,
- reject,
- this.$refs.web.evalJs('uni.postMessage({data:{action:"getOffset",offset:(document.getElementById(' + id + ')||{}).offsetTop}})')
- let deep = ' '
- // #ifdef MP-WEIXIN || MP-QQ || MP-TOUTIAO
- deep = '>>>'
- const selector = uni.createSelectorQuery()
- // #ifndef MP-ALIPAY
- .in(this._in ? this._in.page : this)
- .select((this._in ? this._in.selector : '._root') + (id ? `${deep}#${id}` : '')).boundingClientRect()
- if (this._in) {
- selector.select(this._in.selector).scrollOffset()
- .select(this._in.selector).boundingClientRect()
- // 获取 scroll-view 的位置和滚动距离
- selector.selectViewport().scrollOffset() // 获取窗口的滚动距离
- selector.exec(res => {
- if (!res[0]) {
- reject(Error('Label not found'))
- const scrollTop = res[1].scrollTop + res[0].top - (res[2] ? res[2].top : 0) + offset
- // scroll-view 跳转
- this._in.page[this._in.scrollTop] = scrollTop
- // 页面跳转
- uni.pageScrollTo({
- scrollTop,
- duration: 300
- * @description 获取文本内容
- * @return {String}
- getText (nodes) {
- let text = '';
- (function traversal (nodes) {
- for (let i = 0; i < nodes.length; i++) {
- const node = nodes[i]
- if (node.type === 'text') {
- text += node.text.replace(/&/g, '&')
- } else if (node.name === 'br') {
- text += '\n'
- // 块级标签前后加换行
- const isBlock = node.name === 'p' || node.name === 'div' || node.name === 'tr' || node.name === 'li' || (node.name[0] === 'h' && node.name[1] > '0' && node.name[1] < '7')
- if (isBlock && text && text[text.length - 1] !== '\n') {
- // 递归获取子节点的文本
- if (node.children) {
- traversal(node.children)
- if (isBlock && text[text.length - 1] !== '\n') {
- } else if (node.name === 'td' || node.name === 'th') {
- text += '\t'
- })(nodes || this.nodes)
- return text
- * @description 获取内容大小和位置
- * @return {Promise}
- getRect () {
- uni.createSelectorQuery()
- .in(this)
- .select('#_root').boundingClientRect().exec(res => res[0] ? resolve(res[0]) : reject(Error('Root label not found')))
- * @description 暂停播放媒体
- pauseMedia () {
- for (let i = (this._videos || []).length; i--;) {
- this._videos[i].pause()
- // #ifdef APP-PLUS
- const command = 'for(var e=document.getElementsByTagName("video"),i=e.length;i--;)e[i].pause()'
- let page = this.$parent
- while (!page.$scope) page = page.$parent
- page.$scope.$getAppWebview().evalJS(command)
- this.$refs.web.evalJs(command)
- * @description 设置媒体播放速率
- * @param {Number} rate 播放速率
- setPlaybackRate (rate) {
- this.playbackRate = rate
- this._videos[i].playbackRate(rate)
- const command = 'for(var e=document.getElementsByTagName("video"),i=e.length;i--;)e[i].playbackRate=' + rate
- * @description 设置内容
- * @param {String} content html 内容
- * @param {Boolean} append 是否在尾部追加
- setContent (content, append) {
- if (!append || !this.imgList) {
- this.imgList = []
- const nodes = new Parser(this).parse(content)
- if (this._ready) {
- this._set(nodes, append)
- this.$set(this, 'nodes', append ? (this.nodes || []).concat(nodes) : nodes)
- this._videos = []
- this._hook('onLoad')
- this.$emit('load')
- if (this.lazyLoad || this.imgList._unloadimgs < this.imgList.length / 2) {
- // 设置懒加载,每 350ms 获取高度,不变则认为加载完毕
- let height = 0
- const callback = rect => {
- if (!rect || !rect.height) rect = {}
- // 350ms 总高度无变化就触发 ready 事件
- if (rect.height === height) {
- this.$emit('ready', rect)
- height = rect.height
- this.getRect().then(callback).catch(callback)
- }, 350)
- // 未设置懒加载,等待所有图片加载完毕
- if (!this.imgList._unloadimgs) {
- this.getRect().then(rect => {
- }).catch(() => {
- this.$emit('ready', {})
- * @description 调用插件钩子函数
- _hook (name) {
- if (this.plugins[i][name]) {
- this.plugins[i][name]()
- _set (nodes, append) {
- this.$refs.web.evalJs('setContent(' + JSON.stringify(nodes).replace(/%22/g, '') + ',' + JSON.stringify([this.containerStyle.replace(/(?:margin|padding)[^;]+/g, ''), this.errorImg, this.loadingImg, this.pauseVideo, this.scrollTable, this.selectable]) + ',' + append + ')')
- * @description 接收到 web-view 消息
- _onMessage (e) {
- const message = e.detail.data[0]
- switch (message.action) {
- // web-view 初始化完毕
- case 'onJSBridgeReady':
- this._ready = true
- if (this.nodes) {
- this._set(this.nodes)
- break
- // 内容 dom 加载完毕
- case 'onLoad':
- this.height = message.height
- // 所有图片加载完毕
- case 'onReady':
- this.getRect().then(res => {
- this.$emit('ready', res)
- // 总高度发生变化
- case 'onHeightChange':
- // 图片点击
- case 'onImgTap':
- this.$emit('imgtap', message.attrs)
- if (this.previewImg) {
- uni.previewImage({
- current: parseInt(message.attrs.i),
- urls: this.imgList
- // 链接点击
- case 'onLinkTap': {
- const href = message.attrs.href
- this.$emit('linktap', message.attrs)
- if (href) {
- // 锚点跳转
- if (href[0] === '#') {
- if (this.useAnchor) {
- offset: message.offset
- } else if (href.includes('://')) {
- // 打开外链
- if (this.copyLink) {
- plus.runtime.openWeb(href)
- uni.navigateTo({
- url: href,
- fail () {
- uni.switchTab({
- url: href
- case 'onPlay':
- this.$emit('play')
- // 获取到锚点的偏移量
- case 'getOffset':
- if (typeof message.offset === 'number') {
- offset: message.offset + this._navigateTo.offset
- this._navigateTo.resolve()
- this._navigateTo.reject(Error('Label not found'))
- // 点击
- case 'onClick':
- this.$emit('tap')
- this.$emit('click')
- // 出错
- case 'onError':
- this.$emit('error', {
- source: message.source,
- attrs: message.attrs
-/* #ifndef APP-PLUS-NVUE */
-/* 根节点样式 */
-._root {
- padding: 1px 0;
- overflow-x: auto;
- overflow-y: hidden;
- -webkit-overflow-scrolling: touch;
-/* 长按复制 */
-._select {
- user-select: text;
-/* #endif */
@@ -1,576 +0,0 @@
- <view :id="attrs.id" :class="'_block _'+name+' '+attrs.class" :style="attrs.style">
- <block v-for="(n, i) in childs" v-bind:key="i">
- <!-- 图片 -->
- <!-- 占位图 -->
- <image v-if="n.name==='img'&&!n.t&&((opts[1]&&!ctrl[i])||ctrl[i]<0)" class="_img" :style="n.attrs.style" :src="ctrl[i]<0?opts[2]:opts[1]" mode="widthFix" />
- <!-- 显示图片 -->
- <!-- #ifdef H5 || (APP-PLUS && VUE2) -->
- <img v-if="n.name==='img'" :id="n.attrs.id" :class="'_img '+n.attrs.class" :style="(ctrl[i]===-1?'display:none;':'')+n.attrs.style" :src="n.attrs.src||(ctrl.load?n.attrs['data-src']:'')" :data-i="i" @load="imgLoad" @error="mediaError" @tap.stop="imgTap" @longpress="imgLongTap" />
- <!-- #ifndef H5 || (APP-PLUS && VUE2) -->
- <!-- 表格中的图片,使用 rich-text 防止大小不正确 -->
- <rich-text v-if="n.name==='img'&&n.t" :style="'display:'+n.t" :nodes="[{attrs:{style:n.attrs.style,src:n.attrs.src},name:'img'}]" :data-i="i" @tap.stop="imgTap" />
- <!-- #ifndef H5 || APP-PLUS -->
- <image v-else-if="n.name==='img'" :id="n.attrs.id" :class="'_img '+n.attrs.class" :style="(ctrl[i]===-1?'display:none;':'')+'width:'+(ctrl[i]||1)+'px;height:1px;'+n.attrs.style" :src="n.attrs.src" :mode="!n.h?'widthFix':(!n.w?'heightFix':'')" :lazy-load="opts[0]" :webp="n.webp" :show-menu-by-longpress="opts[3]&&!n.attrs.ignore" :image-menu-prevent="!opts[3]||n.attrs.ignore" :data-i="i" @load="imgLoad" @error="mediaError" @tap.stop="imgTap" @longpress="imgLongTap" />
- <!-- #ifdef APP-PLUS && VUE3 -->
- <image v-else-if="n.name==='img'" :id="n.attrs.id" :class="'_img '+n.attrs.class" :style="(ctrl[i]===-1?'display:none;':'')+'width:'+(ctrl[i]||1)+'px;'+n.attrs.style" :src="n.attrs.src||(ctrl.load?n.attrs['data-src']:'')" :mode="!n.h?'widthFix':(!n.w?'heightFix':'')" :data-i="i" @load="imgLoad" @error="mediaError" @tap.stop="imgTap" @longpress="imgLongTap" />
- <!-- 文本 -->
- <!-- #ifdef MP-WEIXIN -->
- <text v-else-if="n.text" :user-select="opts[4]=='force'&&isiOS" decode>{{n.text}}</text>
- <!-- #ifndef MP-WEIXIN || MP-BAIDU || MP-ALIPAY || MP-TOUTIAO -->
- <text v-else-if="n.text" decode>{{n.text}}</text>
- <text v-else-if="n.name==='br'">\n</text>
- <!-- 链接 -->
- <view v-else-if="n.name==='a'" :id="n.attrs.id" :class="(n.attrs.href?'_a ':'')+n.attrs.class" hover-class="_hover" :style="'display:inline;'+n.attrs.style" :data-i="i" @tap.stop="linkTap">
- <node name="span" :childs="n.children" :opts="opts" style="display:inherit" />
- <!-- 视频 -->
- <!-- #ifdef APP-PLUS -->
- <view v-else-if="n.html" :id="n.attrs.id" :class="'_video '+n.attrs.class" :style="n.attrs.style" v-html="n.html" @vplay.stop="play" />
- <!-- #ifndef APP-PLUS -->
- <video v-else-if="n.name==='video'" :id="n.attrs.id" :class="n.attrs.class" :style="n.attrs.style" :autoplay="n.attrs.autoplay" :controls="n.attrs.controls" :loop="n.attrs.loop" :muted="n.attrs.muted" :object-fit="n.attrs['object-fit']" :poster="n.attrs.poster" :src="n.src[ctrl[i]||0]" :data-i="i" @play="play" @error="mediaError" />
- <!-- #ifdef H5 || APP-PLUS -->
- <iframe v-else-if="n.name==='iframe'" :style="n.attrs.style" :allowfullscreen="n.attrs.allowfullscreen" :frameborder="n.attrs.frameborder" :src="n.attrs.src" />
- <embed v-else-if="n.name==='embed'" :style="n.attrs.style" :src="n.attrs.src" />
- <!-- #ifndef MP-TOUTIAO || ((H5 || APP-PLUS) && VUE3) -->
- <!-- 音频 -->
- <audio v-else-if="n.name==='audio'" :id="n.attrs.id" :class="n.attrs.class" :style="n.attrs.style" :author="n.attrs.author" :controls="n.attrs.controls" :loop="n.attrs.loop" :name="n.attrs.name" :poster="n.attrs.poster" :src="n.src[ctrl[i]||0]" :data-i="i" @play="play" @error="mediaError" />
- <view v-else-if="(n.name==='table'&&n.c)||n.name==='li'" :id="n.attrs.id" :class="'_'+n.name+' '+n.attrs.class" :style="n.attrs.style">
- <node v-if="n.name==='li'" :childs="n.children" :opts="opts" />
- <view v-else v-for="(tbody, x) in n.children" v-bind:key="x" :class="'_'+tbody.name+' '+tbody.attrs.class" :style="tbody.attrs.style">
- <node v-if="tbody.name==='td'||tbody.name==='th'" :childs="tbody.children" :opts="opts" />
- <block v-else v-for="(tr, y) in tbody.children" v-bind:key="y">
- <view v-if="tr.name==='td'||tr.name==='th'" :class="'_'+tr.name+' '+tr.attrs.class" :style="tr.attrs.style">
- <node :childs="tr.children" :opts="opts" />
- <view v-else :class="'_'+tr.name+' '+tr.attrs.class" :style="tr.attrs.style">
- <view v-for="(td, z) in tr.children" v-bind:key="z" :class="'_'+td.name+' '+td.attrs.class" :style="td.attrs.style">
- <node :childs="td.children" :opts="opts" />
- </block>
- <!-- 富文本 -->
- <!-- #ifdef H5 || ((MP-WEIXIN || MP-QQ || APP-PLUS || MP-360) && VUE2) -->
- <rich-text v-else-if="!n.c&&!handler.isInline(n.name, n.attrs.style)" :id="n.attrs.id" :style="n.f" :user-select="opts[4]" :nodes="[n]" />
- <!-- #ifndef H5 || ((MP-WEIXIN || MP-QQ || APP-PLUS || MP-360) && VUE2) -->
- <rich-text v-else-if="!n.c" :id="n.attrs.id" :style="'display:inline;'+n.f" :preview="false" :selectable="opts[4]" :user-select="opts[4]" :nodes="[n]" />
- <!-- 继续递归 -->
- <view v-else-if="n.c===2" :id="n.attrs.id" :class="'_block _'+n.name+' '+n.attrs.class" :style="n.f+';'+n.attrs.style">
- <node v-for="(n2, j) in n.children" v-bind:key="j" :style="n2.f" :name="n2.name" :attrs="n2.attrs" :childs="n2.children" :opts="opts" />
- <node v-else :style="n.f" :name="n.name" :attrs="n.attrs" :childs="n.children" :opts="opts" />
-<script module="handler" lang="wxs">
-// 行内标签列表
-var inlineTags = {
- abbr: true,
- b: true,
- big: true,
- code: true,
- del: true,
- em: true,
- i: true,
- ins: true,
- label: true,
- q: true,
- small: true,
- span: true,
- strong: true,
- sub: true,
- sup: true
- * @description 判断是否为行内标签
-module.exports = {
- isInline: function (tagName, style) {
- return inlineTags[tagName] || (style || '').indexOf('display:inline') !== -1
-import node from './node'
- name: 'node',
- options: {
- // #ifdef MP-WEIXIN
- virtualHost: true,
- // #ifdef MP-TOUTIAO
- addGlobalClass: false
- ctrl: {},
- isiOS: uni.getSystemInfoSync().system.includes('iOS')
- name: String,
- attrs: {
- type: Object,
- default () {
- return {}
- childs: Array,
- opts: Array
- // #ifndef (H5 || APP-PLUS) && VUE3
- for (this.root = this.$parent; this.root.$options.name !== 'mp-html'; this.root = this.root.$parent);
- // #ifdef H5 || APP-PLUS
- if (this.opts[0]) {
- let i
- for (i = this.childs.length; i--;) {
- if (this.childs[i].name === 'img') break
- if (i !== -1) {
- this.observer = uni.createIntersectionObserver(this).relativeToViewport({
- top: 500,
- bottom: 500
- this.observer.observe('._img', res => {
- if (res.intersectionRatio) {
- this.$set(this.ctrl, 'load', 1)
- this.observer.disconnect()
- if (this.observer) {
- methods:{
- toJSON () { return this },
- * @description 播放视频事件
- * @param {Event} e
- play (e) {
- this.root.$emit('play')
- // #ifndef APP-PLUS
- if (this.root.pauseVideo) {
- let flag = false
- const id = e.target.id
- for (let i = this.root._videos.length; i--;) {
- if (this.root._videos[i].id === id) {
- flag = true
- this.root._videos[i].pause() // 自动暂停其他视频
- // 将自己加入列表
- if (!flag) {
- const ctx = uni.createVideoContext(id
- // #ifndef MP-BAIDU
- , this
- )
- ctx.id = id
- if (this.root.playbackRate) {
- ctx.playbackRate(this.root.playbackRate)
- this.root._videos.push(ctx)
- * @description 图片点击事件
- imgTap (e) {
- const node = this.childs[e.currentTarget.dataset.i]
- if (node.a) {
- this.linkTap(node.a)
- if (node.attrs.ignore) return
- node.attrs.src = node.attrs.src || node.attrs['data-src']
- this.root.$emit('imgtap', node.attrs)
- // 自动预览图片
- if (this.root.previewImg) {
- showmenu: this.root.showImgMenu,
- // #ifdef MP-ALIPAY
- enablesavephoto: this.root.showImgMenu,
- enableShowPhotoDownload: this.root.showImgMenu,
- current: parseInt(node.attrs.i),
- urls: this.root.imgList
- * @description 图片长按
- imgLongTap (e) {
- const attrs = this.childs[e.currentTarget.dataset.i].attrs
- if (this.opts[3] && !attrs.ignore) {
- uni.showActionSheet({
- itemList: ['保存图片'],
- success: () => {
- const save = path => {
- uni.saveImageToPhotosAlbum({
- filePath: path,
- success () {
- uni.showToast({
- title: '保存成功'
- if (this.root.imgList[attrs.i].startsWith('http')) {
- uni.downloadFile({
- url: this.root.imgList[attrs.i],
- success: res => save(res.tempFilePath)
- save(this.root.imgList[attrs.i])
- * @description 图片加载完成事件
- imgLoad (e) {
- const i = e.currentTarget.dataset.i
- /* #ifndef H5 || (APP-PLUS && VUE2) */
- if (!this.childs[i].w) {
- // 设置原宽度
- this.$set(this.ctrl, i, e.detail.width)
- } else /* #endif */ if ((this.opts[1] && !this.ctrl[i]) || this.ctrl[i] === -1) {
- // 加载完毕,取消加载中占位图
- this.$set(this.ctrl, i, 1)
- this.checkReady()
- * @description 检查是否所有图片加载完毕
- checkReady () {
- if (this.root && !this.root.lazyLoad) {
- this.root._unloadimgs -= 1
- if (!this.root._unloadimgs) {
- this.root.getRect().then(rect => {
- this.root.$emit('ready', rect)
- this.root.$emit('ready', {})
- * @description 链接点击事件
- linkTap (e) {
- const node = e.currentTarget ? this.childs[e.currentTarget.dataset.i] : {}
- const attrs = node.attrs || e
- const href = attrs.href
- this.root.$emit('linktap', Object.assign({
- innerText: this.root.getText(node.children || []) // 链接内的文本内容
- }, attrs))
- // 跳转锚点
- this.root.navigateTo(href.substring(1)).catch(() => { })
- } else if (href.split('?')[0].includes('://')) {
- // 复制外部链接
- if (this.root.copyLink) {
- // #ifdef H5
- window.open(href)
- // #ifdef MP
- uni.setClipboardData({
- data: href,
- success: () =>
- title: '链接已复制'
- // 跳转页面
- fail () { }
- * @description 错误事件
- mediaError (e) {
- const node = this.childs[i]
- // 加载其他源
- if (node.name === 'video' || node.name === 'audio') {
- let index = (this.ctrl[i] || 0) + 1
- if (index > node.src.length) {
- index = 0
- if (index < node.src.length) {
- this.$set(this.ctrl, i, index)
- } else if (node.name === 'img') {
- // #ifdef H5 && VUE3
- if (this.opts[0] && !this.ctrl.load) return
- // 显示错误占位图
- if (this.opts[2]) {
- this.$set(this.ctrl, i, -1)
- if (this.root) {
- this.root.$emit('error', {
- source: node.name,
- attrs: node.attrs,
- // #ifndef H5 && VUE3
- errMsg: e.detail.errMsg
-/* a 标签默认效果 */
-._a {
- padding: 1.5px 0 1.5px 0;
- color: #366092;
- word-break: break-all;
-/* a 标签点击态效果 */
-._hover {
- text-decoration: underline;
- opacity: 0.7;
-/* 图片默认效果 */
-._img {
- max-width: 100%;
- -webkit-touch-callout: none;
-/* 内部样式 */
-._block {
- display: block;
-._b,
-._strong {
- font-weight: bold;
-._code {
- font-family: monospace;
-._del {
- text-decoration: line-through;
-._em,
-._i {
- font-style: italic;
-._h1 {
- font-size: 2em;
-._h2 {
- font-size: 1.5em;
-._h3 {
- font-size: 1.17em;
-._h5 {
- font-size: 0.83em;
-._h6 {
- font-size: 0.67em;
-._h1,
-._h2,
-._h3,
-._h4,
-._h5,
-._image {
- height: 1px;
-._ins {
-._li {
- display: list-item;
-._ol {
- list-style-type: decimal;
-._ol,
-._ul {
- padding-left: 40px;
- margin: 1em 0;
-._q::before {
- content: '"';
-._q::after {
-._sub {
- font-size: smaller;
- vertical-align: sub;
-._sup {
- vertical-align: super;
-._thead,
-._tbody,
-._tfoot {
- display: table-row-group;
-._tr {
- display: table-row;
-._td,
-._th {
- display: table-cell;
- vertical-align: middle;
- text-align: center;
- list-style-type: disc;
-._ul ._ul {
- margin: 0;
- list-style-type: circle;
-._ul ._ul ._ul {
- list-style-type: square;
-._abbr,
-._code,
-._del,
-._i,
-._ins,
-._label,
-._q,
-._span,
-._strong,
-._sub,
- display: inline;
-/* #ifdef APP-PLUS */
-._video {
- width: 300px;
- height: 225px;
@@ -1,76 +0,0 @@
- "id": "mp-html",
- "displayName": "mp-html 富文本组件【全端支持,支持编辑、latex等扩展】",
- "version": "v2.4.2",
- "description": "一个强大的富文本组件,高效轻量,功能丰富",
- "富文本",
- "编辑器",
- "html",
- "rich-text",
- "editor"
- ],
- "repository": "https://github.com/jin-yufeng/mp-html",
- "npmurl": "https://www.npmjs.com/package/mp-html",
- "type": "component-vue"
- "IE": "u",
- "QQ": "y"
@@ -1,188 +0,0 @@
-## p-f-unicom 跨层级通信插件,解决非父子通信的痛点
-> 前言:我们在使用`Vue`进行开发时如何能够解决非父子组件之间的一个通信问题,那如果碰到这样一个问题其实按照一般的开发步骤解决起来是非常繁琐的可能各种的`parent`、`children`或者有人可能会直接定义在全局环境上那这样的操作会使得你的项目在越来越复杂的业务开发中变得非常的脆弱。
-##### `p-f-unicom` 自定义插件:
-1. 它是`Vue.js`的一个自定义插件,解决了`Vue`中非父子组件通讯的痛点。
-2. 利用订阅者和发布者模式来管理消息。
-##### 功能:
-1. 任意一个`Vue`组件向其他所有组件发送指令。
-2. 任意一个`Vue`组件向某组`Vue`组件发送指令。
-3. 任意一个`Vue`组件向特定`unicom-id`组件发送消息。
-4. 在任意一个`Vue`组件内获取某组组件列表。
-5. 在任意一个`Vue`组件内获取特定`unciom-id`组件。
-6. 发送指令到还没初始化的`unicom-id`组件。
-7. 发送指令到还没初始化的`unicom-group`分组组件。
-8. 组件销毁时自动销毁绑定的订阅事件。
-##### 使用:
-`main.js` 注册`Unicom`插件
-`unicom`是插件内置的名称,如果需要修改可以在`Vue.use`时自定义。
-```javascript
-// 导入
-import unicom from './plugin/p-f-unicom.js'
-// 使用
-Vue.use(unicom, {
- name: 'unicom',
- idName: 'unicomId',
- groupName: 'unicomGroup'
-})
-##### Vue组件内部使用
-child.vue (订阅)
- <div>
- // ......
- // 将这个组件归到 group 分组,必须是数组
- unicomGroup: ['group'],
- unicom: {
- // message 通讯指令名称和 this.$unicom 时对应
- * @desc 注册接收指令
- * sender: 发送指令者(建议只能读区不能修改)
- * args:指令发出者附带参数
- message (sender, ...args){
- // 订阅消息 (名称为 `message`)
-index.vue (发布)
- // unicom-id 不能和其它组件所定的 unicom-id 相同
- // unicom-group 定义组的名称数组,会和组件内的 `unicomGroup` 合并并去重 ,不定义默认使用 child 组件内的 `unicomGroup`
- <child unicom-id="child-id" :unicom-group="aUnicomGroupList"></child>
- import Child from './child.vue'
- Child
- data(){
- // 名字不能叫 unicomGroup,因为已经被 unicom 插件占用自动放到了组件的props对象中所以名字会重名冲突
- aUnicomGroupList: ['group', 'group1']
- doExec () {
- // 发布订阅消息,会自动调用 child 组件内订阅的 `message` 指令
- this.$unicom("message", arg1, arg2, ...)
- // 获取被命名为 child-id 的组件引用
- const child = this.$unicom("#child-id")
- // 获取分组为 group 的所有 vue 组件
- const childs = this.$unicom("@group")
-#### 发布的使用模式:
-##### 组件已经存在
-instruct1 是指令也就是你在 vue 组件中定义的接收消息的事件名称:
-unicom: {
- instruct1(sender, oQueryParams, aYearList) {
- // 查询栏消息
- console.log('订阅消息', JSON.stringify(oQueryParams), aYearList);
-1. instruct1@group (发送到指定分组)
-2. instruct1#id1 (发送到指定组件)
-3. @group (获取指定分组组件)
-4. #id1 (获取指定组件)
-##### 组件还未创建,延迟发送指令(一次性指令)
-指令使用 ~ 打头
-1. ~instruct1 (指令延迟发送,直到包含有 `instruct1` 指令的组件出现)
-2. ~instruct1@group (指令延迟发送,直到出现分组命名`group`的组件)
-3. ~instruct1#id1 (指令延迟发送,直到出现命名`id1`的组件)
-如果你的组件是通过点击按钮这样通过判断来渲染出来的,那么事件的执行可以按下面的示例:
-this.$unicom('~onQuery111@industrialAnalyseFilterGroup', 'hello'); // 这个是发送组件未创建时的指令,指令将被缓存等待组件创建后触发onQuery111指令方法
-this.$unicom('onQuery111@industrialAnalyseFilterGroup', 'hello111'); // 第二次向已经创建完成的组件发送指令onQuery111需要使用不带~号的形式
-对应的组件
- <div>我不是初始化时就渲染</div>
- unicomGroup: ['industrialAnalyseFilterGroup'],
- // unicomId: 'aaaa',
- // onQuery(sender, args) {
- // console.log(sender, args, 11111111111);
- // },
- onQuery111(sender, p) {
- console.log('hello: ', p);
- created(){}
-##### 组件监听
-组件监听使用,指令使用 ~ 打头, 第二个参数为 `callback` 回调
-methods: {
- this.$unicom('~#child-id', function(child){
- // `child`组件创建完成,从 `child` 组件的`created`函数触发出来,所以请不要操作 `child`组件的 dom 元素,组件挂载请监听 this.$nextTick
-1. ~@group (监听分组命名group的组件出现)
-2. ~#id1 (监听命名id1的组件出现)
-具体的使用 demo 请参考 v-demo 目录。
-*****
-注:
-1.此插件原始地址:[vue-plugins](https://gitee.com/zhangh-design/vue-plugins)。
-2.版权归原作者所有,仅为了方便,挂上插件市场。
-3.对原作者表示感谢!
@@ -1,2 +0,0 @@
-## 1.0.0(2023-02-02)
-init
@@ -1,369 +0,0 @@
-import _get from 'lodash/get'
-import _set from 'lodash/set'
-import _isEmpty from 'lodash/isEmpty'
-import _isEqual from 'lodash/isEqual'
-import _forEach from 'lodash/forEach'
-import _isUndefined from 'lodash/isUndefined'
-import _flattenDeep from 'lodash/flattenDeep'
-import _toString from 'lodash/toString'
-import _has from 'lodash/has'
-import _includes from 'lodash/includes'
-import _keys from 'lodash/keys'
-import _isFunction from 'lodash/isFunction'
-import _uniq from 'lodash/uniq'
-import _flatMap from 'lodash/flatMap'
-import _union from 'lodash/union'
- * @desc
- * Vue 跨组件通信插件
-let unicomIdName = ''
-let unicomGroupName = ''
-// vm容器、分组、事件、命名 唯一、推迟触发的事件
-const [vmMap, groupForVm, events, idForVm, sendDefer] = [new Map(), {}, {}, {}, []]
- * @desc 触发执行事件
- * @param {string} method - 指令的名称
- * @param {string} toKey - 目标组件的 unicomId 或者 unicomGroup
- * @param {string} aim - 标识 (#)
- * @param {Array} args - 参数
-const emitEvent = function (method, toKey, aim, args) {
- const evs = _get(events, method, [])
- let evLen = 0
- const len = evs.length
- // 循环已经注册的指令
- for (evLen; evLen < len; evLen++) {
- // 存储的数据
- const { fn, scope } = evs[evLen]
- if (_isEqual(aim, '#')) {
- // id
- if (scope[unicomIdName] !== toKey) {
- // 目标不存在
- continue
- } else if (_isEqual(aim, '@')) {
- // 分组
- const group = _get(vmMap.get(scope), 'group', [])
- if (_isEmpty(group) || _isEqual(_includes(group, toKey), false)) {
- _isEqual(_isUndefined(scope), false) && fn.apply(scope, args)
- // 返回被触发的指令
- return evLen
- * @desc 发送容器 或者 获得 目标容器
- * @param {string} query - 指令名称 (~instruct1#id1)
- * @param {...any} args - 可变参数
-const unicomQuery = function (query, ...args) {
- let [toKey, aim, defer, eventIndex] = ['', '', false, -1]
- // query=instruct1#id1
- const method = query
- .replace(/^([`~])/, function (s0, s1) {
- // query=~instruct1#id1
- if (_isEqual(s1, '~')) {
- defer = true
- return ''
- .replace(/([@#])([^@#]*)$/, function (s0, s1, s2) {
- // query=instruct1@child-a
- // s0=@child-a s1=@ s2=child-a
- toKey = s2
- aim = s1
- // method=instruct1
- if (defer) {
- sendDefer.push([method, toKey, aim, args, this])
- return this
- if (_isEqual(_isEqual(method, ''), false)) {
- args.unshift(this)
- eventIndex = emitEvent(method, toKey, aim, args)
- // 获取目标 vm
- switch (aim) {
- case '#':
- return _get(idForVm, toKey, null)
- case '@':
- return _get(groupForVm, toKey, [])
- return eventIndex
- * @desc 更新分组
- * @param {Object} scope - 组件的实例
- * @param {string[]} nv - 指令 unicom-group 传入的组数据 (新)
- * @param {string[]} [ov] - 指令 unicom-group 传入的组数据 (旧)
-const updateName = function (scope, nv, ov) {
- // 实例上设置分组
- const vmData = vmMap.get(scope) || {}
- const group = _get(vmData, 'group', [])
- // 删除旧的 vm
- if (_isEqual(_isUndefined(ov), false)) {
- _uniq(_flattenDeep(_flatMap(ov))).forEach(function (key) {
- if (_includes(group, key)) {
- const vms = _get(groupForVm, key, [])
- _isEqual(_isEmpty(vms), false) && vms.splice(vms.indexOf(scope), 1)
- if (_isEmpty(vms)) {
- group.splice(group.indexOf(key), 1)
- Reflect.deleteProperty(groupForVm, key)
- // 增加新的
- if (_isEqual(_isUndefined(nv), false)) {
- _uniq(_flattenDeep(_flatMap(nv))).forEach(function (key) {
- _set(groupForVm, key, vms)
- // 新添加 组件 到组里面
- if (_isEqual(_includes(vms, scope), false)) {
- vms.push(scope)
- if (_isEqual(_includes(group, key), false)) {
- group.push(key)
- * @desc 更新 unicomId
- * @param {string} newValue - 指令 unicom-id 传入的id数据 (新)
- * @param {string} [oldValue] - 指令 unicom-id 传入的id数据 (旧)
-const updateId = function (scope, newValue, oldValue) {
- if (_isEqual(newValue, oldValue)) {
- if (_isEqual(_isUndefined(oldValue), false) && _isEqual(_get(idForVm, oldValue), scope)) {
- // watch 监测值修改需要删除,组件销毁时需要删除
- Reflect.deleteProperty(idForVm, oldValue)
- if (_isEqual(_isUndefined(newValue), false) && _isEqual(_has(idForVm, newValue), false)) {
- _set(idForVm, newValue, scope)
- } else if (_isEqual(_isUndefined(newValue), false) && _has(idForVm, newValue)) {
- console.warn(`${unicomIdName}='${newValue}'的组件已经定义并存在。`)
- * @desc 添加事件
- * @param {function} fn - 指令名称对应的函数
- * @param {Object} scope - 指令名称对应函数所运行的作用域
-const appendEvent = function (method, fn, scope) {
- if (_isEqual(_has(events, method), false)) {
- events[method] = []
- if (_isFunction(fn)) {
- events[method].push({ fn, scope, method })
- * @desc 移除事件
-const removeEvent = function (method, scope) {
- if (_isEqual(_isEmpty(evs), false)) {
- for (let i = 0; i < evs.length; i++) {
- if (_isEqual(scope, evs[i].scope)) {
- evs.splice(i, 1)
- install (Vue, { name = 'unicom', idName = `${name}Id`, groupName = `${name}Group` } = {}) {
- // 添加原型方法 (unicomQuery 函数放在 install 外部不然无法获取调用函数的 this 对象)
- Vue.prototype['$' + name] = unicomQuery
- // unicom-id
- unicomIdName = idName
- // 分组 unicom-group
- unicomGroupName = groupName
- // 全局混入
- Vue.mixin({
- // 命名 unicom-id="id1"
- [idName]: {
- // 分组(纯字符串类数组不能是真实的数组) unicom-group="['child-a', 'child-b']"
- [groupName]: {
- type: Array,
- default: () => []
- [idName] (nv, ov) {
- updateId(this, nv, ov)
- deep: true,
- handler (nv, ov) {
- updateName(this, nv, ov);
- // 创建的时候加入事件机制
- beforeCreate () {
- const opt = this.$options
- const vmData = {}
- const [us, uni, group] = [
- _get(opt, name, {}),
- (vmData.uni = {}),
- (vmData.group = [])
- ]
- if (_isEqual(_isEmpty(us), false)) {
- _forEach(us, opt => {
- if (_isEmpty(opt)) {
- return true
- _forEach(opt, (handler, key) => {
- if (_isEqual(_isUndefined(handler), false)) {
- _isUndefined(_get(uni, key)) && _set(uni, key, [])
- uni[key].push(handler)
- // 添加事件
- appendEvent(key, handler, this)
- // 命名分组
- const groupNameOpt = _get(opt, groupName, [])
- if (_isEqual(_isEmpty(groupNameOpt), false)) {
- _forEach(_uniq(_flattenDeep(_flatMap(groupNameOpt))), item => {
- const key = _toString(item)
- _isUndefined(_get(groupForVm, key)) && (groupForVm[key] = [])
- groupForVm[key].push(this)
- if (_isEqual(_isEmpty(group), false) || _isEqual(_isEmpty(uni), false)) {
- vmMap.set(this, vmData)
- // 实例命名 唯一
- const uId = this[idName]
- const uGroupName = this[groupName]
- _isEqual(_isEqual(uId, ''), false) && updateId(this, uId)
- _isEqual(_isEmpty(uGroupName), false) && updateName(this, uGroupName)
- const vmData = vmMap.get(this) || {}
- for (let i = 0; i < sendDefer.length; i++) {
- const [method, toKey, aim, args, scope] = sendDefer[i]
- if (_isEqual(toKey, uId)) {
- if (
- _isEqual(_isUndefined(_get(vmData, 'group')), false) &&
- _includes(_get(vmData, 'group'), toKey)
- ) {
- _isEqual(method, '') ||
- _includes(_keys(_get(vmData, 'uni', {})), method)
- if (flag) {
- // 延后,并且方法为空
- if (_isEqual(method, '')) {
- * @desc 监听组件事件
- * @example
- * this.$unicom('~#id1', function (childScope) {// unicomId=id1的组件创建完成})
- if (_isFunction(args[0])) {
- args[0](this)
- sendDefer.splice(i--, 1)
- args.unshift(scope)
- emitEvent(method, toKey, aim, args)
- // 全局混合,销毁实例的时候销毁事件
- destroyed () {
- // 移除唯一ID
- if (_isEqual(_isEqual(uId, ''), false)) {
- updateId(this, undefined, uId)
- // 移除 命名分组、实例命名
- const uGroupName = _get(this, groupName, [])
- const optGroupName = _get(this.$options, groupName, [])
- if (_isEqual(_isEmpty(uGroupName), false) || _isEqual(_isEmpty(optGroupName), false)) {
- updateName(this, undefined, _union(uGroupName, optGroupName))
- const vmData = vmMap.get(this)
- if (_isUndefined(vmData)) {
- vmMap.delete(this)
- const uni = _get(vmData, 'uni', {})
- // 移除事件
- for (const key in uni) {
- removeEvent(key, this)
- // 分组,一对多, 单个vm可以多个分组名称 组件命名
- _forEach(group, function (name) {
- const gs = groupForVm[name]
- if (_isEqual(_isUndefined(gs), false)) {
- const index = gs.indexOf(this)
- if (index > -1) {
- gs.splice(index, 1)
- if (gs.length === 0) {
- delete groupForVm[name]
- // 监控销毁 method为空
- for (let i = 0; i < sendDefer.length;) {
- const pms = sendDefer[i]
- if (_isEqual(pms[0], '') && _isEqual(pms[4], this)) {
- sendDefer.splice(i, 1)
- i += 1
- // 自定义属性合并策略
- // 混入(mixins)时不是简单的覆盖而是追加
- const merge = _get(Vue, 'config.optionMergeStrategies', {})
- merge[name] = merge[unicomGroupName] = function (parentVal, childVal) {
- const p = parentVal || []
- if (_isEqual(_isUndefined(childVal), false)) {
- p.push(childVal)
- return p
@@ -1,84 +0,0 @@
- "id": "p-f-unicom",
- "displayName": "p-f-unicom",
- "version": "1.0.0",
- "description": "p-f-unicom",
- "p-f-unicom"
- "repository": "https://gitee.com/zhangh-design/vue-plugins",
- "HBuilderX": "^3.1.0"
- "type": "sdk-js",
- "vue2": "u",
- "vue3": "u"
- "app-vue": "u",
- "app-nvue": "u"
- "Safari": "u",
- "Android Browser": "u",
- "微信浏览器(Android)": "u",
- "QQ浏览器(Android)": "u"
- "Chrome": "u",
- "Edge": "u",
- "Firefox": "u",
- "Safari": "u"
- "微信": "u",
- "阿里": "u",
- "百度": "u",
- "字节跳动": "u",
- "QQ": "u",
- "钉钉": "u",
- "快手": "u",
- "飞书": "u",
- "京东": "u"
- "华为": "u",
- "联盟": "u"
- "dependencies": {
- "lodash": "^4.17.21"
@@ -1,33 +0,0 @@
-## 1.2.2(2023-01-28)
-- 修复 运行/打包 控制台警告问题
-## 1.2.1(2022-09-05)
-- 修复 当 text 超过 max-num 时,badge 的宽度计算是根据 text 的长度计算,更改为 css 计算实际展示宽度,详见:[https://ask.dcloud.net.cn/question/150473](https://ask.dcloud.net.cn/question/150473)
-## 1.2.0(2021-11-19)
-- 优化 组件UI,并提供设计资源,详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource)
-- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-badge](https://uniapp.dcloud.io/component/uniui/uni-badge)
-## 1.1.7(2021-11-08)
-- 优化 升级ui
-- 修改 size 属性默认值调整为 small
-- 修改 type 属性,默认值调整为 error,info 替换 default
-## 1.1.6(2021-09-22)
-- 修复 在字节小程序上样式不生效的 bug
-## 1.1.5(2021-07-30)
-- 组件兼容 vue3,如何创建vue3项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
-## 1.1.4(2021-07-29)
-- 修复 去掉 nvue 不支持css 的 align-self 属性,nvue 下不暂支持 absolute 属性
-## 1.1.3(2021-06-24)
-- 优化 示例项目
-## 1.1.1(2021-05-12)
-- 新增 组件示例地址
-## 1.1.0(2021-05-12)
-- 新增 uni-badge 的 absolute 属性,支持定位
-- 新增 uni-badge 的 offset 属性,支持定位偏移
-- 新增 uni-badge 的 is-dot 属性,支持仅显示有一个小点
-- 新增 uni-badge 的 max-num 属性,支持自定义封顶的数字值,超过 99 显示99+
-- 优化 uni-badge 属性 custom-style, 支持以对象形式自定义样式
-## 1.0.7(2021-05-07)
-- 修复 uni-badge 在 App 端,数字小于10时不是圆形的bug
-- 修复 uni-badge 在父元素不是 flex 布局时,宽度缩小的bug
-- 新增 uni-badge 属性 custom-style, 支持自定义样式
-## 1.0.6(2021-02-04)
-- 调整为uni_modules目录规范
@@ -1,268 +0,0 @@
- <view class="uni-badge--x">
- <slot />
- <text v-if="text" :class="classNames" :style="[positionStyle, customStyle, dotStyle]"
- class="uni-badge" @click="onClick()">{{displayValue}}</text>
- * Badge 数字角标
- * @description 数字角标一般和其它控件(列表、9宫格等)配合使用,用于进行数量提示,默认为实心灰色背景
- * @tutorial https://ext.dcloud.net.cn/plugin?id=21
- * @property {String} text 角标内容
- * @property {String} size = [normal|small] 角标内容
- * @property {String} type = [info|primary|success|warning|error] 颜色类型
- * @value info 灰色
- * @value primary 蓝色
- * @value success 绿色
- * @value warning 黄色
- * @value error 红色
- * @property {String} inverted = [true|false] 是否无需背景颜色
- * @property {Number} maxNum 展示封顶的数字值,超过 99 显示 99+
- * @property {String} absolute = [rightTop|rightBottom|leftBottom|leftTop] 开启绝对定位, 角标将定位到其包裹的标签的四角上
- * @value rightTop 右上
- * @value rightBottom 右下
- * @value leftTop 左上
- * @value leftBottom 左下
- * @property {Array[number]} offset 距定位角中心点的偏移量,只有存在 absolute 属性时有效,例如:[-10, -10] 表示向外偏移 10px,[10, 10] 表示向 absolute 指定的内偏移 10px
- * @property {String} isDot = [true|false] 是否显示为一个小点
- * @event {Function} click 点击 Badge 触发事件
- * @example <uni-badge text="1"></uni-badge>
- name: 'UniBadge',
- emits: ['click'],
- type: {
- default: 'error'
- inverted: {
- isDot: {
- maxNum: {
- default: 99
- absolute: {
- offset: {
- return [0, 0]
- text: {
- type: [String, Number],
- size: {
- default: 'small'
- customStyle: {
- return {};
- width() {
- return String(this.text).length * 8 + 12
- classNames() {
- const {
- inverted,
- type,
- size,
- absolute
- } = this
- return [
- inverted ? 'uni-badge--' + type + '-inverted' : '',
- 'uni-badge--' + type,
- 'uni-badge--' + size,
- absolute ? 'uni-badge--absolute' : ''
- ].join(' ')
- positionStyle() {
- if (!this.absolute) return {}
- let w = this.width / 2,
- h = 10
- if (this.isDot) {
- w = 5
- h = 5
- const x = `${- w + this.offset[0]}px`
- const y = `${- h + this.offset[1]}px`
- const whiteList = {
- rightTop: {
- right: x,
- top: y
- rightBottom: {
- bottom: y
- leftBottom: {
- left: x,
- leftTop: {
- const match = whiteList[this.absolute]
- return match ? match : whiteList['rightTop']
- dotStyle() {
- if (!this.isDot) return {}
- width: '10px',
- minWidth: '0',
- height: '10px',
- padding: '0',
- borderRadius: '10px'
- displayValue() {
- isDot,
- text,
- maxNum
- return isDot ? '' : (Number(text) > maxNum ? `${maxNum}+` : text)
- onClick() {
- this.$emit('click');
-<style lang="scss" >
- $uni-primary: #2979ff !default;
- $uni-success: #4cd964 !default;
- $uni-warning: #f0ad4e !default;
- $uni-error: #dd524d !default;
- $uni-info: #909399 !default;
- $bage-size: 12px;
- $bage-small: scale(0.8);
- .uni-badge--x {
- /* #ifdef APP-NVUE */
- // align-self: flex-start;
- /* #endif */
- /* #ifndef APP-NVUE */
- display: inline-block;
- .uni-badge--absolute {
- .uni-badge--small {
- transform: $bage-small;
- transform-origin: center center;
- .uni-badge {
- overflow: hidden;
- font-feature-settings: "tnum";
- min-width: 20px;
- flex-direction: row;
- height: 20px;
- padding: 0 4px;
- line-height: 18px;
- color: #fff;
- border-radius: 100px;
- background-color: $uni-info;
- background-color: transparent;
- border: 1px solid #fff;
- font-family: 'Helvetica Neue', Helvetica, sans-serif;
- font-size: $bage-size;
- /* #ifdef H5 */
- z-index: 999;
- cursor: pointer;
- &--info {
- &--primary {
- background-color: $uni-primary;
- &--success {
- background-color: $uni-success;
- &--warning {
- background-color: $uni-warning;
- &--error {
- background-color: $uni-error;
- &--inverted {
- padding: 0 5px 0 0;
- color: $uni-info;
- &--info-inverted {
- &--primary-inverted {
- color: $uni-primary;
- &--success-inverted {
- color: $uni-success;
- &--warning-inverted {
- color: $uni-warning;
- &--error-inverted {
- color: $uni-error;
- "id": "uni-badge",
- "displayName": "uni-badge 数字角标",
- "version": "1.2.2",
- "description": "数字角标(徽章)组件,在元素周围展示消息提醒,一般用于列表、九宫格、按钮等地方。",
- "",
- "badge",
- "uni-ui",
- "uniui",
- "数字角标",
- "徽章"
- "repository": "https://github.com/dcloudio/uni-ui",
- "HBuilderX": ""
- "directories": {
- "example": "../../temps/example_temps"
-"dcloudext": {
- "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
- "dependencies": ["uni-scss"],
@@ -1,10 +0,0 @@
-## Badge 数字角标
-> **组件名:uni-badge**
-> 代码块: `uBadge`
-数字角标一般和其它控件(列表、9宫格等)配合使用,用于进行数量提示,默认为实心灰色背景,
-### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-badge)
-#### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839
@@ -1,6 +0,0 @@
-## 0.1.2(2022-06-08)
-- 修复 微信小程序 separator 不显示的Bug
-## 0.1.1(2022-06-02)
-- 新增 支持 uni.scss 修改颜色
-## 0.1.0(2022-04-21)
-- 初始化
@@ -1,121 +0,0 @@
- <view class="uni-breadcrumb-item">
- <view :class="{
- 'uni-breadcrumb-item--slot': true,
- 'uni-breadcrumb-item--slot-link': to && currentPage !== to
- }" @click="navTo">
- <i v-if="separatorClass" class="uni-breadcrumb-item--separator" :class="separatorClass" />
- <text v-else class="uni-breadcrumb-item--separator">{{ separator }}</text>
- * BreadcrumbItem 面包屑导航子组件
- * @property {String/Object} to 路由跳转页面路径/对象
- * @property {Boolean} replace 在使用 to 进行路由跳转时,启用 replace 将不会向 history 添加新记录(仅 h5 支持)
- currentPage: ""
- virtualHost: true
- to: {
- replace:{
- inject: {
- uniBreadcrumb: {
- from: "uniBreadcrumb",
- default: null
- created(){
- const pages = getCurrentPages()
- const page = pages[pages.length-1]
- if(page){
- this.currentPage = `/${page.route}`
- separator() {
- return this.uniBreadcrumb.separator
- separatorClass() {
- return this.uniBreadcrumb.separatorClass
- navTo() {
- const { to } = this
- if (!to || this.currentPage === to){
- if(this.replace){
- uni.redirectTo({
- url:to
- }else{
-<style lang="scss">
- $uni-base-color: #6a6a6a !default;
- $uni-main-color: #3a3a3a !default;
- .uni-breadcrumb-item {
- white-space: nowrap;
- font-size: 14px;
- &--slot {
- color: $uni-base-color;
- padding: 0 10px;
- &-link {
- color: $uni-main-color;
- &:hover {
- &--separator {
- font-size: 12px;
- &:first-child &--slot {
- padding-left: 0;
- &:last-child &--separator {
- display: none;
@@ -1,41 +0,0 @@
- <view class="uni-breadcrumb">
- * Breadcrumb 面包屑导航父组件
- * @description 显示当前页面的路径,快速返回之前的任意页面
- * @tutorial https://ext.dcloud.net.cn/plugin?id=xxx
- * @property {String} separator 分隔符,默认为斜杠'/'
- * @property {String} separatorClass 图标分隔符 class
- separator: {
- default: '/'
- separatorClass: {
- provide() {
- uniBreadcrumb: this
- .uni-breadcrumb {
@@ -1,88 +0,0 @@
- "id": "uni-breadcrumb",
- "displayName": "uni-breadcrumb 面包屑",
- "version": "0.1.2",
- "description": "Breadcrumb 面包屑",
- "uni-breadcrumb",
- "breadcrumb",
- "面包屑导航",
- "面包屑"
- "category": [
- "前端组件",
- "通用组件"
- "app-nvue": "n"
@@ -1,66 +0,0 @@
-## breadcrumb 面包屑导航
-> **组件名:uni-breadcrumb**
-> 代码块: `ubreadcrumb`
-显示当前页面的路径,快速返回之前的任意页面。
-### 安装方式
-本组件符合[easycom](https://uniapp.dcloud.io/collocation/pages?id=easycom)规范,`HBuilderX 2.5.5`起,只需将本组件导入项目,在页面`template`中即可直接使用,无需在页面中`import`和注册`components`。
-如需通过`npm`方式使用`uni-ui`组件,另见文档:[https://ext.dcloud.net.cn/plugin?id=55](https://ext.dcloud.net.cn/plugin?id=55)
-### 基本用法
-在 ``template`` 中使用组件
-<uni-breadcrumb separator="/">
- <uni-breadcrumb-item v-for="(route,index) in routes" :key="index" :to="route.to">{{route.name}}</uni-breadcrumb-item>
-</uni-breadcrumb>
-```js
- name: "uni-stat-breadcrumb",
- routes: [{
- to: '/A',
- name: 'A页面'
- }, {
- to: '/B',
- name: 'B页面'
- to: '/C',
- name: 'C页面'
- }]
-## API
-### Breadcrumb Props
-|属性名 |类型 |默认值 |说明 |
-|:-: |:-: |:-: |:-: |
-|separator |String |斜杠'/' |分隔符 |
-|separatorClass |String | |图标分隔符 class |
-### Breadcrumb Item Props
-|to |String | |路由跳转页面路径 |
-|replace|Boolean | |在使用 to 进行路由跳转时,启用 replace 将不会向 history 添加新记录(仅 h5 支持) |
-## 组件示例
-点击查看:[https://hellouniapp.dcloud.net.cn/pages/extUI/breadcrumb/breadcrumb](https://hellouniapp.dcloud.net.cn/pages/extUI/breadcrumb/breadcrumb)
@@ -1,26 +0,0 @@
-## 1.4.10(2023-04-10)
-- 修复 某些情况 monthSwitch 未触发的Bug
-## 1.4.9(2023-02-02)
-- 修复 某些情况切换月份错误的Bug
-## 1.4.8(2023-01-30)
-- 修复 某些情况切换月份错误的Bug [详情](https://ask.dcloud.net.cn/question/161964)
-## 1.4.7(2022-09-16)
-- 优化 支持使用 uni-scss 控制主题色
-## 1.4.6(2022-09-08)
-- 修复 表头年月切换,导致改变当前日期为选择月1号,且未触发change事件的Bug
-## 1.4.5(2022-02-25)
-- 修复 条件编译 nvue 不支持的 css 样式的Bug
-## 1.4.4(2022-02-25)
-## 1.4.3(2021-09-22)
-- 修复 startDate、 endDate 属性失效的Bug
-## 1.4.2(2021-08-24)
-- 新增 支持国际化
-## 1.4.1(2021-08-05)
-- 修复 弹出层被 tabbar 遮盖的Bug
-## 1.4.0(2021-07-30)
-## 1.3.16(2021-05-12)
-## 1.3.15(2021-02-04)
@@ -1,546 +0,0 @@
-* @1900-2100区间内的公历、农历互转
-* @charset UTF-8
-* @github https://github.com/jjonline/calendar.js
-* @Author Jea杨(JJonline@JJonline.Cn)
-* @Time 2014-7-21
-* @Time 2016-8-13 Fixed 2033hex、Attribution Annals
-* @Time 2016-9-25 Fixed lunar LeapMonth Param Bug
-* @Time 2017-7-24 Fixed use getTerm Func Param Error.use solar year,NOT lunar year
-* @Version 1.0.3
-* @公历转农历:calendar.solar2lunar(1987,11,01); //[you can ignore params of prefix 0]
-* @农历转公历:calendar.lunar2solar(1987,09,10); //[you can ignore params of prefix 0]
-*/
-/* eslint-disable */
-var calendar = {
- * 农历1900-2100的润大小信息表
- * @Array Of Property
- * @return Hex
- lunarInfo: [0x04bd8, 0x04ae0, 0x0a570, 0x054d5, 0x0d260, 0x0d950, 0x16554, 0x056a0, 0x09ad0, 0x055d2, // 1900-1909
- 0x04ae0, 0x0a5b6, 0x0a4d0, 0x0d250, 0x1d255, 0x0b540, 0x0d6a0, 0x0ada2, 0x095b0, 0x14977, // 1910-1919
- 0x04970, 0x0a4b0, 0x0b4b5, 0x06a50, 0x06d40, 0x1ab54, 0x02b60, 0x09570, 0x052f2, 0x04970, // 1920-1929
- 0x06566, 0x0d4a0, 0x0ea50, 0x06e95, 0x05ad0, 0x02b60, 0x186e3, 0x092e0, 0x1c8d7, 0x0c950, // 1930-1939
- 0x0d4a0, 0x1d8a6, 0x0b550, 0x056a0, 0x1a5b4, 0x025d0, 0x092d0, 0x0d2b2, 0x0a950, 0x0b557, // 1940-1949
- 0x06ca0, 0x0b550, 0x15355, 0x04da0, 0x0a5b0, 0x14573, 0x052b0, 0x0a9a8, 0x0e950, 0x06aa0, // 1950-1959
- 0x0aea6, 0x0ab50, 0x04b60, 0x0aae4, 0x0a570, 0x05260, 0x0f263, 0x0d950, 0x05b57, 0x056a0, // 1960-1969
- 0x096d0, 0x04dd5, 0x04ad0, 0x0a4d0, 0x0d4d4, 0x0d250, 0x0d558, 0x0b540, 0x0b6a0, 0x195a6, // 1970-1979
- 0x095b0, 0x049b0, 0x0a974, 0x0a4b0, 0x0b27a, 0x06a50, 0x06d40, 0x0af46, 0x0ab60, 0x09570, // 1980-1989
- 0x04af5, 0x04970, 0x064b0, 0x074a3, 0x0ea50, 0x06b58, 0x05ac0, 0x0ab60, 0x096d5, 0x092e0, // 1990-1999
- 0x0c960, 0x0d954, 0x0d4a0, 0x0da50, 0x07552, 0x056a0, 0x0abb7, 0x025d0, 0x092d0, 0x0cab5, // 2000-2009
- 0x0a950, 0x0b4a0, 0x0baa4, 0x0ad50, 0x055d9, 0x04ba0, 0x0a5b0, 0x15176, 0x052b0, 0x0a930, // 2010-2019
- 0x07954, 0x06aa0, 0x0ad50, 0x05b52, 0x04b60, 0x0a6e6, 0x0a4e0, 0x0d260, 0x0ea65, 0x0d530, // 2020-2029
- 0x05aa0, 0x076a3, 0x096d0, 0x04afb, 0x04ad0, 0x0a4d0, 0x1d0b6, 0x0d250, 0x0d520, 0x0dd45, // 2030-2039
- 0x0b5a0, 0x056d0, 0x055b2, 0x049b0, 0x0a577, 0x0a4b0, 0x0aa50, 0x1b255, 0x06d20, 0x0ada0, // 2040-2049
- /** Add By JJonline@JJonline.Cn**/
- 0x14b63, 0x09370, 0x049f8, 0x04970, 0x064b0, 0x168a6, 0x0ea50, 0x06b20, 0x1a6c4, 0x0aae0, // 2050-2059
- 0x0a2e0, 0x0d2e3, 0x0c960, 0x0d557, 0x0d4a0, 0x0da50, 0x05d55, 0x056a0, 0x0a6d0, 0x055d4, // 2060-2069
- 0x052d0, 0x0a9b8, 0x0a950, 0x0b4a0, 0x0b6a6, 0x0ad50, 0x055a0, 0x0aba4, 0x0a5b0, 0x052b0, // 2070-2079
- 0x0b273, 0x06930, 0x07337, 0x06aa0, 0x0ad50, 0x14b55, 0x04b60, 0x0a570, 0x054e4, 0x0d160, // 2080-2089
- 0x0e968, 0x0d520, 0x0daa0, 0x16aa6, 0x056d0, 0x04ae0, 0x0a9d4, 0x0a2d0, 0x0d150, 0x0f252, // 2090-2099
- 0x0d520], // 2100
- * 公历每个月份的天数普通表
- * @return Number
- solarMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
- * 天干地支之天干速查表
- * @Array Of Property trans["甲","乙","丙","丁","戊","己","庚","辛","壬","癸"]
- * @return Cn string
- Gan: ['\u7532', '\u4e59', '\u4e19', '\u4e01', '\u620a', '\u5df1', '\u5e9a', '\u8f9b', '\u58ec', '\u7678'],
- * 天干地支之地支速查表
- * @trans["子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"]
- Zhi: ['\u5b50', '\u4e11', '\u5bc5', '\u536f', '\u8fb0', '\u5df3', '\u5348', '\u672a', '\u7533', '\u9149', '\u620c', '\u4ea5'],
- * 天干地支之地支速查表<=>生肖
- * @trans["鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"]
- Animals: ['\u9f20', '\u725b', '\u864e', '\u5154', '\u9f99', '\u86c7', '\u9a6c', '\u7f8a', '\u7334', '\u9e21', '\u72d7', '\u732a'],
- * 24节气速查表
- * @trans["小寒","大寒","立春","雨水","惊蛰","春分","清明","谷雨","立夏","小满","芒种","夏至","小暑","大暑","立秋","处暑","白露","秋分","寒露","霜降","立冬","小雪","大雪","冬至"]
- solarTerm: ['\u5c0f\u5bd2', '\u5927\u5bd2', '\u7acb\u6625', '\u96e8\u6c34', '\u60ca\u86f0', '\u6625\u5206', '\u6e05\u660e', '\u8c37\u96e8', '\u7acb\u590f', '\u5c0f\u6ee1', '\u8292\u79cd', '\u590f\u81f3', '\u5c0f\u6691', '\u5927\u6691', '\u7acb\u79cb', '\u5904\u6691', '\u767d\u9732', '\u79cb\u5206', '\u5bd2\u9732', '\u971c\u964d', '\u7acb\u51ac', '\u5c0f\u96ea', '\u5927\u96ea', '\u51ac\u81f3'],
- * 1900-2100各年的24节气日期速查表
- * @return 0x string For splice
- sTermInfo: ['9778397bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e', '97bcf97c3598082c95f8c965cc920f',
- '97bd0b06bdb0722c965ce1cfcc920f', 'b027097bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e',
- '97bcf97c359801ec95f8c965cc920f', '97bd0b06bdb0722c965ce1cfcc920f', 'b027097bd097c36b0b6fc9274c91aa',
- '97b6b97bd19801ec9210c965cc920e', '97bcf97c359801ec95f8c965cc920f', '97bd0b06bdb0722c965ce1cfcc920f',
- 'b027097bd097c36b0b6fc9274c91aa', '9778397bd19801ec9210c965cc920e', '97b6b97bd19801ec95f8c965cc920f',
- '97bd09801d98082c95f8e1cfcc920f', '97bd097bd097c36b0b6fc9210c8dc2', '9778397bd197c36c9210c9274c91aa',
- '97b6b97bd19801ec95f8c965cc920e', '97bd09801d98082c95f8e1cfcc920f', '97bd097bd097c36b0b6fc9210c8dc2',
- '9778397bd097c36c9210c9274c91aa', '97b6b97bd19801ec95f8c965cc920e', '97bcf97c3598082c95f8e1cfcc920f',
- '97bd097bd097c36b0b6fc9210c8dc2', '9778397bd097c36c9210c9274c91aa', '97b6b97bd19801ec9210c965cc920e',
- '97bcf97c3598082c95f8c965cc920f', '97bd097bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa',
- '97b6b97bd19801ec9210c965cc920e', '97bcf97c3598082c95f8c965cc920f', '97bd097bd097c35b0b6fc920fb0722',
- '9778397bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e', '97bcf97c359801ec95f8c965cc920f',
- '97bd097bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e',
- '97bcf97c359801ec95f8c965cc920f', '97bd097bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa',
- '97b6b97bd19801ec9210c965cc920e', '97bcf97c359801ec95f8c965cc920f', '97bd097bd07f595b0b6fc920fb0722',
- '9778397bd097c36b0b6fc9210c8dc2', '9778397bd19801ec9210c9274c920e', '97b6b97bd19801ec95f8c965cc920f',
- '97bd07f5307f595b0b0bc920fb0722', '7f0e397bd097c36b0b6fc9210c8dc2', '9778397bd097c36c9210c9274c920e',
- '97b6b97bd19801ec95f8c965cc920f', '97bd07f5307f595b0b0bc920fb0722', '7f0e397bd097c36b0b6fc9210c8dc2',
- '9778397bd097c36c9210c9274c91aa', '97b6b97bd19801ec9210c965cc920e', '97bd07f1487f595b0b0bc920fb0722',
- '7f0e397bd097c36b0b6fc9210c8dc2', '9778397bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e',
- '97bcf7f1487f595b0b0bb0b6fb0722', '7f0e397bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa',
- '97b6b97bd19801ec9210c965cc920e', '97bcf7f1487f595b0b0bb0b6fb0722', '7f0e397bd097c35b0b6fc920fb0722',
- '9778397bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e', '97bcf7f1487f531b0b0bb0b6fb0722',
- '7f0e397bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e',
- '97bcf7f1487f531b0b0bb0b6fb0722', '7f0e397bd07f595b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa',
- '97b6b97bd19801ec9210c9274c920e', '97bcf7f0e47f531b0b0bb0b6fb0722', '7f0e397bd07f595b0b0bc920fb0722',
- '9778397bd097c36b0b6fc9210c91aa', '97b6b97bd197c36c9210c9274c920e', '97bcf7f0e47f531b0b0bb0b6fb0722',
- '7f0e397bd07f595b0b0bc920fb0722', '9778397bd097c36b0b6fc9210c8dc2', '9778397bd097c36c9210c9274c920e',
- '97b6b7f0e47f531b0723b0b6fb0722', '7f0e37f5307f595b0b0bc920fb0722', '7f0e397bd097c36b0b6fc9210c8dc2',
- '9778397bd097c36b0b70c9274c91aa', '97b6b7f0e47f531b0723b0b6fb0721', '7f0e37f1487f595b0b0bb0b6fb0722',
- '7f0e397bd097c35b0b6fc9210c8dc2', '9778397bd097c36b0b6fc9274c91aa', '97b6b7f0e47f531b0723b0b6fb0721',
- '7f0e27f1487f595b0b0bb0b6fb0722', '7f0e397bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa',
- '97b6b7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e397bd097c35b0b6fc920fb0722',
- '9778397bd097c36b0b6fc9274c91aa', '97b6b7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722',
- '7f0e397bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', '97b6b7f0e47f531b0723b0b6fb0721',
- '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e397bd07f595b0b0bc920fb0722', '9778397bd097c36b0b6fc9274c91aa',
- '97b6b7f0e47f531b0723b0787b0721', '7f0e27f0e47f531b0b0bb0b6fb0722', '7f0e397bd07f595b0b0bc920fb0722',
- '9778397bd097c36b0b6fc9210c91aa', '97b6b7f0e47f149b0723b0787b0721', '7f0e27f0e47f531b0723b0b6fb0722',
- '7f0e397bd07f595b0b0bc920fb0722', '9778397bd097c36b0b6fc9210c8dc2', '977837f0e37f149b0723b0787b0721',
- '7f07e7f0e47f531b0723b0b6fb0722', '7f0e37f5307f595b0b0bc920fb0722', '7f0e397bd097c35b0b6fc9210c8dc2',
- '977837f0e37f14998082b0787b0721', '7f07e7f0e47f531b0723b0b6fb0721', '7f0e37f1487f595b0b0bb0b6fb0722',
- '7f0e397bd097c35b0b6fc9210c8dc2', '977837f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721',
- '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e397bd097c35b0b6fc920fb0722', '977837f0e37f14998082b0787b06bd',
- '7f07e7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e397bd097c35b0b6fc920fb0722',
- '977837f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722',
- '7f0e397bd07f595b0b0bc920fb0722', '977837f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721',
- '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e397bd07f595b0b0bc920fb0722', '977837f0e37f14998082b0787b06bd',
- '7f07e7f0e47f149b0723b0787b0721', '7f0e27f0e47f531b0b0bb0b6fb0722', '7f0e397bd07f595b0b0bc920fb0722',
- '977837f0e37f14998082b0723b06bd', '7f07e7f0e37f149b0723b0787b0721', '7f0e27f0e47f531b0723b0b6fb0722',
- '7f0e397bd07f595b0b0bc920fb0722', '977837f0e37f14898082b0723b02d5', '7ec967f0e37f14998082b0787b0721',
- '7f07e7f0e47f531b0723b0b6fb0722', '7f0e37f1487f595b0b0bb0b6fb0722', '7f0e37f0e37f14898082b0723b02d5',
- '7ec967f0e37f14998082b0787b0721', '7f07e7f0e47f531b0723b0b6fb0722', '7f0e37f1487f531b0b0bb0b6fb0722',
- '7f0e37f0e37f14898082b0723b02d5', '7ec967f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721',
- '7f0e37f1487f531b0b0bb0b6fb0722', '7f0e37f0e37f14898082b072297c35', '7ec967f0e37f14998082b0787b06bd',
- '7f07e7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e37f0e37f14898082b072297c35',
- '7ec967f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722',
- '7f0e37f0e366aa89801eb072297c35', '7ec967f0e37f14998082b0787b06bd', '7f07e7f0e47f149b0723b0787b0721',
- '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e37f0e366aa89801eb072297c35', '7ec967f0e37f14998082b0723b06bd',
- '7f07e7f0e47f149b0723b0787b0721', '7f0e27f0e47f531b0723b0b6fb0722', '7f0e37f0e366aa89801eb072297c35',
- '7ec967f0e37f14998082b0723b06bd', '7f07e7f0e37f14998083b0787b0721', '7f0e27f0e47f531b0723b0b6fb0722',
- '7f0e37f0e366aa89801eb072297c35', '7ec967f0e37f14898082b0723b02d5', '7f07e7f0e37f14998082b0787b0721',
- '7f07e7f0e47f531b0723b0b6fb0722', '7f0e36665b66aa89801e9808297c35', '665f67f0e37f14898082b0723b02d5',
- '7ec967f0e37f14998082b0787b0721', '7f07e7f0e47f531b0723b0b6fb0722', '7f0e36665b66a449801e9808297c35',
- '665f67f0e37f14898082b0723b02d5', '7ec967f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721',
- '7f0e36665b66a449801e9808297c35', '665f67f0e37f14898082b072297c35', '7ec967f0e37f14998082b0787b06bd',
- '7f07e7f0e47f531b0723b0b6fb0721', '7f0e26665b66a449801e9808297c35', '665f67f0e37f1489801eb072297c35',
- '7ec967f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722'],
- * 数字转中文速查表
- * @trans ['日','一','二','三','四','五','六','七','八','九','十']
- nStr1: ['\u65e5', '\u4e00', '\u4e8c', '\u4e09', '\u56db', '\u4e94', '\u516d', '\u4e03', '\u516b', '\u4e5d', '\u5341'],
- * 日期转农历称呼速查表
- * @trans ['初','十','廿','卅']
- nStr2: ['\u521d', '\u5341', '\u5eff', '\u5345'],
- * 月份转农历称呼速查表
- * @trans ['正','一','二','三','四','五','六','七','八','九','十','冬','腊']
- nStr3: ['\u6b63', '\u4e8c', '\u4e09', '\u56db', '\u4e94', '\u516d', '\u4e03', '\u516b', '\u4e5d', '\u5341', '\u51ac', '\u814a'],
- * 返回农历y年一整年的总天数
- * @param lunar Year
- * @eg:var count = calendar.lYearDays(1987) ;//count=387
- lYearDays: function (y) {
- var i; var sum = 348
- for (i = 0x8000; i > 0x8; i >>= 1) { sum += (this.lunarInfo[y - 1900] & i) ? 1 : 0 }
- return (sum + this.leapDays(y))
- * 返回农历y年闰月是哪个月;若y年没有闰月 则返回0
- * @return Number (0-12)
- * @eg:var leapMonth = calendar.leapMonth(1987) ;//leapMonth=6
- leapMonth: function (y) { // 闰字编码 \u95f0
- return (this.lunarInfo[y - 1900] & 0xf)
- * 返回农历y年闰月的天数 若该年没有闰月则返回0
- * @return Number (0、29、30)
- * @eg:var leapMonthDay = calendar.leapDays(1987) ;//leapMonthDay=29
- leapDays: function (y) {
- if (this.leapMonth(y)) {
- return ((this.lunarInfo[y - 1900] & 0x10000) ? 30 : 29)
- return (0)
- * 返回农历y年m月(非闰月)的总天数,计算m为闰月时的天数请使用leapDays方法
- * @return Number (-1、29、30)
- * @eg:var MonthDay = calendar.monthDays(1987,9) ;//MonthDay=29
- monthDays: function (y, m) {
- if (m > 12 || m < 1) { return -1 }// 月份参数从1至12,参数错误返回-1
- return ((this.lunarInfo[y - 1900] & (0x10000 >> m)) ? 30 : 29)
- * 返回公历(!)y年m月的天数
- * @param solar Year
- * @return Number (-1、28、29、30、31)
- * @eg:var solarMonthDay = calendar.leapDays(1987) ;//solarMonthDay=30
- solarDays: function (y, m) {
- if (m > 12 || m < 1) { return -1 } // 若参数错误 返回-1
- var ms = m - 1
- if (ms == 1) { // 2月份的闰平规律测算后确认返回28或29
- return (((y % 4 == 0) && (y % 100 != 0) || (y % 400 == 0)) ? 29 : 28)
- return (this.solarMonth[ms])
- * 农历年份转换为干支纪年
- * @param lYear 农历年的年份数
- toGanZhiYear: function (lYear) {
- var ganKey = (lYear - 3) % 10
- var zhiKey = (lYear - 3) % 12
- if (ganKey == 0) ganKey = 10// 如果余数为0则为最后一个天干
- if (zhiKey == 0) zhiKey = 12// 如果余数为0则为最后一个地支
- return this.Gan[ganKey - 1] + this.Zhi[zhiKey - 1]
- * 公历月、日判断所属星座
- * @param cMonth [description]
- * @param cDay [description]
- toAstro: function (cMonth, cDay) {
- var s = '\u9b54\u7faf\u6c34\u74f6\u53cc\u9c7c\u767d\u7f8a\u91d1\u725b\u53cc\u5b50\u5de8\u87f9\u72ee\u5b50\u5904\u5973\u5929\u79e4\u5929\u874e\u5c04\u624b\u9b54\u7faf'
- var arr = [20, 19, 21, 21, 21, 22, 23, 23, 23, 23, 22, 22]
- return s.substr(cMonth * 2 - (cDay < arr[cMonth - 1] ? 2 : 0), 2) + '\u5ea7'// 座
- * 传入offset偏移量返回干支
- * @param offset 相对甲子的偏移量
- toGanZhi: function (offset) {
- return this.Gan[offset % 10] + this.Zhi[offset % 12]
- * 传入公历(!)y年获得该年第n个节气的公历日期
- * @param y公历年(1900-2100);n二十四节气中的第几个节气(1~24);从n=1(小寒)算起
- * @return day Number
- * @eg:var _24 = calendar.getTerm(1987,3) ;//_24=4;意即1987年2月4日立春
- getTerm: function (y, n) {
- if (y < 1900 || y > 2100) { return -1 }
- if (n < 1 || n > 24) { return -1 }
- var _table = this.sTermInfo[y - 1900]
- var _info = [
- parseInt('0x' + _table.substr(0, 5)).toString(),
- parseInt('0x' + _table.substr(5, 5)).toString(),
- parseInt('0x' + _table.substr(10, 5)).toString(),
- parseInt('0x' + _table.substr(15, 5)).toString(),
- parseInt('0x' + _table.substr(20, 5)).toString(),
- parseInt('0x' + _table.substr(25, 5)).toString()
- var _calday = [
- _info[0].substr(0, 1),
- _info[0].substr(1, 2),
- _info[0].substr(3, 1),
- _info[0].substr(4, 2),
- _info[1].substr(0, 1),
- _info[1].substr(1, 2),
- _info[1].substr(3, 1),
- _info[1].substr(4, 2),
- _info[2].substr(0, 1),
- _info[2].substr(1, 2),
- _info[2].substr(3, 1),
- _info[2].substr(4, 2),
- _info[3].substr(0, 1),
- _info[3].substr(1, 2),
- _info[3].substr(3, 1),
- _info[3].substr(4, 2),
- _info[4].substr(0, 1),
- _info[4].substr(1, 2),
- _info[4].substr(3, 1),
- _info[4].substr(4, 2),
- _info[5].substr(0, 1),
- _info[5].substr(1, 2),
- _info[5].substr(3, 1),
- _info[5].substr(4, 2)
- return parseInt(_calday[n - 1])
- * 传入农历数字月份返回汉语通俗表示法
- * @param lunar month
- * @eg:var cnMonth = calendar.toChinaMonth(12) ;//cnMonth='腊月'
- toChinaMonth: function (m) { // 月 => \u6708
- var s = this.nStr3[m - 1]
- s += '\u6708'// 加上月字
- return s
- * 传入农历日期数字返回汉字表示法
- * @param lunar day
- * @eg:var cnDay = calendar.toChinaDay(21) ;//cnMonth='廿一'
- toChinaDay: function (d) { // 日 => \u65e5
- var s
- switch (d) {
- case 10:
- s = '\u521d\u5341'; break
- case 20:
- s = '\u4e8c\u5341'; break
- case 30:
- s = '\u4e09\u5341'; break
- default :
- s = this.nStr2[Math.floor(d / 10)]
- s += this.nStr1[d % 10]
- return (s)
- * 年份转生肖[!仅能大致转换] => 精确划分生肖分界线是“立春”
- * @param y year
- * @eg:var animal = calendar.getAnimal(1987) ;//animal='兔'
- getAnimal: function (y) {
- return this.Animals[(y - 4) % 12]
- * 传入阳历年月日获得详细的公历、农历object信息 <=>JSON
- * @param y solar year
- * @param m solar month
- * @param d solar day
- * @return JSON object
- * @eg:console.log(calendar.solar2lunar(1987,11,01));
- solar2lunar: function (y, m, d) { // 参数区间1900.1.31~2100.12.31
- // 年份限定、上限
- if (y < 1900 || y > 2100) {
- return -1// undefined转换为数字变为NaN
- // 公历传参最下限
- if (y == 1900 && m == 1 && d < 31) {
- return -1
- // 未传参 获得当天
- if (!y) {
- var objDate = new Date()
- var objDate = new Date(y, parseInt(m) - 1, d)
- var i; var leap = 0; var temp = 0
- // 修正ymd参数
- var y = objDate.getFullYear()
- var m = objDate.getMonth() + 1
- var d = objDate.getDate()
- var offset = (Date.UTC(objDate.getFullYear(), objDate.getMonth(), objDate.getDate()) - Date.UTC(1900, 0, 31)) / 86400000
- for (i = 1900; i < 2101 && offset > 0; i++) {
- temp = this.lYearDays(i)
- offset -= temp
- if (offset < 0) {
- offset += temp; i--
- // 是否今天
- var isTodayObj = new Date()
- var isToday = false
- if (isTodayObj.getFullYear() == y && isTodayObj.getMonth() + 1 == m && isTodayObj.getDate() == d) {
- isToday = true
- // 星期几
- var nWeek = objDate.getDay()
- var cWeek = this.nStr1[nWeek]
- // 数字表示周几顺应天朝周一开始的惯例
- if (nWeek == 0) {
- nWeek = 7
- // 农历年
- var year = i
- var leap = this.leapMonth(i) // 闰哪个月
- var isLeap = false
- // 效验闰月
- for (i = 1; i < 13 && offset > 0; i++) {
- // 闰月
- if (leap > 0 && i == (leap + 1) && isLeap == false) {
- --i
- isLeap = true; temp = this.leapDays(year) // 计算农历闰月天数
- temp = this.monthDays(year, i)// 计算农历普通月天数
- // 解除闰月
- if (isLeap == true && i == (leap + 1)) { isLeap = false }
- // 闰月导致数组下标重叠取反
- if (offset == 0 && leap > 0 && i == leap + 1) {
- if (isLeap) {
- isLeap = false
- isLeap = true; --i
- offset += temp; --i
- // 农历月
- var month = i
- // 农历日
- var day = offset + 1
- // 天干地支处理
- var sm = m - 1
- var gzY = this.toGanZhiYear(year)
- // 当月的两个节气
- // bugfix-2017-7-24 11:03:38 use lunar Year Param `y` Not `year`
- var firstNode = this.getTerm(y, (m * 2 - 1))// 返回当月「节」为几日开始
- var secondNode = this.getTerm(y, (m * 2))// 返回当月「节」为几日开始
- // 依据12节气修正干支月
- var gzM = this.toGanZhi((y - 1900) * 12 + m + 11)
- if (d >= firstNode) {
- gzM = this.toGanZhi((y - 1900) * 12 + m + 12)
- // 传入的日期的节气与否
- var isTerm = false
- var Term = null
- if (firstNode == d) {
- isTerm = true
- Term = this.solarTerm[m * 2 - 2]
- if (secondNode == d) {
- Term = this.solarTerm[m * 2 - 1]
- // 日柱 当月一日与 1900/1/1 相差天数
- var dayCyclical = Date.UTC(y, sm, 1, 0, 0, 0, 0) / 86400000 + 25567 + 10
- var gzD = this.toGanZhi(dayCyclical + d - 1)
- // 该日期所属的星座
- var astro = this.toAstro(m, d)
- return { 'lYear': year, 'lMonth': month, 'lDay': day, 'Animal': this.getAnimal(year), 'IMonthCn': (isLeap ? '\u95f0' : '') + this.toChinaMonth(month), 'IDayCn': this.toChinaDay(day), 'cYear': y, 'cMonth': m, 'cDay': d, 'gzYear': gzY, 'gzMonth': gzM, 'gzDay': gzD, 'isToday': isToday, 'isLeap': isLeap, 'nWeek': nWeek, 'ncWeek': '\u661f\u671f' + cWeek, 'isTerm': isTerm, 'Term': Term, 'astro': astro }
- * 传入农历年月日以及传入的月份是否闰月获得详细的公历、农历object信息 <=>JSON
- * @param y lunar year
- * @param m lunar month
- * @param d lunar day
- * @param isLeapMonth lunar month is leap or not.[如果是农历闰月第四个参数赋值true即可]
- * @eg:console.log(calendar.lunar2solar(1987,9,10));
- lunar2solar: function (y, m, d, isLeapMonth) { // 参数区间1900.1.31~2100.12.1
- var isLeapMonth = !!isLeapMonth
- var leapOffset = 0
- var leapMonth = this.leapMonth(y)
- var leapDay = this.leapDays(y)
- if (isLeapMonth && (leapMonth != m)) { return -1 }// 传参要求计算该闰月公历 但该年得出的闰月与传参的月份并不同
- if (y == 2100 && m == 12 && d > 1 || y == 1900 && m == 1 && d < 31) { return -1 }// 超出了最大极限值
- var day = this.monthDays(y, m)
- var _day = day
- // bugFix 2016-9-25
- // if month is leap, _day use leapDays method
- if (isLeapMonth) {
- _day = this.leapDays(y, m)
- if (y < 1900 || y > 2100 || d > _day) { return -1 }// 参数合法性效验
- // 计算农历的时间差
- var offset = 0
- for (var i = 1900; i < y; i++) {
- offset += this.lYearDays(i)
- var leap = 0; var isAdd = false
- for (var i = 1; i < m; i++) {
- leap = this.leapMonth(y)
- if (!isAdd) { // 处理闰月
- if (leap <= i && leap > 0) {
- offset += this.leapDays(y); isAdd = true
- offset += this.monthDays(y, i)
- // 转换闰月农历 需补充该年闰月的前一个月的时差
- if (isLeapMonth) { offset += day }
- // 1900年农历正月一日的公历时间为1900年1月30日0时0分0秒(该时间也是本农历的最开始起始点)
- var stmap = Date.UTC(1900, 1, 30, 0, 0, 0)
- var calObj = new Date((offset + d - 31) * 86400000 + stmap)
- var cY = calObj.getUTCFullYear()
- var cM = calObj.getUTCMonth() + 1
- var cD = calObj.getUTCDate()
- return this.solar2lunar(cY, cM, cD)
-export default calendar
@@ -1,12 +0,0 @@
- "uni-calender.ok": "ok",
- "uni-calender.cancel": "cancel",
- "uni-calender.today": "today",
- "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"
@@ -1,8 +0,0 @@
-import en from './en.json'
-import zhHans from './zh-Hans.json'
-import zhHant from './zh-Hant.json'
- en,
- 'zh-Hans': zhHans,
- 'zh-Hant': zhHant
- "uni-calender.ok": "确定",
- "uni-calender.cancel": "取消",
- "uni-calender.today": "今日",
- "uni-calender.SUN": "日",
- "uni-calender.MON": "一",
- "uni-calender.TUE": "二",
- "uni-calender.WED": "三",
- "uni-calender.THU": "四",
- "uni-calender.FRI": "五",
- "uni-calender.SAT": "六"
- "uni-calender.ok": "確定",
@@ -1,187 +0,0 @@
- <view class="uni-calendar-item__weeks-box" :class="{
- 'uni-calendar-item--disable':weeks.disable,
- 'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
- 'uni-calendar-item--checked':(calendar.fullDate === weeks.fullDate && !weeks.isDay) ,
- 'uni-calendar-item--before-checked':weeks.beforeMultiple,
- 'uni-calendar-item--multiple': weeks.multiple,
- 'uni-calendar-item--after-checked':weeks.afterMultiple,
- }"
- @click="choiceDate(weeks)">
- <view class="uni-calendar-item__weeks-box-item">
- <text v-if="selected&&weeks.extraInfo" class="uni-calendar-item__weeks-box-circle"></text>
- <text class="uni-calendar-item__weeks-box-text" :class="{
- 'uni-calendar-item--isDay-text': weeks.isDay,
- 'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
- }">{{weeks.date}}</text>
- <text v-if="!lunar&&!weeks.extraInfo && weeks.isDay" class="uni-calendar-item__weeks-lunar-text" :class="{
- 'uni-calendar-item--isDay-text':weeks.isDay,
- }">{{todayText}}</text>
- <text v-if="lunar&&!weeks.extraInfo" class="uni-calendar-item__weeks-lunar-text" :class="{
- }">{{weeks.isDay ? todayText : (weeks.lunar.IDayCn === '初一'?weeks.lunar.IMonthCn:weeks.lunar.IDayCn)}}</text>
- <text v-if="weeks.extraInfo&&weeks.extraInfo.info" class="uni-calendar-item__weeks-lunar-text" :class="{
- 'uni-calendar-item--extra':weeks.extraInfo.info,
- }">{{weeks.extraInfo.info}}</text>
- import { initVueI18n } from '@dcloudio/uni-i18n'
- import i18nMessages from './i18n/index.js'
- const { t } = initVueI18n(i18nMessages)
- emits:['change'],
- weeks: {
- calendar: {
- default: () => {
- selected: {
- return []
- lunar: {
- todayText() {
- return t("uni-calender.today")
- choiceDate(weeks) {
- this.$emit('change', weeks)
- $uni-font-size-base:14px;
- $uni-text-color:#333;
- $uni-font-size-sm:12px;
- $uni-color-error: #e43d33;
- $uni-opacity-disabled: 0.3;
- $uni-text-color-disable:#c0c0c0;
- .uni-calendar-item__weeks-box {
- flex: 1;
- .uni-calendar-item__weeks-box-text {
- font-size: $uni-font-size-base;
- color: $uni-text-color;
- .uni-calendar-item__weeks-lunar-text {
- font-size: $uni-font-size-sm;
- .uni-calendar-item__weeks-box-item {
- width: 100rpx;
- height: 100rpx;
- .uni-calendar-item__weeks-box-circle {
- top: 5px;
- right: 5px;
- width: 8px;
- height: 8px;
- border-radius: 8px;
- background-color: $uni-color-error;
- .uni-calendar-item--disable {
- background-color: rgba(249, 249, 249, $uni-opacity-disabled);
- color: $uni-text-color-disable;
- .uni-calendar-item--isDay-text {
- .uni-calendar-item--isDay {
- opacity: 0.8;
- .uni-calendar-item--extra {
- color: $uni-color-error;
- .uni-calendar-item--checked {
- .uni-calendar-item--multiple {
- .uni-calendar-item--before-checked {
- background-color: #ff5a5f;
- .uni-calendar-item--after-checked {
@@ -1,566 +0,0 @@
- <view class="uni-calendar">
- <view v-if="!insert&&show" class="uni-calendar__mask" :class="{'uni-calendar--mask-show':aniMaskShow}" @click="clean"></view>
- <view v-if="insert || show" class="uni-calendar__content" :class="{'uni-calendar--fixed':!insert,'uni-calendar--ani-show':aniMaskShow}">
- <view v-if="!insert" class="uni-calendar__header uni-calendar--fixed-top">
- <view class="uni-calendar__header-btn-box" @click="close">
- <text class="uni-calendar__header-text uni-calendar--fixed-width">{{cancelText}}</text>
- <view class="uni-calendar__header-btn-box" @click="confirm">
- <text class="uni-calendar__header-text uni-calendar--fixed-width">{{okText}}</text>
- <view class="uni-calendar__header">
- <view class="uni-calendar__header-btn-box" @click.stop="pre">
- <view class="uni-calendar__header-btn uni-calendar--left"></view>
- <picker mode="date" :value="date" fields="month" @change="bindDateChange">
- <text class="uni-calendar__header-text">{{ (nowDate.year||'') +' / '+( nowDate.month||'')}}</text>
- </picker>
- <view class="uni-calendar__header-btn-box" @click.stop="next">
- <view class="uni-calendar__header-btn uni-calendar--right"></view>
- <text class="uni-calendar__backtoday" @click="backToday">{{todayText}}</text>
- <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 class="uni-calendar__weeks">
- <view class="uni-calendar__weeks-day">
- <text class="uni-calendar__weeks-day-text">{{SUNText}}</text>
- <text class="uni-calendar__weeks-day-text">{{monText}}</text>
- <text class="uni-calendar__weeks-day-text">{{TUEText}}</text>
- <text class="uni-calendar__weeks-day-text">{{WEDText}}</text>
- <text class="uni-calendar__weeks-day-text">{{THUText}}</text>
- <text class="uni-calendar__weeks-day-text">{{FRIText}}</text>
- <text class="uni-calendar__weeks-day-text">{{SATText}}</text>
- <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" :lunar="lunar" @change="choiceDate"></calendar-item>
- import Calendar from './util.js';
- import CalendarItem from './uni-calendar-item.vue'
- * Calendar 日历
- * @description 日历组件可以查看日期,选择任意范围内的日期,打点操作。常用场景如:酒店日期预订、火车机票选择购买日期、上下班打卡等
- * @tutorial https://ext.dcloud.net.cn/plugin?id=56
- * @property {String} date 自定义当前时间,默认为今天
- * @property {Boolean} lunar 显示农历
- * @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 是否选择月份为背景
- * @event {Function} change 日期改变,`insert :ture` 时生效
- * @event {Function} confirm 确认选择`insert :false` 时生效
- * @event {Function} monthSwitch 切换月份时触发
- * @example <uni-calendar :insert="true":lunar="true" :start-date="'2019-3-2'":end-date="'2019-5-20'"@change="change" />
- CalendarItem
- emits:['close','confirm','change','monthSwitch'],
- date: {
- startDate: {
- endDate: {
- range: {
- insert: {
- showMonth: {
- clearDate: {
- show: false,
- weeks: [],
- calendar: {},
- nowDate: '',
- aniMaskShow: false
- computed:{
- * for i18n
- okText() {
- return t("uni-calender.ok")
- cancelText() {
- return t("uni-calender.cancel")
- 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")
- date(newVal) {
- // this.cale.setDate(newVal)
- this.init(newVal)
- startDate(val){
- this.cale.resetSatrtDate(val)
- this.cale.setDate(this.nowDate.fullDate)
- this.weeks = this.cale.weeks
- endDate(val){
- this.cale.resetEndDate(val)
- selected(newVal) {
- this.cale.setSelectInfo(this.nowDate.fullDate, newVal)
- created() {
- this.cale = new Calendar({
- selected: this.selected,
- startDate: this.startDate,
- endDate: this.endDate,
- range: this.range,
- this.init(this.date)
- // 取消穿透
- clean() {},
- bindDateChange(e) {
- const value = e.detail.value + '-1'
- this.setDate(value)
- const { year,month } = this.cale.getDate(value)
- this.$emit('monthSwitch', {
- year,
- month
- * 初始化日期显示
- * @param {Object} date
- init(date) {
- this.cale.setDate(date)
- this.nowDate = this.calendar = this.cale.getInfo(date)
- * 打开日历弹窗
- open() {
- // 弹窗模式并且清理数据
- if (this.clearDate && !this.insert) {
- this.cale.cleanMultipleStatus()
- // this.cale.setDate(this.date)
- this.show = true
- this.aniMaskShow = true
- }, 50)
- * 关闭日历弹窗
- close() {
- this.aniMaskShow = false
- this.show = false
- this.$emit('close')
- }, 300)
- * 确认按钮
- confirm() {
- this.setEmit('confirm')
- this.close()
- * 变化触发
- change() {
- if (!this.insert) return
- this.setEmit('change')
- * 选择月份触发
- monthSwitch() {
- let {
- } = this.nowDate
- month: Number(month)
- * 派发事件
- * @param {Object} name
- setEmit(name) {
- month,
- date,
- fullDate,
- lunar,
- extraInfo
- } = this.calendar
- this.$emit(name, {
- range: this.cale.multipleStatus,
- fulldate: fullDate,
- extraInfo: extraInfo || {}
- * 选择天触发
- * @param {Object} weeks
- if (weeks.disable) return
- this.calendar = weeks
- // 设置多选
- this.cale.setMultiple(this.calendar.fullDate)
- this.change()
- * 回到今天
- backToday() {
- const nowYearMonth = `${this.nowDate.year}-${this.nowDate.month}`
- const date = this.cale.getDate(new Date())
- const todayYearMonth = `${date.year}-${date.month}`
- if(nowYearMonth !== todayYearMonth) {
- this.monthSwitch()
- this.init(date.fullDate)
- * 上个月
- pre() {
- const preDate = this.cale.getDate(this.nowDate.fullDate, -1, 'month').fullDate
- this.setDate(preDate)
- * 下个月
- next() {
- const nextDate = this.cale.getDate(this.nowDate.fullDate, +1, 'month').fullDate
- this.setDate(nextDate)
- * 设置日期
- setDate(date) {
- this.nowDate = this.cale.getInfo(date)
- $uni-bg-color-mask: rgba($color: #000000, $alpha: 0.4);
- $uni-border-color: #EDEDED;
- $uni-text-color: #333;
- $uni-bg-color-hover:#f1f1f1;
- $uni-text-color-placeholder: #808080;
- $uni-color-subtitle: #555555;
- $uni-text-color-grey:#999;
- .uni-calendar {
- .uni-calendar__mask {
- background-color: $uni-bg-color-mask;
- transition-property: opacity;
- transition-duration: 0.3s;
- .uni-calendar--mask-show {
- opacity: 1
- .uni-calendar--fixed {
- transition-property: transform;
- transform: translateY(460px);
- bottom: calc(var(--window-bottom));
- .uni-calendar--ani-show {
- transform: translateY(0);
- .uni-calendar__content {
- background-color: #fff;
- .uni-calendar__header {
- height: 50px;
- border-bottom-color: $uni-border-color;
- border-bottom-style: solid;
- border-bottom-width: 1px;
- .uni-calendar--fixed-top {
- justify-content: space-between;
- border-top-color: $uni-border-color;
- border-top-style: solid;
- border-top-width: 1px;
- .uni-calendar--fixed-width {
- width: 50px;
- .uni-calendar__backtoday {
- top: 25rpx;
- padding: 0 5px;
- padding-left: 10px;
- height: 25px;
- line-height: 25px;
- border-top-left-radius: 25px;
- border-bottom-left-radius: 25px;
- background-color: $uni-bg-color-hover;
- .uni-calendar__header-text {
- width: 100px;
- .uni-calendar__header-btn-box {
- .uni-calendar__header-btn {
- width: 10px;
- height: 10px;
- border-left-color: $uni-text-color-placeholder;
- border-left-style: solid;
- border-left-width: 2px;
- border-top-color: $uni-color-subtitle;
- border-top-width: 2px;
- .uni-calendar--left {
- transform: rotate(-45deg);
- .uni-calendar--right {
- transform: rotate(135deg);
- .uni-calendar__weeks {
- .uni-calendar__weeks-item {
- .uni-calendar__weeks-day {
- height: 45px;
- border-bottom-color: #F5F5F5;
- .uni-calendar__weeks-day-text {
- .uni-calendar__box {
- .uni-calendar__box-bg {
- .uni-calendar__box-bg-text {
- font-size: 200px;
- color: $uni-text-color-grey;
- opacity: 0.1;
- line-height: 1;
@@ -1,360 +0,0 @@
-import CALENDAR from './calendar.js'
-class Calendar {
- constructor({
- selected,
- startDate,
- endDate,
- range
- } = {}) {
- // 当前日期
- this.date = this.getDate(new Date()) // 当前初入日期
- // 打点信息
- this.selected = selected || [];
- // 范围开始
- this.startDate = startDate
- // 范围结束
- this.endDate = endDate
- this.range = range
- // 多选状态
- this.cleanMultipleStatus()
- // 每周日期
- this.weeks = {}
- // this._getWeek(this.date.fullDate)
- this.selectDate = this.getDate(date)
- this._getWeek(this.selectDate.fullDate)
- * 清理多选状态
- cleanMultipleStatus() {
- this.multipleStatus = {
- before: '',
- after: '',
- data: []
- * 重置开始日期
- resetSatrtDate(startDate) {
- * 重置结束日期
- resetEndDate(endDate) {
- * 获取任意时间
- getDate(date, AddDayCount = 0, str = 'day') {
- if (!date) {
- date = new Date()
- if (typeof date !== 'object') {
- date = date.replace(/-/g, '/')
- const dd = new Date(date)
- switch (str) {
- case 'day':
- dd.setDate(dd.getDate() + AddDayCount) // 获取AddDayCount天后的日期
- case 'month':
- if (dd.getDate() === 31 && AddDayCount>0) {
- dd.setDate(dd.getDate() + AddDayCount)
- const preMonth = dd.getMonth()
- dd.setMonth(preMonth + AddDayCount) // 获取AddDayCount天后的日期
- const nextMonth = dd.getMonth()
- // 处理 pre 切换月份目标月份为2月没有当前日(30 31) 切换错误问题
- if(AddDayCount<0 && preMonth!==0 && nextMonth-preMonth>AddDayCount){
- dd.setMonth(nextMonth+(nextMonth-preMonth+AddDayCount))
- // 处理 next 切换月份目标月份为2月没有当前日(30 31) 切换错误问题
- if(AddDayCount>0 && nextMonth-preMonth>AddDayCount){
- dd.setMonth(nextMonth-(nextMonth-preMonth-AddDayCount))
- case 'year':
- dd.setFullYear(dd.getFullYear() + AddDayCount) // 获取AddDayCount天后的日期
- const y = dd.getFullYear()
- const m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1 // 获取当前月份的日期,不足10补0
- const d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate() // 获取当前几号,不足10补0
- fullDate: y + '-' + m + '-' + d,
- year: y,
- month: m,
- date: d,
- day: dd.getDay()
- * 获取上月剩余天数
- _getLastMonthDays(firstDay, full) {
- let dateArr = []
- for (let i = firstDay; i > 0; i--) {
- const beforeDate = new Date(full.year, full.month - 1, -i + 1).getDate()
- dateArr.push({
- date: beforeDate,
- month: full.month - 1,
- lunar: this.getlunar(full.year, full.month - 1, beforeDate),
- disable: true
- return dateArr
- * 获取本月天数
- _currentMonthDys(dateData, full) {
- let fullDate = this.date.fullDate
- for (let i = 1; i <= dateData; i++) {
- let nowDate = full.year + '-' + (full.month < 10 ?
- full.month : full.month) + '-' + (i < 10 ?
- '0' + i : i)
- let isDay = fullDate === nowDate
- // 获取打点信息
- let info = this.selected && this.selected.find((item) => {
- if (this.dateEqual(nowDate, item.date)) {
- return item
- // 日期禁用
- let disableBefore = true
- let disableAfter = true
- if (this.startDate) {
- // let dateCompBefore = this.dateCompare(this.startDate, fullDate)
- // disableBefore = this.dateCompare(dateCompBefore ? this.startDate : fullDate, nowDate)
- disableBefore = this.dateCompare(this.startDate, nowDate)
- if (this.endDate) {
- // let dateCompAfter = this.dateCompare(fullDate, this.endDate)
- // disableAfter = this.dateCompare(nowDate, dateCompAfter ? this.endDate : fullDate)
- disableAfter = this.dateCompare(nowDate, this.endDate)
- let multiples = this.multipleStatus.data
- let checked = false
- let multiplesStatus = -1
- if (this.range) {
- if (multiples) {
- multiplesStatus = multiples.findIndex((item) => {
- return this.dateEqual(item, nowDate)
- if (multiplesStatus !== -1) {
- checked = true
- let data = {
- fullDate: nowDate,
- year: full.year,
- date: i,
- multiple: this.range ? checked : false,
- beforeMultiple: this.dateEqual(this.multipleStatus.before, nowDate),
- afterMultiple: this.dateEqual(this.multipleStatus.after, nowDate),
- month: full.month,
- lunar: this.getlunar(full.year, full.month, i),
- disable: !(disableBefore && disableAfter),
- isDay
- if (info) {
- data.extraInfo = info
- dateArr.push(data)
- * 获取下月天数
- _getNextMonthDays(surplus, full) {
- for (let i = 1; i < surplus + 1; i++) {
- month: Number(full.month) + 1,
- lunar: this.getlunar(full.year, Number(full.month) + 1, i),
- * 获取当前日期详情
- getInfo(date) {
- const dateInfo = this.canlender.find(item => item.fullDate === this.getDate(date).fullDate)
- return dateInfo
- * 比较时间大小
- dateCompare(startDate, endDate) {
- // 计算截止时间
- startDate = new Date(startDate.replace('-', '/').replace('-', '/'))
- // 计算详细项的截止时间
- endDate = new Date(endDate.replace('-', '/').replace('-', '/'))
- if (startDate <= endDate) {
- return false
- * 比较时间是否相等
- dateEqual(before, after) {
- before = new Date(before.replace('-', '/').replace('-', '/'))
- after = new Date(after.replace('-', '/').replace('-', '/'))
- if (before.getTime() - after.getTime() === 0) {
- * 获取日期范围内所有日期
- * @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.getDate(new Date(parseInt(k))).fullDate)
- return arr
- * 计算阴历日期显示
- getlunar(year, month, date) {
- return CALENDAR.solar2lunar(year, month, date)
- * 设置打点
- setSelectInfo(data, value) {
- this.selected = value
- this._getWeek(data)
- * 获取多选状态
- setMultiple(fullDate) {
- before,
- after
- } = this.multipleStatus
- if (!this.range) return
- if (before && after) {
- this.multipleStatus.before = ''
- this.multipleStatus.after = ''
- this.multipleStatus.data = []
- if (!before) {
- this.multipleStatus.before = fullDate
- this.multipleStatus.after = fullDate
- if (this.dateCompare(this.multipleStatus.before, this.multipleStatus.after)) {
- this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus.after);
- this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus.before);
- this._getWeek(fullDate)
- * 获取每周数据
- * @param {Object} dateData
- _getWeek(dateData) {
- } = this.getDate(dateData)
- let firstDay = new Date(year, month - 1, 1).getDay()
- let currentDay = new Date(year, month, 0).getDate()
- let dates = {
- lastMonthDays: this._getLastMonthDays(firstDay, this.getDate(dateData)), // 上个月末尾几天
- currentMonthDys: this._currentMonthDys(currentDay, this.getDate(dateData)), // 本月天数
- nextMonthDays: [], // 下个月开始几天
- weeks: []
- let canlender = []
- const surplus = 42 - (dates.lastMonthDays.length + dates.currentMonthDys.length)
- dates.nextMonthDays = this._getNextMonthDays(surplus, this.getDate(dateData))
- canlender = canlender.concat(dates.lastMonthDays, dates.currentMonthDys, dates.nextMonthDays)
- let weeks = {}
- // 拼接数组 上个月开始几天 + 本月天数+ 下个月开始几天
- for (let i = 0; i < canlender.length; i++) {
- if (i % 7 === 0) {
- weeks[parseInt(i / 7)] = new Array(7)
- weeks[parseInt(i / 7)][i % 7] = canlender[i]
- this.canlender = canlender
- this.weeks = weeks
- //静态方法
- // static init(date) {
- // if (!this.instance) {
- // this.instance = new Calendar(date);
- // }
- // return this.instance;
-export default Calendar
- "id": "uni-calendar",
- "displayName": "uni-calendar 日历",
- "version": "1.4.10",
- "description": "日历组件",
- "日历",
- "打卡",
- "日历选择"
@@ -1,103 +0,0 @@
-## Calendar 日历
-> **组件名:uni-calendar**
-> 代码块: `uCalendar`
-日历组件
-> **注意事项**
-> 为了避免错误使用,给大家带来不好的开发体验,请在使用组件前仔细阅读下面的注意事项,可以帮你避免一些错误。
-> - 本组件农历转换使用的js是 [@1900-2100区间内的公历、农历互转](https://github.com/jjonline/calendar.js)
-> - 仅支持自定义组件模式
-> - `date`属性传入的应该是一个 String ,如: 2019-06-27 ,而不是 new Date()
-> - 通过 `insert` 属性来确定当前的事件是 @change 还是 @confirm 。理应合并为一个事件,但是为了区分模式,现使用两个事件,这里需要注意
-> - 弹窗模式下无法阻止后面的元素滚动,如有需要阻止,请在弹窗弹出后,手动设置滚动元素为不可滚动
-<view>
- <uni-calendar
- :insert="true"
- :lunar="true"
- :start-date="'2019-3-2'"
- :end-date="'2019-5-20'"
- @change="change"
- />
-</view>
-### 通过方法打开日历
-需要设置 `insert` 为 `false`
- ref="calendar"
- :insert="false"
- @confirm="confirm"
- <button @click="open">打开日历</button>
- open(){
- this.$refs.calendar.open();
- confirm(e) {
- console.log(e);
-};
-### Calendar Props
-| 属性名 | 类型 | 默认值| 说明 |
-| - | - | - | - |
-| date | String |- | 自定义当前时间,默认为今天 |
-| lunar | Boolean | false | 显示农历 |
-| startDate | String |- | 日期选择范围-开始日期 |
-| endDate | String |- | 日期选择范围-结束日期 |
-| range | Boolean | false | 范围选择 |
-| insert | Boolean | false | 插入模式,可选值,ture:插入模式;false:弹窗模式;默认为插入模式 |
-|clearDate |Boolean |true |弹窗模式是否清空上次选择内容 |
-| selected | Array |- | 打点,期待格式[{date: '2019-06-27', info: '签到', data: { custom: '自定义信息', name: '自定义消息头',xxx:xxx... }}] |
-|showMonth | Boolean | true | 是否显示月份为背景 |
-### Calendar Events
-| 事件名 | 说明 |返回值|
-| - | - | - |
-| open | 弹出日历组件,`insert :false` 时生效|- |
-点击查看:[https://hellouniapp.dcloud.net.cn/pages/extUI/calendar/calendar](https://hellouniapp.dcloud.net.cn/pages/extUI/calendar/calendar)
-## 1.3.1(2021-12-20)
-- 修复 在vue页面下略缩图显示不正常的bug
-## 1.3.0(2021-11-19)
-- 重构插槽的用法 ,header 替换为 title
-- 新增 actions 插槽
-- 新增 cover 封面图属性和插槽
-- 新增 padding 内容默认内边距离
-- 新增 margin 卡片默认外边距离
-- 新增 spacing 卡片默认内边距
-- 新增 shadow 卡片阴影属性
-- 取消 mode 属性,可使用组合插槽代替
-- 取消 note 属性 ,使用actions插槽代替
-- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-card](https://uniapp.dcloud.io/component/uniui/uni-card)
-## 1.2.1(2021-07-30)
-- 优化 vue3下事件警告的问题
-## 1.2.0(2021-07-13)
-- 组件兼容 vue3,如何创建vue3项目详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
-## 1.1.8(2021-07-01)
-- 优化 图文卡片无图片加载时,提供占位图标
-- 新增 header 插槽,自定义卡片头部( 图文卡片 mode="style" 时,不支持)
-- 修复 thumbnail 不存在仍然占位的 bug
-## 1.1.7(2021-05-12)
-## 1.1.6(2021-02-04)
@@ -1,272 +0,0 @@
- <view class="uni-card" :class="{ 'uni-card--full': isFull, 'uni-card--shadow': isShadow,'uni-card--border':border}"
- :style="{'margin':isFull?0:margin,'padding':spacing,'box-shadow':isShadow?shadow:''}">
- <!-- 封面 -->
- <slot name="cover">
- <view v-if="cover" class="uni-card__cover">
- <image class="uni-card__cover-image" mode="widthFix" @click="onClick('cover')" :src="cover"></image>
- <slot name="title">
- <view v-if="title || extra" class="uni-card__header">
- <!-- 卡片标题 -->
- <view class="uni-card__header-box" @click="onClick('title')">
- <view v-if="thumbnail" class="uni-card__header-avatar">
- <image class="uni-card__header-avatar-image" :src="thumbnail" mode="aspectFit" />
- <view class="uni-card__header-content">
- <text class="uni-card__header-content-title uni-ellipsis">{{ title }}</text>
- <text v-if="title&&subTitle"
- class="uni-card__header-content-subtitle uni-ellipsis">{{ subTitle }}</text>
- <view class="uni-card__header-extra" @click="onClick('extra')">
- <slot name="extra">
- <text class="uni-card__header-extra-text">{{ extra }}</text>
- <!-- 卡片内容 -->
- <view class="uni-card__content" :style="{padding:padding}" @click="onClick('content')">
- <view class="uni-card__actions" @click="onClick('actions')">
- <slot name="actions"></slot>
- * Card 卡片
- * @description 卡片视图组件
- * @tutorial https://ext.dcloud.net.cn/plugin?id=22
- * @property {String} title 标题文字
- * @property {String} subTitle 副标题
- * @property {Number} padding 内容内边距
- * @property {Number} margin 卡片外边距
- * @property {Number} spacing 卡片内边距
- * @property {String} extra 标题额外信息
- * @property {String} cover 封面图(本地路径需要引入)
- * @property {String} thumbnail 标题左侧缩略图
- * @property {Boolean} is-full = [true | false] 卡片内容是否通栏,为 true 时将去除padding值
- * @property {Boolean} is-shadow = [true | false] 卡片内容是否开启阴影
- * @property {String} shadow 卡片阴影
- * @property {Boolean} border 卡片边框
- * @event {Function} click 点击 Card 触发事件
- name: 'UniCard',
- title: {
- subTitle: {
- padding: {
- default: '10px'
- margin: {
- default: '15px'
- spacing: {
- default: '0 10px'
- extra: {
- cover: {
- thumbnail: {
- isFull: {
- // 内容区域是否通栏
- isShadow: {
- // 是否开启阴影
- shadow: {
- default: '0px 0px 3px 1px rgba(0, 0, 0, 0.08)'
- border: {
- onClick(type) {
- this.$emit('click', type)
- $uni-border-3: #EBEEF5 !default;
- $uni-shadow-base:0 0px 6px 1px rgba($color: #a5a5a5, $alpha: 0.2) !default;
- $uni-secondary-color: #909399 !default;
- $uni-spacing-sm: 8px !default;
- $uni-border-color:$uni-border-3;
- $uni-shadow: $uni-shadow-base;
- $uni-card-title: 15px;
- $uni-cart-title-color:$uni-main-color;
- $uni-card-subtitle: 12px;
- $uni-cart-subtitle-color:$uni-secondary-color;
- $uni-card-spacing: 10px;
- $uni-card-content-color: $uni-base-color;
- .uni-card {
- margin: $uni-card-spacing;
- padding: 0 $uni-spacing-sm;
- border-radius: 4px;
- font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, SimSun, sans-serif;
- .uni-card__cover {
- margin-top: $uni-card-spacing;
- .uni-card__cover-image {
- // width: 100%;
- /* #ifndef APP-PLUS */
- .uni-card__header {
- border-bottom: 1px $uni-border-color solid;
- padding: $uni-card-spacing;
- .uni-card__header-box {
- .uni-card__header-avatar {
- width: 40px;
- height: 40px;
- border-radius: 5px;
- margin-right: $uni-card-spacing;
- .uni-card__header-avatar-image {
- .uni-card__header-content {
- // height: 40px;
- .uni-card__header-content-title {
- font-size: $uni-card-title;
- color: $uni-cart-title-color;
- // line-height: 22px;
- .uni-card__header-content-subtitle {
- font-size: $uni-card-subtitle;
- margin-top: 5px;
- color: $uni-cart-subtitle-color;
- .uni-card__header-extra {
- line-height: 12px;
- .uni-card__header-extra-text {
- .uni-card__content {
- color: $uni-card-content-color;
- line-height: 22px;
- .uni-card__actions {
- .uni-card--border {
- border: 1px solid $uni-border-color;
- .uni-card--shadow {
- box-shadow: $uni-shadow;
- .uni-card--full {
- border-left-width: 0;
- border-radius: 0;
- .uni-card--full:after {
- .uni-ellipsis {
- text-overflow: ellipsis;
- lines: 1;
@@ -1,90 +0,0 @@
- "id": "uni-card",
- "displayName": "uni-card 卡片",
- "version": "1.3.1",
- "description": "Card 组件,提供常见的卡片样式。",
- "card",
- "卡片"
- "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui"
- "dependencies": [
- "uni-icons",
- "uni-scss"
-## Card 卡片
-> **组件名:uni-card**
-> 代码块: `uCard`
-卡片视图组件。
-### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-card)
@@ -1,36 +0,0 @@
-## 1.4.3(2022-01-25)
-- 修复 初始化的时候 ,open 属性失效的bug
-## 1.4.2(2022-01-21)
-- 修复 微信小程序resize后组件收起的bug
-## 1.4.1(2021-11-22)
-- 修复 vue3中个别scss变量无法找到的问题
-## 1.4.0(2021-11-19)
-- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-collapse](https://uniapp.dcloud.io/component/uniui/uni-collapse)
-## 1.3.3(2021-08-17)
-- 优化 show-arrow 属性默认为true
-## 1.3.2(2021-08-17)
-- 新增 show-arrow 属性,控制是否显示右侧箭头
-## 1.3.1(2021-07-30)
-- 优化 vue3下小程序事件警告的问题
-## 1.3.0(2021-07-30)
-## 1.2.2(2021-07-21)
-- 修复 由1.2.0版本引起的 change 事件返回 undefined 的Bug
-## 1.2.1(2021-07-21)
-- 优化 组件示例
-## 1.2.0(2021-07-21)
-- 新增 组件折叠动画
-- 新增 value\v-model 属性 ,动态修改面板折叠状态
-- 新增 title 插槽 ,可定义面板标题
-- 新增 border 属性 ,显示隐藏面板内容分隔线
-- 新增 title-border 属性 ,显示隐藏面板标题分隔线
-- 修复 resize 方法失效的Bug
-- 修复 change 事件返回参数不正确的Bug
-- 优化 H5、App 平台自动更具内容更新高度,无需调用 reszie() 方法
-## 1.1.6(2021-02-05)
-- 优化 组件引用关系,通过uni_modules引用组件
-## 1.1.5(2021-02-05)
@@ -1,402 +0,0 @@
- <view class="uni-collapse-item">
- <!-- onClick(!isOpen) -->
- <view @click="onClick(!isOpen)" class="uni-collapse-item__title"
- :class="{'is-open':isOpen &&titleBorder === 'auto' ,'uni-collapse-item-border':titleBorder !== 'none'}">
- <view class="uni-collapse-item__title-wrap">
- <view class="uni-collapse-item__title-box" :class="{'is-disabled':disabled}">
- <image v-if="thumb" :src="thumb" class="uni-collapse-item__title-img" />
- <text class="uni-collapse-item__title-text">{{ title }}</text>
- <view v-if="showArrow"
- :class="{ 'uni-collapse-item__title-arrow-active': isOpen, 'uni-collapse-item--animation': showAnimation === true }"
- class="uni-collapse-item__title-arrow">
- <uni-icons :color="disabled?'#ddd':'#bbb'" size="14" type="bottom" />
- <view class="uni-collapse-item__wrap" :class="{'is--transition':showAnimation}"
- :style="{height: (isOpen?height:0) +'px'}">
- <view :id="elId" ref="collapse--hook" class="uni-collapse-item__wrap-content"
- :class="{open:isheight,'uni-collapse-item--border':border&&isOpen}">
- // #ifdef APP-NVUE
- const dom = weex.requireModule('dom')
- * CollapseItem 折叠面板子组件
- * @description 折叠面板子组件
- * @property {String} thumb 标题左侧缩略图
- * @property {String} name 唯一标志符
- * @property {Boolean} open = [true|false] 是否展开组件
- * @property {Boolean} titleBorder = [true|false] 是否显示标题分隔线
- * @property {Boolean} border = [true|false] 是否显示分隔线
- * @property {Boolean} disabled = [true|false] 是否展开面板
- * @property {Boolean} showAnimation = [true|false] 开启动画
- * @property {Boolean} showArrow = [true|false] 是否显示右侧箭头
- name: 'uniCollapseItem',
- // 列表标题
- name: {
- type: [Number, String],
- // 是否禁用
- disabled: {
- // 是否显示动画,app 端默认不开启动画,卡顿严重
- showAnimation: {
- // 是否显示动画
- // 是否展开
- open: {
- // 缩略图
- thumb: {
- // 标题分隔线显示类型
- titleBorder: {
- default: 'auto'
- showArrow: {
- // TODO 随机生生元素ID,解决百度小程序获取同一个元素位置信息的bug
- const elId = `Uni_${Math.ceil(Math.random() * 10e5).toString(36)}`
- isOpen: false,
- isheight: null,
- height: 0,
- elId,
- nameSync: 0
- open(val) {
- this.isOpen = val
- this.onClick(val, 'init')
- updated(e) {
- this.init(true)
- this.collapse = this.getCollapse()
- this.oldHeight = 0
- this.onClick(this.open, 'init')
- // TODO vue2
- destroyed() {
- if (this.__isUnmounted) return
- this.uninstall()
- // TODO vue3
- unmounted() {
- this.__isUnmounted = true
- mounted() {
- if (!this.collapse) return
- if (this.name !== '') {
- this.nameSync = this.name
- this.nameSync = this.collapse.childrens.length + ''
- if (this.collapse.names.indexOf(this.nameSync) === -1) {
- this.collapse.names.push(this.nameSync)
- console.warn(`name 值 ${this.nameSync} 重复`);
- if (this.collapse.childrens.indexOf(this) === -1) {
- this.collapse.childrens.push(this)
- this.init()
- init(type) {
- // #ifndef APP-NVUE
- this.getCollapseHeight(type)
- this.getNvueHwight(type)
- uninstall() {
- if (this.collapse) {
- this.collapse.childrens.forEach((item, index) => {
- if (item === this) {
- this.collapse.childrens.splice(index, 1)
- this.collapse.names.forEach((item, index) => {
- if (item === this.nameSync) {
- this.collapse.names.splice(index, 1)
- onClick(isOpen, type) {
- if (this.disabled) return
- this.isOpen = isOpen
- if (this.isOpen && this.collapse) {
- this.collapse.setAccordion(this)
- if (type !== 'init') {
- this.collapse.onChange(isOpen, this)
- getCollapseHeight(type, index = 0) {
- const views = uni.createSelectorQuery().in(this)
- views
- .select(`#${this.elId}`)
- .fields({
- size: true
- }, data => {
- // TODO 百度中可能获取不到节点信息 ,需要循环获取
- if (index >= 10) return
- if (!data) {
- index++
- this.getCollapseHeight(false, index)
- this.height = data.height + 1
- this.height = data.height
- this.isheight = true
- if (type) return
- this.onClick(this.isOpen, 'init')
- .exec()
- getNvueHwight(type) {
- const result = dom.getComponentRect(this.$refs['collapse--hook'], option => {
- if (option && option.result && option.size) {
- this.height = option.size.height + 1
- this.height = option.size.height
- * 获取父元素实例
- getCollapse(name = 'uniCollapse') {
- let parent = this.$parent;
- let parentName = parent.$options.name;
- while (parentName !== name) {
- parent = parent.$parent;
- if (!parent) return false;
- parentName = parent.$options.name;
- return parent;
- .uni-collapse-item {
- &__title {
- transition: border-bottom-color .3s;
- // transition-property: border-bottom-color;
- // transition-duration: 5s;
- &-wrap {
- &-box {
- padding: 0 15px;
- height: 48px;
- line-height: 48px;
- color: #303133;
- font-size: 13px;
- font-weight: 500;
- outline: none;
- &.is-disabled {
- .uni-collapse-item__title-text {
- color: #999;
- &.uni-collapse-item-border {
- border-bottom: 1px solid #ebeef5;
- &.is-open {
- border-bottom-color: transparent;
- &-img {
- height: 22px;
- width: 22px;
- margin-right: 10px;
- &-text {
- color: inherit;
- &-arrow {
- width: 20px;
- &-active {
- transform: rotate(-180deg);
- &__wrap {
- will-change: height;
- height: 0;
- &.is--transition {
- // transition: all 0.3s;
- transition-property: height, border-bottom-width;
- &-content {
- // transition: height 0.3s;
- border-bottom-width: 0;
- &.uni-collapse-item--border {
- border-bottom-color: red;
- border-bottom-color: #ebeef5;
- &.open {
- &--animation {
- transition-timing-function: ease;
@@ -1,147 +0,0 @@
- <view class="uni-collapse">
- * Collapse 折叠面板
- * @description 展示可以折叠 / 展开的内容区域
- * @tutorial https://ext.dcloud.net.cn/plugin?id=23
- * @property {String|Array} value 当前激活面板改变时触发(如果是手风琴模式,参数类型为string,否则为array)
- * @property {Boolean} accordion = [true|false] 是否开启手风琴效果是否开启手风琴效果
- * @event {Function} change 切换面板时触发,如果是手风琴模式,返回类型为string,否则为array
- name: 'uniCollapse',
- emits:['change','activeItem','input','update:modelValue'],
- value: {
- type: [String, Array],
- modelValue: {
- accordion: {
- // 是否开启手风琴效果
- // TODO 兼容 vue2 和 vue3
- dataValue() {
- let value = (typeof this.value === 'string' && this.value === '') ||
- (Array.isArray(this.value) && this.value.length === 0)
- let modelValue = (typeof this.modelValue === 'string' && this.modelValue === '') ||
- (Array.isArray(this.modelValue) && this.modelValue.length === 0)
- if (value) {
- return this.modelValue
- if (modelValue) {
- return this.value
- dataValue(val) {
- this.setOpen(val)
- this.childrens = []
- this.names = []
- this.$nextTick(()=>{
- this.setOpen(this.dataValue)
- setOpen(val) {
- let str = typeof val === 'string'
- let arr = Array.isArray(val)
- this.childrens.forEach((vm, index) => {
- if (str) {
- if (val === vm.nameSync) {
- if (!this.accordion) {
- console.warn('accordion 属性为 false ,v-model 类型应该为 array')
- vm.isOpen = true
- if (arr) {
- val.forEach(v => {
- if (v === vm.nameSync) {
- if (this.accordion) {
- console.warn('accordion 属性为 true ,v-model 类型应该为 string')
- this.emit(val)
- setAccordion(self) {
- if (!this.accordion) return
- if (self !== vm) {
- vm.isOpen = false
- resize() {
- vm.getCollapseHeight()
- vm.getNvueHwight()
- onChange(isOpen, self) {
- let activeItem = []
- activeItem = isOpen ? self.nameSync : ''
- if (vm.isOpen) {
- activeItem.push(vm.nameSync)
- this.$emit('change', activeItem)
- this.emit(activeItem)
- emit(val){
- this.$emit('input', val)
- this.$emit('update:modelValue', val)
- .uni-collapse {
@@ -1,89 +0,0 @@
- "id": "uni-collapse",
- "displayName": "uni-collapse 折叠面板",
- "version": "1.4.3",
- "description": "Collapse 组件,可以折叠 / 展开的内容区域。",
- "折叠",
- "折叠面板",
- "手风琴"
- "uni-scss",
- "uni-icons"
-## Collapse 折叠面板
-> **组件名:uni-collapse**
-> 代码块: `uCollapse`
-> 关联组件:`uni-collapse-item`、`uni-icons`。
-折叠面板用来折叠/显示过长的内容或者是列表。通常是在多内容分类项使用,折叠不重要的内容,显示重要内容。点击可以展开折叠部分。
-### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-collapse)
@@ -1,15 +0,0 @@
-## 1.0.1(2021-11-23)
-- 优化 label、label-width 属性
-## 1.0.0(2021-11-19)
-- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-combox](https://uniapp.dcloud.io/component/uniui/uni-combox)
-## 0.1.0(2021-07-30)
-## 0.0.6(2021-05-12)
-## 0.0.5(2021-04-21)
-- 优化 添加依赖 uni-icons, 导入后自动下载依赖
-## 0.0.4(2021-02-05)
-## 0.0.3(2021-02-04)
@@ -1,294 +0,0 @@
- <view class="uni-combox" :class="border ? '' : 'uni-combox__no-border'">
- <view v-if="label" class="uni-combox__label" :style="labelStyle">
- <text>{{label}}</text>
- <view class="uni-combox__input-box">
- <input class="uni-combox__input" type="text" :placeholder="placeholder"
- placeholder-class="uni-combox__input-plac" v-model="inputVal" @input="onInput" @focus="onFocus" @blur="onBlur" />
- <uni-icons :type="showSelector? 'top' : 'bottom'" size="14" color="#999" @click="toggleSelector">
- </uni-icons>
- <view class="uni-combox__selector" v-if="showSelector">
- <view class="uni-popper__arrow"></view>
- <scroll-view scroll-y="true" class="uni-combox__selector-scroll" @scroll="onScroll">
- <view class="uni-combox__selector-empty" v-if="filterCandidatesLength === 0">
- <text>{{emptyTips}}</text>
- <view class="uni-combox__selector-item" v-for="(item,index) in filterCandidates" :key="index" @click="onSelectorClick(index)">
- <text>{{item}}</text>
- <!-- 新增蒙层,点击蒙层时关闭选项显示 -->
- <view class="uni-combox__mask" v-show="showSelector" @click="showSelector = false"></view>
- * Combox 组合输入框
- * @description 组合输入框一般用于既可以输入也可以选择的场景
- * @tutorial https://ext.dcloud.net.cn/plugin?id=1261
- * @property {String} label 左侧文字
- * @property {String} labelWidth 左侧内容宽度
- * @property {String} placeholder 输入框占位符
- * @property {Array} candidates 候选项列表
- * @property {String} emptyTips 筛选结果为空时显示的文字
- * @property {String} value 组合框的值
- name: 'uniCombox',
- emits: ['input', 'update:modelValue'],
- label: {
- labelWidth: {
- placeholder: {
- candidates: {
- emptyTips: {
- default: '无匹配项'
- showSelector: false,
- inputVal: '',
- blurTimer:null,
- labelStyle() {
- if (this.labelWidth === 'auto') {
- return ""
- return `width: ${this.labelWidth}`
- filterCandidates() {
- if (this.inputVal !== 0 && !this.inputVal) {
- return this.candidates
- return this.candidates.filter((item) => {
- return item.toString().indexOf(this.inputVal) > -1
- filterCandidatesLength() {
- return this.filterCandidates.length
- handler(newVal) {
- this.inputVal = newVal
- immediate: true
- toggleSelector() {
- this.showSelector = !this.showSelector
- onFocus() {
- this.showSelector = true
- onBlur() {
- this.blurTimer = setTimeout(() => {
- this.showSelector = false
- }, 153)
- onScroll(){ // 滚动时将blur的定时器关掉
- if(this.blurTimer) {
- clearTimeout(this.blurTimer)
- this.blurTimer = null
- onSelectorClick(index) {
- this.inputVal = this.filterCandidates[index]
- this.$emit('input', this.inputVal)
- this.$emit('update:modelValue', this.inputVal)
- onInput() {
- .uni-combox {
- border: 1px solid #DCDFE6;
- padding: 6px 10px;
- // border-bottom: solid 1px #DDDDDD;
- .uni-combox__label {
- font-size: 16px;
- padding-right: 10px;
- color: #999999;
- .uni-combox__input-box {
- .uni-combox__input {
- .uni-combox__input-plac {
- .uni-combox__selector {
- top: calc(100% + 12px);
- background-color: #FFFFFF;
- border: 1px solid #EBEEF5;
- border-radius: 6px;
- box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
- z-index: 3;
- padding: 4px 0;
- .uni-combox__selector-scroll {
- max-height: 200px;
- .uni-combox__selector-empty,
- .uni-combox__selector-item {
- line-height: 36px;
- padding: 0px 10px;
- .uni-combox__selector-item:hover {
- background-color: #f9f9f9;
- .uni-combox__selector-empty:last-child,
- .uni-combox__selector-item:last-child {
- border-bottom: none;
- // picker 弹出层通用的指示小三角
- .uni-popper__arrow,
- .uni-popper__arrow::after {
- width: 0;
- border-color: transparent;
- border-style: solid;
- border-width: 6px;
- .uni-popper__arrow {
- 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;
- content: " ";
- top: 1px;
- margin-left: -6px;
- border-bottom-color: #fff;
- .uni-combox__no-border {
- border: none;
- .uni-combox__mask {
- width:100%;
- height:100%;
- "id": "uni-combox",
- "displayName": "uni-combox 组合框",
- "version": "1.0.1",
- "description": "可以选择也可以输入的表单项 ",
- "combox",
- "组合框",
- "select"
@@ -1,11 +0,0 @@
-## Combox 组合框
-> **组件名:uni-combox**
-> 代码块: `uCombox`
-组合框组件。
-### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-combox)
@@ -1,24 +0,0 @@
-## 1.2.2(2022-01-19)
-- 修复 在微信小程序中样式不生效的bug
-## 1.2.1(2022-01-18)
-- 新增 update 方法 ,在动态更新时间后,刷新组件
-- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-countdown](https://uniapp.dcloud.io/component/uniui/uni-countdown)
-## 1.1.3(2021-10-18)
-- 重构
-- 新增 font-size 支持自定义字体大小
-## 1.1.2(2021-08-24)
-## 1.1.1(2021-07-30)
-## 1.1.0(2021-07-30)
-## 1.0.5(2021-06-18)
-- 修复 uni-countdown 重复赋值跳两秒的 bug
-## 1.0.4(2021-05-12)
-## 1.0.3(2021-05-08)
-- 修复 uni-countdown 不能控制倒计时的 bug
-## 1.0.2(2021-02-04)
- "uni-countdown.day": "day",
- "uni-countdown.h": "h",
- "uni-countdown.m": "m",
- "uni-countdown.s": "s"
- "uni-countdown.day": "天",
- "uni-countdown.h": "时",
- "uni-countdown.m": "分",
- "uni-countdown.s": "秒"
- "uni-countdown.h": "時",
@@ -1,267 +0,0 @@
- <view class="uni-countdown">
- <text v-if="showDay" :style="[timeStyle]" class="uni-countdown__number">{{ d }}</text>
- <text v-if="showDay" :style="[splitorStyle]" class="uni-countdown__splitor">{{dayText}}</text>
- <text :style="[timeStyle]" class="uni-countdown__number">{{ h }}</text>
- <text :style="[splitorStyle]" class="uni-countdown__splitor">{{ showColon ? ':' : hourText }}</text>
- <text :style="[timeStyle]" class="uni-countdown__number">{{ i }}</text>
- <text :style="[splitorStyle]" class="uni-countdown__splitor">{{ showColon ? ':' : minuteText }}</text>
- <text :style="[timeStyle]" class="uni-countdown__number">{{ s }}</text>
- <text v-if="!showColon" :style="[splitorStyle]" class="uni-countdown__splitor">{{secondText}}</text>
- import {
- initVueI18n
- } from '@dcloudio/uni-i18n'
- import messages from './i18n/index.js'
- t
- } = initVueI18n(messages)
- * Countdown 倒计时
- * @description 倒计时组件
- * @tutorial https://ext.dcloud.net.cn/plugin?id=25
- * @property {String} backgroundColor 背景色
- * @property {String} color 文字颜色
- * @property {Number} day 天数
- * @property {Number} hour 小时
- * @property {Number} minute 分钟
- * @property {Number} second 秒
- * @property {Number} timestamp 时间戳
- * @property {Boolean} showDay = [true|false] 是否显示天数
- * @property {Boolean} show-colon = [true|false] 是否以冒号为分隔符
- * @property {String} splitorColor 分割符号颜色
- * @event {Function} timeup 倒计时时间到触发事件
- * @example <uni-countdown :day="1" :hour="1" :minute="12" :second="40"></uni-countdown>
- name: 'UniCountdown',
- emits: ['timeup'],
- showDay: {
- showColon: {
- start: {
- backgroundColor: {
- color: {
- default: '#333'
- fontSize: {
- default: 14
- splitorColor: {
- day: {
- default: 0
- hour: {
- minute: {
- second: {
- timestamp: {
- zeroPad: {
- timer: null,
- syncFlag: false,
- d: '00',
- h: '00',
- i: '00',
- s: '00',
- leftTime: 0,
- seconds: 0
- dayText() {
- return t("uni-countdown.day")
- hourText(val) {
- return t("uni-countdown.h")
- minuteText(val) {
- return t("uni-countdown.m")
- secondText(val) {
- return t("uni-countdown.s")
- timeStyle() {
- color,
- backgroundColor,
- fontSize
- fontSize: `${fontSize}px`,
- width: `${fontSize * 22 / 14}px`, // 按字体大小为 14px 时的比例缩放
- lineHeight: `${fontSize * 20 / 14}px`,
- borderRadius: `${fontSize * 3 / 14}px`,
- splitorStyle() {
- const { splitorColor, fontSize, backgroundColor } = this
- color: splitorColor,
- fontSize: `${fontSize * 12 / 14}px`,
- margin: backgroundColor ? `${fontSize * 4 / 14}px` : ''
- day(val) {
- this.changeFlag()
- hour(val) {
- minute(val) {
- second(val) {
- immediate: true,
- handler(newVal, oldVal) {
- if (newVal) {
- this.startData();
- if (!oldVal) return
- clearInterval(this.timer)
- created: function(e) {
- this.seconds = this.toSeconds(this.timestamp, this.day, this.hour, this.minute, this.second)
- this.countDown()
- toSeconds(timestamp, day, hours, minutes, seconds) {
- if (timestamp) {
- return timestamp - parseInt(new Date().getTime() / 1000, 10)
- return day * 60 * 60 * 24 + hours * 60 * 60 + minutes * 60 + seconds
- timeUp() {
- this.$emit('timeup')
- countDown() {
- let seconds = this.seconds
- let [day, hour, minute, second] = [0, 0, 0, 0]
- if (seconds > 0) {
- day = Math.floor(seconds / (60 * 60 * 24))
- hour = Math.floor(seconds / (60 * 60)) - (day * 24)
- minute = Math.floor(seconds / 60) - (day * 24 * 60) - (hour * 60)
- second = Math.floor(seconds) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60)
- this.timeUp()
- day = (day < 10 && this.zeroPad) ? `0${day}` : day
- hour = (hour < 10 && this.zeroPad) ? `0${hour}` : hour
- minute = (minute < 10 && this.zeroPad) ? `0${minute}` : minute
- second = (second < 10 && this.zeroPad) ? `0${second}` : second
- this.d = day
- this.h = hour
- this.i = minute
- this.s = second
- startData() {
- if (this.seconds <= 0) {
- this.seconds = this.toSeconds(0, 0, 0, 0, 0)
- this.timer = setInterval(() => {
- this.seconds--
- if (this.seconds < 0) {
- }, 1000)
- update(){
- changeFlag() {
- if (!this.syncFlag) {
- this.syncFlag = true;
- $font-size: 14px;
- .uni-countdown {
- justify-content: flex-start;
- &__splitor {
- margin: 0 2px;
- font-size: $font-size;
- color: #333;
- &__number {
- border-radius: 3px;
@@ -1,86 +0,0 @@
- "id": "uni-countdown",
- "displayName": "uni-countdown 倒计时",
- "description": "CountDown 倒计时组件",
- "countdown",
- "倒计时"
-## CountDown 倒计时
-> **组件名:uni-countdown**
-> 代码块: `uCountDown`
-倒计时组件。
-### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-countdown)
@@ -1,45 +0,0 @@
-## 1.0.3(2022-09-16)
-- 可以使用 uni-scss 控制主题色
-## 1.0.2(2022-06-30)
-- 优化 在 uni-forms 中的依赖注入方式
-## 1.0.1(2022-02-07)
-- 修复 multiple 为 true 时,v-model 的值为 null 报错的 bug
-- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-data-checkbox](https://uniapp.dcloud.io/component/uniui/uni-data-checkbox)
-## 0.2.5(2021-08-23)
-- 修复 在uni-forms中 modelValue 中不存在当前字段,当前字段必填写也不参与校验的问题
-## 0.2.4(2021-08-17)
-- 修复 单选 list 模式下 ,icon 为 left 时,选中图标不显示的问题
-## 0.2.3(2021-08-11)
-- 修复 在 uni-forms 中重置表单,错误信息无法清除的问题
-## 0.2.2(2021-07-30)
-- 优化 在uni-forms组件,与label不对齐的问题
-## 0.2.1(2021-07-27)
-- 修复 单选默认值为0不能选中的Bug
-## 0.2.0(2021-07-13)
-## 0.1.11(2021-07-06)
-- 优化 删除无用日志
-## 0.1.10(2021-07-05)
-- 修复 由 0.1.9 引起的非 nvue 端图标不显示的问题
-## 0.1.9(2021-07-05)
-- 修复 nvue 黑框样式问题
-## 0.1.8(2021-06-28)
-- 修复 selectedTextColor 属性不生效的Bug
-## 0.1.7(2021-06-02)
-- 新增 map 属性,可以方便映射text/value属性
-## 0.1.6(2021-05-26)
-- 修复 不关联服务空间的情况下组件报错的Bug
-## 0.1.5(2021-05-12)
-## 0.1.4(2021-04-09)
-- 修复 nvue 下无法选中的问题
-## 0.1.3(2021-03-22)
-- 新增 disabled属性
-## 0.1.2(2021-02-24)
-- 优化 默认颜色显示
-## 0.1.1(2021-02-24)
-- 新增 支持nvue
-## 0.1.0(2021-02-18)
-- “暂无数据”显示居中
@@ -1,821 +0,0 @@
- <view class="uni-data-checklist" :style="{'margin-top':isTop+'px'}">
- <template v-if="!isLocal">
- <view class="uni-data-loading">
- <uni-load-more v-if="!mixinDatacomErrorMessage" status="loading" iconType="snow" :iconSize="18" :content-text="contentText"></uni-load-more>
- <text v-else>{{mixinDatacomErrorMessage}}</text>
- </template>
- <template v-else>
- <checkbox-group v-if="multiple" class="checklist-group" :class="{'is-list':mode==='list' || wrap}" @change="chagne">
- <label class="checklist-box" :class="['is--'+mode,item.selected?'is-checked':'',(disabled || !!item.disabled)?'is-disable':'',index!==0&&mode==='list'?'is-list-border':'']"
- :style="item.styleBackgroud" v-for="(item,index) in dataList" :key="index">
- <checkbox class="hidden" hidden :disabled="disabled || !!item.disabled" :value="item[map.value]+''" :checked="item.selected" />
- <view v-if="(mode !=='tag' && mode !== 'list') || ( mode === 'list' && icon === 'left')" class="checkbox__inner" :style="item.styleIcon">
- <view class="checkbox__inner-icon"></view>
- <view class="checklist-content" :class="{'list-content':mode === 'list' && icon ==='left'}">
- <text class="checklist-text" :style="item.styleIconText">{{item[map.text]}}</text>
- <view v-if="mode === 'list' && icon === 'right'" class="checkobx__list" :style="item.styleBackgroud"></view>
- </label>
- </checkbox-group>
- <radio-group v-else class="checklist-group" :class="{'is-list':mode==='list','is-wrap':wrap}" @change="chagne">
- <!-- -->
- <radio class="hidden" hidden :disabled="disabled || item.disabled" :value="item[map.value]+''" :checked="item.selected" />
- <view v-if="(mode !=='tag' && mode !== 'list') || ( mode === 'list' && icon === 'left')" class="radio__inner"
- :style="item.styleBackgroud">
- <view class="radio__inner-icon" :style="item.styleIcon"></view>
- <view v-if="mode === 'list' && icon === 'right'" :style="item.styleRightIcon" class="checkobx__list"></view>
- </radio-group>
- * DataChecklist 数据选择器
- * @description 通过数据渲染 checkbox 和 radio
- * @property {String} mode = [default| list | button | tag] 显示模式
- * @value default 默认横排模式
- * @value list 列表模式
- * @value button 按钮模式
- * @value tag 标签模式
- * @property {Boolean} multiple = [true|false] 是否多选
- * @property {Array|String|Number} value 默认值
- * @property {Array} localdata 本地数据 ,格式 [{text:'',value:''}]
- * @property {Number|String} min 最小选择个数 ,multiple为true时生效
- * @property {Number|String} max 最大选择个数 ,multiple为true时生效
- * @property {Boolean} wrap 是否换行显示
- * @property {String} icon = [left|right] list 列表模式下icon显示位置
- * @property {Boolean} selectedColor 选中颜色
- * @property {Boolean} emptyText 没有数据时显示的文字 ,本地数据无效
- * @property {Boolean} selectedTextColor 选中文本颜色,如不填写则自动显示
- * @property {Object} map 字段映射, 默认 map={text:'text',value:'value'}
- * @value left 左侧显示
- * @value right 右侧显示
- * @event {Function} change 选中发生变化触发
- name: 'uniDataChecklist',
- mixins: [uniCloud.mixinDatacom || {}],
- emits:['input','update:modelValue','change'],
- mode: {
- default: 'default'
- multiple: {
- type: [Array, String, Number],
- default() {
- return '';
- localdata: {
- min: {
- max: {
- wrap: {
- icon: {
- default: 'left'
- selectedColor: {
- selectedTextColor: {
- emptyText:{
- default: '暂无数据'
- disabled:{
- map:{
- default(){
- text:'text',
- value:'value'
- this.range = newVal
- this.dataList = this.getDataList(this.getSelectedValue(newVal))
- deep: true
- mixinDatacomResData(newVal) {
- value(newVal) {
- this.dataList = this.getDataList(newVal)
- // fix by mehaotian is_reset 在 uni-forms 中定义
- // if(!this.is_reset){
- // this.is_reset = false
- // this.formItem && this.formItem.setValue(newVal)
- modelValue(newVal) {
- this.dataList = this.getDataList(newVal);
- dataList: [],
- range: [],
- contentText: {
- contentdown: '查看更多',
- contentrefresh: '加载中',
- contentnomore: '没有更多'
- isLocal:true,
- styles: {
- selectedColor: '#2979ff',
- selectedTextColor: '#666',
- isTop:0
- dataValue(){
- if(this.value === '')return this.modelValue
- if(this.modelValue === '') return this.value
- // this.form = this.getForm('uniForms')
- // this.formItem = this.getForm('uniFormsItem')
- // this.formItem && this.formItem.setValue(this.value)
- // if (this.formItem) {
- // this.isTop = 6
- // if (this.formItem.name) {
- // // 如果存在name添加默认值,否则formData 中不存在这个字段不校验
- // this.formItem.setValue(this.dataValue)
- // this.rename = this.formItem.name
- // this.form.inputChildrens.push(this)
- if (this.localdata && this.localdata.length !== 0) {
- this.isLocal = true
- this.range = this.localdata
- this.dataList = this.getDataList(this.getSelectedValue(this.range))
- if (this.collection) {
- this.isLocal = false
- this.loadData()
- loadData() {
- this.mixinDatacomGet().then(res=>{
- this.mixinDatacomResData = res.result.data
- if(this.mixinDatacomResData.length === 0){
- this.mixinDatacomErrorMessage = this.emptyText
- }).catch(err=>{
- this.mixinDatacomErrorMessage = err.message
- getForm(name = 'uniForms') {
- if (!parent) return false
- chagne(e) {
- const values = e.detail.value
- let detail = {
- value: [],
- if (this.multiple) {
- this.range.forEach(item => {
- if (values.includes(item[this.map.value] + '')) {
- detail.value.push(item[this.map.value])
- detail.data.push(item)
- const range = this.range.find(item => (item[this.map.value] + '') === values)
- if (range) {
- detail = {
- value: range[this.map.value],
- data: range
- // this.formItem && this.formItem.setValue(detail.value)
- // TODO 兼容 vue2
- this.$emit('input', detail.value);
- // // TOTO 兼容 vue3
- this.$emit('update:modelValue', detail.value);
- this.$emit('change', {
- detail
- // 如果 v-model 没有绑定 ,则走内部逻辑
- // if (this.value.length === 0) {
- this.dataList = this.getDataList(detail.value, true)
- this.dataList = this.getDataList(detail.value)
- * 获取渲染的新数组
- * @param {Object} value 选中内容
- getDataList(value) {
- // 解除引用关系,破坏原引用关系,避免污染源数据
- let dataList = JSON.parse(JSON.stringify(this.range))
- let list = []
- if (!Array.isArray(value)) {
- value = []
- dataList.forEach((item, index) => {
- item.disabled = item.disable || item.disabled || false
- if (value.length > 0) {
- let have = value.find(val => val === item[this.map.value])
- item.selected = have !== undefined
- item.selected = false
- item.selected = value === item[this.map.value]
- list.push(item)
- return this.setRange(list)
- * 处理最大最小值
- * @param {Object} list
- setRange(list) {
- let selectList = list.filter(item => item.selected)
- let min = Number(this.min) || 0
- let max = Number(this.max) || ''
- list.forEach((item, index) => {
- if (selectList.length <= min) {
- let have = selectList.find(val => val[this.map.value] === item[this.map.value])
- if (have !== undefined) {
- item.disabled = true
- if (selectList.length >= max && max !== '') {
- if (have === undefined) {
- this.setStyles(item, index)
- list[index] = item
- return list
- * 设置 class
- * @param {Object} item
- * @param {Object} index
- setStyles(item, index) {
- // 设置自定义样式
- item.styleBackgroud = this.setStyleBackgroud(item)
- item.styleIcon = this.setStyleIcon(item)
- item.styleIconText = this.setStyleIconText(item)
- item.styleRightIcon = this.setStyleRightIcon(item)
- * 获取选中值
- * @param {Object} range
- getSelectedValue(range) {
- if (!this.multiple) return this.dataValue
- let selectedArr = []
- range.forEach((item) => {
- if (item.selected) {
- selectedArr.push(item[this.map.value])
- return this.dataValue.length > 0 ? this.dataValue : selectedArr
- * 设置背景样式
- setStyleBackgroud(item) {
- let styles = {}
- let selectedColor = this.selectedColor?this.selectedColor:'#2979ff'
- if (this.selectedColor) {
- if (this.mode !== 'list') {
- styles['border-color'] = item.selected?selectedColor:'#DCDFE6'
- if (this.mode === 'tag') {
- styles['background-color'] = item.selected? selectedColor:'#f5f5f5'
- let classles = ''
- for (let i in styles) {
- classles += `${i}:${styles[i]};`
- return classles
- setStyleIcon(item) {
- styles['background-color'] = item.selected?selectedColor:'#fff'
- if(!item.selected && item.disabled){
- styles['background-color'] = '#F2F6FC'
- setStyleIconText(item) {
- styles.color = item.selected?(this.selectedTextColor?this.selectedTextColor:'#fff'):'#666'
- styles.color = item.selected?(this.selectedTextColor?this.selectedTextColor:selectedColor):'#666'
- styles.color = '#999'
- setStyleRightIcon(item) {
- if (this.mode === 'list') {
- styles['border-color'] = item.selected?this.styles.selectedColor:'#DCDFE6'
- $border-color: #DCDFE6;
- $disable:0.4;
- @mixin flex {
- .uni-data-loading {
- @include flex;
- height: 36px;
- .uni-data-checklist {
- z-index: 0;
- // 多选样式
- .checklist-group {
- flex-wrap: wrap;
- &.is-list {
- .checklist-box {
- margin: 5px 0;
- margin-right: 25px;
- .hidden {
- // 文字样式
- .checklist-content {
- .checklist-text {
- color: #666;
- margin-left: 5px;
- line-height: 14px;
- .checkobx__list {
- border-right-width: 1px;
- border-right-color: #007aff;
- border-right-style: solid;
- border-bottom-width:1px;
- border-bottom-color: #007aff;
- height: 12px;
- width: 6px;
- left: -5px;
- transform-origin: center;
- transform: rotate(45deg);
- .checkbox__inner {
- flex-shrink: 0;
- width: 16px;
- height: 16px;
- border: 1px solid $border-color;
- .checkbox__inner-icon {
- top: 2px;
- left: 5px;
- width: 4px;
- border-right-color: #fff;
- border-bottom-width:1px ;
- transform: rotate(40deg);
- // 单选样式
- .radio__inner {
- border-radius: 16px;
- .radio__inner-icon {
- border-radius: 10px;
- // 默认样式
- &.is--default {
- // 禁用
- &.is-disable {
- cursor: not-allowed;
- background-color: #F2F6FC;
- border-color: $border-color;
- // 选中
- &.is-checked {
- border-color: $uni-primary;
- // 选中禁用
- opacity: $disable;
- // 按钮样式
- &.is--button {
- padding: 5px 10px;
- border: 1px $border-color solid;
- transition: border-color 0.2s;
- border: 1px #eee solid;
- // 标签样式
- &.is--tag {
- background-color: #f5f5f5;
- // 列表样式
- &.is--list {
- padding: 10px 15px;
- &.is-list-border {
- border-top: 1px #eee solid;
- "id": "uni-data-checkbox",
- "displayName": "uni-data-checkbox 数据选择器",
- "version": "1.0.3",
- "description": "通过数据驱动的单选框和复选框",
- "checkbox",
- "单选",
- "多选",
- "单选多选"
- "HBuilderX": "^3.1.1"
- "dependencies": ["uni-load-more","uni-scss"],
@@ -1,18 +0,0 @@
-## DataCheckbox 数据驱动的单选复选框
-> **组件名:uni-data-checkbox**
-> 代码块: `uDataCheckbox`
-本组件是基于uni-app基础组件checkbox的封装。本组件要解决问题包括:
-1. 数据绑定型组件:给本组件绑定一个data,会自动渲染一组候选内容。再以往,开发者需要编写不少代码实现类似功能
-2. 自动的表单校验:组件绑定了data,且符合[uni-forms](https://ext.dcloud.net.cn/plugin?id=2773)组件的表单校验规范,搭配使用会自动实现表单校验
-3. 本组件合并了单选多选
-4. 本组件有若干风格选择,如普通的单选多选框、并列button风格、tag风格。开发者可以快速选择需要的风格。但作为一个封装组件,样式代码虽然不用自己写了,却会牺牲一定的样式自定义性
-在uniCloud开发中,`DB Schema`中配置了enum枚举等类型后,在web控制台的[自动生成表单](https://uniapp.dcloud.io/uniCloud/schema?id=autocode)功能中,会自动生成``uni-data-checkbox``组件并绑定好data
-### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-data-checkbox)
@@ -1,75 +0,0 @@
-## 1.1.2(2023-04-11)
-- 修复 更改 modelValue 报错的 bug
-- 修复 v-for 未使用 key 值控制台 warning
-## 1.1.1(2023-02-21)
-- 修复代码合并时引发 value 属性为空时不渲染数据的问题
-## 1.1.0(2023-02-15)
-- 修复 localdata 不支持动态更新的bug
-## 1.0.9(2023-02-15)
-## 1.0.8(2022-09-16)
-## 1.0.7(2022-07-06)
-- 优化 pc端图标位置不正确的问题
-## 1.0.6(2022-07-05)
-- 优化 显示样式
-## 1.0.5(2022-07-04)
-- 修复 uni-data-picker 在 uni-forms-item 中宽度不正确的bug
-## 1.0.4(2022-04-19)
-- 修复 字节小程序 本地数据无法选择下一级的Bug
-## 1.0.3(2022-02-25)
-- 修复 nvue 不支持的 v-show 的 bug
-## 1.0.2(2022-02-25)
-- 修复 条件编译 nvue 不支持的 css 样式
-- 修复 由上个版本引发的map、v-model等属性不生效的bug
-- 优化 组件 UI,并提供设计资源,详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource)
-- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-data-picker](https://uniapp.dcloud.io/component/uniui/uni-data-picker)
-## 0.4.9(2021-10-28)
-- 修复 VUE2 v-model 概率无效的 bug
-## 0.4.8(2021-10-27)
-- 修复 v-model 概率无效的 bug
-## 0.4.7(2021-10-25)
-- 新增 属性 spaceInfo 服务空间配置 HBuilderX 3.2.11+
-- 修复 树型 uniCloud 数据类型为 int 时报错的 bug
-## 0.4.6(2021-10-19)
-- 修复 非 VUE3 v-model 为 0 时无法选中的 bug
-## 0.4.5(2021-09-26)
-- 新增 清除已选项的功能(通过 clearIcon 属性配置是否显示按钮),同时提供 clear 方法以供调用,二者等效
-- 修复 readonly 为 true 时报错的 bug
-## 0.4.4(2021-09-26)
-- 修复 上一版本造成的 map 属性失效的 bug
-- 新增 ellipsis 属性,支持配置 tab 选项长度过长时是否自动省略
-## 0.4.3(2021-09-24)
-- 修复 某些情况下级联未触发的 bug
-## 0.4.2(2021-09-23)
-- 新增 提供 show 和 hide 方法,开发者可以通过 ref 调用
-- 新增 选项内容过长自动添加省略号
-## 0.4.1(2021-09-15)
-- 新增 map 属性 字段映射,将 text/value 映射到数据中的其他字段
-## 0.4.0(2021-07-13)
-- 组件兼容 vue3,如何创建 vue3 项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
-## 0.3.5(2021-06-04)
-- 修复 无法加载云端数据的问题
-## 0.3.4(2021-05-28)
-- 修复 v-model 无效问题
-- 修复 loaddata 为空数据组时加载时间过长问题
-- 修复 上个版本引出的本地数据无法选择带有 children 的 2 级节点
-## 0.3.3(2021-05-12)
-## 0.3.2(2021-04-22)
-- 修复 非树形数据有 where 属性查询报错的问题
-## 0.3.1(2021-04-15)
-- 修复 本地数据概率无法回显时问题
-## 0.3.0(2021-04-07)
-- 新增 支持云端非树形表结构数据
-- 修复 根节点 parent_field 字段等于 null 时选择界面错乱问题
-## 0.2.0(2021-03-15)
-- 修复 nodeclick、popupopened、popupclosed 事件无法触发的问题
-## 0.1.9(2021-03-09)
-- 修复 微信小程序某些情况下无法选择的问题
-## 0.1.8(2021-02-05)
-- 优化 部分样式在 nvue 上的兼容表现
-## 0.1.7(2021-02-05)
-- 调整为 uni_modules 目录规范
-// #ifdef H5
- name: 'Keypress',
- disable: {
- const keyNames = {
- esc: ['Esc', 'Escape'],
- tab: 'Tab',
- enter: 'Enter',
- space: [' ', 'Spacebar'],
- up: ['Up', 'ArrowUp'],
- left: ['Left', 'ArrowLeft'],
- right: ['Right', 'ArrowRight'],
- down: ['Down', 'ArrowDown'],
- delete: ['Backspace', 'Delete', 'Del']
- const listener = ($event) => {
- if (this.disable) {
- const keyName = Object.keys(keyNames).find(key => {
- const keyName = $event.key
- const value = keyNames[key]
- return value === keyName || (Array.isArray(value) && value.includes(keyName))
- if (keyName) {
- // 避免和其他按键事件冲突
- this.$emit(keyName, {})
- }, 0)
- document.addEventListener('keyup', listener)
- this.$once('hook:beforeDestroy', () => {
- document.removeEventListener('keyup', listener)
- render: () => {}
@@ -1,551 +0,0 @@
- <view class="uni-data-tree">
- <view class="uni-data-tree-input" @click="handleInput">
- <slot :options="options" :data="inputSelected" :error="errorMessage">
- <view class="input-value" :class="{'input-value-border': border}">
- <text v-if="errorMessage" class="selected-area error-text">{{errorMessage}}</text>
- <view v-else-if="loading && !isOpened" class="selected-area">
- <uni-load-more class="load-more" :contentText="loadMore" status="loading"></uni-load-more>
- <scroll-view v-else-if="inputSelected.length" class="selected-area" scroll-x="true">
- <view class="selected-list">
- <view class="selected-item" v-for="(item,index) in inputSelected" :key="index">
- <text class="text-color">{{item.text}}</text><text v-if="index<inputSelected.length-1"
- class="input-split-line">{{split}}</text>
- <text v-else class="selected-area placeholder">{{placeholder}}</text>
- <view v-if="clearIcon && !readonly && inputSelected.length" class="icon-clear" @click.stop="clear">
- <uni-icons type="clear" color="#c0c4cc" size="24"></uni-icons>
- <view class="arrow-area" v-if="(!clearIcon || !inputSelected.length) && !readonly ">
- <view class="input-arrow"></view>
- <view class="uni-data-tree-cover" v-if="isOpened" @click="handleClose"></view>
- <view class="uni-data-tree-dialog" v-if="isOpened">
- <view class="dialog-caption">
- <view class="title-area">
- <text class="dialog-title">{{popupTitle}}</text>
- <view class="dialog-close" @click="handleClose">
- <view class="dialog-close-plus" data-id="close"></view>
- <view class="dialog-close-plus dialog-close-rotate" data-id="close"></view>
- <data-picker-view class="picker-view" ref="pickerView" v-model="dataValue" :localdata="localdata"
- :preload="preload" :collection="collection" :field="field" :orderby="orderby" :where="where"
- :step-searh="stepSearh" :self-field="selfField" :parent-field="parentField" :managed-mode="true" :map="map"
- :ellipsis="ellipsis" @change="onchange" @datachange="ondatachange" @nodeclick="onnodeclick">
- </data-picker-view>
- import dataPicker from "../uni-data-pickerview/uni-data-picker.js"
- import DataPickerView from "../uni-data-pickerview/uni-data-pickerview.vue"
- * DataPicker 级联选择
- * @description 支持单列、和多列级联选择。列数没有限制,如果屏幕显示不全,顶部tab区域会左右滚动。
- * @tutorial https://ext.dcloud.net.cn/plugin?id=3796
- * @property {String} popup-title 弹出窗口标题
- * @property {Array} localdata 本地数据,参考
- * @property {Boolean} border = [true|false] 是否有边框
- * @property {Boolean} readonly = [true|false] 是否仅读
- * @property {Boolean} preload = [true|false] 是否预加载数据
- * @value true 开启预加载数据,点击弹出窗口后显示已加载数据
- * @value false 关闭预加载数据,点击弹出窗口后开始加载数据
- * @property {Boolean} step-searh = [true|false] 是否分布查询
- * @value true 启用分布查询,仅查询当前选中节点
- * @value false 关闭分布查询,一次查询出所有数据
- * @property {String|DBFieldString} self-field 分布查询当前字段名称
- * @property {String|DBFieldString} parent-field 分布查询父字段名称
- * @property {String|DBCollectionString} collection 表名
- * @property {String|DBFieldString} field 查询字段,多个字段用 `,` 分割
- * @property {String} orderby 排序字段及正序倒叙设置
- * @property {String|JQLString} where 查询条件
- * @event {Function} popupshow 弹出的选择窗口打开时触发此事件
- * @event {Function} popuphide 弹出的选择窗口关闭时触发此事件
- name: 'UniDataPicker',
- emits: ['popupopened', 'popupclosed', 'nodeclick', 'input', 'change', 'update:modelValue','inputclick'],
- mixins: [dataPicker],
- DataPickerView
- type: [Object, Array],
- popupTitle: {
- default: '请选择'
- heightMobile: {
- readonly: {
- clearIcon: {
- split: {
- ellipsis: {
- isOpened: false,
- inputSelected: []
- this.load();
- handler() {
- this.load()
- clear() {
- this._dispatchEvent([]);
- onPropsChange() {
- this._treeData = [];
- this.selectedIndex = 0;
- load() {
- if (this.readonly) {
- this._processReadonly(this.localdata, this.dataValue);
- // 回显本地数据
- if (this.isLocalData) {
- this.loadData();
- this.inputSelected = this.selected.slice(0);
- } else if (this.isCloudDataList || this.isCloudDataTree) { // 回显 Cloud 数据
- this.loading = true;
- this.getCloudDataValue().then((res) => {
- this.loading = false;
- this.inputSelected = res;
- }).catch((err) => {
- this.errorMessage = err;
- show() {
- this.isOpened = true
- this.$refs.pickerView.updateData({
- treeData: this._treeData,
- selectedIndex: this.selectedIndex
- }, 200)
- this.$emit('popupopened')
- hide() {
- this.isOpened = false
- this.$emit('popupclosed')
- handleInput() {
- this.$emit('inputclick')
- this.show()
- handleClose(e) {
- this.hide()
- onnodeclick(e) {
- this.$emit('nodeclick', e)
- ondatachange(e) {
- this._treeData = this.$refs.pickerView._treeData
- onchange(e) {
- this.inputSelected = e;
- this._dispatchEvent(e)
- _processReadonly(dataList, value) {
- var isTree = dataList.findIndex((item) => {
- return item.children
- if (isTree > -1) {
- let inputValue
- if (Array.isArray(value)) {
- inputValue = value[value.length - 1]
- if (typeof inputValue === 'object' && inputValue.value) {
- inputValue = inputValue.value
- inputValue = value
- this.inputSelected = this._findNodePath(inputValue, this.localdata)
- if (!this.hasValue) {
- this.inputSelected = []
- let result = []
- for (let i = 0; i < value.length; i++) {
- var val = value[i]
- var item = dataList.find((v) => {
- return v.value == val
- if (item) {
- result.push(item)
- if (result.length) {
- this.inputSelected = result
- _filterForArray(data, valueArray) {
- var result = []
- for (let i = 0; i < valueArray.length; i++) {
- var value = valueArray[i]
- var found = data.find((item) => {
- return item.value == value
- if (found) {
- result.push(found)
- return result
- _dispatchEvent(selected) {
- let item = {}
- if (selected.length) {
- var value = new Array(selected.length)
- for (var i = 0; i < selected.length; i++) {
- value[i] = selected[i].value
- item = selected[selected.length - 1]
- item.value = ''
- if (this.formItem) {
- this.formItem.setValue(item.value)
- this.$emit('input', item.value)
- this.$emit('update:modelValue', item.value)
- detail: {
- value: selected
- .uni-data-tree {
- .error-text {
- color: #DD524D;
- .input-value {
- flex-wrap: nowrap;
- /* line-height: 35px; */
- padding-right: 5px;
- height: 35px;
- .input-value-border {
- border: 1px solid #e5e5e5;
- .selected-area {
- .load-more {
- margin-right: auto;
- .selected-list {
- /* padding: 0 5px; */
- .selected-item {
- /* padding: 0 1px; */
- .text-color {
- .placeholder {
- color: grey;
- .input-split-line {
- opacity: .5;
- .arrow-area {
- margin-bottom: 5px;
- margin-left: auto;
- .input-arrow {
- width: 7px;
- height: 7px;
- border-left: 1px solid #999;
- border-bottom: 1px solid #999;
- .uni-data-tree-cover {
- background-color: rgba(0, 0, 0, .4);
- z-index: 100;
- .uni-data-tree-dialog {
- top: 20%;
- top: 200px;
- border-top-left-radius: 10px;
- border-top-right-radius: 10px;
- z-index: 102;
- width: 750rpx;
- .dialog-caption {
- /* border-bottom: 1px solid #f0f0f0; */
- .title-area {
- margin: auto;
- .dialog-title {
- /* font-weight: bold; */
- line-height: 44px;
- .dialog-close {
- .dialog-close-plus {
- height: 2px;
- background-color: #666;
- border-radius: 2px;
- .dialog-close-rotate {
- .picker-view {
- .icon-clear {
- @media all and (min-width: 768px) {
- top: 55px;
- min-height: 400px;
- max-height: 50vh;
- overflow: unset;
- /* margin-right: 5px; */
- /* picker 弹出层通用的指示小三角, todo:扩展至上下左右方向定位 */
@@ -1,622 +0,0 @@
- type: [Array, Object],
- spaceInfo: {
- collection: {
- action: {
- field: {
- orderby: {
- where: {
- type: [String, Object],
- pageData: {
- default: 'add'
- pageCurrent: {
- pageSize: {
- default: 500
- getcount: {
- getone: {
- gettree: {
- manual: {
- preload: {
- stepSearh: {
- selfField: {
- parentField: {
- map: {
- text: "text",
- value: "value"
- loading: false,
- errorMessage: '',
- loadMore: {
- contentdown: '',
- contentrefresh: '',
- contentnomore: ''
- selected: [],
- selectedIndex: 0,
- page: {
- current: this.pageCurrent,
- size: this.pageSize,
- count: 0
- isLocalData() {
- return !this.collection.length;
- isCloudData() {
- return this.collection.length > 0;
- isCloudDataList() {
- return (this.isCloudData && (!this.parentField && !this.selfField));
- isCloudDataTree() {
- return (this.isCloudData && this.parentField && this.selfField);
- let isModelValue = Array.isArray(this.modelValue) ? (this.modelValue.length > 0) : (this.modelValue !== null ||
- this.modelValue !== undefined);
- return isModelValue ? this.modelValue : this.value;
- hasValue() {
- if (typeof this.dataValue === 'number') {
- return (this.dataValue != null) && (this.dataValue.length > 0)
- this.$watch(() => {
- var al = [];
- ['pageCurrent',
- 'pageSize',
- 'spaceInfo',
- 'value',
- 'modelValue',
- 'localdata',
- 'collection',
- 'action',
- 'field',
- 'orderby',
- 'where',
- 'getont',
- 'getcount',
- 'gettree'
- ].forEach(key => {
- al.push(this[key])
- return al
- }, (newValue, oldValue) => {
- let needReset = false
- for (let i = 2; i < newValue.length; i++) {
- if (newValue[i] != oldValue[i]) {
- needReset = true
- if (newValue[0] != oldValue[0]) {
- this.page.current = this.pageCurrent
- this.page.size = this.pageSize
- this.onPropsChange()
- this._treeData = []
- // 填充 pickview 数据
- async loadData() {
- this.loadLocalData();
- } else if (this.isCloudDataList) {
- this.loadCloudDataList();
- } else if (this.isCloudDataTree) {
- this.loadCloudDataTree();
- // 加载本地数据
- async loadLocalData() {
- this._extractTree(this.localdata, this._treeData);
- let inputValue = this.dataValue;
- if (inputValue === undefined) {
- if (Array.isArray(inputValue)) {
- inputValue = inputValue[inputValue.length - 1];
- if (typeof inputValue === 'object' && inputValue[this.map.value]) {
- inputValue = inputValue[this.map.value];
- this.selected = this._findNodePath(inputValue, this.localdata);
- // 加载 Cloud 数据 (单列)
- async loadCloudDataList() {
- if (this.loading) {
- try {
- let response = await this.getCommand();
- let responseData = response.result.data;
- this._treeData = responseData;
- this._updateBindData();
- this._updateSelected();
- this.onDataChange();
- } catch (e) {
- this.errorMessage = e;
- } finally {
- // 加载 Cloud 数据 (树形)
- async loadCloudDataTree() {
- let commandOptions = {
- field: this._cloudDataPostField(),
- where: this._cloudDataTreeWhere()
- if (this.gettree) {
- commandOptions.startwith = `${this.selfField}=='${this.dataValue}'`;
- let response = await this.getCommand(commandOptions);
- // 加载 Cloud 数据 (节点)
- async loadCloudDataNode(callback) {
- where: this._cloudDataNodeWhere()
- callback(responseData);
- // 回显 Cloud 数据
- getCloudDataValue() {
- if (this.isCloudDataList) {
- return this.getCloudDataListValue();
- if (this.isCloudDataTree) {
- return this.getCloudDataTreeValue();
- // 回显 Cloud 数据 (单列)
- getCloudDataListValue() {
- // 根据 field's as value标识匹配 where 条件
- let where = [];
- let whereField = this._getForeignKeyByField();
- if (whereField) {
- where.push(`${whereField} == '${this.dataValue}'`)
- where = where.join(' || ');
- if (this.where) {
- where = `(${this.where}) && (${where})`
- return this.getCommand({
- where
- }).then((res) => {
- this.selected = res.result.data;
- return res.result.data;
- // 回显 Cloud 数据 (树形)
- getCloudDataTreeValue() {
- getTreePath: {
- startWith: `${this.selfField}=='${this.dataValue}'`
- let treePath = [];
- this._extractTreePath(res.result.data, treePath);
- this.selected = treePath;
- return treePath;
- getCommand(options = {}) {
- /* eslint-disable no-undef */
- let db = uniCloud.database(this.spaceInfo)
- const action = options.action || this.action
- if (action) {
- db = db.action(action)
- const collection = options.collection || this.collection
- db = db.collection(collection)
- const where = options.where || this.where
- if (!(!where || !Object.keys(where).length)) {
- db = db.where(where)
- const field = options.field || this.field
- if (field) {
- db = db.field(field)
- const orderby = options.orderby || this.orderby
- if (orderby) {
- db = db.orderBy(orderby)
- const current = options.pageCurrent !== undefined ? options.pageCurrent : this.page.current
- const size = options.pageSize !== undefined ? options.pageSize : this.page.size
- const getCount = options.getcount !== undefined ? options.getcount : this.getcount
- const getTree = options.gettree !== undefined ? options.gettree : this.gettree
- const getOptions = {
- getCount,
- getTree
- if (options.getTreePath) {
- getOptions.getTreePath = options.getTreePath
- db = db.skip(size * (current - 1)).limit(size).get(getOptions)
- return db
- _cloudDataPostField() {
- let fields = [this.field];
- if (this.parentField) {
- fields.push(`${this.parentField} as parent_value`);
- return fields.join(',');
- _cloudDataTreeWhere() {
- let selected = this.selected
- let parentField = this.parentField
- if (parentField) {
- result.push(`${parentField} == null || ${parentField} == ""`)
- for (var i = 0; i < selected.length - 1; i++) {
- result.push(`${parentField} == '${selected[i].value}'`)
- let where = []
- where.push(`(${this.where})`)
- where.push(`(${result.join(' || ')})`)
- return where.join(' && ')
- _cloudDataNodeWhere() {
- let selected = this.selected;
- where.push(`${this.parentField} == '${selected[selected.length - 1].value}'`);
- return `(${this.where}) && (${where})`
- return where
- _getWhereByForeignKey() {
- result.push(`${whereField} == '${this.dataValue}'`)
- return `(${this.where}) && (${result.join(' || ')})`
- return result.join(' || ')
- _getForeignKeyByField() {
- let fields = this.field.split(',');
- let whereField = null;
- for (let i = 0; i < fields.length; i++) {
- const items = fields[i].split('as');
- if (items.length < 2) {
- continue;
- if (items[1].trim() === 'value') {
- whereField = items[0].trim();
- break;
- return whereField;
- _updateBindData(node) {
- dataList,
- hasNodes
- } = this._filterData(this._treeData, this.selected)
- let isleaf = this._stepSearh === false && !hasNodes
- if (node) {
- node.isleaf = isleaf
- this.dataList = dataList
- this.selectedIndex = dataList.length - 1
- if (!isleaf && this.selected.length < dataList.length) {
- this.selected.push({
- value: null,
- text: "请选择"
- isleaf,
- _updateSelected() {
- let dl = this.dataList
- let sl = this.selected
- let textField = this.map.text
- let valueField = this.map.value
- for (let i = 0; i < sl.length; i++) {
- let value = sl[i].value
- let dl2 = dl[i]
- for (let j = 0; j < dl2.length; j++) {
- let item2 = dl2[j]
- if (item2[valueField] === value) {
- sl[i].text = item2[textField]
- _filterData(data, paths) {
- let dataList = []
- let hasNodes = true
- dataList.push(data.filter((item) => {
- return (item.parent_value === null || item.parent_value === undefined || item.parent_value === '')
- }))
- for (let i = 0; i < paths.length; i++) {
- let value = paths[i].value
- let nodes = data.filter((item) => {
- return item.parent_value === value
- if (nodes.length) {
- dataList.push(nodes)
- hasNodes = false
- _extractTree(nodes, result, parent_value) {
- let list = result || []
- let node = nodes[i]
- let child = {}
- for (let key in node) {
- if (key !== 'children') {
- child[key] = node[key]
- if (parent_value !== null && parent_value !== undefined && parent_value !== '') {
- child.parent_value = parent_value
- result.push(child)
- let children = node.children
- if (children) {
- this._extractTree(children, result, node[valueField])
- _extractTreePath(nodes, result) {
- this._extractTreePath(children, result)
- _findNodePath(key, nodes, path = []) {
- let text = node[textField]
- let value = node[valueField]
- path.push({
- value,
- text
- if (value === key) {
- return path
- const p = this._findNodePath(key, children, path)
- if (p.length) {
- path.pop()
@@ -1,323 +0,0 @@
- <view class="uni-data-pickerview">
- <scroll-view v-if="!isCloudDataList" class="selected-area" scroll-x="true">
- <view
- class="selected-item"
- v-for="(item,index) in selected"
- :key="index"
- :class="{
- 'selected-item-active':index == selectedIndex
- @click="handleSelect(index)"
- >
- <text>{{item.text || ''}}</text>
- <view class="tab-c">
- <scroll-view class="list" :scroll-y="true">
- <view class="item" :class="{'is-disabled': !!item.disable}" v-for="(item, j) in dataList[selectedIndex]" :key="j"
- @click="handleNodeClick(item, selectedIndex, j)">
- <text class="item-text">{{item[map.text]}}</text>
- <view class="check" v-if="selected.length > selectedIndex && item[map.value] == selected[selectedIndex].value"></view>
- <view class="loading-cover" v-if="loading">
- <view class="error-message" v-if="errorMessage">
- <text class="error-text">{{errorMessage}}</text>
- import dataPicker from "./uni-data-picker.js"
- * DataPickerview
- * @description uni-data-pickerview
- name: 'UniDataPickerView',
- emits: ['nodeclick', 'change', 'datachange', 'update:modelValue'],
- managedMode: {
- if (!this.managedMode) {
- handleSelect(index) {
- this.selectedIndex = index;
- handleNodeClick(item, i, j) {
- if (item.disable) {
- const node = this.dataList[i][j];
- const text = node[this.map.text];
- const value = node[this.map.value];
- if (i < this.selected.length - 1) {
- this.selected.splice(i, this.selected.length - i)
- value
- } else if (i === this.selected.length - 1) {
- this.selected.splice(i, 1, {
- if (node.isleaf) {
- this.onSelectedChange(node, node.isleaf)
- } = this._updateBindData()
- // 本地数据
- this.onSelectedChange(node, (!hasNodes || isleaf))
- } else if (this.isCloudDataList) { // Cloud 数据 (单列)
- this.onSelectedChange(node, true)
- } else if (this.isCloudDataTree) { // Cloud 数据 (树形)
- if (isleaf) {
- } else if (!hasNodes) { // 请求一次服务器以确定是否为叶子节点
- this.loadCloudDataNode((data) => {
- if (!data.length) {
- node.isleaf = true
- this._treeData.push(...data)
- this._updateBindData(node)
- updateData(data) {
- this._treeData = data.treeData
- this.selected = data.selected
- if (!this._treeData.length) {
- //this.selected = data.selected
- this._updateBindData()
- onDataChange() {
- this.$emit('datachange');
- onSelectedChange(node, isleaf) {
- this._dispatchEvent()
- this.$emit('nodeclick', node)
- _dispatchEvent() {
- this.$emit('change', this.selected.slice(0))
- $uni-primary: #007aff !default;
- .uni-data-pickerview {
- .loading-cover {
- background-color: rgba(255, 255, 255, .5);
- z-index: 1001;
- .error-message {
- padding: 15px;
- opacity: .9;
- border-bottom: 1px solid #f8f8f8;
- margin-left: 10px;
- padding: 12px 0;
- .selected-item-text-overflow {
- width: 168px;
- /* fix nvue */
- width: 6em;
- -o-text-overflow: ellipsis;
- .selected-item-active {
- border-bottom: 2px solid $uni-primary;
- .selected-item-text {
- .tab-c {
- .list {
- .item {
- padding: 12px 15px;
- .is-disabled {
- .item-text {
- /* flex: 1; */
- color: #333333;
- .item-text-overflow {
- width: 280px;
- width: 20em;
- .check {
- margin-right: 5px;
- border: 2px solid $uni-primary;
- border-left: 0;
- border-top: 0;
- transition: all 0.3s;
- "id": "uni-data-picker",
- "displayName": "uni-data-picker 数据驱动的picker选择器",
- "version": "1.1.2",
- "description": "单列、多列级联选择器,常用于省市区城市选择、公司部门选择、多级分类等场景",
- "picker",
- "级联",
- "省市区",
- ""
- "uni-load-more",
@@ -1,22 +0,0 @@
-## DataPicker 级联选择
-> **组件名:uni-data-picker**
-> 代码块: `uDataPicker`
-> 关联组件:`uni-data-pickerview`、`uni-load-more`。
-`<uni-data-picker>` 是一个选择类[datacom组件](https://uniapp.dcloud.net.cn/component/datacom)。
-支持单列、和多列级联选择。列数没有限制,如果屏幕显示不全,顶部tab区域会左右滚动。
-候选数据支持一次性加载完毕,也支持懒加载,比如示例图中,选择了“北京”后,动态加载北京的区县数据。
-`<uni-data-picker>` 组件尤其适用于地址选择、分类选择等选择类。
-`<uni-data-picker>` 支持本地数据、云端静态数据(json),uniCloud云数据库数据。
-`<uni-data-picker>` 可以通过JQL直连uniCloud云数据库,配套[DB Schema](https://uniapp.dcloud.net.cn/uniCloud/schema),可在schema2code中自动生成前端页面,还支持服务器端校验。
-在uniCloud数据表中新建表“uni-id-address”和“opendb-city-china”,这2个表的schema自带foreignKey关联。在“uni-id-address”表的表结构页面使用schema2code生成前端页面,会自动生成地址管理的维护页面,自动从“opendb-city-china”表包含的中国所有省市区信息里选择地址。
-### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-data-picker)
@@ -1,35 +0,0 @@
-## 1.0.6(2023-04-12)
-- 修复 微信小程序点击时会改变背景颜色的 bug
-## 1.0.5(2023-02-03)
-- 修复 禁用时会显示清空按钮
-## 1.0.4(2023-02-02)
-- 优化 查询条件短期内多次变更只查询最后一次变更后的结果
-- 调整 内部缓存键名调整为 uni-data-select-lastSelectedValue
-## 1.0.3(2023-01-16)
-- 修复 不关联服务空间报错的问题
-## 1.0.2(2023-01-14)
-- 新增 属性 `format` 可用于格式化显示选项内容
-## 1.0.1(2022-12-06)
-- 修复 当where变化时,数据不会自动更新的问题
-## 0.1.9(2022-09-05)
-- 修复 微信小程序下拉框出现后选择会点击到蒙板后面的输入框
-## 0.1.8(2022-08-29)
-- 修复 点击的位置不准确
-## 0.1.7(2022-08-12)
-- 新增 支持 disabled 属性
-## 0.1.6(2022-07-06)
-- 修复 pc端宽度异常的bug
-## 0.1.5
-## 0.1.4(2022-07-05)
-## 0.1.3(2022-06-02)
-- 修复 localdata 赋值不生效的 bug
-- 新增 支持选项禁用(数据选项设置 disabled: true 即禁用)
-## 0.1.2(2022-05-08)
-- 修复 当 value 为 0 时选择不生效的 bug
-## 0.1.1(2022-05-07)
-- 新增 记住上次的选项(仅 collection 存在时有效)
-## 0.1.0(2022-04-22)
@@ -1,517 +0,0 @@
- <view class="uni-stat__select">
- <span v-if="label" class="uni-label-text hide-on-phone">{{label + ':'}}</span>
- <view class="uni-stat-box" :class="{'uni-stat__actived': current}">
- <view class="uni-select" :class="{'uni-select--disabled':disabled}">
- <view class="uni-select__input-box" @click="toggleSelector">
- <view v-if="current" class="uni-select__input-text">{{current}}</view>
- <view v-else class="uni-select__input-text uni-select__input-placeholder">{{typePlaceholder}}</view>
- <view v-if="current && clear && !disabled" @click.stop="clearVal" >
- <uni-icons type="clear" color="#c0c4cc" size="24"/>
- <view v-else>
- <uni-icons :type="showSelector? 'top' : 'bottom'" size="14" color="#999" />
- <view class="uni-select--mask" v-if="showSelector" @click="toggleSelector" />
- <view class="uni-select__selector" v-if="showSelector">
- <scroll-view scroll-y="true" class="uni-select__selector-scroll">
- <view class="uni-select__selector-empty" v-if="mixinDatacomResData.length === 0">
- <view v-else class="uni-select__selector-item" v-for="(item,index) in mixinDatacomResData" :key="index"
- @click="change(item)">
- <text :class="{'uni-select__selector__disabled': item.disable}">{{formatItemName(item)}}</text>
- * @description 通过数据渲染的下拉框组件
- * @tutorial https://uniapp.dcloud.io/component/uniui/uni-data-select
- * @property {String} value 默认值
- * @property {Boolean} clear 是否可以清空已选项
- * @property {String} label 左侧标题
- * @property {String} placeholder 输入框的提示文字
- * @property {Boolean} disabled 是否禁用
- name: "uni-data-select",
- default: '无选项'
- clear: {
- defItem: {
- // 格式化输出 用法 field="_id as value, version as text, uni_platform as label" format="{label} - {text}"
- format: {
- current: '',
- mixinDatacomResData: [],
- apps: [],
- channels: [],
- cacheKey: "uni-data-select-lastSelectedValue",
- this.debounceGet = this.debounce(() => {
- this.query();
- if (this.collection && !this.localdata.length) {
- this.debounceGet();
- typePlaceholder() {
- const text = {
- 'opendb-stat-app-versions': '版本',
- 'opendb-app-channels': '渠道',
- 'opendb-app-list': '应用'
- const common = this.placeholder
- const placeholder = text[this.collection]
- return placeholder ?
- common + placeholder :
- common
- valueCom(){
- return this.modelValue;
- return this.value;
- handler(val, old) {
- if (Array.isArray(val) && old !== val) {
- this.mixinDatacomResData = val
- valueCom(val, old) {
- this.initDefVal()
- mixinDatacomResData: {
- handler(val) {
- if (val.length) {
- debounce(fn, time = 100){
- let timer = null
- return function(...args) {
- if (timer) clearTimeout(timer)
- timer = setTimeout(() => {
- fn.apply(this, args)
- }, time)
- // 执行数据库查询
- query(){
- this.mixinDatacomEasyGet();
- // 监听查询条件变更事件
- onMixinDatacomPropsChange(){
- initDefVal() {
- let defValue = ''
- if ((this.valueCom || this.valueCom === 0) && !this.isDisabled(this.valueCom)) {
- defValue = this.valueCom
- let strogeValue
- strogeValue = this.getCache()
- if (strogeValue || strogeValue === 0) {
- defValue = strogeValue
- let defItem = ''
- if (this.defItem > 0 && this.defItem <= this.mixinDatacomResData.length) {
- defItem = this.mixinDatacomResData[this.defItem - 1].value
- defValue = defItem
- if (defValue || defValue === 0) {
- this.emit(defValue)
- const def = this.mixinDatacomResData.find(item => item.value === defValue)
- this.current = def ? this.formatItemName(def) : ''
- * @param {[String, Number]} value
- * 判断用户给的 value 是否同时为禁用状态
- isDisabled(value) {
- let isDisabled = false;
- this.mixinDatacomResData.forEach(item => {
- if (item.value === value) {
- isDisabled = item.disable
- return isDisabled;
- clearVal() {
- this.emit('')
- this.removeCache()
- change(item) {
- if (!item.disable) {
- this.current = this.formatItemName(item)
- this.emit(item.value)
- emit(val) {
- this.$emit('change', val)
- this.setCache(val);
- if (this.disabled) {
- formatItemName(item) {
- channel_code
- } = item
- channel_code = channel_code ? `(${channel_code})` : ''
- if (this.format) {
- // 格式化输出
- let str = "";
- str = this.format;
- for (let key in item) {
- str = str.replace(new RegExp(`{${key}}`,"g"),item[key]);
- return str;
- return this.collection.indexOf('app-list') > 0 ?
- `${text}(${value})` :
- (
- text ?
- text :
- `未命名${channel_code}`
- // 获取当前加载的数据
- getLoadData(){
- return this.mixinDatacomResData;
- // 获取当前缓存key
- getCurrentCacheKey(){
- return this.collection;
- // 获取缓存
- getCache(name=this.getCurrentCacheKey()){
- let cacheData = uni.getStorageSync(this.cacheKey) || {};
- return cacheData[name];
- // 设置缓存
- setCache(value, name=this.getCurrentCacheKey()){
- cacheData[name] = value;
- uni.setStorageSync(this.cacheKey, cacheData);
- // 删除缓存
- removeCache(name=this.getCurrentCacheKey()){
- delete cacheData[name];
- $uni-main-color: #333 !default;
- $uni-border-3: #e5e5e5;
- @media screen and (max-width: 500px) {
- .hide-on-phone {
- .uni-stat__select {
- // padding: 15px;
- .uni-stat-box {
- .uni-stat__actived {
- // outline: 1px solid #2979ff;
- .uni-label-text {
- margin: auto 0;
- .uni-select {
- border: 1px solid $uni-border-3;
- user-select: none;
- border-bottom: solid 1px $uni-border-3;
- &--disabled {
- background-color: #f5f7fa;
- .uni-select__label {
- color: $uni-secondary-color;
- .uni-select__input-box {
- .uni-select__input {
- .uni-select__input-plac {
- .uni-select__selector {
- .uni-select__selector-scroll {
- @media (min-width: 768px) {
- max-height: 600px;
- .uni-select__selector-empty,
- .uni-select__selector-item {
- line-height: 35px;
- /* border-bottom: solid 1px $uni-border-3; */
- .uni-select__selector-item:hover {
- .uni-select__selector-empty:last-child,
- .uni-select__selector-item:last-child {
- .uni-select__selector__disabled {
- opacity: 0.4;
- cursor: default;
- /* picker 弹出层通用的指示小三角 */
- .uni-select__input-text {
- // width: 280px;
- .uni-select__input-placeholder {
- .uni-select--mask {
- z-index: 2;
- "id": "uni-data-select",
- "displayName": "uni-data-select 下拉框选择器",
- "version": "1.0.6",
- "description": "通过数据驱动的下拉框选择器",
- "select",
- "uni-data-select",
- "下拉框",
- "下拉选"
- "dependencies": ["uni-load-more"],
-## DataSelect 下拉框选择器
-> **组件名:uni-data-select**
-> 代码块: `uDataSelect`
-当选项过多时,使用下拉菜单展示并选择内容
-### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-data-select)
-- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-dateformat](https://uniapp.dcloud.io/component/uniui/uni-dateformat)
-## 0.0.5(2021-07-08)
-- 调整 默认时间不再是当前时间,而是显示'-'字符
-## 0.0.4(2021-05-12)
-- 修复 iOS 平台日期格式化出错的问题
@@ -1,200 +0,0 @@
-// yyyy-MM-dd hh:mm:ss.SSS 所有支持的类型
-function pad(str, length = 2) {
- str += ''
- while (str.length < length) {
- str = '0' + str
- return str.slice(-length)
-const parser = {
- yyyy: (dateObj) => {
- return pad(dateObj.year, 4)
- yy: (dateObj) => {
- return pad(dateObj.year)
- MM: (dateObj) => {
- return pad(dateObj.month)
- M: (dateObj) => {
- return dateObj.month
- dd: (dateObj) => {
- return pad(dateObj.day)
- d: (dateObj) => {
- return dateObj.day
- hh: (dateObj) => {
- return pad(dateObj.hour)
- h: (dateObj) => {
- return dateObj.hour
- mm: (dateObj) => {
- return pad(dateObj.minute)
- m: (dateObj) => {
- return dateObj.minute
- ss: (dateObj) => {
- return pad(dateObj.second)
- s: (dateObj) => {
- return dateObj.second
- SSS: (dateObj) => {
- return pad(dateObj.millisecond, 3)
- S: (dateObj) => {
- return dateObj.millisecond
-// 这都n年了iOS依然不认识2020-12-12,需要转换为2020/12/12
-function getDate(time) {
- if (time instanceof Date) {
- return time
- switch (typeof time) {
- case 'string':
- {
- // 2020-12-12T12:12:12.000Z、2020-12-12T12:12:12.000
- if (time.indexOf('T') > -1) {
- return new Date(time)
- return new Date(time.replace(/-/g, '/'))
- default:
-export function formatDate(date, format = 'yyyy/MM/dd hh:mm:ss') {
- if (!date && date !== 0) {
- date = getDate(date)
- const dateObj = {
- year: date.getFullYear(),
- month: date.getMonth() + 1,
- day: date.getDate(),
- hour: date.getHours(),
- minute: date.getMinutes(),
- second: date.getSeconds(),
- millisecond: date.getMilliseconds()
- const tokenRegExp = /yyyy|yy|MM|M|dd|d|hh|h|mm|m|ss|s|SSS|SS|S/
- let flag = true
- let result = format
- while (flag) {
- flag = false
- result = result.replace(tokenRegExp, function(matched) {
- return parser[matched](dateObj)
-export function friendlyDate(time, {
- locale = 'zh',
- threshold = [60000, 3600000],
- format = 'yyyy/MM/dd hh:mm:ss'
-}) {
- if (time === '-') {
- if (!time && time !== 0) {
- const localeText = {
- zh: {
- year: '年',
- month: '月',
- day: '天',
- hour: '小时',
- minute: '分钟',
- second: '秒',
- ago: '前',
- later: '后',
- justNow: '刚刚',
- soon: '马上',
- template: '{num}{unit}{suffix}'
- en: {
- year: 'year',
- month: 'month',
- day: 'day',
- hour: 'hour',
- minute: 'minute',
- second: 'second',
- ago: 'ago',
- later: 'later',
- justNow: 'just now',
- soon: 'soon',
- template: '{num} {unit} {suffix}'
- const text = localeText[locale] || localeText.zh
- let date = getDate(time)
- let ms = date.getTime() - Date.now()
- let absMs = Math.abs(ms)
- if (absMs < threshold[0]) {
- return ms < 0 ? text.justNow : text.soon
- if (absMs >= threshold[1]) {
- return formatDate(date, format)
- let num
- let unit
- let suffix = text.later
- if (ms < 0) {
- suffix = text.ago
- ms = -ms
- const seconds = Math.floor((ms) / 1000)
- const minutes = Math.floor(seconds / 60)
- const hours = Math.floor(minutes / 60)
- const days = Math.floor(hours / 24)
- const months = Math.floor(days / 30)
- const years = Math.floor(months / 12)
- switch (true) {
- case years > 0:
- num = years
- unit = text.year
- case months > 0:
- num = months
- unit = text.month
- case days > 0:
- num = days
- unit = text.day
- case hours > 0:
- num = hours
- unit = text.hour
- case minutes > 0:
- num = minutes
- unit = text.minute
- num = seconds
- unit = text.second
- if (locale === 'en') {
- if (num === 1) {
- num = 'a'
- unit += 's'
- return text.template.replace(/{\s*num\s*}/g, num + '').replace(/{\s*unit\s*}/g, unit).replace(/{\s*suffix\s*}/g,
- suffix)
- <text>{{dateShow}}</text>
- import {friendlyDate} from './date-format.js'
- * Dateformat 日期格式化
- * @description 日期格式化组件
- * @tutorial https://ext.dcloud.net.cn/plugin?id=3279
- * @property {Object|String|Number} date 日期对象/日期字符串/时间戳
- * @property {String} locale 格式化使用的语言
- * @value zh 中文
- * @value en 英文
- * @property {Array} threshold 应用不同类型格式化的阈值
- * @property {String} format 输出日期字符串时的格式
- name: 'uniDateformat',
- type: [Object, String, Number],
- return '-'
- locale: {
- default: 'zh',
- threshold: {
- default: 'yyyy/MM/dd hh:mm:ss'
- // refreshRate使用不当可能导致性能问题,谨慎使用
- refreshRate: {
- refreshMark: 0
- dateShow() {
- this.refreshMark
- return friendlyDate(this.date, {
- locale: this.locale,
- threshold: this.threshold,
- format: this.format
- this.setAutoRefresh()
- this.refreshMark++
- setAutoRefresh() {
- clearInterval(this.refreshInterval)
- if (this.refreshRate) {
- this.refreshInterval = setInterval(() => {
- this.refresh()
- }, parseInt(this.refreshRate))
- "id": "uni-dateformat",
- "displayName": "uni-dateformat 日期格式化",
- "description": "日期格式化组件,可以将日期格式化为1分钟前、刚刚等形式",
- "日期格式化",
- "时间格式化",
- "格式化时间",
-### DateFormat 日期格式化
-> **组件名:uni-dateformat**
-> 代码块: `uDateformat`
-日期格式化组件。
-### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-dateformat)
@@ -1,133 +0,0 @@
-## 2.2.22(2023-03-30)
-- 修复 日历 picker 修改年月后,自动选中当月1日 [详情](https://ask.dcloud.net.cn/question/165937)
-- 修复 小程序端 低版本 ios NaN [详情](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 属性支持配置选择器打开时默认显示的时间
-- 优化 非范围选择未选择日期时间,点击确认按钮选中当前日期时间
-- 优化 字节小程序日期时间范围选择,底部日期换行问题
-## 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)
-## 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)
-## 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 适配
@@ -1,177 +0,0 @@
- 'uni-calendar-item--before-checked-x':weeks.beforeMultiple,
- '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,
- }">
- <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 :class="{'uni-calendar-item--today': weeks.isToday}"></view>
- checkHover: {
- handleMousemove(weeks) {
- this.$emit('handleMouse', weeks)
- margin: 1px 0;
- // font-family: Lato-Bold, Lato;
- color: darken($color: $uni-primary, $amount: 40%);
- background-color: #dd524d;
- .uni-calendar-item__weeks-box .uni-calendar-item--disable {
- .uni-calendar-item--disable .uni-calendar-item__weeks-box-text-disable {
- color: #D1D1D1;
- .uni-calendar-item--today {
- top: 10px;
- right: 17%;
- width:6px;
- height: 6px;
- color: #dd524d;
- .uni-calendar-item__weeks-box .uni-calendar-item--checked {
- border: 3px solid #fff;
- .uni-calendar-item--checked .uni-calendar-item--checked-text {
- .uni-calendar-item--multiple .uni-calendar-item--checked-range-text {
- background-color: #F6F7FC;
- // color: #fff;
- .uni-calendar-item--multiple .uni-calendar-item--before-checked,
- .uni-calendar-item--multiple .uni-calendar-item--after-checked {
- border: 3px solid #F6F7FC;
- .uni-calendar-item--before-checked .uni-calendar-item--checked-text,
- .uni-calendar-item--after-checked .uni-calendar-item--checked-text {
- .uni-calendar-item--before-checked-x {
- border-top-left-radius: 50px;
- border-bottom-left-radius: 50px;
- .uni-calendar-item--after-checked-x {
- border-top-right-radius: 50px;
- border-bottom-right-radius: 50px;
@@ -1,928 +0,0 @@
- <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')">
- <text
- class="uni-calendar__header-text">{{ (nowDate.year||'') + yearText + ( nowDate.month||'') + monthText}}</text>
- <view class="uni-calendar__header-btn-box" @click.stop="changeMonth('next')">
- <view v-if="!insert" class="dialog-close" @click="close">
- <view class="uni-calendar__weeks" style="padding-bottom: 7px;">
- <text class="uni-calendar__weeks-day-text">{{MONText}}</text>
- <calendar-item class="uni-calendar-item--hook" :weeks="weeks" :calendar="calendar"
- :selected="selected" :checkHover="range" @change="choiceDate"
- @handleMouse="handleMouse">
- </calendar-item>
- <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 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}}
- <time-picker type="time" :start="timepickerStartTime" v-model="timeRange.startTime" :border="false"
- :hide-second="hideSecond" :disabled="!tempRange.before" class="time-picker-style">
- <view style="line-height: 50px;">
- <uni-icons type="arrowthinright" color="#999"></uni-icons>
- <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">
- <view v-if="!insert" class="uni-date-changed uni-date-btn--ok">
- <view class="uni-datetime-picker--btn" @click="confirm">{{confirmText}}</view>
- import { Calendar, getDate, getTime } from './util.js';
- import calendarItem from './calendar-item.vue'
- import timePicker from './time-picker.vue'
- * @property {[String} defaultValue 选择器打开时默认显示的时间
- * @example <uni-calendar :insert="true" :start-date="'2019-3-2'":end-date="'2019-5-20'"@change="change" />
- calendarItem,
- timePicker
- defTime: {
- selectableTimes: {
- type: [Object],
- startPlaceholder: {
- endPlaceholder: {
- hasTime: {
- hideSecond: {
- type: [Boolean],
- pleStatus: {
- data: [],
- fulldate: ''
- defaultValue: {
- type: [String, Object, Array],
- nowDate: {},
- aniMaskShow: false,
- firstEnter: true,
- time: '',
- timeRange: {
- startTime: '',
- endTime: ''
- tempSingleDate: '',
- tempRange: {
- after: ''
- if (!this.range) {
- this.tempSingleDate = newVal
- }, 100)
- this.time = newVal
- this.timeRange.startTime = newVal.start
- this.timeRange.endTime = newVal.end
- startDate(val) {
- // 字节小程序 watch 早于 created
- if(!this.cale){
- this.cale.setStartDate(val)
- endDate(val) {
- this.cale.setEndDate(val)
- after,
- fulldate,
- which
- } = newVal
- this.tempRange.before = before
- this.tempRange.after = after
- if (fulldate) {
- this.cale.setHoverMultiple(fulldate)
- this.cale.lastHover = true
- if (this.rangeWithinMonth(after, before)) return
- this.setDate(before)
- this.cale.setMultiple(fulldate)
- this.setDate(this.nowDate.fullDate)
- this.calendar.fullDate = ''
- this.cale.lastHover = false
- this.cale.setDefaultMultiple(before, after)
- if (which === 'left' && before) {
- } else if(after) {
- this.setDate(after)
- }, 16)
- 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 : ''
- 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")
- return t("uni-datetime-picker.ok")
- yearText() {
- return t("uni-datetime-picker.year")
- monthText() {
- return t("uni-datetime-picker.month")
- MONText() {
- confirmText() {
- return t("uni-calender.confirm")
- // 获取日历方法实例
- // 选中某一天
- leaveCale() {
- this.firstEnter = true
- handleMouse(weeks) {
- if (this.cale.lastHover) return
- } = this.cale.multipleStatus
- if (!before) return
- // 设置范围选
- this.cale.setHoverMultiple(this.calendar.fullDate)
- // 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.$emit('maskClose')
- clearCalender() {
- 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.time = ''
- this.tempSingleDate = ''
- this.setDate(new Date())
- this.cale.setDate(date || new Date())
- this.calendar = {...this.nowDate}
- if(!date){
- // 优化date为空默认不选中今天
- 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 = {
- day
- this.tempSingleDate = fullDate
- this.time = getTime(defaultDate, this.hideSecond)
- 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)
- time: this.time,
- timeRange: this.timeRange,
- this.calendar.userChecked = true
- this.cale.setMultiple(this.calendar.fullDate, true)
- 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
- this.tempRange.before = this.cale.multipleStatus.before
- this.tempRange.after = this.cale.multipleStatus.after
- 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)
- background-color: rgba(0, 0, 0, 0.4);
- .uni-calendar__content-mobile {
- box-shadow: 0px 0px 5px 3px rgba(0, 0, 0, 0.1);
- .uni-calendar__header-mobile {
- padding: 10px;
- padding-bottom: 0;
- border-top-color: rgba(0, 0, 0, 0.4);
- background-color: #f1f1f1;
- font-size: 15px;
- .uni-calendar__button-text {
- letter-spacing: 3px;
- width: 9px;
- height: 9px;
- border-left-color: #808080;
- border-left-width: 1px;
- border-top-color: #555555;
- color: #B2B2B2;
- // padding: 0 10px;
- padding-bottom: 7px;
- .uni-date-changed {
- // line-height: 50px;
- border-top-color: #DCDCDC;
- ;
- .uni-date-btn--ok {
- padding: 20px 15px;
- .uni-date-changed--time-start {
- .uni-date-changed--time-end {
- .uni-date-changed--time-date {
- line-height: 50px;
- /* #ifdef MP-TOUTIAO */
- // opacity: 0.6;
- .time-picker-style {
- // width: 62px;
- align-items: center
- .mr-10 {
- padding: 0 25px;
- margin-top: 10px;
- background-color: #737987;
- .uni-datetime-picker--btn {
- line-height: 40px;
- letter-spacing: 2px;
- .uni-datetime-picker--btn:active {
- "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.SUN": "SUN",
- "uni-calender.confirm": "confirm"
- "uni-datetime-picker.selectDate": "选择日期",
- "uni-datetime-picker.selectTime": "选择时间",
- "uni-datetime-picker.selectDateTime": "选择日期时间",
- "uni-datetime-picker.startDate": "开始日期",
- "uni-datetime-picker.endDate": "结束日期",
- "uni-datetime-picker.startTime": "开始时间",
- "uni-datetime-picker.endTime": "结束时间",
- "uni-datetime-picker.ok": "确定",
- "uni-datetime-picker.clear": "清除",
- "uni-datetime-picker.cancel": "取消",
- "uni-datetime-picker.year": "年",
- "uni-datetime-picker.month": "月",
- "uni-calender.SAT": "六",
- "uni-calender.confirm": "确认"
- "uni-datetime-picker.selectDate": "選擇日期",
- "uni-datetime-picker.selectTime": "選擇時間",
- "uni-datetime-picker.selectDateTime": "選擇日期時間",
- "uni-datetime-picker.startDate": "開始日期",
- "uni-datetime-picker.endDate": "結束日期",
- "uni-datetime-picker.startTime": "開始时间",
- "uni-datetime-picker.endTime": "結束时间",
- "uni-datetime-picker.ok": "確定",
- "uni-calender.confirm": "確認"
@@ -1,934 +0,0 @@
- <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 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">
- <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>
- </picker-view-column>
- <view class="uni-datetime-picker-item" v-for="(item,index) in months" :key="index">
- <view class="uni-datetime-picker-item" v-for="(item,index) in days" :key="index">
- </picker-view>
- <!-- 兼容 nvue 不支持伪类 -->
- <text class="uni-datetime-picker-sign sign-left">-</text>
- <text class="uni-datetime-picker-sign sign-right">-</text>
- <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">
- <view class="uni-datetime-picker-item" v-for="(item,index) in hours" :key="index">
- <view class="uni-datetime-picker-item" v-for="(item,index) in minutes" :key="index">
- <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-sign" :class="[hideSecond ? 'sign-center' : 'sign-left']">:</text>
- <text v-if="!hideSecond" class="uni-datetime-picker-sign sign-right">:</text>
- <view class="uni-datetime-picker-btn">
- <view @click="clearTime">
- <text class="uni-datetime-picker-btn-text">{{clearText}}</text>
- <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 @click="setTime">
- <text class="uni-datetime-picker-btn-text">{{okText}}</text>
- import { fixIosDateFormat } from './util'
- * DatetimePicker 时间选择器
- * @description 可以同时选择日期和时间的选择器
- * @property {String} type = [datetime | date | time] 显示模式
- * @property {String|Number} value 默认值
- * @property {String|Number} start 起始日期或时间
- * @property {String|Number} end 起始日期或时间
- * @property {String} return-type = [timestamp | string]
- name: 'UniDatetimePicker',
- indicatorStyle: `height: 50px;`,
- visible: false,
- fixNvueBug: {},
- dateShow: true,
- timeShow: true,
- title: '日期和时间',
- // 输入框当前时间
- // 当前的年月日时分秒
- 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,
- default: 'datetime'
- end: {
- returnType: {
- default: 'string'
- this.parseValue(fixIosDateFormat(newVal))
- this.initTime(false)
- this.parseValue(Date.now())
- 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 = '时间'
- this.title = '日期和时间'
- this.parseDatetimeRange(fixIosDateFormat(newVal), 'start')
- this.parseDatetimeRange(fixIosDateFormat(newVal), 'end')
- // 月、日、时、分、秒可选范围变化后,检查当前值是否在范围内,不在则当前值重置为可选范围第一项
- 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)
- // 当前年、月、日、时、分、秒选择范围
- 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
- return 1
- maxMonth() {
- if (this.year === this.endYear) {
- return this.endMonth
- return 12
- minDay() {
- if (this.year === this.startYear && this.month === this.startMonth) {
- return this.startDay
- maxDay() {
- if (this.year === this.endYear && this.month === this.endMonth) {
- return this.endDay
- return this.daysInMonth(this.year, this.month)
- minHour() {
- if (this.type === 'datetime') {
- if (this.currentDateIsStart) {
- return this.startHour
- return 0
- if (this.type === 'time') {
- maxHour() {
- if (this.currentDateIsEnd) {
- return this.endHour
- return 23
- minMinute() {
- if (this.currentDateIsStart && this.hour === this.startHour) {
- return this.startMinute
- if (this.hour === this.startHour) {
- maxMinute() {
- if (this.currentDateIsEnd && this.hour === this.endHour) {
- return this.endMinute
- return 59
- if (this.hour === this.endHour) {
- minSecond() {
- if (this.currentDateIsStart && this.hour === this.startHour && this.minute === this.startMinute) {
- return this.startSecond
- if (this.hour === this.startHour && this.minute === this.startMinute) {
- maxSecond() {
- if (this.currentDateIsEnd && this.hour === this.endHour && this.minute === this.endMinute) {
- return this.endSecond
- if (this.hour === this.endHour && this.minute === this.endMinute) {
- selectTimeText() {
- return t("uni-datetime-picker.selectTime")
- clearText() {
- return t("uni-datetime-picker.clear")
- return t("uni-datetime-picker.cancel")
- const res = uni.getSystemInfoSync();
- this.fixNvueBug = {
- top: res.windowHeight / 2,
- left: res.windowWidth / 2
- * 小于 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)
- 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)
- 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)
- return winner
- * 转换为可比较的时间戳,接受日期、时分秒、时间戳
- 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) {
- if (this.type === 'time' && typeof value === "string") {
- this.parseTimeType(value)
- 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,年月日字符串、时间戳
- 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
- const pointArr = point.split(':')
- this[pointType + 'Hour'] = Number(pointArr[0])
- this[pointType + 'Minute'] = Number(pointArr[1])
- this[pointType + 'Second'] = Number(pointArr[2])
- pointType === 'start' ? this.startYear = this.year - 60 : this.endYear = this.year + 60
- 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()
- 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();
- //兼容 iOS、safari 日期格式
- fixIosDateFormat(value) {
- if (typeof value === 'string') {
- value = value.replace(/-/g, '/')
- return value
- * 生成时间戳
- * @param {Object} time
- createTimeStamp(time) {
- if (!time) return
- if (typeof time === "number") {
- 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)
- return yymmdd
- } else if (this.type === 'time') {
- return hhmmss
- 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))
- this.$emit('change', this.time)
- this.$emit('input', this.time)
- this.$emit('update:modelValue', this.time)
- * 用户选择日期或时间更新 data
- * @param {Object} 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) {
- this.hour = this.hours[val[0]]
- this.minute = this.minutes[val[1]]
- this.second = this.seconds[val[2]]
- * 初始化弹出层
- initTimePicker() {
- const value = fixIosDateFormat(this.time)
- this.initPickerValue(value)
- this.visible = !this.visible
- * 触发或关闭弹框
- tiggerTimePicker(e) {
- * 用户点击“清空”按钮,清空当前值
- clearTime() {
- this.tiggerTimePicker()
- * 用户点击“确定”按钮
- setTime() {
- this.initTime()
- .uni-datetime-picker {
- /* width: 100%; */
- .uni-datetime-picker-view {
- height: 130px;
- width: 270px;
- .uni-datetime-picker-item {
- .uni-datetime-picker-btn {
- margin-top: 60px;
- .uni-datetime-picker-btn-text {
- .uni-datetime-picker-btn-group {
- .uni-datetime-picker-cancel {
- margin-right: 30px;
- .uni-datetime-picker-mask {
- bottom: 0px;
- top: 0px;
- left: 0px;
- right: 0px;
- z-index: 998;
- .uni-datetime-picker-popup {
- padding: 30px;
- height: 500px;
- width: 330px;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- .fix-nvue-height {
- height: 330px;
- .uni-datetime-picker-time {
- .uni-datetime-picker-column {
- .uni-datetime-picker-timebox {
- border: 1px solid #E5E5E5;
- padding: 7px 10px;
- .uni-datetime-picker-timebox-pointer {
- .uni-datetime-picker-disabled {
- cursor: not-allowed !important;
- .uni-datetime-picker-text {
- line-height: 50px
- .uni-datetime-picker-sign {
- top: 53px;
- /* 减掉 10px 的元素高度,兼容nvue */
- .sign-left {
- left: 86px;
- .sign-right {
- right: 86px;
- .sign-center {
- left: 135px;
- .uni-datetime-picker__container-box {
- margin-top: 40px;
- .time-hide-second {
- width: 180px;
@@ -1,403 +0,0 @@
- range,
- this.date = this.getDateObj(new Date()) // 当前初入日期
- // 终止时间
- // 是否范围选择
- this.lastHover = false
- const selectDate = this.getDateObj(date)
- this.getWeeks(selectDate.fullDate)
- setStartDate(startDate) {
- setEndDate(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.setMonth(oldMonth + 1)
- if(newMonth - oldMonth > 1){
- * 获取指定格式Date对象
- getDateObj(date) {
- fullDate: getDate(date),
- 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(),
- * 获取本月日期集合
- getCurrentMonthDays(amount, dateObj) {
- 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)) {
- disableBefore = dateCompare(this.startDate, currentDate)
- disableAfter = dateCompare(currentDate, this.endDate)
- if (this.range && multiples) {
- return this.dateEqual(item, currentDate)
- const checked = multiplesStatus !== -1
- fullDate: currentDate,
- year: dateObj.year,
- 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
- * 获取下一个月日期集合
- _getNextMonthDays(amount, dateObj) {
- const month = dateObj.month + 1
- return this.calendar.find(item => item.fullDate === this.getDateObj(date).fullDate)
- before = new Date(fixIosDateFormat(before))
- after = new Date(fixIosDateFormat(after))
- return before.valueOf() === after.valueOf()
- * 比较真实起始日期
- isLogicBefore(currentDate, before, after) {
- let logicBefore = before
- logicBefore = dateCompare(before, after) ? before : after
- return this.dateEqual(logicBefore, currentDate)
- isLogicAfter(currentDate, before, after) {
- let logicAfter = after
- logicAfter = dateCompare(before, after) ? after : before
- return this.dateEqual(logicAfter, currentDate)
- arr.push(this.getDateObj(new Date(parseInt(k))).fullDate)
- if (!this.lastHover) {
- this.lastHover = true
- this.multipleStatus.fulldate = ''
- if (dateCompare(this.multipleStatus.before, this.multipleStatus.after)) {
- this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus
- .after);
- this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus
- .before);
- this.getWeeks(fullDate)
- * 鼠标 hover 更新多选状态
- setHoverMultiple(fullDate) {
- if (!this.range || this.lastHover) return
- const { before } = this.multipleStatus
- * 更新默认值多选状态
- setDefaultMultiple(before, after) {
- this.multipleStatus.before = before
- this.multipleStatus.after = after
- if (dateCompare(before, after)) {
- this.multipleStatus.data = this.geDateAll(before, after);
- this.getWeeks(after)
- this.multipleStatus.data = this.geDateAll(after, before);
- this.getWeeks(before)
- getWeeks(dateData) {
- } = 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
-function getDateTime(date, hideSecond){
- return `${getDate(date)} ${getTime(date, hideSecond)}`
-function getDate(date) {
- const year = date.getFullYear()
- const month = date.getMonth()+1
- const day = date.getDate()
- return `${year}-${addZero(month)}-${addZero(day)}`
-function getTime(date, hideSecond){
- 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)) {
-export {Calendar, getDateTime, getDate, getTime, addZero, getDefaultSecond, dateCompare, checkDate, fixIosDateFormat}
@@ -1,87 +0,0 @@
- "id": "uni-datetime-picker",
- "displayName": "uni-datetime-picker 日期选择器",
- "version": "2.2.22",
- "description": "uni-datetime-picker 日期时间选择器,支持日历,支持范围选择",
- "uni-datetime-picker",
- "日期时间选择器",
- "日期时间"
@@ -1,21 +0,0 @@
-> `重要通知:组件升级更新 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)
@@ -1,13 +0,0 @@
-## 1.2.1(2021-11-22)
-- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-drawer](https://uniapp.dcloud.io/component/uniui/uni-drawer)
-## 1.1.0(2021-07-13)
-## 1.0.7(2021-05-12)
- // this.$once('hook:beforeDestroy', () => {
- // document.removeEventListener('keyup', listener)
- // })
@@ -1,183 +0,0 @@
- <view v-if="visibleSync" :class="{ 'uni-drawer--visible': showDrawer }" class="uni-drawer" @touchmove.stop.prevent="clear">
- <view class="uni-drawer__mask" :class="{ 'uni-drawer__mask--visible': showDrawer && mask }" @tap="close('mask')" />
- <view class="uni-drawer__content" :class="{'uni-drawer--right': rightMode,'uni-drawer--left': !rightMode, 'uni-drawer__content--visible': showDrawer}" :style="{width:drawerWidth+'px'}">
- <!-- #ifdef H5 -->
- <keypress @esc="close('mask')" />
- import keypress from './keypress.js'
- * Drawer 抽屉
- * @description 抽屉侧滑菜单
- * @tutorial https://ext.dcloud.net.cn/plugin?id=26
- * @property {Boolean} mask = [true | false] 是否显示遮罩
- * @property {Boolean} maskClick = [true | false] 点击遮罩是否关闭
- * @property {Boolean} mode = [left | right] Drawer 滑出位置
- * @value left 从左侧滑出
- * @value right 从右侧侧滑出
- * @property {Number} width 抽屉的宽度 ,仅 vue 页面生效
- * @event {Function} close 组件关闭时触发事件
- name: 'UniDrawer',
- keypress
- * 显示模式(左、右),只在初始化生效
- * 蒙层显示状态
- mask: {
- * 遮罩是否可点击关闭
- maskClick:{
- * 抽屉宽度
- width: {
- default: 220
- visibleSync: false,
- showDrawer: false,
- rightMode: false,
- watchTimer: null,
- drawerWidth: 220
- this.drawerWidth = this.width
- this.rightMode = this.mode === 'right'
- clear(){},
- close(type) {
- // fixed by mehaotian 抽屉尚未完全关闭或遮罩禁止点击时不触发以下逻辑
- if((type === 'mask' && !this.maskClick) || !this.visibleSync) return
- this._change('showDrawer', 'visibleSync', false)
- // fixed by mehaotian 处理重复点击打开的事件
- if(this.visibleSync) return
- this._change('visibleSync', 'showDrawer', true)
- _change(param1, param2, status) {
- this[param1] = status
- if (this.watchTimer) {
- clearTimeout(this.watchTimer)
- this.watchTimer = setTimeout(() => {
- this[param2] = status
- this.$emit('change',status)
- }, status ? 50 : 300)
- $uni-mask: rgba($color: #000000, $alpha: 0.4) ;
- // 抽屉宽度
- $drawer-width: 220px;
- .uni-drawer {
- .uni-drawer__content {
- width: $drawer-width;
- background-color: $uni-bg-color;
- transition: transform 0.3s ease;
- .uni-drawer--left {
- transform: translateX(-$drawer-width);
- transform: translateX(-100%);
- .uni-drawer--right {
- transform: translateX($drawer-width);
- transform: translateX(100%);
- .uni-drawer__content--visible {
- transform: translateX(0px);
- .uni-drawer__mask {
- background-color: $uni-mask;
- transition: opacity 0.3s;
- .uni-drawer__mask--visible {
- "id": "uni-drawer",
- "displayName": "uni-drawer 抽屉",
- "version": "1.2.1",
- "description": "抽屉式导航,用于展示侧滑菜单,侧滑导航。",
- "drawer",
- "抽屉",
- "侧滑导航"
-## Drawer 抽屉
-> **组件名:uni-drawer**
-> 代码块: `uDrawer`
-抽屉侧滑菜单。
-### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-drawer)
@@ -1,97 +0,0 @@
-## 1.1.9(2023-04-11)
-- 修复 vue3 下 keyboardheightchange 事件报错的bug
-## 1.1.8(2023-03-29)
-- 优化 trim 属性默认值
-## 1.1.7(2023-03-29)
-- 新增 cursor-spacing 属性
-## 1.1.6(2023-01-28)
-- 新增 keyboardheightchange 事件,可监听键盘高度变化
-## 1.1.5(2022-11-29)
-- 优化 主题样式
-## 1.1.4(2022-10-27)
-- 修复 props 中背景颜色无默认值的bug
-## 1.1.0(2022-06-30)
-- 新增 在 uni-forms 1.4.0 中使用可以在 blur 时校验内容
-- 新增 clear 事件,点击右侧叉号图标触发
-- 新增 change 事件 ,仅在输入框失去焦点或用户按下回车时触发
-- 优化 组件样式,组件获取焦点时高亮显示,图标颜色调整等
-## 1.0.5(2022-06-07)
-- 优化 clearable 显示策略
-## 1.0.4(2022-06-07)
-## 1.0.3(2022-05-20)
-- 修复 关闭图标某些情况下无法取消的 bug
-## 1.0.2(2022-04-12)
-- 修复 默认值不生效的 bug
-## 1.0.1(2022-04-02)
-- 修复 value 不能为 0 的 bug
-- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-easyinput](https://uniapp.dcloud.io/component/uniui/uni-easyinput)
-## 0.1.4(2021-08-20)
-- 修复 在 uni-forms 的动态表单中默认值校验不通过的 bug
-## 0.1.3(2021-08-11)
-## 0.1.2(2021-07-30)
-- 优化 vue3 下事件警告的问题
-## 0.1.1
-- 优化 errorMessage 属性支持 Boolean 类型
-## 0.1.0(2021-07-13)
-## 0.0.16(2021-06-29)
-- 修复 confirmType 属性(仅 type="text" 生效)导致多行文本框无法换行的 bug
-## 0.0.15(2021-06-21)
-- 修复 passwordIcon 属性拼写错误的 bug
-## 0.0.14(2021-06-18)
-- 新增 passwordIcon 属性,当 type=password 时是否显示小眼睛图标
-- 修复 confirmType 属性不生效的问题
-## 0.0.13(2021-06-04)
-- 修复 disabled 状态可清出内容的 bug
-## 0.0.12(2021-05-12)
-## 0.0.11(2021-05-07)
-- 修复 input-border 属性不生效的问题
-## 0.0.10(2021-04-30)
-- 修复 ios 遮挡文字、显示一半的问题
-## 0.0.9(2021-02-05)
-- 优化 兼容 nvue 页面
@@ -1,56 +0,0 @@
- * @desc 函数防抖
- * @param func 目标函数
- * @param wait 延迟执行毫秒数
- * @param immediate true - 立即执行, false - 延迟执行
-export const debounce = function(func, wait = 1000, immediate = true) {
- let timer;
- console.log(1);
- return function() {
- console.log(123);
- let context = this,
- args = arguments;
- if (timer) clearTimeout(timer);
- if (immediate) {
- let callNow = !timer;
- timer = null;
- }, wait);
- if (callNow) func.apply(context, args);
- func.apply(context, args);
- }, wait)
- * @desc 函数节流
- * @param func 函数
- * @param type 1 使用表时间戳,在时间段开始的时候触发 2 使用表定时器,在时间段结束的时候触发
-export const throttle = (func, wait = 1000, type = 1) => {
- let previous = 0;
- let timeout;
- let context = this;
- let args = arguments;
- if (type === 1) {
- let now = Date.now();
- if (now - previous > wait) {
- previous = now;
- } else if (type === 2) {
- if (!timeout) {
- timeout = setTimeout(() => {
- timeout = null;
- func.apply(context, args)