first commit

This commit is contained in:
编码猿
2024-09-27 01:32:49 +08:00
commit 28ebe05a64
7399 changed files with 1174529 additions and 0 deletions

View File

@@ -0,0 +1 @@
c5fb51e3-6e36-41d5-8d4b-68dee1b87612

View File

@@ -0,0 +1 @@
e7070433-045e-4a3e-a423-7bec01a09cdd

View File

@@ -0,0 +1 @@
5e9b44c2-583d-4463-9edd-33ed2db98f8d

View File

@@ -0,0 +1,29 @@
Component({
externalClasses: ['i-class', 'i-class-alone'],
properties: {
count: {
type: Number,
value: 0,
observer: 'finalCount'
},
overflowCount: {
type: Number,
value: 99
},
dot: {
type: Boolean,
value: false
},
},
data: {
finalCount: 0
},
methods: {
finalCount() {
this.setData({
finalCount: parseInt(this.data.count) >= parseInt(this.data.overflowCount) ? `${this.data.overflowCount}+` : this.data.count
});
},
}
});

View File

@@ -0,0 +1,3 @@
{
"component": true
}

View File

@@ -0,0 +1,5 @@
<view class="i-class i-badge">
<slot></slot>
<view class="i-badge-dot" wx:if="{{ dot }}"></view>
<view class="i-badge-count i-class-alone" wx:elif="{{ count !== 0 }}">{{ finalCount }}</view>
</view>

View File

@@ -0,0 +1 @@
.i-badge{position:relative;display:inline-block;line-height:1;vertical-align:middle}.i-badge-count{position:absolute;transform:translateX(50%);top:-6px;right:0;height:18px;border-radius:9px;min-width:18px;background:#ed3f14;border:1px solid transparent;color:#fff;line-height:18px;text-align:center;padding:0 5px;font-size:12px;white-space:nowrap;transform-origin:-10% center;z-index:10;box-shadow:0 0 0 1px #fff;box-sizing:border-box;text-rendering:optimizeLegibility}.i-badge-count-alone{top:auto;display:block;position:relative;transform:translateX(0)}.i-badge-dot{position:absolute;transform:translateX(-50%);transform-origin:0 center;top:-4px;right:-8px;height:8px;width:8px;border-radius:100%;background:#ed3f14;z-index:10;box-shadow:0 0 0 1px #fff}

View File

@@ -0,0 +1 @@
f3f73713-c88d-41d9-8403-7aa414a3840c

View File

@@ -0,0 +1,37 @@
function getCtx (selector) {
const pages = getCurrentPages();
const ctx = pages[pages.length - 1];
const componentCtx = ctx.selectComponent(selector);
if (!componentCtx) {
console.error('无法找到对应的组件,请按文档说明使用组件');
return null;
}
return componentCtx;
}
function Toast(options) {
const { selector = '#toast' } = options;
const ctx = getCtx(selector);
ctx.handleShow(options);
}
Toast.hide = function (selector = '#toast') {
const ctx = getCtx(selector);
ctx.handleHide();
};
function Message(options) {
const { selector = '#message' } = options;
const ctx = getCtx(selector);
ctx.handleShow(options);
}
module.exports = {
$Toast: Toast,
$Message: Message
};

View File

@@ -0,0 +1 @@
7a8dec79-d5ba-48d7-b345-54d95510f1c5

View File

@@ -0,0 +1,22 @@
Component({
externalClasses: ['i-class'],
properties: {
type: {
type: String,
value: ''
},
custom: {
type: String,
value: ''
},
size: {
type: Number,
value: 14
},
color: {
type: String,
value: ''
}
}
});

View File

@@ -0,0 +1,3 @@
{
"component": true
}

View File

@@ -0,0 +1 @@
<view class="i-class i-icon {{ type === '' ? '' : 'i-icon-' + type }} {{ custom }}" style="font-size: {{ size }}px; {{ color ? 'color:' + color : '' }}"></view>

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
329dcedb-f785-4c7d-9146-07ae7ebfc6d8

View File

@@ -0,0 +1,101 @@
function addNum (num1, num2) {
let sq1, sq2, m;
try {
sq1 = num1.toString().split('.')[1].length;
}
catch (e) {
sq1 = 0;
}
try {
sq2 = num2.toString().split('.')[1].length;
}
catch (e) {
sq2 = 0;
}
m = Math.pow(10, Math.max(sq1, sq2));
return (Math.round(num1 * m) + Math.round(num2 * m)) / m;
}
Component({
externalClasses: ['i-class'],
properties: {
// small || default || large
size: String,
value: {
type: Number,
value: 1
},
min: {
type: Number,
value: -Infinity
},
max: {
type: Number,
value: Infinity
},
step: {
type: Number,
value: 1
}
},
methods: {
handleChangeStep(e, type) {
const { dataset = {} } = e.currentTarget;
const { disabled } = dataset;
const { step } = this.data;
let { value } = this.data;
if (disabled) return null;
if (type === 'minus') {
value = addNum(value, -step);
} else if (type === 'plus') {
value = addNum(value, step);
}
if (value < this.data.min || value > this.data.max) return null;
this.handleEmit(value, type);
},
handleMinus(e) {
this.handleChangeStep(e, 'minus');
},
handlePlus(e) {
this.handleChangeStep(e, 'plus');
},
handleBlur(e) {
let { value } = e.detail;
const { min, max } = this.data;
if (!value) {
setTimeout(() => {
this.handleEmit(value);
}, 16);
return;
}
value = +value;
if (value > max) {
value = max;
} else if (value < min) {
value = min;
}
this.handleEmit(value);
},
handleEmit (value, type) {
const data = {
value: value
};
if (type) data.type = type;
this.triggerEvent('change', data);
}
}
});

View File

@@ -0,0 +1,6 @@
{
"component": true,
"usingComponents": {
"wux-icon": "../../../wux/dist/icon/index"
}
}

View File

@@ -0,0 +1,9 @@
<view class="i-class i-input-number i-input-number-size-{{ size }}">
<view class="i-input-number-minus {{ value <= min ? 'i-input-number-disabled' : '' }}" data-disabled="{{ value <= min }}" catchtap="handleMinus">
<wux-icon size="18" type="md-remove" />
</view>
<input disabled class="i-input-number-text {{ min >= max ? 'i-input-number-disabled' : '' }}" type="number" value="{{ value }}" bindblur="handleBlur" />
<view class="i-input-number-plus {{ value >= max ? 'i-input-number-disabled' : '' }}" data-disabled="{{ value >= max }}" catchtap="handlePlus">
<wux-icon size="18" type="md-add" />
</view>
</view>

View File

@@ -0,0 +1 @@
.i-input-number{color:#495060}.i-input-number view{display:inline-block;line-height:20px;padding:5px 0;text-align:center;min-width:40px;box-sizing:border-box;vertical-align:middle;font-size:12px;border:1rpx solid #dddee1}.i-input-number-minus{border-right:none;border-radius:2px 0 0 2px}.i-input-number-plus{border-left:none;border-radius:0 2px 2px 0}.i-input-number-text{border:1rpx solid #dddee1;display:inline-block;text-align:center;vertical-align:middle;height:30px;width:40px;min-height:auto;font-size:12px;line-height:30px}.i-input-number-disabled{border-color:#dddee1;color:#bbbec4;background:#f7f7f7}

View File

@@ -0,0 +1 @@
d18574ad-fea5-4631-8d02-df4c37ff7b1a

View File

@@ -0,0 +1,50 @@
Component({
externalClasses: ['i-class'],
relations: {
'../tabs/index': {
type: 'parent'
}
},
properties: {
key: {
type: String,
value: ''
},
title: {
type: String,
value: ''
},
dot: {
type: Boolean,
value: false
},
count: {
type: Number,
value: 0
}
},
data: {
current: false,
currentColor: '',
scroll: false
},
methods: {
changeCurrent (current) {
this.setData({ current });
},
changeCurrentColor (currentColor) {
this.setData({ currentColor });
},
changeScroll (scroll) {
this.setData({ scroll });
},
handleClickItem () {
const parent = this.getRelationNodes('../tabs/index')[0];
parent.emitEvent(this.data.key);
}
}
});

View File

@@ -0,0 +1,7 @@
{
"component": true,
"usingComponents":
{
"i-badge": "../badge/index"
}
}

View File

@@ -0,0 +1,9 @@
<view class="i-class i-tabs-tab {{ scroll ? 'i-tabs-tab-scroll' : '' }} {{ current ? 'i-tabs-tab-current' : '' }}" bindtap="handleClickItem">
<i-badge dot="{{ dot }}" count="{{ dot ? 0 : count }}">
<view>
<view class="i-tabs-tab-title {{ current ? 'i-tabs-tab-title-current' : '' }}" wx:if="{{ current && currentColor }}" style="color: {{ currentColor }}">{{ title }}</view>
<view class="i-tabs-tab-title {{ current ? 'i-tabs-tab-title-current' : '' }}" wx:else>{{ title }}</view>
</view>
</i-badge>
<view class="i-tabs-tab-bar" wx:if="{{ current }}" style="background: {{ currentColor }}"></view>
</view>

View File

@@ -0,0 +1 @@
.i-tabs-tab{flex:1;display:flex;width:100%;-webkit-box-pack:center;justify-content:center;-webkit-box-align:center;align-items:center;-webkit-box-orient:vertical;-webkit-box-direction:normal;flex-direction:column;text-align:center;position:relative}.i-tabs-tab-bar{display:block;width:100%;height:3px;background:0 0;position:absolute;bottom:0;left:0;background:#1dbf45}.i-tabs-tab-title{font-size:14px;text-align:center;box-sizing:border-box;color:#80848f}.i-tabs-tab-title-current{color:#1dbf45;font-weight:500;}.i-tabs-tab-scroll{display:inline-block;}

View File

@@ -0,0 +1 @@
30522d48-eaa5-4d6f-aba1-85fbbbed5420

View File

@@ -0,0 +1,56 @@
Component({
externalClasses: ['i-class'],
relations: {
'../tab/index': {
type: 'child',
linked () {
this.changeCurrent();
},
linkChanged () {
this.changeCurrent();
},
unlinked () {
this.changeCurrent();
}
}
},
properties: {
current: {
type: String,
value: '',
observer: 'changeCurrent'
},
color: {
type: String,
value: ''
},
scroll: {
type: Boolean,
value: false
},
fixed: {
type: Boolean,
value: false
}
},
methods: {
changeCurrent (val = this.data.current) {
let items = this.getRelationNodes('../tab/index');
const len = items.length;
if (len > 0) {
items.forEach(item => {
item.changeScroll(this.data.scroll);
item.changeCurrent(item.data.key === val);
item.changeCurrentColor(this.data.color);
});
}
},
emitEvent (key) {
this.triggerEvent('change', { key });
}
}
});

View File

@@ -0,0 +1,3 @@
{
"component": true
}

View File

@@ -0,0 +1,2 @@
<scroll-view wx:if="{{ scroll }}" scroll-x="true" class="i-class i-tabs i-tabs-scroll {{ fixed ? 'i-tabs-fixed' : '' }}"><slot></slot></scroll-view>
<view wx:else class="i-class i-tabs {{ fixed ? 'i-tabs-fixed' : '' }}"><slot></slot></view>

View File

@@ -0,0 +1 @@
.i-tabs{display:flex;width:100%;height:42px;line-height:42px;box-sizing:border-box;position:relative;justify-content:space-around;align-items:center;-webkit-box-align:center;background:#fff}.i-tabs::after{content:'';position:absolute;top:0;left:0;width:200%;height:200%;transform:scale(.5);transform-origin:0 0;pointer-events:none;box-sizing:border-box;border:0 solid #e9eaec;border-bottom-width:1px}.i-tabs-scroll{display:block;overflow-x:auto;-webkit-overflow-scrolling: touch;white-space:nowrap}.i-tabs-fixed{position:fixed;top:0;z-index:2}

View File

@@ -0,0 +1 @@
53e3281c-0cd2-4342-b252-fae4d4a980a1

View File

@@ -0,0 +1,48 @@
const default_data = {
visible: false,
content: '',
icon: '',
image: '',
duration: 2,
mask: true,
type: 'default', // default || success || warning || error || loading
};
let timmer = null;
Component({
externalClasses: ['i-class'],
data: {
...default_data
},
methods: {
handleShow (options) {
const { type = 'default', duration = 2 } = options;
this.setData({
...options,
type,
duration,
visible: true
});
const d = this.data.duration * 1000;
if (timmer) clearTimeout(timmer);
if (d !== 0) {
timmer = setTimeout(() => {
this.handleHide();
timmer = null;
}, d);
}
},
handleHide () {
this.setData({
...default_data
});
}
}
});

View File

@@ -0,0 +1,7 @@
{
"component": true,
"usingComponents":
{
"i-icon": "../icon/index"
}
}

View File

@@ -0,0 +1,16 @@
<view class="i-toast-mask" wx:if="{{ visible && mask }}" bindtap="handleHide"></view>
<view class="i-class i-toast {{ type }}" wx:if="{{ visible }}">
<block wx:if="{{ type !== 'default' }}">
<view class="i-toast-type">
<!-- <i-icon i-class="i-toast-icon" type="success" wx:if="{{ type === 'success' }}"></i-icon>
<i-icon i-class="i-toast-icon" type="prompt" wx:elif="{{ type === 'warning' }}"></i-icon>
<i-icon i-class="i-toast-icon" type="delete" wx:elif="{{ type === 'error' }}"></i-icon>
<view class="i-toast-icon i-toast-loading" wx:elif="{{ type === 'loading' }}"></view> -->
</view>
</block>
<block wx:else>
<i-icon i-class="i-toast-icon" type="{{ icon }}" wx:if="{{ icon }}"></i-icon>
<image class="i-toast-image" src="{{ image }}" wx:if="{{ image }}" mode="aspectFit"></image>
</block>
<view class="i-toast-content {{ type }}" wx:if="{{ content }}">{{ content }}</view>
</view>

View File

@@ -0,0 +1,17 @@
.i-toast{position:fixed;top:35%;left:50%;transform:translate3d(-50%,-50%,0);background:rgba(0,0,0,.7);color:#fff;font-size:14px;line-height:1.5em;margin:0 auto;box-sizing:border-box;padding:10px 18px;text-align:center;border-radius:4px;z-index:1010}.i-toast-mask{position:fixed;top:0;bottom:0;left:0;right:0;z-index:1010}.i-toast-icon{font-size:38px!important;margin-bottom:6px}.i-toast-image{max-width:100px;max-height:100px}.i-toast-loading{display:inline-block;vertical-align:middle;width:28px;height:28px;background:0 0;border-radius:50%;border:2px solid #fff;border-color:#fff #fff #fff #2d8cf0;animation:btn-spin .8s linear;animation-iteration-count:infinite}@keyframes btn-spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}
.success {
color: #67c23a;
background-color: #f0f9eb;
border-color: #e1f3d8;
}
.error{
color: #f56c6c;
background-color: #fef0f0;
border-color: #fde2e2;
}
.warning{
color: #e6a23c;
background-color: #fdf6ec;
border-color: #faecd8;
}