index.vue
1.74 KB
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
<!--
* @Date: 2022-08-29 14:31:20
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-11-22 14:23:49
* @FilePath: /data-table/src/components/DividerField/index.vue
* @Description: 按钮组件
-->
<template>
<div class="button-field-page">
<van-row justify="center" gutter="20">
<van-col v-for="item in props.item.component_props.config" key="index">
<van-button
@click="handleButton(item)"
:icon="iconType(item)"
:color="item.background ? item.background : backgroundColor"
>{{ item.text }}
</van-button>
</van-col>
</van-row>
</div>
<van-overlay :show="show" @click="onClose">
<div class="wrapper">
<div class="block">
<van-image width="100%" fit="cover" :src="qr_url" />
</div>
</div>
</van-overlay>
</template>
<script setup>
import { styleColor } from "@/constant.js";
const props = defineProps({
item: Object,
});
const show = ref(false);
const backgroundColor = styleColor.baseColor;
const iconType = (item) => {
if (item.type === "tel") return "phone-o";
if (item.type === "link") return "link-o";
if (item.type === "qr") return "qr";
};
const qr_url = ref("");
const handleButton = ({ type, content }) => {
if (type === "tel") {
location.href = "tel://" + content;
}
if (type === "link") {
location.href = content;
}
if (type === "qr") {
show.value = true;
qr_url.value = content;
}
};
const onClose = () => {
show.value = false;
};
onMounted(() => {});
</script>
<style lang="less" scoped>
.button-field-page {
}
.wrapper {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
}
.block {
width: 10rem;
height: 10rem;
background-color: #fff;
}
</style>