This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
Component({
|
||||
data: {
|
||||
visible: false,
|
||||
title: '',
|
||||
content: '',
|
||||
icon: '',
|
||||
cancelText: '',
|
||||
confirmText: '确定',
|
||||
confirmType: 'primary',
|
||||
layout: 'column',
|
||||
editable: false,
|
||||
placeholderText: '',
|
||||
inputValue: ''
|
||||
},
|
||||
|
||||
methods: {
|
||||
open(options = {}) {
|
||||
this._onClose = typeof options.onClose === 'function' ? options.onClose : null
|
||||
this.setData({
|
||||
visible: true,
|
||||
title: options.title || '',
|
||||
content: options.content || '',
|
||||
icon: options.icon || '',
|
||||
cancelText: options.cancelText || '',
|
||||
confirmText: options.confirmText || '确定',
|
||||
confirmType: options.confirmType || 'primary',
|
||||
layout: options.layout || (options.cancelText ? 'row' : 'column'),
|
||||
editable: options.editable === true,
|
||||
placeholderText: options.placeholderText || '',
|
||||
inputValue: ''
|
||||
})
|
||||
},
|
||||
|
||||
close(result) {
|
||||
this.setData({ visible: false })
|
||||
const onClose = this._onClose
|
||||
this._onClose = null
|
||||
if (onClose) onClose(result)
|
||||
},
|
||||
|
||||
onInput(event) {
|
||||
this.setData({ inputValue: event.detail.value })
|
||||
},
|
||||
|
||||
onConfirm() {
|
||||
this.close({ confirm: true, cancel: false, content: this.data.inputValue })
|
||||
},
|
||||
|
||||
onCancel() {
|
||||
this.close({ confirm: false, cancel: true, content: this.data.inputValue })
|
||||
},
|
||||
|
||||
stopEvent() {
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"styleIsolation": "apply-shared"
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<view wx:if="{{visible}}" class="action-modal-mask" catchtouchmove="stopEvent">
|
||||
<view class="action-modal-card">
|
||||
<view wx:if="{{icon}}" class="action-modal-icon {{icon}}">{{icon === 'warning' ? '!' : 'i'}}</view>
|
||||
<text class="action-modal-title">{{title}}</text>
|
||||
<text wx:if="{{content}}" class="action-modal-content">{{content}}</text>
|
||||
<input wx:if="{{editable}}" class="action-modal-input" value="{{inputValue}}" maxlength="60" placeholder="{{placeholderText}}" bindinput="onInput" />
|
||||
<view class="action-modal-actions {{layout === 'row' ? 'row' : ''}}">
|
||||
<button wx:if="{{cancelText}}" class="action-modal-btn secondary" bindtap="onCancel">{{cancelText}}</button>
|
||||
<button class="action-modal-btn {{confirmType === 'danger' ? 'danger' : 'primary'}}" bindtap="onConfirm">{{confirmText}}</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,117 @@
|
||||
.action-modal-mask {
|
||||
position: fixed;
|
||||
z-index: 80;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 40rpx;
|
||||
background: rgba(23, 33, 31, 0.45);
|
||||
}
|
||||
|
||||
.action-modal-card {
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
width: 100%;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 40rpx 32rpx 32rpx;
|
||||
border-radius: 28rpx;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.action-modal-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 88rpx;
|
||||
height: 88rpx;
|
||||
margin-bottom: 20rpx;
|
||||
border-radius: 50%;
|
||||
background: #FFF1DC;
|
||||
color: #8B5E24;
|
||||
font-size: 44rpx;
|
||||
font-weight: 800;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.action-modal-title {
|
||||
color: #17211f;
|
||||
font-size: 32rpx;
|
||||
font-weight: 800;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.action-modal-content {
|
||||
margin-top: 16rpx;
|
||||
color: #71807a;
|
||||
font-size: 26rpx;
|
||||
line-height: 1.6;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.action-modal-input {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
height: 88rpx;
|
||||
margin-top: 24rpx;
|
||||
padding: 0 24rpx;
|
||||
border: 1rpx solid #e7ece9;
|
||||
border-radius: 16rpx;
|
||||
background: #f7faf8;
|
||||
color: #17211f;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.action-modal-actions {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
flex-direction: column;
|
||||
gap: 20rpx;
|
||||
margin-top: 32rpx;
|
||||
}
|
||||
|
||||
.action-modal-actions.row {
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.action-modal-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
height: 88rpx;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 20rpx;
|
||||
font-size: 26rpx;
|
||||
font-weight: 700;
|
||||
line-height: 88rpx;
|
||||
}
|
||||
|
||||
.action-modal-btn::after {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.action-modal-btn.secondary {
|
||||
border: 1rpx solid #E7ECE9;
|
||||
background: #F1F3F2;
|
||||
color: #71807A;
|
||||
}
|
||||
|
||||
.action-modal-btn.primary {
|
||||
background: #247B63;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.action-modal-btn.danger {
|
||||
background: #B3261E;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.action-modal-actions.row .action-modal-btn {
|
||||
width: auto;
|
||||
min-width: 0;
|
||||
flex: 1 1 0;
|
||||
}
|
||||
Reference in New Issue
Block a user