wong1988 1 year ago
parent
commit
5b95cf0296
  1. 38
      uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog.vue

38
uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog.vue

@ -5,12 +5,14 @@
</view> </view>
<view v-if="mode === 'base'" class="uni-dialog-content"> <view v-if="mode === 'base'" class="uni-dialog-content">
<slot> <slot>
<text class="uni-dialog-content-text">{{content}}</text> <textarea class="uni-dialog-content-text" :value="content" :auto-height="false"
style="max-height: 200px;"></textarea>
</slot> </slot>
</view> </view>
<view v-else class="uni-dialog-content"> <view v-else class="uni-dialog-content">
<slot> <slot>
<input class="uni-dialog-input" v-model="val" :type="inputType" :placeholder="placeholderText" :focus="focus" > <input class="uni-dialog-input" v-model="val" :type="inputType" :placeholder="placeholderText"
:focus="focus">
</slot> </slot>
</view> </view>
<view class="uni-dialog-button-group" v-if="!showConfirm"> <view class="uni-dialog-button-group" v-if="!showConfirm">
@ -21,7 +23,7 @@
<text class="uni-dialog-button-text uni-button-color">{{okText}}</text> <text class="uni-dialog-button-text uni-button-color">{{okText}}</text>
</view> </view>
</view> </view>
<!-- 倒计时按钮 --> <!-- 倒计时按钮 -->
<view class="uni-dialog-button-group" v-if="showConfirm"> <view class="uni-dialog-button-group" v-if="showConfirm">
<view class="uni-dialog-button uni-border-left" @click="onOk"> <view class="uni-dialog-button uni-border-left" @click="onOk">
@ -35,10 +37,12 @@
<script> <script>
import popup from '../uni-popup/popup.js' import popup from '../uni-popup/popup.js'
import { import {
initVueI18n initVueI18n
} from '@dcloudio/uni-i18n' } from '@dcloudio/uni-i18n'
import messages from '../uni-popup/i18n/index.js' import messages from '../uni-popup/i18n/index.js'
const { t } = initVueI18n(messages) const {
t
} = initVueI18n(messages)
/** /**
* PopUp 弹出层-对话框样式 * PopUp 弹出层-对话框样式
* @description 弹出层-对话框样式 * @description 弹出层-对话框样式
@ -62,9 +66,9 @@
export default { export default {
name: "uniPopupDialog", name: "uniPopupDialog",
mixins: [popup], mixins: [popup],
emits:['confirm','close'], emits: ['confirm', 'close'],
props: { props: {
inputType:{ inputType: {
type: String, type: String,
default: 'text' default: 'text'
}, },
@ -96,11 +100,11 @@
type: Boolean, type: Boolean,
default: false default: false
}, },
cancelText:{ cancelText: {
type: String, type: String,
default: '' default: ''
}, },
confirmText:{ confirmText: {
type: String, type: String,
default: '' default: ''
}, },
@ -118,7 +122,7 @@
}, },
computed: { computed: {
okText() { okText() {
console.log('confirmText',this.confirmText); console.log('confirmText', this.confirmText);
return this.confirmText || t("uni-popup.ok") return this.confirmText || t("uni-popup.ok")
}, },
closeText() { closeText() {
@ -163,12 +167,12 @@
* 点击确认按钮 * 点击确认按钮
*/ */
onOk() { onOk() {
if (this.mode === 'input'){ if (this.mode === 'input') {
this.$emit('confirm', this.val) this.$emit('confirm', this.val)
}else{ } else {
this.$emit('confirm') this.$emit('confirm')
} }
if(this.beforeClose) return if (this.beforeClose) return
this.popup.close() this.popup.close()
}, },
/** /**
@ -176,17 +180,17 @@
*/ */
closeDialog() { closeDialog() {
this.$emit('close') this.$emit('close')
if(this.beforeClose) return if (this.beforeClose) return
this.popup.close() this.popup.close()
}, },
close(){ close() {
this.popup.close() this.popup.close()
} }
} }
} }
</script> </script>
<style lang="scss" > <style lang="scss">
.uni-popup-dialog { .uni-popup-dialog {
width: 300px; width: 300px;
border-radius: 11px; border-radius: 11px;
@ -284,4 +288,4 @@
.uni-popup__info { .uni-popup__info {
color: #909399; color: #909399;
} }
</style> </style>
Loading…
Cancel
Save