123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- <template>
- <view class="page-total" v-if="isShow">
- <view class="box" :class="AClass[AnIndex][AnIdx]">
- <view class="dialog-box">
- <view class="close" @click="onCancel">
- <image src="http://c.yujianmate.com/images/v1/dialog_close.png" mode="widthFix"></image>
- </view>
- <view class="title">{{options.title}}</view>
- <view class="content" v-if="options.DialogType == 'input'">
- <input type="text" v-model="options.value" :placeholder="options.placeholder">
- <text class="iconfont icon-clear" @click.stop="onClear"></text>
- </view>
- <view class="inquiry" v-else-if="options.DialogType == 'inquiry'">
- <text>{{options.content}}</text>
- </view>
- <view class="operation-btn">
- <view class="btn1" @click="onCancel">
- <text>{{options.btn1}}</text>
- </view>
- <view class="btn2" @click="onConfirm">
- <text class="activity">{{options.btn2}}</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- AClass: [
- ['a-fadein', 'a-fadeout'],
- ['a-bouncein', 'a-bounceout'],
- ],
- AnIndex: 0,
- AnIdx: 0,
- isShow: false,
- SetTime: null,
- value: '',
- // parmoise
- resolve: '',
- reject: '',
- promise: '',
- // 配置
- options: {
- // 提示标题
- title: '',
- // 内容
- content: '',
- btn1: '',
- btn2: '',
- // 提示内容
- placeholder: '请输入内容',
- // 提示框类型
- DialogType: 'input',
- // 动画类型
- animation: 0,
- },
- };
- },
- props: {
- // 提示标题
- title: {
- type: String,
- default: '提示',
- },
- // 内容
- content: {
- type: String,
- default: '',
- },
- // 提示内容
- placeholder: {
- type: String,
- default: '请输入内容',
- },
- // 提示框类型
- DialogType: {
- type: String,
- default: 'input'
- },
- // 动画类型
- animation: {
- type: Number,
- default: 0
- }
- },
- methods: {
- // 询问框
- confirm(options) {
- this.AnIndex = options.animation || 0;
- this.AnIdx = options.animation || 0;
- this.options = {
- // 提示标题
- title: options.title || '',
- // 内容
- content: options.content || '',
- btn1: options.btn1 || '否',
- btn2: options.btn2 || '是',
- // 提示内容
- placeholder: options.placeholder || '请输入内容',
- // 提示框类型
- DialogType: options.DialogType || 'input',
- // 动画类型
- animation: options.animation || 0,
- // input输入的值
- value: options.value || '',
- };
- this.show();
- this.promise = new Promise((resolve, reject) => {
- this.resolve = resolve;
- this.reject = reject;
- });
- return this.promise; //返回promise对象,给父级组件调用
- },
- /**
- * 显示
- */
- show(callback) {
- this.isShow = true;
- },
- /**
- * 隐藏
- */
- hide() {
- this.AnIdx = 1;
- this.SetTime = setTimeout(() => {
- this.isShow = false;
- }, 300);
- },
- /**
- * 清除输入值
- */
- onClear() {
- this.options.value = '';
- },
- /**
- * 取消点击
- */
- onCancel() {
- this.hide();
- this.reject({
- value: this.options.value,
- isConfirm: true,
- });
- },
- /**
- * 确定点击
- */
- onConfirm() {
- this.hide();
- this.resolve({
- value: this.options.value,
- isConfirm: true,
- });
- },
- },
- }
- </script>
- <style scoped lang="scss">
- @import 'DialogBoxW3.scss'
- </style>
|