init
This commit is contained in:
42
fuintUniapp/components/actionsheet/index.js
Normal file
42
fuintUniapp/components/actionsheet/index.js
Normal file
@@ -0,0 +1,42 @@
|
||||
'use strict';
|
||||
|
||||
Component({
|
||||
externalClasses: ['mask-class', 'container-class'],
|
||||
properties: {
|
||||
actions: {
|
||||
type: Array,
|
||||
value: []
|
||||
},
|
||||
show: {
|
||||
type: Boolean,
|
||||
value: false
|
||||
},
|
||||
cancelWithMask: {
|
||||
type: Boolean,
|
||||
value: true
|
||||
},
|
||||
cancelText: {
|
||||
type: String,
|
||||
value: ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onMaskClick: function onMaskClick() {
|
||||
if (this.data.cancelWithMask) {
|
||||
this.cancelClick();
|
||||
}
|
||||
},
|
||||
cancelClick: function cancelClick() {
|
||||
this.triggerEvent('cancel');
|
||||
},
|
||||
handleBtnClick: function handleBtnClick(_ref) {
|
||||
var _ref$currentTarget = _ref.currentTarget,
|
||||
currentTarget = _ref$currentTarget === undefined ? {} : _ref$currentTarget;
|
||||
|
||||
var dataset = currentTarget.dataset || {};
|
||||
var index = dataset.index;
|
||||
|
||||
this.triggerEvent('actionclick', { index: index });
|
||||
}
|
||||
}
|
||||
});
|
||||
6
fuintUniapp/components/actionsheet/index.json
Normal file
6
fuintUniapp/components/actionsheet/index.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"zan-btn": "../btn/index"
|
||||
}
|
||||
}
|
||||
39
fuintUniapp/components/actionsheet/index.wxml
Normal file
39
fuintUniapp/components/actionsheet/index.wxml
Normal file
@@ -0,0 +1,39 @@
|
||||
<view class="zan-actionsheet {{ show ? 'zan-actionsheet--show' : '' }}">
|
||||
<view
|
||||
class="mask-class zan-actionsheet__mask"
|
||||
bindtap="onMaskClick"
|
||||
></view>
|
||||
<view class="container-class zan-actionsheet__container">
|
||||
<!-- 选项按钮 -->
|
||||
<zan-btn
|
||||
wx:for="{{ actions }}"
|
||||
wx:key="this"
|
||||
bind:btnclick="handleBtnClick"
|
||||
data-index="{{ index }}"
|
||||
open-type="{{ item.openType }}"
|
||||
custom-class="zan-actionsheet__btn"
|
||||
loading="{{ item.loading }}"
|
||||
>
|
||||
<!-- 自定义组件控制 slot 样式有问题,故在 slot 容器上传入 loading 信息 -->
|
||||
<view class="zan-actionsheet__btn-content {{ item.loading ? 'zan-actionsheet__btn--loading' : '' }}">
|
||||
<view class="zan-actionsheet__name">{{ item.name }}</view>
|
||||
<view
|
||||
wx:if="{{ item.subname }}"
|
||||
class="zan-actionsheet__subname">
|
||||
{{ item.subname }}
|
||||
</view>
|
||||
</view>
|
||||
</zan-btn>
|
||||
|
||||
<!-- 关闭按钮 -->
|
||||
<view
|
||||
wx:if="{{ cancelText }}"
|
||||
class="zan-actionsheet__footer"
|
||||
>
|
||||
<zan-btn
|
||||
custom-class="zan-actionsheet__btn"
|
||||
catchtap="cancelClick"
|
||||
>{{ cancelText }}</zan-btn>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
86
fuintUniapp/components/actionsheet/index.wxss
Normal file
86
fuintUniapp/components/actionsheet/index.wxss
Normal file
@@ -0,0 +1,86 @@
|
||||
.zan-actionsheet {
|
||||
background-color: #f8f8f8;
|
||||
}
|
||||
|
||||
.zan-actionsheet__mask {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 10;
|
||||
background: rgba(0, 0, 0, 0.7);
|
||||
display: none;
|
||||
}
|
||||
|
||||
.zan-actionsheet__container {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: #f8f8f8;
|
||||
-webkit-transform: translate3d(0, 50%, 0);
|
||||
transform: translate3d(0, 50%, 0);
|
||||
-webkit-transform-origin: center;
|
||||
transform-origin: center;
|
||||
-webkit-transition: all 0.2s ease;
|
||||
transition: all 0.2s ease;
|
||||
z-index: 11;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.zan-actionsheet__btn {
|
||||
margin-bottom: 0 !important;
|
||||
}
|
||||
|
||||
.zan-actionsheet__footer .zan-actionsheet__btn {
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.zan-actionsheet__btn-content {
|
||||
display: -webkit-box;
|
||||
display: flex;
|
||||
-webkit-box-orient: horizontal;
|
||||
-webkit-box-direction: normal;
|
||||
flex-direction: row;
|
||||
-webkit-box-pack: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.zan-actionsheet__subname {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.zan-actionsheet__name, .zan-actionsheet__subname {
|
||||
height: 45px;
|
||||
line-height: 45px;
|
||||
}
|
||||
|
||||
.zan-actionsheet__btn.zan-btn:last-child::after {
|
||||
border-bottom-width: 0;
|
||||
}
|
||||
|
||||
.zan-actionsheet__subname {
|
||||
margin-left: 2px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.zan-actionsheet__footer {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.zan-actionsheet__btn--loading .zan-actionsheet__subname {
|
||||
color: transparent;
|
||||
}
|
||||
|
||||
.zan-actionsheet--show .zan-actionsheet__container {
|
||||
opacity: 1;
|
||||
-webkit-transform: translate3d(0, 0, 0);
|
||||
transform: translate3d(0, 0, 0);
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.zan-actionsheet--show .zan-actionsheet__mask {
|
||||
display: block;
|
||||
}
|
||||
Reference in New Issue
Block a user