| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- <template>
- <u-modal
- :show="visible"
- :show-cancel-button="false"
- :show-confirm-button="false"
- >
- <view class="modal-content">
- <view class="modal-header">
- <text class="modal-title">{{ title }}</text>
- </view>
- <view class="modal-body">
- <u-input
- v-model="localValue"
- :placeholder="placeholder"
- class="modal-input"
- />
- </view>
- <view class="modal-footer">
- <text @click="handleCancel" class="btn cancel-btn">取消</text>
- <text @click="handleConfirm" class="btn confirm-btn">确定</text>
- </view>
- </view>
- </u-modal>
- </template>
- <script>
- export default {
- name: 'CustomModal',
- props: {
- visible: {
- type: Boolean,
- default: false
- },
- title: {
- type: String,
- default: ''
- },
- value: {
- type: String,
- default: ''
- },
- placeholder: {
- type: String,
- default: ''
- }
- },
- data() {
- return {
- localValue: this.value
- }
- },
- watch: {
- value(newVal) {
- this.localValue = newVal
- },
- visible(newVal) {
- if (newVal) {
- this.localValue = this.value
- }
- }
- },
- methods: {
- handleCancel() {
- this.$emit('cancel')
- },
- handleConfirm() {
- this.$emit('confirm', this.localValue)
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .modal-content {
- display: flex;
- flex-direction: column;
- gap: 30rpx;
- padding: 20rpx;
- }
- .modal-header {
- display: flex;
- justify-content: center;
- padding: 10rpx 0;
- }
- .modal-title {
- font-size: 32rpx;
- font-weight: bold;
- color: #333;
- }
- .modal-body {
- padding: 10rpx 0;
- }
- .modal-input {
- border: 2rpx solid #e0e0e0;
- border-radius: 10rpx;
- padding: 20rpx;
- font-size: 28rpx;
- }
- .modal-footer {
- display: flex;
- justify-content: space-between;
- gap: 20rpx;
- padding: 10rpx 0;
- }
- .btn {
- flex: 1;
- text-align: center;
- padding: 20rpx;
- border-radius: 10rpx;
- font-size: 28rpx;
- font-weight: 500;
- cursor: pointer;
- }
- .cancel-btn {
- background-color: #f5f5f5;
- color: #666;
- }
- .confirm-btn {
- background-color: blueviolet;
- color: white;
- }
- </style>
|