wangzhibo
4 天以前 10595d8632f959d0954d1939243196f4eed02372
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<template>
    <cl-page :padding="20">
        <cl-action-sheet ref="ActionSheet" />
 
        <cl-card label="基础用法">
            <cl-button @tap="open">打开</cl-button>
        </cl-card>
 
        <cl-card label="添加图标">
            <cl-button @tap="open2">打开</cl-button>
        </cl-card>
 
        <cl-card label="禁用">
            <cl-button @tap="open3">打开</cl-button>
        </cl-card>
 
        <cl-card label="关闭回调">
            <cl-button @tap="open4">打开</cl-button>
        </cl-card>
    </cl-page>
</template>
 
<script lang="ts" setup>
import { ref } from "vue";
import { useUi } from "/$/cool-ui";
 
const ui = useUi();
 
const ActionSheet = ref<ClActionSheet.Ref>();
 
function open() {
    ActionSheet.value?.open({
        list: [
            {
                label: "删除好友",
            },
        ],
    });
}
 
function open2() {
    ActionSheet.value?.open({
        list: [
            {
                label: "微信支付",
                icon: "cl-icon-payment",
            },
        ],
    });
}
 
function open3() {
    ActionSheet.value?.open({
        title: "删除好友会同时删除所有聊天记录",
        list: [
            {
                label: "删除好友",
                color: "red",
            },
        ],
    });
}
 
function open4() {
    ActionSheet.value?.open({
        closeOnClickModal: false,
        list: [
            {
                label: "删除好友",
                color: "red",
            },
        ],
        beforeClose(index, done) {
            if (index == 0) {
                ui.showConfirm({
                    title: "提示",
                    message: "是否删除该联系人",
                    callback(action) {
                        if (action == "confirm") {
                            ui.showToast("删除成功");
                        }
 
                        done();
                    },
                });
            } else {
                done();
            }
        },
    });
}
</script>