linui
This commit is contained in:
parent
2c7b3fffff
commit
57ae7e00c4
|
@ -68,6 +68,11 @@
|
|||
"kbone": true,
|
||||
"weui": true
|
||||
},
|
||||
"usingComponents": {
|
||||
"l-toast": "/miniprogram_npm/lin-ui/toast/index",
|
||||
"l-message": "/miniprogram_npm/lin-ui/message/index",
|
||||
"l-button":"/miniprogram_npm/lin-ui/button/index"
|
||||
},
|
||||
"style": "v2",
|
||||
"sitemapLocation": "sitemap.json"
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
import zIndex from"../behaviors/zIndex";import hover from"../behaviors/hover";Component({behaviors:[zIndex,hover],externalClasses:["l-class-title","l-class-item","l-class-cancel","l-title-class","l-item-class","l-cancel-class"],properties:{locked:Boolean,showCancel:Boolean,show:Boolean,itemList:Array,cancelText:{type:String,value:"取消"},title:String,zIndex:{type:Number,value:777},openApi:{type:Boolean,value:!0}},data:{success:"",fail:"",isIphoneX:!1},attached(){this.data.openApi&&this.initActionSheet(),this.initUIAdapter()},pageLifetimes:{show(){this.data.openApi&&this.initActionSheet()}},methods:{initUIAdapter(){wx.getSystemInfo({success:e=>{this.setData({isIphoneX:"iPhone X"===e.model})}})},initActionSheet(){wx.lin=wx.lin||{},wx.lin.showActionSheet=(e={})=>{const{itemList:t=[],success:s=null,fail:i=null,title:a="",locked:l=!1,cancelText:n="取消",showCancel:c=!1}=e;return this.setData({itemList:t.slice(0,10),success:s,fail:i,title:a,locked:l,cancelText:n,showCancel:c,show:!0}),this}},handleClickItem(e){const{success:t}=this.data;t&&t({...e.currentTarget.dataset}),this.triggerEvent("linitemtap",{...e.currentTarget.dataset},{bubbles:!0,composed:!0}),this._hideActionSheet()},_showActionSheet(){this.setData({show:!0})},_hideActionSheet(){this.setData({show:!1})},handleClickCancel(){const{fail:e}=this.data;e&&e({errMsg:"showactionsheet:fail cancel"}),this.triggerEvent("lincancel",{errMsg:"showactionsheet:fail cancel"},{bubbles:!0,composed:!0}),this._hideActionSheet()},handleClickPopUp(){this.data.locked||this.handleClickCancel()}}});
|
|
@ -0,0 +1 @@
|
|||
{"component":true,"usingComponents":{"l-icon":"../icon/index","l-popup":"../popup/index","l-button":"../button/index"} }
|
|
@ -0,0 +1,21 @@
|
|||
<l-popup show="{{show}}" showMask="{{true}}" contentAlign="bottom" locked="{{locked}}" bind:lintap="handleClickPopUp" z-index="{{zIndex}}">
|
||||
<view class="l-action-sheet">
|
||||
<view class="l-item-button l-class-title l-title-class" wx:if="{{title}}">
|
||||
{{ title }}
|
||||
</view>
|
||||
<view wx:for="{{ itemList }}" wx:key="name" hover-class="{{isHover?'list-hover':''}}">
|
||||
<l-button bind:lintap="handleClickItem" data-index="{{ index }}" data-item="{{ item }}" open-type="{{ item.openType }}" icon="{{ item.icon }}" type="default" size="large" special="{{true}}" long>
|
||||
<view style="{{ item.color ? 'color: ' + item.color : '' }}" class="l-item-button l-class-item l-item-class {{item.image || item.icon ? 'l-image-button':''}}">
|
||||
<image wx:if="{{item.image}}" class="l-button-image" src="{{item.image}}" style="{{item.imageStyle}}"/>
|
||||
<l-icon wx:elif="{{ item.icon }}" name="{{ item.icon }}" l-class="l-item-button" size="{{ item.iconSize }}" color="{{item.iconColor?item.iconColor:item.color}}"></l-icon>
|
||||
<text class="l-button-text">{{ item.name }}</text>
|
||||
</view>
|
||||
</l-button>
|
||||
</view>
|
||||
<view class="l-cancel l-class-cancel l-cancel-class {{isIphoneX ? 'l-cancel-x':''}}" wx:if="{{ showCancel }}" hover-class="{{isHover?'list-hover':''}}">
|
||||
<l-button type="default" size="large" long="true" bind:lintap="handleClickCancel" special="{{true}}">
|
||||
<view class="l-item-button l-cancel-button">{{ cancelText }}</view>
|
||||
</l-button>
|
||||
</view>
|
||||
</view>
|
||||
</l-popup>
|
|
@ -0,0 +1 @@
|
|||
.l-action-sheet{background:#f7f7f7}.l-item-button{height:88rpx;line-height:88rpx;text-align:center;background:#fff;border-bottom:2rpx solid #f3f3f3;font-size:28rpx;color:#45526b;display:flex;align-items:center;justify-content:center;width:100%;overflow:hidden}.l-cancel{margin-top:12rpx}.l-cancel-x .l-item-button{padding-bottom:44rpx}.l-image-button>.l-button-text{margin-left:20rpx}.list-hover{opacity:.8}
|
|
@ -0,0 +1 @@
|
|||
Component({externalClasses:["l-class","l-single-image-class","l-multi-image-class"],properties:{urls:{type:Array},preview:{type:Boolean,value:!0},gapRow:{type:Number,value:10},gapColumn:{type:Number,value:10},singleSize:{type:Number,value:360},multipleSize:{type:Number,value:158},singleMode:{type:String,value:"aspectFit"},multipleMode:{type:String,value:"aspectFill"},key:{type:String,value:"url"}},data:{newType:!0,shortSideValue:0,row:0,colum:0},lifetimes:{attached(){if(this.data.urls.length>9){const e=this.data.urls.slice(0,9);this.setData({urls:e}),console.warn("超过9张图片!")}this.preview()}},observers:{urls:function(){this.preview()}},methods:{judgeType(){const e=this.data.urls;return 0===e.length||"object"==typeof e[0]},horizontalOrVertical:function(e){wx.getImageInfo({src:e,success:e=>{const t=e.width>=e.height?e.width:e.height,i=e.width>=e.height?e.height:e.width;this.setData({horizontalScreen:e.width>=e.height,shortSideValue:i*this.data.singleSize/t})}})},preview:function(){const e=this.judgeType();this.setData({newType:e});const t=this.data.urls,i=this.data.key;1===t.length&&this.horizontalOrVertical(e?t[0][i]:t[0])},onPreviewTap(e){const t=e.currentTarget.id,i=this.data.urls;let s="",a=[];const l=this.data.newType,r=this.data.key;if(l){s=i[t][r];for(let e=0;e<i.length;e++)a.push(i[e][r])}else s=i[t],a=i;let n={index:t,current:i[t],all:i};!0===this.data.preview&&wx.previewImage({current:s,urls:a}),this.triggerEvent("lintap",n,{})}}});
|
|
@ -0,0 +1 @@
|
|||
{"component":true,"usingComponents":{}}
|
|
@ -0,0 +1,6 @@
|
|||
<wxs src="index.wxs" module="album"></wxs>
|
||||
<view class="container l-class" style="{{album.containerStyle(urls, multipleSize, gapRow, gapColumn)}}">
|
||||
<block wx:for="{{urls}}" wx:key="index">
|
||||
<image id="{{index}}" bind:tap="onPreviewTap" class="{{album.blockClass(urls, horizontalScreen)}}" style="{{album.blockStyle(urls, horizontalScreen, shortSideValue, singleSize, multipleSize)}}" src="{{newType?item[key]:item}}" mode="{{urls.length === 1?singleMode:multipleMode}}"/>
|
||||
</block>
|
||||
</view>
|
|
@ -0,0 +1,39 @@
|
|||
var containerStyle = function (urls, multipleSize, gapRow, gapColumn) {
|
||||
urls.length === 2 || urls.length === 4 ? 'width:' + (2 * multipleSize + gapRow) + 'rpx;' : 'width:' + (3 * multipleSize + 2 * gapRow) + 'rpx;'
|
||||
if (urls.length === 2 || urls.length === 4) {
|
||||
return 'width:' + (2 * multipleSize + gapRow) + 'rpx; grid-row-gap:' + gapColumn + 'rpx; grid-column-gap:' + gapRow + 'rpx;grid-template-columns:repeat(auto-fit, ' + multipleSize + 'rpx);'
|
||||
} else {
|
||||
return 'width:' + (3 * multipleSize + 2 * gapRow) + 'rpx; grid-row-gap:' + gapColumn + 'rpx; grid-column-gap:' + gapRow + 'rpx;grid-template-columns:repeat(auto-fit, ' + multipleSize + 'rpx);'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var blockClass = function (urls, horizontalScreen) {
|
||||
if (urls.length === 1) {
|
||||
if (horizontalScreen) {
|
||||
return 'l-single-image-class'
|
||||
} else {
|
||||
return 'vertical l-single-image-class'
|
||||
}
|
||||
} else {
|
||||
return 'l-multi-image-class'
|
||||
}
|
||||
}
|
||||
|
||||
var blockStyle = function (urls, horizontalScreen, shortSideValue, singleSize, multipleSize) {
|
||||
if (urls.length === 1) {
|
||||
if (horizontalScreen) {
|
||||
return 'height:' + shortSideValue + 'rpx;width:' + singleSize + 'rpx;'
|
||||
} else {
|
||||
return 'width:' + shortSideValue + 'rpx;height:' + singleSize + 'rpx;'
|
||||
}
|
||||
} else {
|
||||
return 'height:' + multipleSize + 'rpx;width:' + multipleSize + 'rpx;'
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
containerStyle: containerStyle,
|
||||
blockClass: blockClass,
|
||||
blockStyle: blockStyle
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
.container{display:grid}.vertical{height:360rpx}
|
|
@ -0,0 +1 @@
|
|||
import validator from"../behaviors/validator";import zIndex from"../behaviors/zIndex";const detail=!0,option={bubbles:!0,composed:!0};Component({behaviors:[zIndex,validator],externalClasses:["l-class","l-panel-class","l-bg-class","l-header-class"],options:{multipleSlots:!0},properties:{show:{type:Boolean,value:!1},maxHeight:{type:Number,value:600},minHeight:{type:Number,value:200},arcRadius:{type:Number,value:18},transition:{type:Boolean,value:!0},locked:{type:Boolean,value:!1},opacity:{type:Number,value:.4},direction:{type:String,options:["top","bottom"],value:"bottom"},headerFixed:{type:Boolean,value:!0}},data:{_arcRadiusTop:12,_ardRadiusBottom:18,arcStyle:""},observers:{show:function(t){t?(this.triggerEvent("linshow",!0,option),this.getArcPopupStyle()):this.triggerEvent("linclose",!0,option)},arcRadius:function(t){"top"===this.properties.direction?this.data._arcRadiusTop=t:this.data._ardRadiusBottom=t,this.getArcPopupStyle()}},pageLifetimes:{show(){this._init()}},methods:{_init(){wx.lin=wx.lin||{},wx.lin.showArcPopup=t=>{const{zIndex:o=99,tranistion:e=!0,direction:i="bottom",locked:a=!1}={...t};this.setData({zIndex:o,tranistion:e,direction:i,locked:a,show:!0})},wx.lin.hideArcPopup=()=>{this.setData({show:!1})}},getArcPopupStyle(){const t=this.properties.direction,o=this.data._arcRadiusTop,e=this.data._ardRadiusBottom,i=`\n border-bottom-left-radius:${"top"===t?o:0}rpx;\n border-bottom-right-radius:${"top"===t?o:0}rpx;\n border-top-left-radius:${"bottom"===t?e:0}rpx;\n border-top-right-radius:${"bottom"===t?e:0}rpx;\n max-height:${this.properties.maxHeight}rpx;\n min-height:${this.properties.minHeight}rpx;\n `;this.setData({arcStyle:i})},onArcPopupTap(){this.data.locked||this.properties.show&&this.setData({show:!1})}},ready(){this.getArcPopupStyle()}});
|
|
@ -0,0 +1 @@
|
|||
{"component":true,"usingComponents":{"l-popup":"../popup/index"}}
|
|
@ -0,0 +1,10 @@
|
|||
<l-popup show="{{show}}" direction="{{direction}}" transition="{{transition}}" opacity="{{opacity}}" locked="{{locked}}" z-index="{{zIndex}}" l-class="l-class" l-bg-class="l-bg-class" bind:lintap="onArcPopupTap">
|
||||
<scroll-view scroll-y="true" class="arc-popup l-panel-class" style="{{arcStyle}}">
|
||||
<view class="header-popup {{headerFixed ? 'fixed' : ''}} l-header-class">
|
||||
<slot name="header"/>
|
||||
</view>
|
||||
<view class="content-arc-popup">
|
||||
<slot/>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</l-popup>
|
|
@ -0,0 +1 @@
|
|||
.container-arc-popup{width:100%}.arc-popup{overflow:hidden;width:100%;background:#fff}.content-arc-popup{padding:30rpx;box-sizing:border-box}.header-popup{width:100%;z-index:999}.header-popup.fixed{position:sticky;top:0;background-color:#fff}
|
|
@ -0,0 +1 @@
|
|||
Component({externalClasses:["l-class","l-class-text","l-text-class"],properties:{icon:String,iconColor:{type:String,value:"#3963BC"},iconSize:{type:String,value:"28"},text:String,src:String,openData:{type:Array,observer:"_initOpenData"},shape:{type:String,value:"circle"},mode:{type:String,value:"scaleToFill"},size:{type:Number,value:120},placement:{type:String,value:"right"}},data:{_isHaveUserNickName:!1,_isHaveUserAvatarUrl:!1,_iconSize:"",_iconColor:"#ffffff"},methods:{_initOpenData:function(e){this._isHaveUserAvatarUrl(e),this._isHaveUserNickName(e)},_isHaveUserAvatarUrl:function(e){this.setData({_isHaveUserAvatarUrl:-1!==e.indexOf("userAvatarUrl")})},_isHaveUserNickName:function(e){this.setData({_isHaveUserNickName:-1!==e.indexOf("userNickName")})},tapAvatar:function(e){this.triggerEvent("lintap",e,{bubbles:!0,composed:!0})}}});
|
|
@ -0,0 +1 @@
|
|||
{"component":true,"usingComponents":{"l-icon":"../icon/index"} }
|
|
@ -0,0 +1,12 @@
|
|||
|
||||
<view class="l-avatar {{text||_isHaveUserNickName?'l-placement-'+placement:''}}" bindtap="tapAvatar">
|
||||
<view class="l-avatar-image {{shape?'l-'+shape:''}} l-class" wx:if="{{_isHaveUserAvatarUrl||icon||src}}" style="width:{{size}}rpx;height:{{size}}rpx">
|
||||
<open-data class="open-data" wx:if="{{_isHaveUserAvatarUrl}}" type="userAvatarUrl"/>
|
||||
<l-icon wx:elif="{{icon}}" size="{{iconSize || size*0.6}}" color="{{iconColor||'#ffffff'}}" name="{{icon}}"/>
|
||||
<image wx:elif="{{src}}" src="{{src}}" mode="{{mode}}" style="width:{{size}}rpx;height:{{size}}rpx"/>
|
||||
</view>
|
||||
<view class="l-avatar-text l-class-text l-text-class" wx:if="{{text||_isHaveUserNickName}}">
|
||||
<open-data class="open-data" wx:if="{{_isHaveUserNickName}}" type="userNickName"/>
|
||||
<text class="l-avatar-text-text" wx:elif="{{text}}">{{text}}</text>
|
||||
</view>
|
||||
</view>
|
|
@ -0,0 +1 @@
|
|||
.l-avatar{display:inline-flex;justify-content:center;align-items:center}.l-avatar-image{flex:1;display:inline-flex;justify-content:center;align-items:center;background:#ccc;overflow:hidden}.l-avatar-text{display:inline-block;height:max-content;width:max-content;font-size:28rpx;color:#45526b;line-height:40px}.open-data{width:100%;height:100%}.l-avatar-text .l-avatar-text-text,.l-avatar-text .open-data{font-size:inherit;color:inherit;line-height:inherit}.l-square{border-radius:8rpx}.l-circle{border-radius:50%}.l-placement-left,.l-placement-right{align-items:center;justify-content:center}.l-placement-left{margin-right:24rpx;flex-direction:row-reverse}.l-placement-left .l-avatar-text{margin-right:24rpx}.l-placement-right{flex-direction:row}.l-placement-right .l-avatar-text{margin-left:24rpx}.l-placement-top{flex-direction:column-reverse}.l-placement-top .l-avatar-text{margin-bottom:12rpx}.l-placement-bottom{flex-direction:column}.l-placement-bottom .l-avatar-text{margin-top:12rpx}
|
|
@ -0,0 +1 @@
|
|||
import validator from"../behaviors/validator";Component({externalClasses:["l-class","l-class-self","l-self-class"],behaviors:[validator],properties:{dot:{type:Boolean,value:!1},shape:{type:String,value:"horn",options:["horn","circle"]},value:{type:String,value:"0"},mode:{type:String,value:"number",options:["number","text"]},maxCount:{type:Number,value:99},numberType:{type:String,value:"overflow",options:["overflow","limit","ellipsis"]},show:{type:Boolean,value:!0}},data:{finalCount:0},observers:{value:function(){this.finalCount()}},methods:{finalCount(){isNaN(Number(this.data.value))||"text"===this.data.mode?this.setData({finalCount:this.data.value}):this.switchType()},switchType(){switch(this.data.numberType){case"overflow":this.setData({finalCount:Number(this.data.value)>Number(this.data.maxCount)?this.data.maxCount+"+":this.data.value});break;case"ellipsis":this.setData({finalCount:Number(this.data.value)>Number(this.data.maxCount)?"...":this.data.value});break;case"limit":this.setData({finalCount:Number(this.data.value)>999?Number(this.data.value)>=9999?Math.floor(this.data.value/1e4*100)/100+"w":Math.floor(this.data.value/1e3*100)/100+"k":this.data.value});break;default:this.setData({finalCount:Number(this.data.value)})}},handleTap(){this.triggerEvent("lintap",{},{bubbles:!0,composed:!0})}}});
|
|
@ -0,0 +1 @@
|
|||
{"component":true,"usingComponents":{}}
|
|
@ -0,0 +1,7 @@
|
|||
<view class="l-badge" bindtap="handleTap">
|
||||
<slot/>
|
||||
<block wx:if="{{show}}">
|
||||
<view wx:if="{{dot}}" class="l-badge-dot l-class l-class-self l-self-class"></view>
|
||||
<view wx:else class="{{'l-badge-content-'+shape}} l-badge-content l-class l-class-self l-self-class">{{finalCount}}</view>
|
||||
</block>
|
||||
</view>
|
|
@ -0,0 +1 @@
|
|||
.l-badge{position:relative;display:inline-block;line-height:1;vertical-align:middle}.l-badge-content{max-width:650rpx;left:70%;background-color:#ff474b;color:#fff;position:absolute;font-size:20rpx;display:inline-block;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;text-align:center;box-sizing:border-box;z-index:10;letter-spacing:.5rpx}.l-badge-content-horn{height:28rpx;min-width:54rpx;padding:0 8rpx;border-radius:14rpx 14rpx 14rpx 0rpx;line-height:28rpx;top:-10rpx}.l-badge-content-circle{height:32rpx;min-width:32rpx;padding:0 10rpx;border-radius:16rpx;line-height:32rpx;top:-10rpx}.l-badge-dot{height:16rpx;width:16rpx;transform:translateX(50%);border-radius:50%;background-color:#ff474b;position:absolute;top:-4rpx;right:0rpx}
|
|
@ -0,0 +1 @@
|
|||
export default Behavior({behaviors:[],properties:{},data:{distance:0},attached(){this.offsetMargin()},methods:{offsetMargin(){const{windowHeight:t,screenHeight:e}=wx.getSystemInfoSync();this.setData({distance:e-t})}}});
|
|
@ -0,0 +1 @@
|
|||
export default Behavior({behaviors:[],properties:{time:{type:Date,value:(new Date).getTime()+864e5,observer:function(t,e){t&&!e&&this.getLatestTime()}},status:{type:Boolean,value:!0,observer:function(t){t?this.init():t||clearInterval(this.data.timer)}},timeType:{type:String,value:"datetime"},format:{type:String,value:"{%d}天{%h}时{%m}分{%s}秒"},isZeroPadd:{type:Boolean,value:!0},countdownType:{type:String,value:"normal"},isClearInterval:{type:Boolean,value:!0}},data:{initAddTime:0,timer:null,date:[]},ready:function(){this.getLatestTime()},detached:function(){this.data.isClearInterval&&clearInterval(this.data.timer)},pageLifetimes:{hide(){this.data.isClearInterval&&clearInterval(this.data.timer)},show(){this.data.isClearInterval&&this.getLatestTime()}},methods:{zeroPadding:t=>(t=t.toString())[1]?t:"0"+t,init(){clearInterval(this.data.timer);const t=setTimeout(()=>{this.getLatestTime.call(this)},1e3);this.setData({timer:t})},getLatestTime(){let{time:t,status:e,timeType:i,initAddTime:a,countdownType:n}=this.data,s=t;if("normal"===n){if("second"!==i&&(s="string"==typeof t?s.replace(/-/g,"/"):s,s=Math.ceil((new Date(s).getTime()-(new Date).getTime())/1e3)),s<0&&"second"!==i)return this._getTimeValue(0),void this.CountdownEnd();s-a>0?this.getLatestForCountDown(s):s-a<0?this.getLatestForAddTime(s):s-a==0&&(a<=0&&this._getTimeValue(s),this.CountdownEnd()),e&&s-a!=0&&this.init.call(this)}else"anniversary"===n?"second"===i?console.error(`countdownType为${n}类型时,不可设置timeType值为second`):(s="string"==typeof t?s.replace(/-/g,"/"):s,s=Math.ceil(((new Date).getTime()-new Date(s).getTime())/1e3),s>=0?(this.getLatestForCountDown(s),this.init.call(this)):console.error("time传值错误")):console.error("错误的countdownType类型")},getLatestForAddTime(t){let{initAddTime:e}=this.data;e!==Math.abs(t)&&(e++,this._getTimeValue(e),this.setData({initAddTime:e}))},getLatestForCountDown(t){this._getTimeValue(t),this.setData({time:"second"===this.data.timeType?--t:this.data.time})},_getTimeValue(t){const{format:e}=this.data,i=[],a=e.split(/(\{.*?\})/);let n=t;return[{key:"{%d}",type:"day",count:86400},{key:"{%h}",type:"hour",count:3600},{key:"{%m}",type:"minute",count:60},{key:"{%s}",type:"second",count:1}].forEach(t=>{const e=this._findTimeName(a,t.key);if(-1===e)return;const s=a[e],o={type:t.type,name:s,value:parseInt(n/t.count)};this.data.isZeroPadd&&(o.value=this.zeroPadding(o.value)),n%=t.count,i.push(o)}),this.setData({date:i}),i},_findTimeName(t,e){const i=t.indexOf(e);return-1===i?-1:i+1},CountdownEnd(){this.triggerEvent("linend",{})}}});
|
|
@ -0,0 +1 @@
|
|||
export default Behavior({behaviors:[],properties:{isHover:{type:Boolean,value:!0}}});
|
|
@ -0,0 +1 @@
|
|||
import Schema from"../common/async-validator/index";import validator from"../behaviors/validator";export default Behavior({behaviors:[validator],properties:{rules:{type:[Object,Array],value:[]},tipType:{type:String,value:"toast",options:["toast","message","text"]}},data:{schema:"",tipFun:{message:"showMessage",toast:"showToast"},tipContent:{message:"content",toast:"title"},errorText:"",errors:[]},methods:{initRules(){const{rules:t}=this.data;t&&("[object Object]"===Object.prototype.toString.call(t)&&(this.data.rules=[t]),this.data.rules.forEach(t=>{t.trigger?"string"!=typeof t.trigger||(t.trigger=[t.trigger]):t.trigger=[]}))},getNeedValidateRule(t){const e=this.data.name,{rules:a}=this.data;if(!a)return;const r=t?a.filter(e=>e.trigger.indexOf(t)>-1):a,s=new Schema({[e]:r});return this.setData({schema:s}),r},validatorData(t,e){const{tipType:a,tipFun:r,tipContent:s}=this.data;this.getNeedValidateRule(e)&&(Object.getOwnPropertyNames(t).forEach(e=>{""===t[e]&&(t[e]=void 0)}),this.data.schema.validate(t,t=>{if(this.setData({errors:t||[]}),this.triggerEvent("linvalidate",{errors:t,isError:!!t}),t&&a){const e=r[a],i=s[a];return"text"===a?(this.setData({errorText:t[0].message}),t):wx.lin&&wx.lin[e]?(wx.lin[e]&&wx.lin[e]({[i]:t[0].message,duration:1500,mask:!1}),t):(wx.showToast({icon:"none",title:`请在页面内引入${a}组件`}),t)}!t&&a&&this.setData({errorText:""})}))}}});
|
|
@ -0,0 +1 @@
|
|||
export default Behavior({methods:{getRect(e,t=!1){return new Promise((r,o)=>{const s=wx.createSelectorQuery().in(this);(t?s.selectAll(e):s.select(e)).boundingClientRect(e=>{if(!e)return o("找不到元素");r(e)}).exec()})},queryScrollNode(e,t,r="width"){if(t<0)return;const o=e[t];this.getRect(".l-tabsscroll").then(s=>{if(!s)return console.error("找不到元素");const c=s[r];let n=e.slice(0,t).reduce((e,t)=>e+t[r],0);n+=(o[r]-c)/2,"width"===r?this.setData({transformX:n,transformY:0}):this.setData({transformX:0,transformY:n})}).catch(e=>{console.error(e)})},queryMultipleNodes(){const{placement:e,currentIndex:t}=this.data;this.getRect(".l-tabs-item",!0).then(r=>{-1!==["top","bottom"].indexOf(e)?this.queryScrollNode(r,t):this.queryScrollNode(r,t,"height")}).catch(e=>{console.error(e)})}}});
|
|
@ -0,0 +1 @@
|
|||
const isObj=e=>{const t=typeof e;return null!==e&&("object"===t||"function"===t)},getClassNames=e=>({enter:`l-${e}-enter l-${e}-enter-active l-enter-class l-enter-active-class`,"enter-to":`l-${e}-enter-to l-${e}-enter-active l-enter-to-class l-enter-active-class`,leave:`l-${e}-leave l-${e}-leave-active l-leave-class l-leave-active-class`,"leave-to":`l-${e}-leave-to l-${e}-leave-active l-leave-to-class l-leave-active-class`}),nextTick=()=>new Promise(e=>setTimeout(e,1e3/30));export default e=>Behavior({properties:{customStyle:String,show:{type:Boolean,value:e,observer:"observeShow"},duration:{type:null,value:300,observer:"observeDuration"},name:{type:String,value:"fade"}},data:{type:"",inited:!1,display:!1},attached(){this.data.show&&this.enter()},methods:{observeShow(e){e?this.enter():this.leave()},enter(){const{duration:e,name:t}=this.data,s=getClassNames(t),a=isObj(e)?e.enter:e;this.status="enter",this.triggerEvent("linbeforeenter"),Promise.resolve().then(nextTick).then(()=>{this.checkStatus("enter"),this.triggerEvent("linenter"),this.setData({inited:!0,display:!0,classes:s.enter,currentDuration:a})}).then(nextTick).then(()=>{this.checkStatus("enter"),this.transitionEnded=!1,this.setData({classes:s["enter-to"]})}).catch(()=>{})},leave(){if(!this.data.display)return;const{duration:e,name:t}=this.data,s=getClassNames(t),a=isObj(e)?e.leave:e;this.status="leave",this.triggerEvent("linbeforeleave"),Promise.resolve().then(nextTick).then(()=>{this.checkStatus("leave"),this.triggerEvent("linleave"),this.setData({classes:s.leave,currentDuration:a})}).then(nextTick).then(()=>{this.checkStatus("leave"),this.transitionEnded=!1,setTimeout(()=>this.onTransitionEnd(),a),this.setData({classes:s["leave-to"]})}).catch(()=>{})},checkStatus(e){if(e!==this.status)throw new Error("incongruent status: "+e)},onTransitionEnd(){if(this.transitionEnded)return;this.transitionEnded=!0,this.triggerEvent("linafter"+this.status);const{show:e,display:t}=this.data;!e&&t&&this.setData({display:!1})}}});
|
|
@ -0,0 +1 @@
|
|||
export default Behavior({definitionFilter(e){const{properties:o}=e;Object.keys(o).forEach(e=>{const{options:t}=o[e];t&&(o[e].observer=function(o){!t.includes(o)&&o&&console.error(`${e}: ${o} must be in the [${t}]`)})})}});
|
|
@ -0,0 +1 @@
|
|||
export default Behavior({observers:{show:function(t){t&&this.changeStatus(),t||this.setData({status:t})}},methods:{changeStatus(){this.setData({status:!0}),this.data.timer&&clearTimeout(this.data.timer),this.data.timer=setTimeout(()=>{this.setData({status:!1}),this.data.success&&this.data.success(),this.data.timer=null},this.properties.duration)}}});
|
|
@ -0,0 +1 @@
|
|||
export default Behavior({behaviors:[],properties:{zIndex:{type:Number,value:777}}});
|
|
@ -0,0 +1 @@
|
|||
import validator from"../behaviors/validator";Component({externalClasses:["l-class","l-label-class","l-hover-class","l-img-class","l-icon-class"],behaviors:[validator],properties:{name:{type:String,value:"lin"},type:{type:String,value:"default",options:["warning","success","error","default"]},plain:Boolean,size:{type:String,value:"medium",options:["medium","large","mini","long"]},shape:{type:String,value:"circle",options:["square","circle","semicircle"]},disabled:{type:Boolean,value:!1},special:{type:Boolean,value:!1},loading:{type:Boolean,value:!1},width:Number,height:Number,icon:String,image:String,bgColor:String,iconColor:String,iconSize:String,openType:String,appParameter:String,lang:String,hoverStopPropagation:Boolean,hoverStartTime:{type:Number,value:20},hoverStayTime:{type:Number,value:70},sessionFrom:{type:String,value:""},sendMessageTitle:String,sendMessagePath:String,sendMessageImg:String,showMessageCard:Boolean,formType:String},methods:{handleTap(){if(this.data.disabled||this.data.loading)return!1;this.triggerEvent("lintap",{},{bubbles:!0,composed:!0})},openTypeEvent(e){this.triggerEvent(e.type,e.detail,{})}}});
|
|
@ -0,0 +1 @@
|
|||
{"component":true,"usingComponents":{"l-icon":"../icon/index"}}
|
|
@ -0,0 +1,16 @@
|
|||
<label for="{{name}}" bindtap="handleTap" class="l-label-class">
|
||||
<block wx:if="{{special}}">
|
||||
<view class="special-container l-class">
|
||||
<slot/>
|
||||
</view>
|
||||
</block>
|
||||
<block wx:else>
|
||||
<view class="l-btn {{ 'l-btn-' + size }} {{ 'l-btn-' + type }} {{ 'l-btn-' + shape }} {{plain?'l-btn-plain':''}} {{ disabled ? 'l-btn-disabled' : ''}} l-class" hover-class="{{disabled?'':'btn-hover l-hover-class'}}" hover-stop-propagation="{{hoverStopPropagation}}" hover-start-time="{{hoverStartTime}}" hover-stay-time="{{hoverStayTime}}" style="{{width?'min-width:'+width+'rpx;':''}} {{height?'height:'+height+'rpx;'+'line-height:'+height+'rpx;':''}} {{size=='long'?'border-radius:0;':''}} {{'background-color:'+bgColor}}">
|
||||
<view wx:if="{{loading}}" class="l-btn-loading {{'margin-' + size}} {{ plain ?'l-btn-loading-' + type : '' }}"></view>
|
||||
<l-icon l-class="l-icon-class" class="{{'margin-' + size}}" wx:if="{{icon}}" name="{{icon}}" color="{{iconColor}}" size="{{iconSize}}"/>
|
||||
<slot/>
|
||||
</view>
|
||||
</block>
|
||||
</label>
|
||||
<button style="position: absolute;top: -999px;left: -999px;" wx:if="{{openType}}" id="{{name}}" lang="{{lang}}" form-type="{{formType}}" open-type="{{openType}}" app-parameter="{{ appParameter }}" hover-stop-propagation="{{ hoverStopPropagation }}" hover-start-time="{{ hoverStartTime }}" hover-stay-time="{{ hoverStayTime }}" session-from="{{ sessionFrom }}" send-message-title="{{ sendMessageTitle }}" send-message-path="{{ sendMessagePath }}" send-message-img="{{ sendMessageImg }}" show-message-card="{{ showMessageCard }}" bindcontact="openTypeEvent" bindgetuserinfo="openTypeEvent" bindgetphonenumber="openTypeEvent" bindopensetting="openTypeEvent">
|
||||
</button>
|
|
@ -0,0 +1 @@
|
|||
.btn-hover::before{opacity:.15;position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;transform:translate(-50%,-50%);content:' ';background-color:#333;border-color:#333}.special-container{display:flex}.l-btn{display:inline-flex;align-items:center;justify-content:center;white-space:nowrap;font-size:28rpx;position:relative;color:#fff;padding:0 12rpx;box-sizing:border-box}.l-btn-img-mini{width:30rpx;height:30rpx}.l-btn-img-medium{width:36rpx;height:36rpx}.l-btn-img-large{height:44rpx;width:44rpx}.l-btn-long{border-radius:0;margin:0;height:88rpx;width:100%}.l-btn-medium{height:72rpx;min-width:180rpx}.l-btn-large{height:88rpx;min-width:710rpx}.l-btn-mini{height:60rpx;min-width:140rpx;font-size:24rpx}.l-btn-default{background-color:#3963bc}.l-btn-success{background-color:#34bfa3}.l-btn-warning{background-color:#ffe57f;color:#333}.l-btn-error{background-color:#f4516c}.l-btn-square{border-radius:0}.l-btn-semicircle{border-radius:40rpx}.l-btn-large.l-btn-semicircle{border-radius:48rpx}.l-btn-mini.l-btn-semicircle{border-radius:30rpx}.l-btn-circle{border-radius:8rpx}.l-btn-large.l-btn-circle{border-radius:9.6rpx}.l-btn-mini.l-btn-circle{border-radius:6rpx}.l-btn-plain{background-color:#fff;color:#3963bc;border:2rpx solid #3963bc}.l-btn-success.l-btn-plain{background-color:#fff;color:#34bfa3;border:2rpx solid #34bfa3}.l-btn-error.l-btn-plain{background-color:#fff;color:#f4516c;border:2rpx solid #f4516c}.l-btn-warning.l-btn-plain{background-color:#fff;color:#ffe57f;border:2rpx solid #ffe57f}.l-btn-loading{opacity:.6;display:inline-block;vertical-align:middle;width:24rpx;height:24rpx;background:0 0;border-radius:50%;border:4rpx solid #fff;border-color:#fff #fff #fff transparent;animation:btn-spin .6s linear;animation-iteration-count:infinite}.l-btn-loading-default{border:4rpx solid #3963bc;border-color:#3963bc #3963bc #3963bc transparent}.l-btn-loading-success{border:4rpx solid #34bfa3;border-color:#34bfa3 #34bfa3 #34bfa3 transparent}.l-btn-loading-error{border:4rpx solid #f4516c;border-color:#f4516c #f4516c #f4516c transparent}.l-btn-loading-warning{border:4rpx solid #ffe57f;border-color:#ffe57f #ffe57f #ffe57f transparent}.l-btn-disabled{opacity:.8}.icon{display:flex!important}.margin-mini{margin-right:10rpx}.margin-medium{margin-right:18rpx}.margin-large{margin-right:24rpx}@keyframes btn-spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}
|
Binary file not shown.
After Width: | Height: | Size: 381 B |
Binary file not shown.
After Width: | Height: | Size: 372 B |
Binary file not shown.
After Width: | Height: | Size: 421 B |
Binary file not shown.
After Width: | Height: | Size: 434 B |
|
@ -0,0 +1 @@
|
|||
import deviceUtil from"../utils/device-util";import validator from"../behaviors/validator";import eventUtil from"../core/utils/event-util";Component({behaviors:[validator],externalClasses:["l-title-class"],properties:{bgColor:{type:String,value:"white"},statusBarColor:{type:String,value:"transparent"},titleBarColor:{type:String,value:"transparent"},titleColor:{type:String,value:"black"},capsuleColor:{type:String,value:"black",options:["white","black"]},disableBack:{type:Boolean,value:!1},disableHome:{type:Boolean,value:!1},hiddenCapsule:{type:Boolean,value:!1},homePage:{type:String,value:""},title:{type:String,value:""},hasPadding:{type:Boolean,value:!0}},data:{titleBarHeight:deviceUtil.getTitleBarHeight(),statusBarHeight:deviceUtil.getStatusBarHeight(),capsuleButtonInfo:null},lifetimes:{ready:function(){this.setData({capsuleButtonInfo:this.getCapsuleButtonInfo()})}},methods:{getCapsuleButtonInfo(){const t=wx.getSystemInfoSync().screenWidth,e=wx.getMenuButtonBoundingClientRect();return e.left=t-e.right,e.right=e.left+e.width,e},onTapLeftButton(){eventUtil.emit(this,"linlefttap"),this.data.disableBack||wx.navigateBack()},onLongPressLeftButton(){eventUtil.emit(this,"linleftlongpress")},async onTapRightButton(){eventUtil.emit(this,"linrighttap");const t=this.data.homePage;this.data.disableHome||wx.switchTab({url:t,fail(){wx.navigateTo({url:t})}})},onLongPressRightButton(){eventUtil.emit(this,"linrightlongpress")}}});
|
|
@ -0,0 +1 @@
|
|||
{"component":true}
|
|
@ -0,0 +1,35 @@
|
|||
|
||||
|
||||
<view class="container" style="padding-top: {{hasPadding?titleBarHeight+statusBarHeight:'0'}}rpx">
|
||||
|
||||
<cover-view class="capsule-bar" style="background-color: {{bgColor}};">
|
||||
|
||||
|
||||
<cover-view class="status-bar" style="height: {{statusBarHeight+4}}rpx;background-color: {{statusBarColor}};"></cover-view>
|
||||
|
||||
|
||||
<cover-view class="title-bar" style="height: {{titleBarHeight}}rpx;background-color: {{titleBarColor}};">
|
||||
<cover-view class="title l-title-class" style="color: {{titleColor}};">{{title}}</cover-view>
|
||||
</cover-view>
|
||||
|
||||
|
||||
<cover-view wx:if="{{!hiddenCapsule}}" class="capsule-button" style="border-color: rgba({{capsuleColor==='black'?'0,0,0,0.1':'255,255,255,0.25'}});background-color: rgba({{capsuleColor==='black'?'255,255,255,0.6':'0,0,0,0.15'}});width: {{capsuleButtonInfo.width}}px;height: {{capsuleButtonInfo.height}}px;left: {{capsuleButtonInfo.left}}px;top: {{capsuleButtonInfo.top}}px;">
|
||||
|
||||
<cover-view catch:tap="onTapLeftButton" catch:longpress="onLongPressLeftButton" hover-class="icon-wrapper-hover-{{capsuleColor}}" class="icon-wrapper" style="width: {{capsuleButtonInfo.width/2}}px;height: {{capsuleButtonInfo.height}}px;">
|
||||
<cover-image class="icon-left" src="icons/capsule-left-{{capsuleColor}}.png"></cover-image>
|
||||
</cover-view>
|
||||
|
||||
|
||||
<cover-view class="line"></cover-view>
|
||||
|
||||
|
||||
<cover-view catch:tap="onTapRightButton" catch:longpress="onLongPressRightButton" hover-class="icon-wrapper-hover-{{capsuleColor}}" class="icon-wrapper" style="width: {{capsuleButtonInfo.width/2}}px;height: {{capsuleButtonInfo.height}}px;">
|
||||
<cover-image class="icon-right" src="icons/capsule-right-{{capsuleColor}}.png"></cover-image>
|
||||
</cover-view>
|
||||
</cover-view>
|
||||
</cover-view>
|
||||
|
||||
<view class="content-container">
|
||||
<slot></slot>
|
||||
</view>
|
||||
</view>
|
|
@ -0,0 +1 @@
|
|||
.container{position:relative}.container .capsule-bar{width:100%;position:fixed;display:flex;flex-direction:column;top:0;left:0;z-index:999}.container .capsule-bar .status-bar{width:100%}.container .capsule-bar .title-bar{width:100%;display:flex;align-items:center;justify-content:center;margin-top:-4rpx;padding-top:4rpx;box-sizing:border-box}.container .capsule-bar .title-bar .title{font-size:36rpx;font-weight:700}.container .capsule-bar .capsule-button{border-radius:99999px;display:flex;align-items:center;border:1px solid rgba(0,0,0,.1);position:fixed}.container .capsule-bar .capsule-button .icon-wrapper-hover-black{background-color:rgba(0,0,0,.36)}.container .capsule-bar .capsule-button .icon-wrapper-hover-white{background-color:rgba(255,255,255,.339)}.container .capsule-bar .capsule-button .icon-wrapper{display:flex;justify-content:center;align-items:center}.container .capsule-bar .capsule-button .icon-wrapper .icon-left{display:block;width:20rpx;height:34rpx}.container .capsule-bar .capsule-button .icon-wrapper .icon-right{display:block;width:38rpx;height:34rpx}.container .capsule-bar .capsule-button .line{height:18px;width:1px;line-height:1;background-color:rgba(255,255,255,.25)}.container .content-container{width:100%;position:absolute;left:0}
|
|
@ -0,0 +1 @@
|
|||
import validator from"../behaviors/validator";Component({externalClasses:["l-class","l-img-class","l-title-class"],options:{multipleSlots:!0},behaviors:[validator],properties:{image:String,title:String,describe:String,plaintext:Boolean,full:Boolean,position:{type:String,value:"left",options:["left","right"]},type:{type:String,value:"primary",options:["primary","avatar","cover"]},imageMode:{type:String,value:"scaleToFill"}},data:{},methods:{}});
|
|
@ -0,0 +1 @@
|
|||
{"component":true,"usingComponents":{}}
|
|
@ -0,0 +1,22 @@
|
|||
<view class="l-class card-container {{'card-container-' + type}} {{'card-container-' + type + '-' + position}} {{full?'card-container-full':'card-container-unfull'}}">
|
||||
<block wx:if="{{type ==='primary' || type ==='cover'}}">
|
||||
<image wx:if="{{!plaintext}}" class="l-img-class {{full?'cover-img-full':'cover-img-unfull'}} {{ 'card-img-' + type }} {{ 'card-img-' + type + '-' + position }}" mode="{{imageMode}}" lazy-load src="{{image}}"></image>
|
||||
<view class="card-content">
|
||||
<text class="l-title-class card-title {{'card-title-' + type}}">{{title}}</text>
|
||||
<slot/>
|
||||
</view>
|
||||
</block>
|
||||
<block wx:if="{{type ==='avatar'}}">
|
||||
<view class="card-avatar-top">
|
||||
<view class="card-avatar-left">
|
||||
<image mode="aspectFill" class="l-img-class {{ 'card-img-' + type }}" src="{{image}}" mode="{{imageMode}}" lazy-load></image>
|
||||
<view class="card-avatar">
|
||||
<text class="l-title-class card-title {{'card-title-' + type}}">{{title}}</text>
|
||||
<text class="describe">{{describe}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<slot name="more"/>
|
||||
</view>
|
||||
<slot/>
|
||||
</block>
|
||||
</view>
|
|
@ -0,0 +1 @@
|
|||
.card-container{margin:0 auto;padding:30rpx;box-sizing:border-box;background:#fff;display:flex}.card-container-full{width:100%}.card-container-unfull{width:92%;box-shadow:0 4rpx 20rpx 0 rgba(212,217,223,.5);border-radius:4px}.card-container-primary-left{flex-direction:row}.card-container-primary-right{flex-direction:row-reverse}.card-container-avatar{flex-direction:column}.card-container-cover{flex-direction:column}.cover-img-full{width:100%;height:260rpx}.cover-img-unfull{width:100%;height:260rpx}.card-img-primary{height:240rpx;width:240rpx;overflow:hidden}.card-img-primary-left{margin-right:40rpx}.card-img-primary-right{margin-left:40rpx}.card-img-avatar{height:60rpx;width:60rpx;border-radius:50%;margin-right:30rpx}.card-img-avatar{height:60rpx;width:60rpx;border-radius:50%;margin-right:30rpx}.card-content{position:relative;display:flex;flex-direction:column;flex:1}.card-title{overflow:hidden;text-overflow:ellipsis;color:#333}.card-title-primary{font-size:32rpx;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.card-title-avatar{font-size:28rpx}.card-title-cover{font-size:30rpx;margin-top:10rpx}.card-title-avatar{font-size:28rpx}.card-avatar-top{display:flex;flex-direction:row;height:100rpx;align-items:center;justify-content:space-between}.card-avatar-left{display:flex;flex-direction:row;align-items:center}.card-avatar{display:flex;flex-direction:column}.describe{color:#666;font-size:24rpx}
|
|
@ -0,0 +1 @@
|
|||
import eventBus from"../core/utils/event-bus";import rules from"../behaviors/rules";Component({behaviors:["wx://form-field",rules],externalClasses:["l-class","l-error-text","l-error-text-class"],relations:{"../checkbox/index":{type:"child",linked(e){this.init(e)},linkChanged(){},unlinked(){}}},properties:{placement:{type:String,value:"column"},maxSelected:{type:[Number,null],value:null},minSelected:{type:[Number,null],value:null}},data:{},attached(){let{minSelected:e,maxSelected:t}=this.properties;this.checkMax(e,t)},methods:{init(e){void 0===this._keys&&(this._keys={}),void 0===this._selected&&(this._selected={}),this.checkDefaultItem(e),this.checkedKeyRepeat(e)},checkedKeyRepeat(e){let{key:t}=e.properties;if(this._keys[t])throw new Error("keys有重复元素, checkbox的key属性不能重复:"+t);this._keys[t]=!0},checkDefaultItem(e){const{key:t,checked:l,cell:s}=e.properties;l&&(this._selected[t]={...s,checked:!0,value:t})},checkMax(e,t){if(null!==e&&e<0)throw new Error("最小选择个数必须大于等于0");if(null!==t&&t<0)throw new Error("最多选择个数必须大于0");if(null!==t&&null!==e&&e>=t)throw new Error("最多选择个数必须大于最小选择个数")},onEmitEventHandle(e){e.checked?this.addSelect(e):this.removeSelect(e.key),this.validatorData({[this.data.name]:Object.values(this._selected)}),this.triggerEvent("linchange",e,{bubbles:!0,composed:!0}),eventBus.emit("lin-form-change-"+this.id,this.id)},onEmitOverflowHandle(e){this.triggerEvent("linout",e,{bubbles:!0,composed:!0})},removeSelect(e){delete this._selected[e]},addSelect(e){let{key:t,...l}=e;this._selected[t]={...l,value:t}},getValues(){return Object.values(this._selected)},reset(){this._selected={};return this.getRelationNodes("../checkbox/index").forEach(e=>e.setData({checked:!1}))}}});
|
|
@ -0,0 +1 @@
|
|||
{"component":true,"usingComponents":{"l-error-tip":"../error-tip/index","l-checkbox":"../checkbox/index"}}
|
|
@ -0,0 +1,4 @@
|
|||
<view class="l-class checkbox-group checkbox-group-{{placement}}">
|
||||
<slot></slot>
|
||||
</view>
|
||||
<l-error-tip l-error-text-class="l-error-text l-error-text-class" errorText="{{errorText}}" wx:if="{{errorText}}"/>
|
|
@ -0,0 +1 @@
|
|||
.checkbox-group{flex-wrap:wrap}.checkbox-group-row{display:flex;flex-direction:row}.checkbox-group-column{display:flex;flex-direction:column}
|
|
@ -0,0 +1 @@
|
|||
Component({behaviors:["wx://form-field"],externalClasses:["l-class","l-disabled-class"],relations:{"../checkbox-group/index":{type:"parent"}},options:{multipleSlots:!0},properties:{placement:{type:String,value:"left"},custom:{type:Boolean,value:!1},key:{type:String,value:""},cell:{type:Object,value:{}},size:{type:String,value:"38rpx"},disabled:{type:Boolean,value:!1},selectColor:{type:String,value:"#3963BC"},disabledColor:{type:String,value:"#ccc"},color:{type:String,value:"#ccc"},checked:{type:Boolean,value:!1}},data:{parentPlacement:""},ready(){const e=this.getRelationNodes("../checkbox-group/index")[0];let{placement:t}=e.properties;this.setData({parentPlacement:t})},methods:{onCheckboxChangeTap(){if(this.properties.disabled||this.data.parentDisabled)return;const e=this.getRelationNodes("../checkbox-group/index")[0];if(this.properties.checked){if(this.isOverflow("minSelected"))return}else if(this.isOverflow("maxSelected"))return;const t={checked:!this.properties.checked,key:this.properties.key,cell:this.properties.cell};e&&e.onEmitEventHandle(t)},isOverflow(e){const t=this.getRelationNodes("../checkbox-group/index")[0],l=t.properties[e];if(!l)return!1;const i=Object.values(t._selected).length;let o="minSelected"===e?i<=l:i>=l;if(o){let i="minSelected"===e?"min_selected":"max_selected";t.onEmitOverflowHandle&&t.onEmitOverflowHandle({key:this.properties.key,limitNumber:l,type:"overflow_"+i})}return o}}});
|
|
@ -0,0 +1 @@
|
|||
{"component":true,"usingComponents":{"l-button":"../button/index"}}
|
|
@ -0,0 +1,7 @@
|
|||
<view bind:tap="onCheckboxChangeTap" class="label label-{{placement}} label-placement-{{parentPlacement}} {{disabled ? 'label-disabled l-disabled-class' : 'l-class'}}">
|
||||
<view class="checkbox" style="color:{{checked ? selectColor : (disabled ? disabledColor : color)}};font-size: {{size}}">
|
||||
<slot wx:if="{{custom}}" name="icon"/>
|
||||
<view wx:else class="iconfont {{checked? 'icon-select': 'icon-unselect'}}"></view>
|
||||
</view>
|
||||
<slot/>
|
||||
</view>
|
|
@ -0,0 +1 @@
|
|||
.label{display:flex;flex:1;align-items:center;font-size:30rpx;color:#333;width:100%;box-sizing:border-box}.label-left{flex-direction:row}.label-right{flex-direction:row-reverse;justify-content:space-between}.label-disabled{color:#ccc}.label-placement-row{padding-right:30rpx}.checkbox{margin-right:20rpx}.iconfont{font-family:iconfont!important;display:inline-flex;font-style:normal;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}@font-face{font-family:iconfont;src:url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAAAMMAAsAAAAABxgAAAK9AAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEIGVgCDBgqBeIFdATYCJAMMCwgABCAFhG0HQBstBlGUzMkA2c8E020e0uBCKA1ReoTOr2jhX60Fez8evvb7nbu7X40GSTTS8S6aRBOpkCB1plMyIWkJb/+nLTemUXn+tjy1proDbGd+u9OXhuW20ygDQoJwOPhjfw50kxP0dlsW4tKSEtLyKhWqIpT/3MKy5KTZgMvpr8TnWZbTWts2jgmYYEBjDHuKrEQCzjUF2R2BWvJ9Am0LeioHm9MVtBXOskC8RIED7VJMUaRiU6i37C3iHV4zvaZPKG/x5+OfLdoktcxZe/S89mH27bv8VD0phAT5ch5Ih8jYBApx3eq7Uktzm2rahqZu1oO6IqSlklVFLDMN9YP+8RJR55R2wSrNJ775IoLvWEgggzoKDoFYipp4U38JhsVnsZqMDSLDTR9O5v6lxM+emWKnJ0j1WkJfv81PpvtdvqfbrTPuXw1+/Yswbx81bvFu4GNdLq7/WnYQrkR7OT7DTrwSHIOw0QhHGI+BEQb/TCiV/n/7MQFAQ9mO3iwSi9Gz9MCEpIu0tWgZiFkilLN8tRFgA1SnfMgz8o0Kgo9Q+Gcx3f/tTgFfe45JtDoVFO7QvAt/8FflYE8xlY49F13my+xAtjTRk6ASOahCOaGxn+mGGVxKaJrlSBrmkTUtkoWziZqOLdQ1baNtw/Zwx4SoidLCuneCMPSBpO8T2dAXWTjfqJnzi7ph1NB2EdwzO5Yj6oaEHCUf3UeMPM6N59RuUn6m4DZ1pKiMuTckZZTE8WBULW4pJ1liQ3kXTFQNGuEMN+QxSlPGQjgmTwehajEdDk3biwYeZ9C1TxCHIj7keoQiHpYz4XDVrb3/jARupRzS09AQv0FEKRodjQ2MAHKry6GGR2FTuhOYUMpAhmAZtCEekro5hor2WTHiUQPhhExhasgGGVQ32N6Q/UCp1ILzXI4UOYrOQ0he4vKDxXk7twIAAAAA') format('woff2')}.icon-unselect:before{content:"\e727"}.icon-select:before{content:"\e725"}
|
|
@ -0,0 +1 @@
|
|||
import nodeUtil from"../core/utils/node-util";Component({externalClasses:["l-class","l-title-class","l-body-class"],relations:{"../collapse/index":{type:"parent"}},options:{multipleSlots:!0,pureDataPattern:/^_/},properties:{itemId:{type:String,value:"default"},title:{type:String,value:"默认标题"},customTitle:{type:Boolean,value:!1},disable:{type:Boolean,value:!1},animationTime:{type:String,value:"0.3"}},data:{bodyHeight:"0",isExpandContent:!1,_idDefault:-1},methods:{async onTapTitle(){if(this.data.disable)return;let t=this.getRelationNodes("../collapse/index");await t[0].onTapCollapseItem(this)},async foldContent(){const t=await nodeUtil.getNodeRectFromComponent(this,".container-body-wrapper");this.data.isExpandContent?(this.setData({bodyHeight:t.height+"px"}),setTimeout(()=>{this.setData({isExpandContent:!1,bodyHeight:"0px"})},20)):this.setData({isExpandContent:!1,bodyHeight:"0px"})},async expandContent(){const t=await nodeUtil.getNodeRectFromComponent(this,".container-body-wrapper");this.setData({isExpandContent:!0,bodyHeight:t.height+"px"})},onTransitionend(){this.data.isExpandContent&&this.setData({bodyHeight:"auto"})}}});
|
|
@ -0,0 +1 @@
|
|||
{"component":true,"usingComponents":{"l-list":"../list/index","l-icon":"../icon/index"}}
|
|
@ -0,0 +1,12 @@
|
|||
<view class="container l-class">
|
||||
<view bind:tap="onTapTitle" class="container-title l-title-class">
|
||||
<view style="{{disable?'color:#DEE2E6':''}}" wx:if="{{!customTitle}}">{{title}}</view>
|
||||
<l-icon class="container-title-icon" wx:if="{{!customTitle}}" style="{{isExpandContent?'transform:rotate(-180deg);':''}}" name="down" size="28" color="{{disable?'#DEE2E6':'#333'}}"></l-icon>
|
||||
<slot name="title"></slot>
|
||||
</view>
|
||||
<view catch:transitionend="onTransitionend" class="container-body" style="height:{{bodyHeight}};transition-duration:{{animationTime}}s">
|
||||
<view class="container-body-wrapper l-body-class">
|
||||
<slot></slot>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
|
@ -0,0 +1 @@
|
|||
.container{display:flex;flex-direction:column;width:100%;box-sizing:border-box}.container-title{display:flex;justify-content:space-between;padding:10rpx;align-items:center;font-size:32rpx;color:#333}.container-title-l-icon{transition:.3s}.container-body{width:100%;color:#888;box-sizing:border-box;font-size:28rpx;transition:height .3s ease-in-out;overflow:hidden}.container-body-wrapper{position:relative;padding:10rpx}
|
|
@ -0,0 +1 @@
|
|||
Component({options:{pureDataPattern:/^_/},relations:{"../collapse-item/index":{type:"child",linked:function(){this._setAllItemId()},linkChanged:function(){this._setAllItemId()},unlinked:function(){this._setAllItemId()}}},lifetimes:{ready:function(){this.updateView()}},properties:{type:{type:String,value:"normal"},expandItemId:{type:Array,value:[]}},data:{_expandItems:[]},observers:{expandItemId:function(){this.updateView()}},methods:{async updateView(){let t;t="accordion"===this.data.type?this.data.expandItemId.slice(0,1):this.data.expandItemId;let e=this.getRelationNodes("../collapse-item/index");for(let a=0;a<e.length;a++){let d=e[a],i=d.id?d.id:a;t.indexOf(i)>-1&&!d.isExpandContent?await this.setCollapseItemStatus(d,!0):(d.isExpandContent||"accordion"===this.data.type)&&await this.setCollapseItemStatus(d,!1)}},async onTapCollapseItem(t){"accordion"===this.data.type&&await this.foldAllExpandItem(t),this.setCollapseItemStatus(t,!t.data.isExpandContent),t.data.isExpandContent?this.triggerEvent("linfold",{id:t.data.itemId?t.data.itemId:t.data._idDefault}):this.triggerEvent("linexpand",{id:t.data.itemId?t.data.itemId:t.data._idDefault})},async setCollapseItemStatus(t,e){if(e)t.expandContent(),this.data._expandItems.push(t);else{await t.foldContent();for(let e=0;e<this.data._expandItems.length;e++)this.data._expandItems[e]===t&&this.data._expandItems.splice(e,1)}},foldAllExpandItem(t){for(let e=0;e<this.data._expandItems.length;e++)t!==this.data._expandItems[e]&&this.data._expandItems[e].foldContent();this.data._expandItems=[]},_setAllItemId(){this.getRelationNodes("../collapse-item/index").forEach((t,e)=>{t.data._idDefault=e})}}});
|
|
@ -0,0 +1 @@
|
|||
{"component":true,"usingComponents":{}}
|
|
@ -0,0 +1,3 @@
|
|||
<view class="container">
|
||||
<slot></slot>
|
||||
</view>
|
|
@ -0,0 +1 @@
|
|||
import nodeUtil from"../core/utils/node-util";Component({externalClasses:["l-class-header","l-class-active","l-class-inactive","l-class-line","l-class-tabimage","l-header-class","l-active-class","l-inactive-class","l-line-class","l-tabimage-class","l-content-class"],relations:{"../tabpanel/index":{type:"child"},linked(){this.initTabs()}},options:{multipleSlots:!0},properties:{activeKey:{type:String,value:"",observer:"changeCurrent"},placement:{type:String,value:"top"},aminmated:Boolean,scrollable:Boolean,swipeable:{type:Boolean,value:!0},hasLine:{type:Boolean,value:!0},activeColor:{type:String,value:"#333333"},inactiveColor:{type:String,value:"#bbbbbb"}},data:{tabList:[],currentIndex:0,transformX:0,transformY:0},ready(){this.initTabs()},methods:{initTabs(){this.initTabList(),this.initActiveIndex()},initActiveIndex(t=this.data.activeKey){let e=t,a=this.data.currentIndex;this.data.tabList.forEach((s,i)=>{e=t||0!==i?e:s.key,a=s.key===e?i:a}),this.setData({activeKey:e,currentIndex:a},()=>{this.data.scrollable&&this.queryMultipleNodes()})},initTabList(){let t=this.getRelationNodes("../tabpanel/index");if(t.length>0){const e=[];t.forEach(t=>{const a=e.findIndex(e=>e.tab===t.data.tab);let s={};-1===a&&(s={tab:t.data.tab,key:t.data.key,icon:t.data.icon,iconStyle:t.data.iconStyle,image:t.data.image,subTabs:[]},e.push(s));const i=-1===a?s:e[a];if(t.data.subTab){i.subTabs=i.subTabs||[];const e={tab:t.data.subTab,key:t.data.subKey};i.subTabs.push(e),i.activeSubKey=this.data.subActiveKey||i.subTabs[0].key,i.subCurrentIndex=0}}),this.setData({tabList:e})}},swiperChange(t){const{source:e,current:a}=t.detail;if("touch"===e){const t=a,e=this.data.tabList[a].key,s=this.data.tabList[t].subCurrentIndex,i=this.data.tabList[t].activeSubKey;this._setChangeData({activeKey:e,currentIndex:t,subCurrentIndex:s,activeSubKey:i})}},subSwiperChange(t){const{source:e,current:a}=t.detail;if("touch"===e){const{currentIndex:t,activeKey:e}=this.data,s=a,i=this.data.tabList[t].subTabs[s].key,n=this.data.tabList[t];n.activeSubKey=i,n.subCurrentIndex=s,this.setData({[`tabList[${t}]`]:n}),this._setChangeData({activeKey:e,currentIndex:t,activeSubKey:i,subCurrentIndex:s})}},handleChange(t){const e="subTab"===t.currentTarget.dataset.headerType,{currentIndex:a,activeKey:s}=this.data,i=t.currentTarget.dataset.index,n=e?i:this.data.tabList[i].subCurrentIndex,r=e?this.data.tabList[a].subTabs[n].key:this.data.tabList[i].activeSubKey;if(e){const t=this.data.tabList[a];t.activeSubKey=r,t.subCurrentIndex=n,this.setData({[`tabList[${a}]`]:t}),this._setChangeData({activeKey:s,currentIndex:a,activeSubKey:r,subCurrentIndex:n})}else{const e=t.currentTarget.dataset.key;this._setChangeData({activeKey:e,currentIndex:i,subCurrentIndex:n,activeSubKey:r})}},_setChangeData({activeKey:t,currentIndex:e,activeSubKey:a="",subCurrentIndex:s=null}){this.setData({activeKey:t,currentIndex:e},()=>{this.data.scrollable&&this.queryMultipleNodes()}),this.triggerEvent("linchange",{activeKey:t,currentIndex:e,activeSubKey:a,subCurrentIndex:s})},async queryMultipleNodes(){const{placement:t,activeKey:e,tabList:a}=this.data,s=await nodeUtil.getNodeRectFromComponent(this,"#"+e);if(-1!==["top","bottom"].indexOf(t))this.setData({transformX:s.left-a.length/2*s.width,transformY:0});else{const t=await nodeUtil.getNodeRectFromComponent(this,".l-tabs-header"),e=s.top-t.top-t.height/2;this.setData({transformX:0,transformY:e})}}}});
|
|
@ -0,0 +1 @@
|
|||
{"component":true,"usingComponents":{"l-icon":"../icon/index","l-badge":"../badge/index"}}
|
|
@ -0,0 +1,44 @@
|
|||
|
||||
<view class="l-tabs l-placement-top l-tabs-horizontal {{aminmated ? 'l-aminmated' :''}} {{scrollable ? 'l-tabs-scroll':''}}">
|
||||
<template is="tab-header" data="{{tab:tabList,placemanet,scrollable,transformY,transformX,activeKey,hasLine,activeColor,inactiveColor,headerType:'tab'}}"></template>
|
||||
<view class="l-tabs l-sub-placement-left l-tabs-vertical {{aminmated ? 'l-aminmated' :''}} {{scrollable ? 'l-tabs-scroll':''}}">
|
||||
<template is="tab-header" wx:if="{{tabList[currentIndex].subTabs.length}}" data="{{tab:tabList[currentIndex].subTabs,placemanet,scrollable,transformY,transformX,activeKey:tabList[currentIndex].activeSubKey,hasLine,activeColor,inactiveColor,headerType:'subTab'}}"></template>
|
||||
<view class="l-tabs-main">
|
||||
<view wx:if="{{!swipeable}}" class="l-tabpanel-content l-content-class">
|
||||
<view class="l-tabpanel {{item.key===activeKey?'l-tabpanel-active':'l-tabpanel-inactive'}}" wx:for="{{tabList}}" wx:key="key" style="{{placement=='left'||placement=='right' ? 'position:absolute;width:100%;height:100%;transform:translate(0,'+ 100 * index +'%) translateZ(0px);':''}}">
|
||||
<view class="l-subpanel-content" wx:if="{{item.subTabs.length>0}}" style="{{'transform:translate(0,'+ -100 * item.subCurrentIndex +'%) translateZ(0px);'}}">
|
||||
<view class="l-subpanel" wx:for="{{item.subTabs}}" wx:for-item="tab" wx:key="key">
|
||||
<slot name="{{tab.key}}"></slot>
|
||||
</view>
|
||||
</view>
|
||||
<slot name="{{item.key}}" wx:else></slot>
|
||||
</view>
|
||||
</view>
|
||||
<swiper wx:else class="l-tabpanel-content l-content-class" bindchange="swiperChange" current="{{currentIndex}}">
|
||||
<swiper-item class="l-tabpanel {{item.key===activeKey?'l-tabpanel-active':''}}" wx:for="{{tabList}}" wx:key="key">
|
||||
<view wx:if="{{item.subTabs.length>0}}">
|
||||
<swiper class="" vertical bindchange="subSwiperChange" current="{{item.subCurrentIndex}}">
|
||||
<swiper-item wx:for="{{item.subTabs}}" wx:for-item="tab" wx:key="key">
|
||||
<slot name="{{tab.key}}"></slot>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
|
||||
</view>
|
||||
<slot name="{{item.key}}" wx:else></slot>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<template name="tab-header">
|
||||
<scroll-view scroll-x="{{headerType==='tab' && scrollable}}" scroll-y="{{headerType==='subTab' && scrollable}}" scroll-top="{{transformY}}" scroll-left="{{transformX}}" scroll-with-animation class="l-tabsscroll">
|
||||
<view class="l-tabs-header l-class-header l-header-class {{hasLine?'l-tabs-header-line':''}}">
|
||||
<view id="{{item.key}}" class="l-tabs-item {{item.key===activeKey ?'l-class-active l-active-class l-tabs-active':'l-class-inactive l-inactive-class l-tabs-inactive'}} {{'l-tab-image-placement-'+item.image.placement}}" style="color:{{item.key===activeKey?activeColor:inactiveColor}}" wx:for="{{tab}}" wx:key="key" data-key="{{item.key}}" data-index="{{index}}" data-header-type="{{headerType}}" bind:tap="handleChange">
|
||||
<image wx:if="{{ item.image.activeImage || item.image.defaultImage }}" src="{{item.key===activeKey? item.image.activeImage:item.image.defaultImage}}" class="l-tab-image l-class-tabimage l-tabimage-class"/>
|
||||
<l-icon wx:if="{{item.icon}}" l-class="{{item.key===activeKey ? 'l-icon-active':'l-icon-inactive'}}" name="{{item.icon}}" size="28" color="{{item.key===activeKey?activeColor:inactiveColor}}"/>
|
||||
{{item.tab}}
|
||||
<view class="l-tab-line l-class-line l-line-class" wx:if="{{hasLine && item.key===activeKey}}" style="background:{{item.key===activeKey?activeColor:inactiveColor}}"></view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</template>
|
|
@ -0,0 +1 @@
|
|||
.l-tabs{display:flex;border-radius:8rpx;box-sizing:border-box;overflow:hidden;flex-direction:column;background:#fff;height:100%}.l-tabs .l-tabs-header{display:flex;width:100%;flex-direction:row;background:#fff;align-items:center}.l-tabs .l-tabs-header .l-tabs-item{flex:1;font-size:28rpx;text-align:center;box-sizing:border-box;display:flex;justify-content:center;align-items:center}.l-tabs .l-tabs-header .l-icon-active,.l-tabs .l-tabs-header .l-tabs-active{color:#333;font-size:28rpx}.l-tabs .l-tabs-header .l-icon-inactive,.l-tabs .l-tabs-header .l-tabs-inactive{font-size:28rpx;color:#bbb}.l-tabs .l-tabs-header .l-tabsitems-row{flex-direction:row}.l-tabs .l-tabs-header .l-tabsitems-row .l-icon-active,.l-tabs .l-tabs-header .l-tabsitems-row .l-icon-inactive{margin-right:10rpx}.l-tabs .l-tabs-header .l-tabsitems-row-reverse{flex-direction:row-reverse}.l-tabs .l-tabs-header .l-tabsitems-row-reverse .l-icon-active,.l-tabs .l-tabs-header .l-tabsitems-row-reverse .l-icon-inactive{margin-left:10rpx}.l-placement-top .l-tabs-header{height:80rpx}.l-placement-top .l-tabs-header .l-tabs-item{min-height:100%}.l-sub-placement-left{flex-direction:row}.l-sub-placement-left .l-tabs-header{flex-direction:column;width:160rpx}.l-sub-placement-left .l-tabs-header>.l-tabs-item{width:100%;height:80rpx;background:#f6f8fa}.l-sub-placement-left .l-tabs-header>.l-tabs-active{background:#fff}.l-sub-placement-left .l-tabs-main .l-tabpanel-content{width:100%;-webkit-box-orient:vertical;-webkit-box-direction:normal;flex-direction:column;position:relative;will-change:transform;transition:transform .3s cubic-bezier(.645,.045,.355,1)}.l-placement-top .l-tabpanel-content{width:100%;height:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row}.l-subpanel-content{width:100%;height:100%}.l-tabpanel{width:100%;height:100%;-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;-webkit-transition:opacity .45s;transition:opacity .45s;opacity:1;text-overflow:ellipsis}.l-tabpanel-inactive{opacity:0;height:0;padding:0!important;pointer-events:none}.l-subpanel{height:100%}.l-tabs-scroll.l-tabs-horizontal .l-tabs-header{-webkit-overflow-scrolling:touch;white-space:nowrap}.l-tabs-scroll.l-tabs-horizontal .l-tabs-header .l-tabs-item{overflow:visible;min-width:160rpx}.l-tabs-scroll.l-tabs-horizontal .l-tabpanel-content{height:150px}.l-tabs-vertical .l-tabsscroll{width:160rpx}.l-tabs-vertical .l-tabs-header{height:100%;min-height:80rpx;-webkit-overflow-scrolling:touch;white-space:nowrap}.l-tabs-vertical .l-tabs-header .l-tabs-item{overflow:visible;min-height:80rpx}.l-tabs-item{position:relative}.l-tab-line{position:absolute;bottom:0;left:0;right:0;width:0;background:#000}.l-tabs-horizontal .l-tab-line{height:4rpx;margin:0 auto}.l-tabs-horizontal .l-tabs-active .l-tab-line{width:100%;transition-delay:.1s}.l-placement-top .l-tab-line{bottom:0}.l-placement-top .l-tabs-header-line{border-bottom:1px solid #f3f3f3}.l-tabs-vertical .l-tabs-active .l-tab-line{width:6rpx!important;height:40rpx!important;border-radius:0 6rpx 6rpx 0;top:0;left:0;margin:auto 0;transition-delay:.1s}.l-sub-placement-left .l-tab-line{left:0;right:auto}.l-sub-placement-left .l-tabs-header-line{border-right:1px solid #f3f3f3}.l-tab-image{width:100rpx;height:100rpx}.l-tab-image-placement-top{flex-direction:column}.l-tab-image-placement-left{flex-direction:row}.l-tabs-main{flex:1}.l-combined-tabs-main{display:flex}
|
|
@ -0,0 +1 @@
|
|||
import{format,complementError,asyncMap,warning,deepMerge}from"./util.js";import validators from"./validator/index.js";import{messages as defaultMessages,newMessages}from"./messages.js";function Schema(e){this.rules=null,this._messages=defaultMessages,this.define(e)}Schema.prototype={messages(e){return e&&(this._messages=deepMerge(newMessages(),e)),this._messages},define(e){if(!e)throw new Error("Cannot configure a schema with no rules");if("object"!=typeof e||Array.isArray(e))throw new Error("Rules must be an object");let t,s;for(t in this.rules={},e)e.hasOwnProperty(t)&&(s=e[t],this.rules[t]=Array.isArray(s)?s:[s])},validate(e,t={},s){let r,a,o=e,i=t,n=s;if("function"==typeof i&&(n=i,i={}),!this.rules||0===Object.keys(this.rules).length)return void(n&&n());if(i.messages){let e=this.messages();e===defaultMessages&&(e=newMessages()),deepMerge(e,i.messages),i.messages=e}else i.messages=this.messages();const l={};(i.keys||Object.keys(this.rules)).forEach(t=>{r=this.rules[t],a=o[t],r.forEach(s=>{let r=s;"function"==typeof r.transform&&(o===e&&(o={...o}),a=o[t]=r.transform(a)),r="function"==typeof r?{validator:r}:{...r},r.validator=this.getValidationMethod(r),r.field=t,r.fullField=r.fullField||t,r.type=this.getType(r),r.validator&&(l[t]=l[t]||[],l[t].push({rule:r,value:a,source:o,field:t}))})});const f={};asyncMap(l,i,(e,t)=>{const s=e.rule;let r=!("object"!==s.type&&"array"!==s.type||"object"!=typeof s.fields&&"object"!=typeof s.defaultField);function a(e,t){return{...t,fullField:`${s.fullField}.${e}`}}function o(o=[]){let n=o;if(Array.isArray(n)||(n=[n]),n.length&&warning("async-validator:",n),n.length&&s.message&&(n=[].concat(s.message)),n=n.map(complementError(s)),i.first&&n.length)return f[s.field]=1,t(n);if(r){if(s.required&&!e.value)return n=s.message?[].concat(s.message).map(complementError(s)):i.error?[i.error(s,format(i.messages.required,s.field))]:[],t(n);let r={};if(s.defaultField)for(const t in e.value)e.value.hasOwnProperty(t)&&(r[t]=s.defaultField);r={...r,...e.rule.fields};for(const e in r)if(r.hasOwnProperty(e)){const t=Array.isArray(r[e])?r[e]:[r[e]];r[e]=t.map(a.bind(null,e))}const o=new Schema(r);o.messages(i.messages),e.rule.options&&(e.rule.options.messages=i.messages,e.rule.options.error=i.error),o.validate(e.value,e.rule.options||i,e=>{t(e&&e.length?n.concat(e):e)})}else t(n)}r=r&&(s.required||!s.required&&e.value),s.field=e.field;const n=s.validator(s,e.value,o,e.source,i);n&&n.then&&n.then(()=>o(),e=>o(e))},e=>{!function(e){let t,s,r=[],a={};for(t=0;t<e.length;t++)o=e[t],Array.isArray(o)?r=r.concat.apply(r,o):r.push(o);var o;if(r.length)for(t=0;t<r.length;t++)s=r[t].field,a[s]=a[s]||[],a[s].push(r[t]);else r=null,a=null;n(r,a)}(e)})},getType(e){if(void 0===e.type&&e.pattern instanceof RegExp&&(e.type="pattern"),"function"!=typeof e.validator&&e.type&&!validators.hasOwnProperty(e.type))throw new Error(format("Unknown rule type %s",e.type));return e.type||"string"},getValidationMethod(e){if("function"==typeof e.validator)return e.validator;const t=Object.keys(e),s=t.indexOf("message");return-1!==s&&t.splice(s,1),1===t.length&&"required"===t[0]?validators.required:validators[this.getType(e)]||!1}},Schema.register=function(e,t){if("function"!=typeof t)throw new Error("Cannot register a validator by type, validator is not a function");validators[e]=t},Schema.messages=defaultMessages;export default Schema;
|
|
@ -0,0 +1 @@
|
|||
export function newMessages(){return{default:"Validation error on field %s",required:"%s is required",enum:"%s must be one of %s",whitespace:"%s cannot be empty",date:{format:"%s date %s is invalid for format %s",parse:"%s date could not be parsed, %s is invalid ",invalid:"%s date %s is invalid"},types:{string:"%s is not a %s",method:"%s is not a %s (function)",array:"%s is not an %s",object:"%s is not an %s",number:"%s is not a %s",date:"%s is not a %s",boolean:"%s is not a %s",integer:"%s is not an %s",float:"%s is not a %s",regexp:"%s is not a valid %s",email:"%s is not a valid %s",url:"%s is not a valid %s",hex:"%s is not a valid %s"},string:{len:"%s must be exactly %s characters",min:"%s must be at least %s characters",max:"%s cannot be longer than %s characters",range:"%s must be between %s and %s characters"},number:{len:"%s must equal %s",min:"%s cannot be less than %s",max:"%s cannot be greater than %s",range:"%s must be between %s and %s"},array:{len:"%s must be exactly %s in length",min:"%s cannot be less than %s in length",max:"%s cannot be greater than %s in length",range:"%s must be between %s and %s in length"},pattern:{mismatch:"%s value %s does not match pattern %s"},clone(){const s=JSON.parse(JSON.stringify(this));return s.clone=this.clone,s}}}export const messages=newMessages();
|
|
@ -0,0 +1 @@
|
|||
import*as util from"../util";const ENUM="enum";function enumerable(e,u,n,m,r){e.enum=Array.isArray(e.enum)?e.enum:[],-1===e.enum.indexOf(u)&&m.push(util.format(r.messages.enum,e.fullField,e.enum.join(", ")))}export default enumerable;
|
|
@ -0,0 +1 @@
|
|||
import required from"./required.js";import whitespace from"./whitespace.js";import type from"./type.js";import range from"./range.js";import enumRule from"./enum.js";import pattern from"./pattern.js";export default{required:required,whitespace:whitespace,type:type,range:range,enum:enumRule,pattern:pattern};
|
|
@ -0,0 +1 @@
|
|||
import*as util from"../util";function pattern(t,e,a,p,n){if(t.pattern)if(t.pattern instanceof RegExp)t.pattern.lastIndex=0,t.pattern.test(e)||p.push(util.format(n.messages.pattern.mismatch,t.fullField,e,t.pattern));else if("string"==typeof t.pattern){new RegExp(t.pattern.replace(/^\/|\/$/g,"")).test(e)||p.push(util.format(n.messages.pattern.mismatch,t.fullField,e,t.pattern))}}export default pattern;
|
|
@ -0,0 +1 @@
|
|||
import*as util from"../util";function range(e,l,n,m,t){const u="number"==typeof e.len,r="number"==typeof e.min,a="number"==typeof e.max,i=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;let s=l,f=null;const o="number"==typeof l,g="string"==typeof l,p=Array.isArray(l);if(o?f="number":g?f="string":p&&(f="array"),!f)return!1;p&&(s=l.length),g&&(s=l.replace(i,"_").length),u?s!==e.len&&m.push(util.format(t.messages[f].len,e.fullField,e.len)):r&&!a&&s<e.min?m.push(util.format(t.messages[f].min,e.fullField,e.min)):a&&!r&&s>e.max?m.push(util.format(t.messages[f].max,e.fullField,e.max)):r&&a&&(s<e.min||s>e.max)&&m.push(util.format(t.messages[f].range,e.fullField,e.min,e.max))}export default range;
|
|
@ -0,0 +1 @@
|
|||
import*as util from"../util";function required(e,r,i,u,t,l){!e.required||i.hasOwnProperty(e.field)&&!util.isEmptyValue(r,l||e.type)||u.push(util.format(t.messages.required,e.fullField))}export default required;
|
|
@ -0,0 +1 @@
|
|||
import*as util from"../util";import required from"./required";const pattern={email:/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,url:new RegExp("^(?!mailto:)(?:(?:http|https|ftp)://|//)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?$","i"),hex:/^#?([a-f0-9]{6}|[a-f0-9]{3})$/i},types={integer:e=>types.number(e)&&parseInt(e,10)===e,float:e=>types.number(e)&&!types.integer(e),array:e=>Array.isArray(e),regexp(e){if(e instanceof RegExp)return!0;try{return!!new RegExp(e)}catch(e){return!1}},date:e=>"function"==typeof e.getTime&&"function"==typeof e.getMonth&&"function"==typeof e.getYear,number:e=>!isNaN(e)&&""!==e,object:e=>"object"==typeof e&&!types.array(e),method:e=>"function"==typeof e,email:e=>"string"==typeof e&&!!e.match(pattern.email)&&e.length<255,url:e=>"string"==typeof e&&!!e.match(pattern.url),hex:e=>"string"==typeof e&&!!e.match(pattern.hex)};function type(e,t,r,a,f){if(e.required&&void 0===t)return void required(e,t,r,a,f);const p=e.type;["integer","float","array","regexp","object","method","email","number","date","url","hex"].indexOf(p)>-1?types[p](t)||a.push(util.format(f.messages.types[p],e.fullField,e.type)):p&&typeof t!==e.type&&a.push(util.format(f.messages.types[p],e.fullField,e.type))}export default type;
|
|
@ -0,0 +1 @@
|
|||
import*as util from"../util";function whitespace(t,e,s,i,a){(/^\s+$/.test(e)||""===e)&&i.push(util.format(a.messages.whitespace,t.fullField))}export default whitespace;
|
|
@ -0,0 +1 @@
|
|||
const formatRegExp=/%[sdj%]/g;export let warning=()=>{};export function format(...t){let e=1;const r=t[0],n=t.length;if("function"==typeof r)return r.apply(null,t.slice(1));if("string"==typeof r){let i=String(r).replace(formatRegExp,r=>{if("%%"===r)return"%";if(e>=n)return r;switch(r){case"%s":return String(t[e++]);case"%d":return Number(t[e++]);case"%j":try{return JSON.stringify(t[e++])}catch(t){return"[Circular]"}default:return r}});for(let r=t[e];e<n;r=t[++e])i+=" "+r;return i}return r}function isNativeStringType(t){return"string"===t||"url"===t||"hex"===t||"email"===t||"pattern"===t}export function isEmptyValue(t,e){return null==t||(!("array"!==e||!Array.isArray(t)||t.length)||!(!isNativeStringType(e)||"string"!=typeof t||t))}export function isEmptyObject(t){return 0===Object.keys(t).length}function asyncParallelArray(t,e,r){const n=[];let i=0;const l=t.length;function a(t){n.push.apply(n,t),i++,i===l&&r(n)}t.forEach(t=>{e(t,a)})}function asyncSerialArray(t,e,r){let n=0;const i=t.length;!function l(a){if(a&&a.length)return void r(a);const c=n;n+=1,c<i?e(t[c],l):r([])}([])}function flattenObjArr(t){const e=[];return Object.keys(t).forEach(r=>{e.push.apply(e,t[r])}),e}export function asyncMap(t,e,r,n){if(e.first){return asyncSerialArray(flattenObjArr(t),r,n)}let i=e.firstFields||[];!0===i&&(i=Object.keys(t));const l=Object.keys(t),a=l.length;let c=0;const o=[],s=t=>{o.push.apply(o,t),c++,c===a&&n(o)};l.forEach(e=>{const n=t[e];-1!==i.indexOf(e)?asyncSerialArray(n,r,s):asyncParallelArray(n,r,s)})}export function complementError(t){return e=>e&&e.message?(e.field=e.field||t.fullField,e):{message:e,field:e.field||t.fullField}}export function deepMerge(t,e){if(e)for(const r in e)if(e.hasOwnProperty(r)){const n=e[r];"object"==typeof n&&"object"==typeof t[r]?t[r]={...t[r],...n}:t[r]=n}return t}
|
|
@ -0,0 +1 @@
|
|||
import rules from"../rule/index.js";import{isEmptyValue}from"../util";function array(r,e,a,u,i){const t=[];if(r.required||!r.required&&u.hasOwnProperty(r.field)){if(isEmptyValue(e,"array")&&!r.required)return a();rules.required(r,e,u,t,i,"array"),isEmptyValue(e,"array")||(rules.type(r,e,u,t,i),rules.range(r,e,u,t,i))}a(t)}export default array;
|
|
@ -0,0 +1 @@
|
|||
import{isEmptyValue}from"../util";import rules from"../rule/index.js";function boolean(e,r,i,u,o){const t=[];if(e.required||!e.required&&u.hasOwnProperty(e.field)){if(isEmptyValue(r)&&!e.required)return i();rules.required(e,r,u,t,o),void 0!==r&&rules.type(e,r,u,t,o)}i(t)}export default boolean;
|
|
@ -0,0 +1 @@
|
|||
import rules from"../rule/index.js";import{isEmptyValue}from"../util";function date(e,r,t,i,u){const l=[];if(e.required||!e.required&&i.hasOwnProperty(e.field)){if(isEmptyValue(r)&&!e.required)return t();if(rules.required(e,r,i,l,u),!isEmptyValue(r)){let t;t="number"==typeof r?new Date(r):r,rules.type(e,t,i,l,u),t&&rules.range(e,t.getTime(),i,l,u)}}t(l)}export default date;
|
|
@ -0,0 +1 @@
|
|||
import rules from"../rule/index.js";import{isEmptyValue}from"../util";const ENUM="enum";function enumerable(e,r,u,i,t){const l=[];if(e.required||!e.required&&i.hasOwnProperty(e.field)){if(isEmptyValue(r)&&!e.required)return u();rules.required(e,r,i,l,t),r&&rules.enum(e,r,i,l,t)}u(l)}export default enumerable;
|
|
@ -0,0 +1 @@
|
|||
import rules from"../rule/index.js";import{isEmptyValue}from"../util";function floatFn(e,r,i,u,t){const l=[];if(e.required||!e.required&&u.hasOwnProperty(e.field)){if(isEmptyValue(r)&&!e.required)return i();rules.required(e,r,u,l,t),void 0!==r&&(rules.type(e,r,u,l,t),rules.range(e,r,u,l,t))}i(l)}export default floatFn;
|
|
@ -0,0 +1 @@
|
|||
import string from"./string";import method from"./method";import number from"./number";import boolean from"./boolean";import regexp from"./regexp";import integer from"./integer";import float from"./float";import array from"./array";import object from"./object";import enumValidator from"./enum";import pattern from"./pattern";import date from"./date";import required from"./required";import type from"./type";export default{string:string,method:method,number:number,boolean:boolean,regexp:regexp,integer:integer,float:float,array:array,object:object,enum:enumValidator,pattern:pattern,date:date,url:type,hex:type,email:type,required:required};
|
|
@ -0,0 +1 @@
|
|||
import rules from"../rule/index.js";import{isEmptyValue}from"../util";function integer(e,r,i,u,t){const l=[];if(e.required||!e.required&&u.hasOwnProperty(e.field)){if(isEmptyValue(r)&&!e.required)return i();rules.required(e,r,u,l,t),void 0!==r&&(rules.type(e,r,u,l,t),rules.range(e,r,u,l,t))}i(l)}export default integer;
|
|
@ -0,0 +1 @@
|
|||
import rules from"../rule/index.js";import{isEmptyValue}from"../util";function method(e,r,i,t,u){const o=[];if(e.required||!e.required&&t.hasOwnProperty(e.field)){if(isEmptyValue(r)&&!e.required)return i();rules.required(e,r,t,o,u),void 0!==r&&rules.type(e,r,t,o,u)}i(o)}export default method;
|
|
@ -0,0 +1 @@
|
|||
import rules from"../rule/index.js";import{isEmptyValue}from"../util";function number(e,r,u,i,t){const l=[];if(e.required||!e.required&&i.hasOwnProperty(e.field)){if(isEmptyValue(r)&&!e.required)return u();rules.required(e,r,i,l,t),void 0!==r&&(rules.type(e,r,i,l,t),rules.range(e,r,i,l,t))}u(l)}export default number;
|
|
@ -0,0 +1 @@
|
|||
import rules from"../rule/index.js";import{isEmptyValue}from"../util";function object(e,r,i,t,u){const o=[];if(e.required||!e.required&&t.hasOwnProperty(e.field)){if(isEmptyValue(r)&&!e.required)return i();rules.required(e,r,t,o,u),void 0!==r&&rules.type(e,r,t,o,u)}i(o)}export default object;
|
|
@ -0,0 +1 @@
|
|||
import rules from"../rule/index.js";import{isEmptyValue}from"../util";function pattern(r,e,t,i,u){const n=[];if(r.required||!r.required&&i.hasOwnProperty(r.field)){if(isEmptyValue(e,"string")&&!r.required)return t();rules.required(r,e,i,n,u),isEmptyValue(e,"string")||rules.pattern(r,e,i,n,u)}t(n)}export default pattern;
|
|
@ -0,0 +1 @@
|
|||
import rules from"../rule/index.js";import{isEmptyValue}from"../util";function regexp(e,r,i,u,t){const l=[];if(e.required||!e.required&&u.hasOwnProperty(e.field)){if(isEmptyValue(r)&&!e.required)return i();rules.required(e,r,u,l,t),isEmptyValue(r)||rules.type(e,r,u,l,t)}i(l)}export default regexp;
|
|
@ -0,0 +1 @@
|
|||
import rules from"../rule/index.js";function required(r,e,u,i,o){const t=[],a=Array.isArray(e)?"array":typeof e;rules.required(r,e,i,t,o,a),u(t)}export default required;
|
|
@ -0,0 +1 @@
|
|||
import rules from"../rule/index.js";import{isEmptyValue}from"../util";function string(e,r,i,t,s){const u=[];if(e.required||!e.required&&t.hasOwnProperty(e.field)){if(isEmptyValue(r,"string")&&!e.required)return i();rules.required(e,r,t,u,s,"string"),isEmptyValue(r,"string")||(rules.type(e,r,t,u,s),rules.range(e,r,t,u,s),rules.pattern(e,r,t,u,s),!0===e.whitespace&&rules.whitespace(e,r,t,u,s))}i(u)}export default string;
|
|
@ -0,0 +1 @@
|
|||
import rules from"../rule/index.js";import{isEmptyValue}from"../util";function type(e,r,t,i,u){const p=e.type,l=[];if(e.required||!e.required&&i.hasOwnProperty(e.field)){if(isEmptyValue(r,p)&&!e.required)return t();rules.required(e,r,i,l,u,p),isEmptyValue(r,p)||rules.type(e,r,i,l,u)}t(l)}export default type;
|
|
@ -0,0 +1 @@
|
|||
class DataUtil{setDiffData(t,a){const e={};Object.keys(a).forEach(s=>{t.data[s]!==a[s]&&(e[s]=a[s])}),Object.keys(e).length&&t.setData(e)}}const dataUtil=new DataUtil;export default dataUtil;
|
|
@ -0,0 +1 @@
|
|||
let EventBus=function(){};var objBus=[],arrBus=[];EventBus.prototype={obj:{set:function(r,u){if(r&&u){var n={};n.k=r,n.v=u;for(var t=0,s=objBus.length;t<s;t++){objBus[t].k===r&&objBus.splice(t,1)}objBus.push(n)}},get:function(r){if(r)for(var u=0,n=objBus.length;u<n;u++){var t=objBus[u];if(t.k===r)return t.v()}}},emit:function(r,u){if(r)for(var n=0,t=arrBus.length;n<t;n++){var s=arrBus[n];if(s.k===r)return s.v(u)}return new Promise(r=>{r()})},on:function(r,u){if(r&&u){var n={};n.k=r,n.v=u,arrBus.push(n)}},arr:{push:function(r,u){if(r&&u){var n={};n.k=r,n.v=u,arrBus.push(n)}},pop:function(r){if(r)for(var u=0,n=arrBus.length;u<n;u++){var t=arrBus[u];t.k===r&&t.v()}}}};var eventBus=new EventBus;export default eventBus;
|
|
@ -0,0 +1 @@
|
|||
class EventUtil{emit(e,t,l){e.triggerEvent(t,l,{bubbles:!0,composed:!0,capturePhase:!0})}}const eventUtil=new EventUtil;export default eventUtil;
|
|
@ -0,0 +1 @@
|
|||
class NodeUtil{async getNodeRectFromComponent(e,t){return await new Promise(o=>{e.createSelectorQuery().select(t).boundingClientRect(e=>{o(e)}).exec()})}async getNodesRectFromComponent(e,t){return await new Promise(o=>{e.createSelectorQuery().selectAll(t).boundingClientRect(e=>{o(e)}).exec()})}async getNodeFieldsFromComponent(e,t,o){return await new Promise(n=>{e.createSelectorQuery().select(t).fields(o,e=>{n(e)}).exec()})}}const nodeUtil=new NodeUtil;export default nodeUtil;
|
|
@ -0,0 +1 @@
|
|||
class PixelUtil{constructor(t){this.systemInfo=t}px2rpx(t){return 750/this.systemInfo.screenWidth*t}rpx2px(t){return t/750*this.systemInfo.screenWidth}}const pixelUtil=new PixelUtil(wx.getSystemInfoSync());export default pixelUtil;
|
|
@ -0,0 +1 @@
|
|||
Component({externalClasses:["l-class","l-symbol-class","l-count-class","l-disabled-class"],properties:{count:{type:Number,value:1},max:{type:Number,value:9999},min:{type:Number,value:1},step:{type:Number,value:1},disabled:Boolean,iconSize:String,iconColor:String},data:{focus:!1,result:1},observers:{"count,min,max":function(){this.valueRange(this.data.count,"parameter")}},methods:{doNothing(t){const{type:e}=t.currentTarget.dataset;this.triggerEvent("linout",{type:e,way:"icon"},{bubbles:!0,composed:!0})},onCount(){this.setData({focus:!0})},onBlur(t){this.setData({focus:!1});let{value:e}=t.detail;setTimeout(()=>{this.blurCount(Number(e),()=>{this.data.count=this.data.result,this.triggerEvent("lintap",{count:this.data.result,type:"blur"},{bubbles:!0,composed:!0})})},50)},blurCount(t,e){t?this.valueRange(t):this.setData({result:this.properties.count}),e&&e()},valueRange(t,e="input"){t>this.properties.max?this.setData({result:this.properties.max},()=>{this.triggerEvent("linout",{type:"overflow_max",way:e},{bubbles:!0,composed:!0})}):t<this.properties.min?this.setData({result:this.properties.min},()=>{this.triggerEvent("linout",{type:"overflow_min",way:e},{bubbles:!0,composed:!0})}):this.setData({result:t})},reduceTap(){this.data.count-this.properties.step<=this.properties.min?this.data.count=this.properties.min:this.data.count-=this.properties.step,this.setData({result:this.data.count}),this.triggerEvent("lintap",{count:this.data.result,type:"reduce"},{bubbles:!0,composed:!0})},addTap(){this.data.count+this.properties.step>=this.properties.max?this.data.count=this.properties.max:this.data.count+=this.properties.step,this.setData({result:this.data.count}),this.triggerEvent("lintap",{count:this.data.result,type:"add"},{bubbles:!0,composed:!0})}}});
|
|
@ -0,0 +1 @@
|
|||
{"component":true,"usingComponents":{"l-icon":"../icon/index"}}
|
|
@ -0,0 +1,10 @@
|
|||
<view class="l-class container-count">
|
||||
<view class="symbol {{result<=min|| disabled?'disabled l-disabled-class':'abled l-symbol-class'}}" catchtap="{{result<=min|| disabled?'doNothing':'reduceTap'}}" data-type="overflow_min" hover-class="count-hover">
|
||||
<view class="l-icon l-icon-reduce" style="font-size:{{iconSize}};color:{{iconColor}}"></view>
|
||||
</view>
|
||||
<input wx:if="{{focus}}" class="l-count-class count" disabled="{{disabled}}" type="number" focus="{{focus}}" value="{{result}}" bindblur="onBlur"/>
|
||||
<view wx:else class="l-count-class count" bindtap="onCount">{{result}}</view>
|
||||
<view class="l-symbol-class symbol {{result>=max|| disabled?'disabled l-disabled-class':'abled l-symbol-class'}}" catchtap="{{result>=max|| disabled?'doNothing':'addTap'}}" data-type="overflow_max" hover-class="count-hover">
|
||||
<view class="l-icon l-icon-add" style="font-size:{{iconSize}};color:{{iconColor}}"></view>
|
||||
</view>
|
||||
</view>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue