12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <template>
-
- <view class="modal-bg" v-if="fabRef?.isShow" @click="handleCollapseFab"></view>
-
- <uni-fab
- ref="fabRef"
- horizontal="right"
- vertical="bottom"
- :direction="state.direction"
- :pattern="state.pattern"
- :content="state.content"
- @trigger="handleOpenLink"
- />
- </template>
- <script setup>
-
- import sheep from '@/sheep';
- import { reactive, ref, unref } from 'vue';
- import { onBackPress } from '@dcloudio/uni-app';
-
- const props = defineProps({
- data: {
- type: Object,
- default() {},
- }
- })
-
- const state = reactive({
-
- pattern: [],
-
- content: [],
-
- direction: '',
- });
-
- const fabRef = ref(null);
-
- state.direction = props.data.direction;
- props.data?.list.forEach((item) => {
-
- const text = props.data?.showText ? item.text : ''
-
- state.content.push({ iconPath: sheep.$url.cdn(item.imgUrl), url: item.url, text });
-
- state.pattern.push({ color: item.textColor });
- });
-
- function handleOpenLink(e) {
- sheep.$router.go(e.item.url);
- }
-
- function handleCollapseFab() {
- if (unref(fabRef)?.isShow) {
- unref(fabRef)?.close();
- }
- }
-
- onBackPress(() => {
- if (unref(fabRef)?.isShow) {
- unref(fabRef)?.close();
- return true;
- }
- return false;
- });
- </script>
- <style lang="scss" scoped>
-
- .modal-bg {
- position: fixed;
- left: 0;
- top: 0;
- z-index: 11;
- width: 100%;
- height: 100%;
- background-color: rgba(#000000, 0.4);
- }
- </style>
|