Files
2024-02-22 18:37:23 +08:00

172 lines
3.6 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!--
@name: GridCard
@author: kahu4
@date: 2023-11-09 15:09
@descriptionGridCard
@update: 2023-11-09 15:09
-->
<script setup>
import { toRefs } from "vue";
import { useRouter } from "@/hooks/useRouter";
import { useInterface } from "@/hooks/useInterface";
import { storeToRefs } from "pinia";
import { useMainStore } from "@/store/modules/useMainStore";
import { useService } from "@/hooks/useService";
const props = defineProps({
list: {
type: Array,
default: () => ([])
},
dotInfo: {
type: Object
},
title: {
type: String,
default: () => ''
},
buttonText: {
type: String,
default: ''
}
})
const {list, title, buttonText, dotInfo} = toRefs(props)
const emits = defineEmits(['buttonClick'])
const {push} = useRouter();
const {toast} = useInterface();
const mainStore = useMainStore();
const {user} = storeToRefs(mainStore);
async function toLink(listItem) {
if (!user.value) return toast({title: '请先登录'})
if (!listItem.path) return toast({title: ' 暂未开放 '})
if (listItem.path === 'kf') {
const {getServiceData, openService} = useService();
await getServiceData()
await openService()
return
}
push({url: listItem.path}, listItem?.params ?? {})
}
</script>
<template>
<view class="grid-container">
<view
class="title-row"
v-if="title || buttonText"
>
<view>
{{ title }}
</view>
<view
class="right"
@click="emits('buttonClick')"
>
{{ buttonText }}
<uv-icon
v-if="buttonText"
name="arrow-right"
color="#ccc"
size="12"
/>
</view>
</view>
<view class="icon-box">
<view
class="icon-item"
v-for="item in list"
:key="item"
@click="toLink(item)"
>
<template v-if="item&&item.rightTopDot">
<view
class="dot"
v-if="dotInfo && dotInfo[item.dotField] && dotInfo[item.dotField]>0"
>
{{ dotInfo[item.dotField] < 100 ? dotInfo[item.dotField] : `${ dotInfo[item.dotField] }+` }}
</view>
</template>
<image
class="icon"
:src="item.icon"
/>
<view class="text">
{{ item.label }}
</view>
</view>
</view>
</view>
</template>
<style
scoped
lang="scss"
>
.grid-container {
width: 100%;
background: $white-color;
border-radius: 15rpx;
margin: 20rpx 0;
.title-row {
@include useFlex(space-between, center);
@include usePadding(30, 30);
font-size: 32rpx;
color: #333;
font-weight: 500;
border-bottom: 1rpx solid #f5f5f5;
.right {
@include useFlex(space-between, center);
font-size: 24rpx;
color: $tips-color;
font-weight: normal;
}
}
.icon-box {
@include usePadding(30, 20);
display: grid;
grid-template-columns: repeat(4, 1fr);
.icon-item {
@include useFlex(space-between, center, column);
width: 100%;
font-size: 24rpx;
color: #333333;
position: relative;
.dot {
z-index: 99;
position: absolute;
background: #EE6D46;
color: #fff;
right: 20%;
top: 0;
transform: translateY(-20%);
font-size: 18rpx;
width: 38rpx;
height: 38rpx;
text-align: center;
line-height: 38rpx;
box-sizing: border-box;
border-radius: 50%;
border: 2rpx solid #ffffff;
}
.icon {
width: 60rpx;
height: 60rpx;
}
.text {
margin: 14rpx 0;
}
}
}
}
</style>