New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@smt-ui/component

Package Overview
Dependencies
Maintainers
8
Versions
150
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@smt-ui/component - npm Package Compare versions

Comparing version 0.0.38-alpha.0 to 0.0.39-alpha.0

7

package.json
{
"name": "@smt-ui/component",
"version": "0.0.38-alpha.0",
"version": "0.0.39-alpha.0",
"description": "extension base",

@@ -40,3 +40,6 @@ "author": "jialipeng <jialipeng@baidu.com>",

},
"gitHead": "0b4c348b29307af2e979154939ad7b454e85e2fa"
"gitHead": "2d91807caacf4f387a97c0233bb1ae4346d40fab",
"dependencies": {
"@babel/runtime": "^7.7.7"
}
}

@@ -1,1 +0,1 @@

{"npmPackageName":"@smt-ui/component","npmPackageVersion":"0.0.37-alpha.0","componentsList":[{"name":"layout","label":"布局组件","icon":"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2NiA2NiI+PHBhdGggZD0iTTIzLjkgMjUuOGMtMS40IDAtMi41IDEuMS0yLjUgMi41VjM5YzAgMS40IDEuMSAyLjUgMi41IDIuNXMyLjUtMS4xIDIuNS0yLjVWMjguM2MwLTEuNC0xLjEtMi41LTIuNS0yLjV6TTQ1LjkgMjYuOWMtMS0xLTIuNS0xLTMuNSAwTDM4IDMxLjNjLS42LjYtLjkgMS40LS44IDIuMi0uMS44LjIgMS42LjggMi4xbDQuNCA0LjRjLjUuNSAxLjEuNyAxLjguN3MxLjMtLjMgMS44LS43LjctMS4xLjctMS44LS4zLTEuMy0uNy0xLjhsLTMtMyAzLTNjLjktLjkuOS0yLjUtLjEtMy41eiIvPjxwYXRoIGQ9Ik01MC44IDE0LjdjLTMuNy0xLjgtMTAuNC0zLjEtMTcuNi0zLjItNy4yLjEtMTQgMS4zLTE3LjcgMy4yLTUuNyAyLjctOCA4LjMtOCAxOS4yIDAgOC43IDIuNCAxNSA2LjUgMTcuMiA1LjMgMi43IDEwLjEgMy42IDE5LjEgMy42IDkuMSAwIDEzLjktLjkgMTktMy41IDQuMi0yLjMgNi42LTguNyA2LjYtMTcuMyAwLTEwLjgtMi40LTE2LjUtNy45LTE5LjJ6bTIuOSAxOS4xYzAgNy40LTIgMTEuOC0zLjkgMTIuOS0zLjggMS45LTcuNiAyLjktMTYuNyAyLjktOSAwLTEyLjktMS0xNi44LTIuOS0xLjktMS0zLjgtNS41LTMuOC0xMi45IDAtOC43IDEuNS0xMi45IDUuMS0xNC44IDMtMS41IDkuMi0yLjYgMTUuNS0yLjYgNi4zLjEgMTIuNSAxLjIgMTUuNSAyLjYgMy42IDEuOSA1LjEgNi4xIDUuMSAxNC44eiIvPjwvc3ZnPg==","components":[{"name":"smt-feed-item","label":"信息流子项","description":"信息流子项:包括左文右图、纯文本、上文下图、多图及视频模式。","codeSnap":"<smt-feed-item theme='default' content='title: '宠物自己在家时, 如何帮助它度过孤独时光',infoSource: '萌宠在家',commentsNum: 2' status='0'></smt-feed-item>","groups":"layout","fragement":"swanide://fragment/afebdafc13cda2201207a3d6721577481577175550244","properties":{"attributes":[{"name":"theme","type":"string","description":"信息流子项的主题","required":"是","default":"default"},{"name":"content","type":"Object","description":"信息流子项目的内容","required":"是","default":"{title: '标题',infoSource: '网易新闻',commentsNum: 2,images: []}"},{"name":"video","type":"Object","description":"是否为视频和视频信息","required":"否","default":"{isVideo: true, time: '05:00'}"},{"name":"status","type":"String","description":"阅读状态:0未读,1已读","required":"否","default":"0"}],"events":[{"name":"bindfeeditemtap","type":"Event","description":"点击feed-item之后的回调","required":"否","default":"-"}]},"type":"component","doc":"https://smartprogram.baidu.com/docs/develop/component/smt-feed-item","qrCode":"https://b.bdstatic.com/miniapp/assets/images/doc_demo/smt-feed-item.png","usingComponents":{"smt-feed-item":"@smt-ui/component/src/feed-item"}},{"name":"smt-feed","label":"信息流","description":"信息流组件,可配置下拉刷新、列表加载、上滑加载功能,适用于列表信息展示,并可放置在页面的任何部分;组件包含手势下拉以及api调用两种使用方式\n* 注意:\n1. 和scroll-view一样,信息流组件作为局部滚动组件,必须在它的父级或本身指定高度\n2. 当同时启用下拉刷新和上滑加载且请求不稳定时,可使用CancelToken取消先前的请求","codeSnap":"<smt-feed pull-to-refresh><view>list</view></smt-feed>","groups":"layout","fragement":"swanide://fragment/7b9bf19d0c974d45d9b68fd9fc4429b31577200628346","properties":{"attributes":[{"name":"theme","type":"String","description":"主题配置,默认浅色;深色主题请指定dark","required":"否","default":"-"},{"name":"loadingHeight","type":"Number","description":"加载、话术区域高度,单位为设备px,转换方法: import {upx2dpx} from '@smt-ui/component/src/common/utils/px';","required":"否","default":"192px(设计稿宽度为1242)"},{"name":"pullToRefresh","type":"Boolean","description":"是否开启手势下拉刷新; 默认只能通过组件api调起","required":"否","default":"false"},{"name":"lowerThreshold","type":"Number","description":"触发scrolltolower事件的阈值","required":"否","default":"150px(设备上的px)"},{"name":"text","type":"String","description":"加载成功时的展示话术","required":"否","default":"建议最多显示18个汉字,超出内容截断"},{"name":"refresh","type":"EventHandle","description":"手势滑动触发加载时,响应该onRefresh事件; 通过调用api加载,不会触发该事件","required":"否","default":""},{"name":"startRefresh","type":"EventHandle","description":"手动调用该api,触发加载","required":"否","default":""},{"name":"stopRefresh","type":"EventHandle","description":"手动调用该api,停止加载,并弹出加载提示(对应属性text);可使用await等待关闭动画结束","required":"否","default":""},{"name":"closeLoading","type":"EventHandle","description":"手动调用该api,立即关闭加载,不弹出加载提示;例如接口异常,建义直接关闭加载(小球交替一次大约为500ms,调用前可加延时避免关闭太快)","required":"否","default":""},{"name":"smt-feed-container","type":"externalClass","description":"组件整体class名","required":"否","default":"-"},{"name":"smt-feed-loading","type":"externalClass","description":"加载区域class名","required":"否","default":"-"},{"name":"smt-feed-content","type":"externalClass","description":"滚动区域class名,用于设置ios回弹背景","required":"false","default":""},{"name":"smt-refresh-circle-left","type":"externalClass","description":"加载中左侧小球class名","required":"否","default":"-"},{"name":"smt-refresh-circle-right","type":"externalClass","description":"加载中右侧小球class名","required":"否","default":"-"},{"name":"ext-cls-content","type":"externalClass","description":"滚动区域class名","required":"否","default":"-"},{"name":"smt-refresh-result-container","type":"externalClass","description":"加载话术外框class名","required":"否","default":"-"},{"name":"ext-cls-result-text","type":"externalClass","description":"加载话术文字class名","required":"否","default":"-"}],"events":[{"name":"bindscroll","type":"Event","description":"滚动时触发,返回当前组件的值","required":"否","default":"-"}]},"type":"component","doc":"https://smartprogram.baidu.com/docs/develop/component/smt-feed","qrCode":"https://b.bdstatic.com/miniapp/assets/images/doc_demo/smt-feed.png","usingComponents":{"smt-feed":"@smt-ui/component/src/feed"}},{"name":"smt-icon","label":"图标","description":"包括天气、系统设置、互动社交、生活服务、书籍影音、政务服务、交通出行7个行业类别的图标。请扫描示例二维码查看图标全集。","codeSnap":"<smt-icon name='add'></smt-icon>","groups":"layout","fragement":"swanide://fragment/1151cb408d98313c4e79bb6a62755bfa1577193673206","properties":{"attributes":[{"name":"name","type":"String","description":"icon的英文名称","required":"是"},{"name":"color","type":"String, Array.<String>","description":"icon的颜色,多色图标支持传入色值的数组"},{"name":"size","type":"Number","description":"icon的尺寸,单位px","default":25}],"events":[]},"type":"component","doc":"https://smartprogram.baidu.com/docs/develop/component/smt-icon","qrCode":"https://b.bdstatic.com/miniapp/assets/images/doc_demo/smt-icon.png","usingComponents":{"smt-icon":"@smt-ui/component/src/icon"}},{"name":"navigation","label":"顶部导航bar","description":"顶部导航bar可以自定义","codeSnap":"<smt-navigation></smt-navigation>","groups":"layout","properties":{"properties":[],"events":[]},"type":"component","doc":"https://smartprogram.baidu.com/docs/develop/component/navigation","qrCode":"https://b.bdstatic.com/miniapp/assets/images/doc_demo/navigation.png","usingComponents":{"navigation":"@smt-ui/component/src/navigation"}},{"name":"smt-page-status","label":"页面状态组件","description":"页面状态组件,可用于全屏和半屏。用于展示页面加载,页面异常-有操作、页面异常-无操作三种页面状态。","codeSnap":"<smt-page-status></smt-page-status>","groups":"layout","fragment":"swanide://fragment/4cc92982287ac8a30b5fe19f220dc8f71577190736077","properties":{"attributes":[{"name":"theme","type":"String","description":"主题配置,默认浅色;沉浸式主题请指定dark","required":"否","default":""},{"name":"loading","type":"Boolean","description":"页面状态配置,默认不展示加载状态页面","required":"否","default":"false"},{"name":"icon","type":"String","description":"空态/缺省页面下的图标名称","required":"否","default":"content"},{"name":"loadingTitle","type":"String","description":"加载页面下的标题文案","required":"否","default":"正在加载..."},{"name":"title","type":"String","description":"空态/缺省页面下的标题文案","required":"否","default":"单行标题"},{"name":"desc","type":"String","description":"空态/缺省页面下的描述文案","required":"否","default":""},{"name":"showBtn","type":"Boolean","description":"是否展示空态/缺省页面下的操作按钮,默认展示","required":"否","default":"true"},{"name":"btnText","type":"String","description":"空态/缺省页面下,操作按钮的描述文案,建议最多显示4个汉字,超出内容截断","required":"否","default":"重新加载"}],"events":[{"name":"reloading","type":"Event","description":"空态/缺省页面下,点击操作按钮时触发","required":"否","default":"-"}]},"type":"component","doc":"https://smartprogram.baidu.com/docs/develop/component/smt-page-status","qrCode":"https://b.bdstatic.com/miniapp/assets/images/doc_demo/smt-page-status.png","usingComponents":{"smt-page-status":"@smt-ui/component/src/page-status"}},{"name":"publish","label":"发布器","description":"发布器组件可以用于用户直接发布文章使用,可以包含文字与图片,在支持发布器的客户端上,会直接调用API来展示发布器,在不支持发布器的客户端上,则会展示降级版的发布器","codeSnap":"<smt-publish></smt-publish>","groups":"layout","properties":{"attributes":[{"name":"theme","type":"String","description":"主题配置,默认浅色;深色主题请指定dark","required":"false","default":"-"},{"name":"loadingHgt","type":"Number","description":"加载区域高度","required":"false","default":"192px(需转换为设备尺寸)"},{"name":"offsetY","type":"Number","description":"垂直移动距离,*建议后续在sjs中使用","required":"false","default":"0"},{"name":"status","type":"Number","description":"加载状态 0: 未开始 1: 加载中 2: 展示话术","required":"false","default":"0"},{"name":"text","type":"String","description":"加载成功时的展示话术","required":"false","default":"建议最多显示18个汉字,超出内容截断"}],"events":[]},"type":"component","doc":"https://smartprogram.baidu.com/docs/develop/component/publish","qrCode":"https://b.bdstatic.com/miniapp/assets/images/doc_demo/publish.png","usingComponents":{"publish":"@smt-ui/component/src/publish"}},{"name":"smt-refresh","label":"刷新","description":"可用于页面任意区域;使用时需自行添加下拉逻辑改变offset-y参数;smt-feed组件对smt-refresh进行了封装,支持手势交互和api调起刷新。","codeSnap":"<smt-refresh offset-y=\"{{0}}\" status=\"{{1}}\" text=\"为你推荐15条更新\"></smt-refresh>","fragement":"swanide://fragment/598510a21b650b89e2e5d13c814dc46c1577192328823","groups":"layout","properties":{"attributes":[{"name":"theme","type":"String","description":"主题配置,默认浅色;深色主题请指定dark","required":"否","default":"-"},{"name":"loadingHgt","type":"Number","description":"加载区域高度","required":"否","default":"192px(需转换为设备尺寸)"},{"name":"offsetY","type":"Number","description":"垂直移动距离,*建议后续在sjs中使用","required":"否","default":"0"},{"name":"status","type":"Number","description":"加载状态 0: 未开始 1: 加载中 2: 展示话术","required":"否","default":"0"},{"name":"text","type":"String","description":"加载成功时的展示话术","required":"否","default":"建议最多显示18个汉字,超出内容截断"}],"events":[]},"type":"component","doc":"https://smartprogram.baidu.com/docs/develop/component/smt-refresh","qrCode":"https://b.bdstatic.com/miniapp/assets/images/doc_demo/smt-refresh.png","usingComponents":{"smt-refresh":"@smt-ui/component/src/refresh"}},{"name":"smt-spin","label":"加载","description":"加载组件,可用于全屏和半屏。用于展示加载状态,点击加载、正在加载、加载完成、重新加载四种状态。","codeSnap":"<spin status='1'></spin>","groups":"layout","fragement":"swanide://fragment/25af44248f8aad73b64e274ead38d6151577191316430","properties":{"attributes":[{"name":"status","type":"Number","description":"加载状态配置","required":"是"},{"name":"theme","type":"String","description":"主题配置,默认浅色;深色主题请指定dark","required":"否","default":""},{"name":"textConfig","type":"Array","description":"加载状态对应的文案","required":"否","default":"['点击加载更多', '正在加载...', '已经到底啦', '加载失败 点击重新加载']"},{"name":"secureBottom","type":"Boolean","description":"默认兼容iPhoneX 及以上型号底部安全区,非全屏可关闭","required":"否","default":"true"}],"events":[]},"type":"component","doc":"https://smartprogram.baidu.com/docs/develop/component/smt-spin","qrCode":"https://b.bdstatic.com/miniapp/assets/images/doc_demo/smt-spin.png","usingComponents":{"smt-spin":"@smt-ui/component/src/spin"}}]}]}
{"npmPackageName":"@smt-ui/component","npmPackageVersion":"0.0.38-alpha.0","componentsList":[{"name":"layout","label":"布局组件","icon":"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2NiA2NiI+PHBhdGggZD0iTTIzLjkgMjUuOGMtMS40IDAtMi41IDEuMS0yLjUgMi41VjM5YzAgMS40IDEuMSAyLjUgMi41IDIuNXMyLjUtMS4xIDIuNS0yLjVWMjguM2MwLTEuNC0xLjEtMi41LTIuNS0yLjV6TTQ1LjkgMjYuOWMtMS0xLTIuNS0xLTMuNSAwTDM4IDMxLjNjLS42LjYtLjkgMS40LS44IDIuMi0uMS44LjIgMS42LjggMi4xbDQuNCA0LjRjLjUuNSAxLjEuNyAxLjguN3MxLjMtLjMgMS44LS43LjctMS4xLjctMS44LS4zLTEuMy0uNy0xLjhsLTMtMyAzLTNjLjktLjkuOS0yLjUtLjEtMy41eiIvPjxwYXRoIGQ9Ik01MC44IDE0LjdjLTMuNy0xLjgtMTAuNC0zLjEtMTcuNi0zLjItNy4yLjEtMTQgMS4zLTE3LjcgMy4yLTUuNyAyLjctOCA4LjMtOCAxOS4yIDAgOC43IDIuNCAxNSA2LjUgMTcuMiA1LjMgMi43IDEwLjEgMy42IDE5LjEgMy42IDkuMSAwIDEzLjktLjkgMTktMy41IDQuMi0yLjMgNi42LTguNyA2LjYtMTcuMyAwLTEwLjgtMi40LTE2LjUtNy45LTE5LjJ6bTIuOSAxOS4xYzAgNy40LTIgMTEuOC0zLjkgMTIuOS0zLjggMS45LTcuNiAyLjktMTYuNyAyLjktOSAwLTEyLjktMS0xNi44LTIuOS0xLjktMS0zLjgtNS41LTMuOC0xMi45IDAtOC43IDEuNS0xMi45IDUuMS0xNC44IDMtMS41IDkuMi0yLjYgMTUuNS0yLjYgNi4zLjEgMTIuNSAxLjIgMTUuNSAyLjYgMy42IDEuOSA1LjEgNi4xIDUuMSAxNC44eiIvPjwvc3ZnPg==","components":[{"name":"smt-feed-item","label":"信息流子项","description":"信息流子项:包括左文右图、纯文本、上文下图、多图及视频模式。","codeSnap":"<smt-feed-item theme='default' content='title: '宠物自己在家时, 如何帮助它度过孤独时光',infoSource: '萌宠在家',commentsNum: 2' status='0'></smt-feed-item>","groups":"layout","fragement":"swanide://fragment/afebdafc13cda2201207a3d6721577481577175550244","properties":{"attributes":[{"name":"theme","type":"string","description":"信息流子项的主题","required":"是","default":"default"},{"name":"content","type":"Object","description":"信息流子项目的内容","required":"是","default":"{title: '标题',infoSource: '网易新闻',commentsNum: 2,images: []}"},{"name":"video","type":"Object","description":"是否为视频和视频信息","required":"否","default":"{isVideo: true, time: '05:00'}"},{"name":"status","type":"String","description":"阅读状态:0未读,1已读","required":"否","default":"0"}],"events":[{"name":"bindfeeditemtap","type":"Event","description":"点击feed-item之后的回调","required":"否","default":"-"}]},"type":"component","doc":"https://smartprogram.baidu.com/docs/develop/component/smt-feed-item","qrCode":"https://b.bdstatic.com/miniapp/assets/images/doc_demo/smt-feed-item.png","usingComponents":{"smt-feed-item":"@smt-ui/component/src/feed-item"}},{"name":"smt-feed","label":"信息流","description":"信息流组件,可配置下拉刷新、列表加载、上滑加载功能,适用于列表信息展示,并可放置在页面的任何部分;组件包含手势下拉以及api调用两种使用方式\n* 注意:\n1. 和scroll-view一样,信息流组件作为局部滚动组件,必须在它的父级或本身指定高度\n2. 当同时启用下拉刷新和上滑加载且请求不稳定时,可使用CancelToken取消先前的请求","codeSnap":"<smt-feed pull-to-refresh><view>list</view></smt-feed>","groups":"layout","fragement":"swanide://fragment/7b9bf19d0c974d45d9b68fd9fc4429b31577200628346","properties":{"attributes":[{"name":"theme","type":"String","description":"主题配置,默认浅色;深色主题请指定dark","required":"否","default":"-"},{"name":"loadingHeight","type":"Number","description":"加载、话术区域高度,单位为设备px,转换方法: import {upx2dpx} from '@smt-ui/component/src/common/utils/px';","required":"否","default":"192px(设计稿宽度为1242)"},{"name":"pullToRefresh","type":"Boolean","description":"是否开启手势下拉刷新; 默认只能通过组件api调起","required":"否","default":"false"},{"name":"lowerThreshold","type":"Number","description":"触发scrolltolower事件的阈值","required":"否","default":"150px(设备上的px)"},{"name":"text","type":"String","description":"加载成功时的展示话术","required":"否","default":"建议最多显示18个汉字,超出内容截断"},{"name":"refresh","type":"EventHandle","description":"手势滑动触发加载时,响应该onRefresh事件; 通过调用api加载,不会触发该事件","required":"否","default":""},{"name":"startRefresh","type":"EventHandle","description":"手动调用该api,触发加载","required":"否","default":""},{"name":"stopRefresh","type":"EventHandle","description":"手动调用该api,停止加载,并弹出加载提示(对应属性text);可使用await等待关闭动画结束","required":"否","default":""},{"name":"closeLoading","type":"EventHandle","description":"手动调用该api,立即关闭加载,不弹出加载提示;例如接口异常,建义直接关闭加载(小球交替一次大约为500ms,调用前可加延时避免关闭太快)","required":"否","default":""},{"name":"smt-feed-container","type":"externalClass","description":"组件整体class名","required":"否","default":"-"},{"name":"smt-feed-loading","type":"externalClass","description":"加载区域class名","required":"否","default":"-"},{"name":"smt-feed-content","type":"externalClass","description":"滚动区域class名,用于设置ios回弹背景","required":"false","default":""},{"name":"smt-refresh-circle-left","type":"externalClass","description":"加载中左侧小球class名","required":"否","default":"-"},{"name":"smt-refresh-circle-right","type":"externalClass","description":"加载中右侧小球class名","required":"否","default":"-"},{"name":"ext-cls-content","type":"externalClass","description":"滚动区域class名","required":"否","default":"-"},{"name":"smt-refresh-result-container","type":"externalClass","description":"加载话术外框class名","required":"否","default":"-"},{"name":"ext-cls-result-text","type":"externalClass","description":"加载话术文字class名","required":"否","default":"-"}],"events":[{"name":"bindscroll","type":"Event","description":"滚动时触发,返回当前组件的值","required":"否","default":"-"}]},"type":"component","doc":"https://smartprogram.baidu.com/docs/develop/component/smt-feed","qrCode":"https://b.bdstatic.com/miniapp/assets/images/doc_demo/smt-feed.png","usingComponents":{"smt-feed":"@smt-ui/component/src/feed"}},{"name":"smt-icon","label":"图标","description":"包括天气、系统设置、互动社交、生活服务、书籍影音、政务服务、交通出行7个行业类别的图标。请扫描示例二维码查看图标全集。","codeSnap":"<smt-icon name='add'></smt-icon>","groups":"layout","fragement":"swanide://fragment/1151cb408d98313c4e79bb6a62755bfa1577193673206","properties":{"attributes":[{"name":"name","type":"String","description":"icon的英文名称","required":"是"},{"name":"color","type":"String, Array.<String>","description":"icon的颜色,多色图标支持传入色值的数组"},{"name":"size","type":"Number","description":"icon的尺寸,单位px","default":25}],"events":[]},"type":"component","doc":"https://smartprogram.baidu.com/docs/develop/component/smt-icon","qrCode":"https://b.bdstatic.com/miniapp/assets/images/doc_demo/smt-icon.png","usingComponents":{"smt-icon":"@smt-ui/component/src/icon"}},{"name":"navigation","label":"顶部导航bar","description":"顶部导航bar可以自定义","codeSnap":"<smt-navigation></smt-navigation>","groups":"layout","properties":{"properties":[],"events":[]},"type":"component","doc":"https://smartprogram.baidu.com/docs/develop/component/navigation","qrCode":"https://b.bdstatic.com/miniapp/assets/images/doc_demo/navigation.png","usingComponents":{"navigation":"@smt-ui/component/src/navigation"}},{"name":"smt-page-status","label":"页面状态组件","description":"页面状态组件,可用于全屏和半屏。用于展示页面加载,页面异常-有操作、页面异常-无操作三种页面状态。","codeSnap":"<smt-page-status></smt-page-status>","groups":"layout","fragment":"swanide://fragment/4cc92982287ac8a30b5fe19f220dc8f71577190736077","properties":{"attributes":[{"name":"theme","type":"String","description":"主题配置,默认浅色;沉浸式主题请指定dark","required":"否","default":""},{"name":"loading","type":"Boolean","description":"页面状态配置,默认不展示加载状态页面","required":"否","default":"false"},{"name":"icon","type":"String","description":"空态/缺省页面下的图标名称","required":"否","default":"content"},{"name":"loadingTitle","type":"String","description":"加载页面下的标题文案","required":"否","default":"正在加载..."},{"name":"title","type":"String","description":"空态/缺省页面下的标题文案","required":"否","default":"单行标题"},{"name":"desc","type":"String","description":"空态/缺省页面下的描述文案","required":"否","default":""},{"name":"showBtn","type":"Boolean","description":"是否展示空态/缺省页面下的操作按钮,默认展示","required":"否","default":"true"},{"name":"btnText","type":"String","description":"空态/缺省页面下,操作按钮的描述文案,建议最多显示4个汉字,超出内容截断","required":"否","default":"重新加载"}],"events":[{"name":"reloading","type":"Event","description":"空态/缺省页面下,点击操作按钮时触发","required":"否","default":"-"}]},"type":"component","doc":"https://smartprogram.baidu.com/docs/develop/component/smt-page-status","qrCode":"https://b.bdstatic.com/miniapp/assets/images/doc_demo/smt-page-status.png","usingComponents":{"smt-page-status":"@smt-ui/component/src/page-status"}},{"name":"publish","label":"发布器","description":"发布器组件可以用于用户直接发布文章使用,可以包含文字与图片,在支持发布器的客户端上,会直接调用API来展示发布器,在不支持发布器的客户端上,则会展示降级版的发布器","codeSnap":"<smt-publish></smt-publish>","groups":"layout","properties":{"attributes":[{"name":"theme","type":"String","description":"主题配置,默认浅色;深色主题请指定dark","required":"false","default":"-"},{"name":"loadingHgt","type":"Number","description":"加载区域高度","required":"false","default":"192px(需转换为设备尺寸)"},{"name":"offsetY","type":"Number","description":"垂直移动距离,*建议后续在sjs中使用","required":"false","default":"0"},{"name":"status","type":"Number","description":"加载状态 0: 未开始 1: 加载中 2: 展示话术","required":"false","default":"0"},{"name":"text","type":"String","description":"加载成功时的展示话术","required":"false","default":"建议最多显示18个汉字,超出内容截断"}],"events":[]},"type":"component","doc":"https://smartprogram.baidu.com/docs/develop/component/publish","qrCode":"https://b.bdstatic.com/miniapp/assets/images/doc_demo/publish.png","usingComponents":{"publish":"@smt-ui/component/src/publish"}},{"name":"smt-refresh","label":"刷新","description":"可用于页面任意区域;使用时需自行添加下拉逻辑改变offset-y参数;smt-feed组件对smt-refresh进行了封装,支持手势交互和api调起刷新。","codeSnap":"<smt-refresh offset-y=\"{{0}}\" status=\"{{1}}\" text=\"为你推荐15条更新\"></smt-refresh>","fragement":"swanide://fragment/598510a21b650b89e2e5d13c814dc46c1577192328823","groups":"layout","properties":{"attributes":[{"name":"theme","type":"String","description":"主题配置,默认浅色;深色主题请指定dark","required":"否","default":"-"},{"name":"loadingHgt","type":"Number","description":"加载区域高度","required":"否","default":"192px(需转换为设备尺寸)"},{"name":"offsetY","type":"Number","description":"垂直移动距离,*建议后续在sjs中使用","required":"否","default":"0"},{"name":"status","type":"Number","description":"加载状态 0: 未开始 1: 加载中 2: 展示话术","required":"否","default":"0"},{"name":"text","type":"String","description":"加载成功时的展示话术","required":"否","default":"建议最多显示18个汉字,超出内容截断"}],"events":[]},"type":"component","doc":"https://smartprogram.baidu.com/docs/develop/component/smt-refresh","qrCode":"https://b.bdstatic.com/miniapp/assets/images/doc_demo/smt-refresh.png","usingComponents":{"smt-refresh":"@smt-ui/component/src/refresh"}},{"name":"smt-spin","label":"加载","description":"加载组件,可用于全屏和半屏。用于展示加载状态,点击加载、正在加载、加载完成、重新加载四种状态。","codeSnap":"<spin status='1'></spin>","groups":"layout","fragement":"swanide://fragment/25af44248f8aad73b64e274ead38d6151577191316430","properties":{"attributes":[{"name":"status","type":"Number","description":"加载状态配置","required":"是"},{"name":"theme","type":"String","description":"主题配置,默认浅色;深色主题请指定dark","required":"否","default":""},{"name":"textConfig","type":"Array","description":"加载状态对应的文案","required":"否","default":"['点击加载更多', '正在加载...', '已经到底啦', '加载失败 点击重新加载']"},{"name":"secureBottom","type":"Boolean","description":"默认兼容iPhoneX 及以上型号底部安全区,非全屏可关闭","required":"否","default":"true"}],"events":[]},"type":"component","doc":"https://smartprogram.baidu.com/docs/develop/component/smt-spin","qrCode":"https://b.bdstatic.com/miniapp/assets/images/doc_demo/smt-spin.png","usingComponents":{"smt-spin":"@smt-ui/component/src/spin"}}]}]}

@@ -209,3 +209,3 @@ /**

*/
export const syncSetData = async (context, obj = {}) => new Promise(r => context.setData(obj, r));
export const syncSetData = (context, obj = {}) => new Promise(r => context.setData(obj, r));

@@ -212,0 +212,0 @@ /**

@@ -1,13 +0,1 @@

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _px = require("../../common/utils/px");
var _index = require("../../common/utils/index");
/**

@@ -18,719 +6,423 @@ * @file 下拉刷新

*/
var STATUS = {
IDLE: 0,
LOADING: 1,
SHOWTEXT: 2
import {upx2dpx} from '../../common/utils/px';
import {calcCircle, linearAccu, promiseDebounce, syncSetData} from '../../common/utils/index';
const STATUS = {
IDLE: 0,
LOADING: 1,
SHOWTEXT: 2
};
Component({
externalClasses: ['smt-feed-container', 'smt-feed-loading', 'smt-feed-content', 'smt-refresh-circle-left', 'smt-refresh-circle-right', 'smt-refresh-result-container', 'smt-refresh-result-text'],
properties: {
// 是否开启下拉刷新
pullToRefresh: {
type: Boolean,
value: false
},
// loading加载区域高度 * 必须是device px
loadingHeight: {
type: Number,
value: (0, _px.upx2dpx)(192),
observer: function observer(n) {
if (typeof n !== 'number') {
throw 'loadingHeight 必须是数字类型!否则下拉可造成卡顿闪屏';
}
}
},
// 距底部距离 触发 scrolltolower 事件
lowerThreshold: {
type: Number,
value: 150
},
// 加载成功话术 * 不要默认值,prop抖动
text: {
type: String,
value: '',
observer: function observer(n) {
this.clipText(n);
}
},
theme: {
type: String,
value: ''
},
// 禁止下拉 * 场景:处于滚动页面且api加载(demo示例平台)
disableTouch: {
type: Boolean,
value: false
}
},
data: {
// 左右小球信息
circle: {
// 小球尺寸 * device px防止变形
size: (0, _px.upx2dpx)(21),
// 小球移动距离
offsetX: (0, _px.upx2dpx)(33),
// 左右渐隐(有先后)
opacityL: 0,
opacityR: 0,
// 左右距离(有先后)
xL: 0,
xR: 0
},
// 是否禁用scrollView
enableScroll: true,
// 滑动距离
offsetY: 0,
// 滑动区域高度,用于计算阻尼值
clientHeight: 0,
// 最长18个汉字
clipedText: '',
// 0: 未开始 1: 加载中 2: 展示话术
status: STATUS.IDLE,
// 滚动高度
scrollTop: 0
},
methods: {
/**
* 截取18位文字
* @param {string} str 传入的文字
*/
clipText: function clipText(str) {
this.setData({
clipedText: str.slice(0, 18)
});
},
externalClasses: [
'smt-feed-container',
'smt-feed-loading',
'smt-feed-content',
/**
* scrollView 滚动参数
* @param {Object} param Event
*/
scrollHdl: function scrollHdl(_ref) {
var _this = this;
'smt-refresh-circle-left',
'smt-refresh-circle-right',
'smt-refresh-result-container',
'smt-refresh-result-text'
],
var detail = _ref.detail;
this.scrollTop = detail.scrollTop; // 如果是ios惯性,就禁掉回弹
properties: {
// 是否开启下拉刷新
pullToRefresh: {
type: Boolean,
value: false
},
if (this.data.pullToRefresh && this.scrollTop < 0 && this.data.enableScroll && this.offsetY === 0) {
this.setData({
enableScroll: false
}, function () {
_this.setData({
enableScroll: true
});
});
}
// loading加载区域高度 * 必须是device px
loadingHeight: {
type: Number,
value: upx2dpx(192),
observer(n) {
if (typeof n !== 'number') {
throw 'loadingHeight 必须是数字类型!否则下拉可造成卡顿闪屏';
}
}
},
this.triggerEvent('scroll', detail);
},
// 距底部距离 触发 scrolltolower 事件
lowerThreshold: {
type: Number,
value: 150
},
/**
* 阻尼值转换 * 四参方程有常数,便于转换屏幕比
* 两种情况: 滚动区域 > 400 ? 用系数 = .7 : .65
* x: 0, 50, 100, 150, 200, 250, 300, 350, 400, 800, 40000, 120000
* y: 0,32,62,90,115,136,153,164,170,270, 420, 440
*
* @param {number} pullDistance 下拉的总距离
* @param {number=} base 基础值,calc(iphone 8p - 40px)
* @return {number} 返回值
*/
dumping: function dumping(offsetY) {
var base = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 464;
var y = offsetY > 0 ? offsetY : 0;
var ratio = this.data.clientHeight / base;
var result = 0;
// 加载成功话术 * 不要默认值,prop抖动
text: {
type: String,
value: '',
observer(n) {
this.clipText(n);
}
},
if (this.data.clientHeight > 400) {
// 系数 .65
result = (440.5 + .5) * ratio / (1 + Math.pow(y / 551.5665, -1.009)) - .5;
} else {
// 系数 .7
result = (440.0483 + .0510) * ratio / (1 + Math.pow(y / 444.0544, -1.2801)) - .0510;
}
theme: {
type: String,
value: ''
},
return Math.round(result);
// 禁止下拉 * 场景:处于滚动页面且api加载(demo示例平台)
disableTouch: {
type: Boolean,
value: false
}
},
touchHdl: function () {
var _touchHdl = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee(_ref2) {
var _this2 = this;
var type, _ref2$touches, touches, _ref2$changedTouches, changedTouches, _ref2$manual, manual, disabled, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, touch, id, pageY, distance, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, _touch, _id, _pageY, offsetY, pullDown, circleInfo, setOffsetY, _iteratorNormalCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, _touch2, _id2, _pageY2, shouldLoad, result;
data: {
// 左右小球信息
circle: {
// 小球尺寸 * device px防止变形
size: upx2dpx(21),
// 小球移动距离
offsetX: upx2dpx(33),
// 左右渐隐(有先后)
opacityL: 0,
opacityR: 0,
// 左右距离(有先后)
xL: 0,
xR: 0
},
return _regenerator["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
type = _ref2.type, _ref2$touches = _ref2.touches, touches = _ref2$touches === void 0 ? [] : _ref2$touches, _ref2$changedTouches = _ref2.changedTouches, changedTouches = _ref2$changedTouches === void 0 ? [] : _ref2$changedTouches, _ref2$manual = _ref2.manual, manual = _ref2$manual === void 0 ? false : _ref2$manual;
// 是否禁用scrollView
enableScroll: true,
if (!(this.closing || this.data.disableTouch && !manual)) {
_context.next = 3;
break;
}
// 滑动距离
offsetY: 0,
return _context.abrupt("return");
// 滑动区域高度,用于计算阻尼值
clientHeight: 0,
case 3:
// ue规定: 如果api调用下拉刷新,则不启用手势刷新
disabled = !this.data.pullToRefresh && !manual && this.status === STATUS.IDLE; // 禁用多点触控
// 最长18个汉字
clipedText: '',
_context.t0 = type;
_context.next = _context.t0 === 'touchstart' ? 7 : _context.t0 === 'touchmove' ? 37 : _context.t0 === 'touchend' ? 70 : 99;
break;
// 0: 未开始 1: 加载中 2: 展示话术
status: STATUS.IDLE,
case 7:
this.touching = true;
_iteratorNormalCompletion = true;
_didIteratorError = false;
_iteratorError = undefined;
_context.prev = 11;
_iterator = touches[Symbol.iterator]();
// 滚动高度
scrollTop: 0
},
case 13:
if (_iteratorNormalCompletion = (_step = _iterator.next()).done) {
_context.next = 22;
break;
}
methods: {
/**
* 截取18位文字
* @param {string} str 传入的文字
*/
clipText(str) {
this.setData({
clipedText: str.slice(0, 18)
});
},
touch = _step.value;
id = touch.identifier, pageY = touch.pageY;
if (!(this.pos[id] == null)) {
_context.next = 19;
break;
}
this.pos[id] = pageY + this.scrollTop;
return _context.abrupt("break", 22);
case 19:
_iteratorNormalCompletion = true;
_context.next = 13;
break;
case 22:
_context.next = 28;
break;
case 24:
_context.prev = 24;
_context.t1 = _context["catch"](11);
_didIteratorError = true;
_iteratorError = _context.t1;
case 28:
_context.prev = 28;
_context.prev = 29;
if (!_iteratorNormalCompletion && _iterator["return"] != null) {
_iterator["return"]();
}
case 31:
_context.prev = 31;
if (!_didIteratorError) {
_context.next = 34;
break;
}
throw _iteratorError;
case 34:
return _context.finish(31);
case 35:
return _context.finish(28);
case 36:
return _context.abrupt("break", 99);
case 37:
distance = 0;
_iteratorNormalCompletion2 = true;
_didIteratorError2 = false;
_iteratorError2 = undefined;
_context.prev = 41;
for (_iterator2 = touches[Symbol.iterator](); !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
_touch = _step2.value;
_id = _touch.identifier, _pageY = _touch.pageY;
if (this.pos[_id]) {
distance += Math.round(_pageY - this.pos[_id]);
}
}
_context.next = 49;
break;
case 45:
_context.prev = 45;
_context.t2 = _context["catch"](41);
_didIteratorError2 = true;
_iteratorError2 = _context.t2;
case 49:
_context.prev = 49;
_context.prev = 50;
if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) {
_iterator2["return"]();
}
case 52:
_context.prev = 52;
if (!_didIteratorError2) {
_context.next = 55;
break;
}
throw _iteratorError2;
case 55:
return _context.finish(52);
case 56:
return _context.finish(49);
case 57:
offsetY = this.offsetY = this.dumping(distance + this.lastOffsetY);
pullDown = distance > 0; // 没loading动画时下拉计算动画
if (this.status === STATUS.IDLE) {
circleInfo = (0, _index.calcCircle)(offsetY, this.data.loadingHeight);
circleInfo && this.setData(circleInfo);
} // 还未加载时,向上划要收起loading
if (!(!pullDown && this.status !== STATUS.IDLE && Math.abs(offsetY) > 20)) {
_context.next = 66;
break;
}
this.fadeCircle();
/**
* scrollView 滚动参数
* @param {Object} param Event
*/
scrollHdl({detail}) {
this.scrollTop = detail.scrollTop;
// 如果是ios惯性,就禁掉回弹
if (this.data.pullToRefresh && this.scrollTop < 0 && this.data.enableScroll && this.offsetY === 0) {
this.setData({
status: STATUS.IDLE,
offsetY: 0
enableScroll: false
}, () => {
this.setData({
enableScroll: true
});
});
this.status = STATUS.IDLE;
this.lastOffsetY = this.offsetY = 0;
return _context.abrupt("return");
}
this.triggerEvent('scroll', detail);
},
case 66:
if (!disabled) {
_context.next = 68;
break;
}
/**
* 阻尼值转换 * 四参方程有常数,便于转换屏幕比
* 两种情况: 滚动区域 > 400 ? 用系数 = .7 : .65
* x: 0, 50, 100, 150, 200, 250, 300, 350, 400, 800, 40000, 120000
* y: 0,32,62,90,115,136,153,164,170,270, 420, 440
*
* @param {number} pullDistance 下拉的总距离
* @param {number=} base 基础值,calc(iphone 8p - 40px)
* @return {number} 返回值
*/
dumping(offsetY, base = 464) {
const y = offsetY > 0 ? offsetY : 0;
const ratio = this.data.clientHeight / base;
let result = 0;
if (this.data.clientHeight > 400) {
// 系数 .65
result = (440.5 + .5) * ratio / (1 + (y / 551.5665) ** -1.009) - .5;
}
else {
// 系数 .7
result = (440.0483 + .0510) * ratio / (1 + (y / 444.0544) ** -1.2801) - .0510;
}
return Math.round(result);
},
return _context.abrupt("return");
async touchHdl({type, touches = [], changedTouches = [], manual = false}) { // eslint-disable-line fecs-max-statements
// 如果上一次没完全关闭,禁止下拉
if (this.closing || (this.data.disableTouch && !manual)) {
return;
}
// ue规定: 如果api调用下拉刷新,则不启用手势刷新
const disabled = !this.data.pullToRefresh && !manual && this.status === STATUS.IDLE;
case 68:
// offsetY快,setData慢,可能造成向上划没到顶。
// 要注意 初始就向下划,过滤掉
if (offsetY > 0 || this.data.offsetY > 0) {
setOffsetY = function setOffsetY() {
return _this2.setData({
offsetY: offsetY
});
}; // 如果已经禁止滚动&&还往下拉,直接赋值
if (!this.data.enableScroll) {
setOffsetY();
} else {
this.setData({
// 该setData 不会多次执行
enableScroll: false
}, setOffsetY);
}
// 禁用多点触控
switch (type) {
case 'touchstart': {
this.touching = true;
for (const touch of touches) {
const {identifier: id, pageY} = touch;
if (this.pos[id] == null) {
this.pos[id] = pageY + this.scrollTop;
break;
}
}
break;
}
case 'touchmove': {
let distance = 0;
for (const touch of touches) {
const {identifier: id, pageY} = touch;
if (this.pos[id]) {
distance += Math.round(pageY - this.pos[id]);
}
}
let offsetY = this.offsetY = this.dumping(distance + this.lastOffsetY);
return _context.abrupt("break", 99);
const pullDown = distance > 0;
// 没loading动画时下拉计算动画
if (this.status === STATUS.IDLE) {
const circleInfo = calcCircle(offsetY, this.data.loadingHeight);
circleInfo && this.setData(circleInfo);
}
case 70:
_iteratorNormalCompletion3 = true;
_didIteratorError3 = false;
_iteratorError3 = undefined;
_context.prev = 73;
// 还未加载时,向上划要收起loading
if (!pullDown && this.status !== STATUS.IDLE && Math.abs(offsetY) > 20) {
this.fadeCircle();
this.setData({
status: STATUS.IDLE,
offsetY: 0
});
this.status = STATUS.IDLE;
this.lastOffsetY = this.offsetY = 0;
return;
}
for (_iterator3 = changedTouches[Symbol.iterator](); !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
_touch2 = _step3.value;
_id2 = _touch2.identifier, _pageY2 = _touch2.pageY;
if (this.pos[_id2]) {
this.lastOffsetY += _pageY2 - this.pos[_id2];
}
if (disabled) {
return;
}
// offsetY快,setData慢,可能造成向上划没到顶。
// 要注意 初始就向下划,过滤掉
if (offsetY > 0 || this.data.offsetY > 0) {
const setOffsetY = () => this.setData({offsetY});
// 如果已经禁止滚动&&还往下拉,直接赋值
if (!this.data.enableScroll) {
setOffsetY();
}
else {
this.setData({ // 该setData 不会多次执行
enableScroll: false
}, setOffsetY);
}
}
break;
}
case 'touchend': {
for (const touch of changedTouches) {
const {identifier: id, pageY} = touch;
if (this.pos[id]) {
this.lastOffsetY += pageY - this.pos[id];
}
}
_context.next = 81;
break;
if (touches.length || disabled) {
return;
}
case 77:
_context.prev = 77;
_context.t3 = _context["catch"](73);
_didIteratorError3 = true;
_iteratorError3 = _context.t3;
this.touching = false;
this.pos = {};
case 81:
_context.prev = 81;
_context.prev = 82;
if (!_iteratorNormalCompletion3 && _iterator3["return"] != null) {
_iterator3["return"]();
// 判断是否加载
const shouldLoad = this.scrollTop <= 0 && this.offsetY >= this.data.loadingHeight;
let result = 0;
if (shouldLoad) {
// 只有status === 0时,触发加载
if (this.status === STATUS.IDLE) {
this.triggerEvent('refresh');
this.setData({status: STATUS.LOADING});
this.status = STATUS.LOADING;
}
this.startRefreshTime = Date.now();
result = this.data.loadingHeight;
}
else {
this.fadeCircle();
}
this.setData({
enableScroll: true
},
() => {
this.setData({
offsetY: result
});
});
this.lastOffsetY = this.offsetY = result;
break;
}
}
},
case 84:
_context.prev = 84;
if (!_didIteratorError3) {
_context.next = 87;
break;
/**
* circle渐隐
*/
fadeCircle() {
return linearAccu((y, callback) => {
const circleInfo = calcCircle(y, this.data.loadingHeight);
if (circleInfo) {
this.setData(circleInfo, callback);
}
throw _iteratorError3;
case 87:
return _context.finish(84);
case 88:
return _context.finish(81);
case 89:
if (!(touches.length || disabled)) {
_context.next = 91;
break;
else {
callback();
}
}, this.data.loadingHeight, 0);
},
return _context.abrupt("return");
/**
* 渐隐loadingbar
*/
async closeLoading() {
// 防止关闭后,touchend还在触发中
this.closing = true;
this.offsetY = 0;
if (!this.data.enableScroll) {
await syncSetData(this, {enableScroll: true});
}
await syncSetData(this, {offsetY: 0});
// 关闭动画200ms
await new Promise(r => setTimeout(r, 200));
// 放在后面防止小球和text重叠
await syncSetData(this, {status: STATUS.IDLE});
this.status = STATUS.IDLE;
this.lastOffsetY = this.offsetY = 0;
this.closing = false;
},
case 91:
this.touching = false;
this.pos = {}; // 判断是否加载
shouldLoad = this.scrollTop <= 0 && this.offsetY >= this.data.loadingHeight;
result = 0;
if (shouldLoad) {
// 只有status === 0时,触发加载
if (this.status === STATUS.IDLE) {
this.triggerEvent('refresh');
this.setData({
status: STATUS.LOADING
});
this.status = STATUS.LOADING;
}
this.startRefreshTime = Date.now();
result = this.data.loadingHeight;
} else {
this.fadeCircle();
/**
* 调用模拟下拉刷新
*/
async startRefresh() {
// 未关闭又调用
if (this.status !== STATUS.IDLE) {
this.debCloseLoading.cancel();
await this.closeLoading();
}
this.status = STATUS.LOADING;
this.setData({
enableScroll: false,
status: STATUS.LOADING
}, () => {
if (this.closing) {
return;
}
this.offsetY = this.data.loadingHeight;
this.touchHdl({type: 'touchend', manual: true});
});
},
this.setData({
enableScroll: true
}, function () {
_this2.setData({
offsetY: result
});
});
this.lastOffsetY = this.offsetY = result;
return _context.abrupt("break", 99);
/**
* 停止当前刷新
*/
async stopRefresh() {
// 用户下拉,至少保证小球转1圈
let time = 500 - (Date.now() - this.startRefreshTime);
time = time > 0 ? time : 0;
await new Promise(r => setTimeout(r, time));
this.status = STATUS.SHOWTEXT;
this.setData({
status: STATUS.SHOWTEXT
});
await this.debCloseLoading();
},
case 99:
case "end":
return _context.stop();
}
}
}, _callee, this, [[11, 24, 28, 36], [29,, 31, 35], [41, 45, 49, 57], [50,, 52, 56], [73, 77, 81, 89], [82,, 84, 88]]);
}));
/**
* 滚动到底部时触发
* @param {Object} param detail 事件
*/
scrollToLower({detail}) {
this.triggerEvent('scrolltolower', detail);
},
function touchHdl(_x) {
return _touchHdl.apply(this, arguments);
}
return touchHdl;
}(),
/**
* circle渐隐
*/
fadeCircle: function fadeCircle() {
var _this3 = this;
return (0, _index.linearAccu)(function (y, callback) {
var circleInfo = (0, _index.calcCircle)(y, _this3.data.loadingHeight);
if (circleInfo) {
_this3.setData(circleInfo, callback);
} else {
callback();
setScrollTop(scrollTop) {
this.setData({
scrollTop
});
}
}, this.data.loadingHeight, 0);
},
/**
* 渐隐loadingbar
*/
closeLoading: function () {
var _closeLoading = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee2() {
return _regenerator["default"].wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
// 防止关闭后,touchend还在触发中
this.closing = true;
this.offsetY = 0;
created() {
this.setData({
max: upx2dpx(this.data.maxDistance)
});
if (this.data.enableScroll) {
_context2.next = 5;
break;
}
this.clipText(this.data.text);
// 记录用户下拉开始时间,到加载结束至少保证小球转3圈
this.startRefreshTime = 0;
_context2.next = 5;
return (0, _index.syncSetData)(this, {
enableScroll: true
});
// 滚动高度,用于计算是否触顶下拉
this.scrollTop = 0;
case 5:
_context2.next = 7;
return (0, _index.syncSetData)(this, {
offsetY: 0
});
// 是否有手指在屏幕
this.touching = false;
case 7:
_context2.next = 9;
return new Promise(function (r) {
return setTimeout(r, 200);
});
// 多点触控位置,解决手指交叉切换问题
this.pos = {};
case 9:
_context2.next = 11;
return (0, _index.syncSetData)(this, {
status: STATUS.IDLE
});
// 上次结束位置
this.lastOffsetY = 0;
case 11:
this.status = STATUS.IDLE;
this.lastOffsetY = this.offsetY = 0;
this.closing = false;
// 手指移动位置 * 用这个来判断是否手机离开屏幕
this.offsetY = 0;
case 14:
case "end":
return _context2.stop();
}
}
}, _callee2, this);
}));
// 0: 未开始 1: 加载中 2: 展示话术
this.status = STATUS.IDLE;
function closeLoading() {
return _closeLoading.apply(this, arguments);
}
// 是否正在关闭
this.closing = false;
return closeLoading;
}(),
// 循环检测是否要关闭loading
this.debOffsetCheck = () => new Promise(resolve => {
const timer = setInterval(() => {
if (this.touching) {
return;
}
clearInterval(timer);
resolve();
}, 300);
});
/**
* 调用模拟下拉刷新
*/
startRefresh: function () {
var _startRefresh = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee3() {
var _this4 = this;
// 关闭loading bar; text显示时长: 800ms
this.debCloseLoading = promiseDebounce(async () => {
await this.debOffsetCheck();
await new Promise(r => setTimeout(r, 800));
await this.closeLoading();
}, 100);
},
return _regenerator["default"].wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
if (!(this.status !== STATUS.IDLE)) {
_context3.next = 4;
break;
ready() {
// 计算滑动区域高度,用于计算阻尼值
swan.createSelectorQuery().in(this)
.select('.smt-feed-wrap').boundingClientRect(res => {
try {
if (!res) {
throw '未找到节点';
}
this.debCloseLoading.cancel();
_context3.next = 4;
return this.closeLoading();
case 4:
this.status = STATUS.LOADING;
this.setData({
enableScroll: false,
status: STATUS.LOADING
}, function () {
if (_this4.closing) {
return;
}
_this4.offsetY = _this4.data.loadingHeight;
_this4.touchHdl({
type: 'touchend',
manual: true
});
});
case 6:
case "end":
return _context3.stop();
const clientHeight = res.height;
this.setData({clientHeight});
}
}
}, _callee3, this);
}));
function startRefresh() {
return _startRefresh.apply(this, arguments);
}
return startRefresh;
}(),
/**
* 停止当前刷新
*/
stopRefresh: function () {
var _stopRefresh = (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee4() {
var time;
return _regenerator["default"].wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
// 用户下拉,至少保证小球转1圈
time = 500 - (Date.now() - this.startRefreshTime);
time = time > 0 ? time : 0;
_context4.next = 4;
return new Promise(function (r) {
return setTimeout(r, time);
});
case 4:
this.status = STATUS.SHOWTEXT;
this.setData({
status: STATUS.SHOWTEXT
});
_context4.next = 8;
return this.debCloseLoading();
case 8:
case "end":
return _context4.stop();
catch (err) {
console.error('获取节点信息错误');
}
}
}, _callee4, this);
}));
function stopRefresh() {
return _stopRefresh.apply(this, arguments);
}
return stopRefresh;
}(),
/**
* 滚动到底部时触发
* @param {Object} param detail 事件
*/
scrollToLower: function scrollToLower(_ref3) {
var detail = _ref3.detail;
this.triggerEvent('scrolltolower', detail);
},
setScrollTop: function setScrollTop(scrollTop) {
this.setData({
scrollTop: scrollTop
});
}).exec();
}
},
created: function created() {
var _this5 = this;
this.setData({
max: (0, _px.upx2dpx)(this.data.maxDistance)
});
this.clipText(this.data.text); // 记录用户下拉开始时间,到加载结束至少保证小球转3圈
this.startRefreshTime = 0; // 滚动高度,用于计算是否触顶下拉
this.scrollTop = 0; // 是否有手指在屏幕
this.touching = false; // 多点触控位置,解决手指交叉切换问题
this.pos = {}; // 上次结束位置
this.lastOffsetY = 0; // 手指移动位置 * 用这个来判断是否手机离开屏幕
this.offsetY = 0; // 0: 未开始 1: 加载中 2: 展示话术
this.status = STATUS.IDLE; // 是否正在关闭
this.closing = false; // 循环检测是否要关闭loading
this.debOffsetCheck = function () {
return new Promise(function (resolve) {
var timer = setInterval(function () {
if (_this5.touching) {
return;
}
clearInterval(timer);
resolve();
}, 300);
});
}; // 关闭loading bar; text显示时长: 800ms
this.debCloseLoading = (0, _index.promiseDebounce)(
/*#__PURE__*/
(0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regenerator["default"].mark(function _callee5() {
return _regenerator["default"].wrap(function _callee5$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
_context5.next = 2;
return _this5.debOffsetCheck();
case 2:
_context5.next = 4;
return new Promise(function (r) {
return setTimeout(r, 800);
});
case 4:
_context5.next = 6;
return _this5.closeLoading();
case 6:
case "end":
return _context5.stop();
}
}
}, _callee5);
})), 100);
},
ready: function ready() {
var _this6 = this;
// 计算滑动区域高度,用于计算阻尼值
swan.createSelectorQuery()["in"](this).select('.smt-feed-wrap').boundingClientRect(function (res) {
try {
if (!res) {
throw '未找到节点';
}
var clientHeight = res.height;
_this6.setData({
clientHeight: clientHeight
});
} catch (err) {
console.error('获取节点信息错误');
}
}).exec();
}
});
});

@@ -1,1 +0,1 @@

{"name":"component","label":"布局组件","type":"component","configPath":"./smart-design-config.json","version":"0.0.37-alpha.0"}
{"name":"component","label":"布局组件","type":"component","configPath":"./smart-design-config.json","version":"0.0.38-alpha.0"}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc