file-selector

This commit is contained in:
Xu Chang 2022-05-17 13:54:09 +08:00
parent 11a7861252
commit 7d416a4cdd
5 changed files with 75 additions and 3 deletions

View File

@ -0,0 +1,10 @@
{
"component": true,
"usingComponents": {
"g-btn": "../../UI/g-btn/index",
"g-icon": "../../UI/g-icon/index"
},
"componentGenerics": {
"item": true
}
}

View File

@ -0,0 +1,19 @@
@import "../../../styles/base.less";
.default-item-container {
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.default-item {
width: 200rpx;
height: 300rpx;
border: 1ch solid black;
}
.insert-btn {
display: flex;
align-items: center;
justify-content: center;
}

View File

@ -0,0 +1,37 @@
Component({
externalClasses: ['item-container', 'item'],
properties: {
oakValue: Array,
maxCount: Number,
disableInsert: Boolean,
},
methods: {
onClick(touch: WechatMiniprogram.Touch) {
},
checkAllowInsert(value?: Array<any>, count?: number) {
const count2 = count || this.data.maxCount;
const value2 = value || this.data.oakValue;
if (typeof count2 === 'number' && value2?.length >= count2) {
this.setData({
disableInsert: true,
});
}
}
},
observers: {
oakValue: function (oakValue) {
this.checkAllowInsert(oakValue);
},
maxCount: function (maxCount) {
this.checkAllowInsert(undefined, maxCount);
}
},
lifetimes: {
ready() {
this.checkAllowInsert();
}
}
});

View File

@ -0,0 +1,8 @@
<view class="default-item-container item-container">
<view class="default-item item" wx:for="{{oakValue}}" wx:key="index">
<item oak:value="item"/>
</view>
<view class="default-item item insert-btn" wx:if="{{!disableInsert}}">
<g-icon name="add"></g-icon>>
</view>
</view>

View File

@ -1,4 +1,2 @@
<!-- index.wxml -->
<view class="container">
<image src="{{src}}" mode="aspectFit" />
</view>
<image src="{{src}}" mode="aspectFit" />