123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- <template>
- <view class="yModal-container" :class="show ? 'show' : ''">
- <!-- 提示 -->
- <view class="yModal">
- <view class="yModal-content">
- <view class="yModal-title">
- {{title}}
- </view>
- <slot></slot>
- </view>
- <view class="yModal-bottom">
- <view class="yModal-bottom-item">
- <button plain class="yModal-bottom-btn cancel-btn" hover-class="active" @click="cancel">
- {{cancelTxt}}
- </button>
- </view>
- <view class="yModal-bottom-item">
- <button plain class="yModal-bottom-btn confirm-btn" hover-class="active" @click="confirm">
- {{confirmTxt}}
- </button>
- </view>
- </view>
- </view>
- <view v-if="show" class="yModal-mask"></view>
- </view>
- </template>
- <script>
- export default {
- props: {
- title: {
- type: String,
- required: true,
- },
- show: {
- type: Boolean,
- default: false
- },
- cancelTxt: {
- type: String,
- default: '取消'
- },
- confirmTxt: {
- type: String,
- default: '确认'
- }
- },
- methods: {
- // 取消
- cancel() {
- this.$emit('onCancel');
- },
- // 确认
- confirm() {
- this.$emit('onConfirm');
- }
- }
- }
- </script>
- <style lang="scss">
- .yModal-container {
- width: 100%;
- height: 100%;
- position: fixed;
- top: 0;
- left: 0;
- z-index: -1;
- display: none;
- &.show {
- z-index: 900;
- display: block;
- }
- }
- .yModal {
- position: absolute;
- width: 622rpx;
- background-color: #fff;
- top: 50%;
- left: 50%;
- transform: translate3d(-50%, -50%, 0);
- border-radius: 30rpx;
- font-size: 32rpx;
- color: #323233;
- z-index: 902;
- .yModal-content {
- padding: 40rpx 30rpx;
- }
- .yModal-title {
- text-align: center;
- }
- .yModal-bottom {
- display: flex;
- .yModal-bottom-item {
- flex: 1;
- &:last-of-type {
- .yModal-bottom-btn {
- border-left: 1px solid #EBEDF0;
- border-bottom-left-radius: 0;
- }
- }
- }
- .yModal-bottom-btn {
- border: 0;
- border-top: 1px solid #EBEDF0;
- border-top-left-radius: 0;
- border-top-right-radius: 0;
- &.active {
- opacity: 0.6;
- }
- }
- // 确认按钮
- .confirm-btn {
- color: $uni-primary;
- }
- }
- }
- .yModal-mask {
- background-color: rgba(0, 0, 0, .3);
- z-index: 901;
- width: 100%;
- height: 100%;
- position: fixed;
- }
- </style>
|