Skip to content

Commit dfc1857

Browse files
committed
update: 修改扩展组件列表排序
1 parent 7adec13 commit dfc1857

6 files changed

Lines changed: 526 additions & 178 deletions

File tree

‎components/uni-fab/uni-fab.vue‎

Lines changed: 90 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
11
<template>
22
<view>
3-
<view class="fab-box fab" :class="{
4-
leftBottom: leftBottom,
5-
rightBottom: rightBottom,
6-
leftTop: leftTop,
7-
rightTop: rightTop
8-
}">
9-
<view class="fab-circle" :class="{
10-
left: horizontal === 'left' && direction === 'horizontal',
11-
top: vertical === 'top' && direction === 'vertical',
12-
bottom: vertical === 'bottom' && direction === 'vertical',
13-
right: horizontal === 'right' && direction === 'horizontal'
14-
}" :style="{ 'background-color': styles.buttonColor }" @click="_onClick">
15-
<text class="uni-icon uni-icon-plusempty" :class="{ active: isShow }"></text>
3+
<view :class="{
4+
leftBottom: leftBottom,
5+
rightBottom: rightBottom,
6+
leftTop: leftTop,
7+
rightTop: rightTop
8+
}" class="fab-box fab">
9+
<view :class="{
10+
left: horizontal === 'left' && direction === 'horizontal',
11+
top: vertical === 'top' && direction === 'vertical',
12+
bottom: vertical === 'bottom' && direction === 'vertical',
13+
right: horizontal === 'right' && direction === 'horizontal'
14+
}" :style="{ 'background-color': styles.buttonColor }" class="fab-circle" @click="_onClick">
15+
<text :class="{ active: isShow }" class="uni-icon uni-icon-plusempty" />
1616
</view>
17-
<view class="fab-content" :class="{
18-
left: horizontal === 'left',
19-
right: horizontal === 'right',
20-
flexDirection: direction === 'vertical',
21-
flexDirectionStart: flexDirectionStart,
22-
flexDirectionEnd: flexDirectionEnd
23-
}" :style="{ width: boxWidth, height: boxHeight, background: styles.backgroundColor }">
24-
<view v-if="flexDirectionStart || horizontalLeft" class="fab-item first"></view>
25-
<view class="fab-item" v-for="(item, index) in content" :key="index" :class="{ active: isShow }" :style="{
26-
color: item.active ? styles.selectedColor : styles.color
27-
}" @click="_onItemClick(index, item)">
28-
<image class="content-image" :src="item.active ? item.selectedIconPath : item.iconPath" mode="widthFix"></image>
17+
<view :class="{
18+
left: horizontal === 'left',
19+
right: horizontal === 'right',
20+
flexDirection: direction === 'vertical',
21+
flexDirectionStart: flexDirectionStart,
22+
flexDirectionEnd: flexDirectionEnd
23+
}" :style="{ width: boxWidth, height: boxHeight, background: styles.backgroundColor }" class="fab-content">
24+
<view v-if="flexDirectionStart || horizontalLeft" class="fab-item first" />
25+
<view v-for="(item, index) in content" :key="index" :class="{ active: isShow }" :style="{
26+
color: item.active ? styles.selectedColor : styles.color
27+
}" class="fab-item" @click="_onItemClick(index, item)">
28+
<image :src="item.active ? item.selectedIconPath : item.iconPath" class="content-image" mode="widthFix" />
2929
<text class="text">{{ item.text }}</text>
3030
</view>
31-
<view v-if="flexDirectionEnd || horizontalRight" class="fab-item first"></view>
31+
<view v-if="flexDirectionEnd || horizontalRight" class="fab-item first" />
3232
</view>
3333
</view>
3434
</view>
3535
</template>
3636

3737
<script>
3838
export default {
39-
name: 'uni-fab',
39+
name: 'UniFab',
4040
props: {
4141
pattern: {
4242
type: Object,
4343
default () {
44-
return {};
44+
return {}
4545
}
4646
},
4747
horizontal: {
@@ -59,7 +59,7 @@
5959
content: {
6060
type: Array,
6161
default () {
62-
return [];
62+
return []
6363
}
6464
},
6565
show: {
@@ -78,100 +78,100 @@
7878
backgroundColor: '#fff',
7979
buttonColor: '#3c3e49'
8080
}
81-
};
82-
},
83-
created() {
84-
this.isShow = this.show;
85-
if (this.top === 0) {
86-
this.fabShow = true;
87-
}
88-
// 初始化样式
89-
this.styles = Object.assign({}, this.styles, this.pattern);
90-
},
91-
methods: {
92-
_onClick() {
93-
this.isShow = !this.isShow;
94-
},
95-
open() {
96-
this.isShow = true;
97-
},
98-
close() {
99-
this.isShow = false;
100-
},
101-
/**
102-
* 按钮点击事件
103-
*/
104-
_onItemClick(index, item) {
105-
this.$emit('trigger', {
106-
index,
107-
item
108-
});
109-
},
110-
/**
111-
* 获取 位置信息
112-
*/
113-
getPosition(types, paramA, paramB) {
114-
if (types === 0) {
115-
return this.horizontal === paramA && this.vertical === paramB;
116-
} else if (types === 1) {
117-
return this.direction === paramA && this.vertical === paramB;
118-
} else if (types === 2) {
119-
return this.direction === paramA && this.horizontal === paramB;
120-
} else {
121-
return this.isShow && this.direction === paramA ? this.contentWidth : this.contentWidthMin;
122-
}
123-
}
124-
},
125-
watch: {
126-
pattern(newValue, oldValue) {
127-
console.log(JSON.stringify(newValue));
128-
this.styles = Object.assign({}, this.styles, newValue);
12981
}
13082
},
13183
computed: {
13284
contentWidth(e) {
133-
return uni.upx2px((this.content.length + 1) * 110 + 20) + 'px';
85+
return uni.upx2px((this.content.length + 1) * 110 + 20) + 'px'
13486
},
13587
contentWidthMin() {
136-
return uni.upx2px(110) + 'px';
88+
return uni.upx2px(110) + 'px'
13789
},
13890
// 动态计算宽度
13991
boxWidth() {
140-
return this.getPosition(3, 'horizontal');
92+
return this.getPosition(3, 'horizontal')
14193
},
14294
// 动态计算高度
14395
boxHeight() {
144-
return this.getPosition(3, 'vertical');
96+
return this.getPosition(3, 'vertical')
14597
},
14698
// 计算左下位置
14799
leftBottom() {
148-
return this.getPosition(0, 'left', 'bottom');
100+
return this.getPosition(0, 'left', 'bottom')
149101
},
150102
// 计算右下位置
151103
rightBottom() {
152-
return this.getPosition(0, 'right', 'bottom');
104+
return this.getPosition(0, 'right', 'bottom')
153105
},
154106
// 计算左上位置
155107
leftTop() {
156-
return this.getPosition(0, 'left', 'top');
108+
return this.getPosition(0, 'left', 'top')
157109
},
158110
rightTop() {
159-
return this.getPosition(0, 'right', 'top');
111+
return this.getPosition(0, 'right', 'top')
160112
},
161113
flexDirectionStart() {
162-
return this.getPosition(1, 'vertical', 'top');
114+
return this.getPosition(1, 'vertical', 'top')
163115
},
164116
flexDirectionEnd() {
165-
return this.getPosition(1, 'vertical', 'bottom');
117+
return this.getPosition(1, 'vertical', 'bottom')
166118
},
167119
horizontalLeft() {
168-
return this.getPosition(2, 'horizontal', 'left');
120+
return this.getPosition(2, 'horizontal', 'left')
169121
},
170122
horizontalRight() {
171-
return this.getPosition(2, 'horizontal', 'right');
123+
return this.getPosition(2, 'horizontal', 'right')
124+
}
125+
},
126+
watch: {
127+
pattern(newValue, oldValue) {
128+
console.log(JSON.stringify(newValue))
129+
this.styles = Object.assign({}, this.styles, newValue)
130+
}
131+
},
132+
created() {
133+
this.isShow = this.show
134+
if (this.top === 0) {
135+
this.fabShow = true
136+
}
137+
// 初始化样式
138+
this.styles = Object.assign({}, this.styles, this.pattern)
139+
},
140+
methods: {
141+
_onClick() {
142+
this.isShow = !this.isShow
143+
},
144+
open() {
145+
this.isShow = true
146+
},
147+
close() {
148+
this.isShow = false
149+
},
150+
/**
151+
* 按钮点击事件
152+
*/
153+
_onItemClick(index, item) {
154+
this.$emit('trigger', {
155+
index,
156+
item
157+
})
158+
},
159+
/**
160+
* 获取 位置信息
161+
*/
162+
getPosition(types, paramA, paramB) {
163+
if (types === 0) {
164+
return this.horizontal === paramA && this.vertical === paramB
165+
} else if (types === 1) {
166+
return this.direction === paramA && this.vertical === paramB
167+
} else if (types === 2) {
168+
return this.direction === paramA && this.horizontal === paramB
169+
} else {
170+
return this.isShow && this.direction === paramA ? this.contentWidth : this.contentWidthMin
171+
}
172172
}
173173
}
174-
};
174+
}
175175
</script>
176176

177177
<style scoped>

0 commit comments

Comments
 (0)