123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- // components/w-dialog/index.ts
- Component({
- options: {
- multipleSlots: true,
- styleIsolation: "shared"
- },
- /**
- * 组件的属性列表
- */
- properties: {
- show: {
- type: Boolean,
- value: false
- },
- /** 标题 */
- title: {
- type: String,
- value: ''
- },
- /** 文本内容 */
- message: {
- type: String,
- value: ''
- },
- /**
- * 内容对齐方式,可选值为left right
- */
- messageAlign: {
- type: String,
- value: 'center'
- },
- /**
- * 样式风格,可选值为round-button
- */
- theme: {
- type: String,
- value: 'default'
- },
- /**
- * z-index 层级
- */
- zIndex: {
- type: Number,
- default: 100
- },
- /** 是否展示确认按钮 */
- showConfirmButton: {
- type: Boolean,
- value: true,
- },
- /** 是否展示取消按钮 */
- showCancelButton: {
- type: Boolean,
- value: true,
- },
- /** 确认按钮的文案 */
- confirmButtonText: {
- type: String,
- value: '确认'
- },
- /** 取消按钮的文案 */
- cancelButtonText: {
- type: String,
- value: '取消'
- },
- /** 是否展示遮罩层 */
- overlay: {
- type: Boolean,
- value: true,
- },
- /** 是否在点击遮罩层后关闭 */
- closeOnClickOverlay: {
- type: Boolean,
- value: true,
- }
- },
- /**
- * 组件的初始数据
- */
- data: {
- },
- /**
- * 组件的方法列表
- */
- methods: {
- /** 取消 */
- onDialogClose() {
- this.setData({
- show: false
- })
- this.triggerEvent('close', false)
- },
- /** 确认 */
- onDialogConfirm() {
- this.setData({
- show: false
- })
- this.triggerEvent('confirm')
- },
- onClickOverlay() {
- if(this.data.closeOnClickOverlay) {
- this.setData({
- show: false
- })
- this.triggerEvent('click-overlay')
- }
- }
- }
- })
|