!25 商城装修

Merge pull request !25 from 疯狂的世界/master-vue3
pull/26/head^2
芋道源码 2023-12-10 01:34:25 +00:00 committed by Gitee
commit 2ee3c77249
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
8 changed files with 96 additions and 72 deletions

View File

@ -5,8 +5,6 @@
<s-block v-for="(item, index) in template.components" :key="index" :styles="item.property.style"> <s-block v-for="(item, index) in template.components" :key="index" :styles="item.property.style">
<s-block-item :type="item.id" :data="item.property" :styles="item.property.style" /> <s-block-item :type="item.id" :data="item.property" :styles="item.property.style" />
</s-block> </s-block>
<!-- 广告模块 -->
<s-popup-image />
</s-layout> </s-layout>
</view> </view>
</template> </template>
@ -89,4 +87,4 @@
onPageScroll(() => {}); onPageScroll(() => {});
</script> </script>
<style></style> <style></style>

View File

@ -6,7 +6,6 @@
:bgStyle="template.page" :bgStyle="template.page"
:navbarStyle="template.style?.navbar" :navbarStyle="template.style?.navbar"
onShareAppMessage onShareAppMessage
:showFloatButton="true"
> >
<s-block v-for="(item, index) in template.components" :key="index" :styles="item.property.style"> <s-block v-for="(item, index) in template.components" :key="index" :styles="item.property.style">
<s-block-item :type="item.id" :data="item.property" :styles="item.property.style" /> <s-block-item :type="item.id" :data="item.property" :styles="item.property.style" />

View File

@ -10,6 +10,10 @@
<s-menu-list v-if="type === 'MenuList'" :data="data" /> <s-menu-list v-if="type === 'MenuList'" :data="data" />
<!-- 基础组件宫格导航 --> <!-- 基础组件宫格导航 -->
<s-menu-grid v-if="type === 'MenuGrid'" :data="data" /> <s-menu-grid v-if="type === 'MenuGrid'" :data="data" />
<!-- 基础组件弹窗广告 -->
<s-popup-image v-if="type === 'Popover'" :data="data" />
<!-- 基础组件悬浮按钮 -->
<s-float-menu v-if="type === 'FloatingActionButton'" :data="data" />
<!-- 图文组件图片展示 --> <!-- 图文组件图片展示 -->
<s-image-block v-if="type === 'ImageBar'" :data="data" :styles="styles" /> <s-image-block v-if="type === 'ImageBar'" :data="data" :styles="styles" />

View File

@ -1,75 +1,93 @@
<template> <template>
<!-- TODO-jj: 点击遮罩关闭 --> <!-- 模态背景展开时显示点击后折叠 -->
<view> <view class="modal-bg" v-if="fabRef?.isShow" @click="handleCollapseFab"></view>
<view v-if="data?.show === 1"> <!-- 悬浮按钮 -->
<uni-fab <uni-fab
ref="fabRef" ref="fabRef"
:pattern="state.pattern" horizontal="right"
:content="state.content" vertical="bottom"
horizontal="right" :direction="state.direction"
vertical="bottom" :pattern="state.pattern"
:direction="state.direction" :content="state.content"
@trigger="trigger" @trigger="handleOpenLink"
@fabClick="fabClick" />
:popMenu="true"
></uni-fab>
</view>
<view :class="state.show ? 'float-bg' : ''" @click="onTap"></view>
</view>
</template> </template>
<script setup> <script setup>
/**
* 悬浮按钮
*/
import sheep from '@/sheep'; import sheep from '@/sheep';
import { computed, reactive, ref, unref, getCurrentInstance } from 'vue'; import { reactive, ref, unref } from 'vue';
import { onBackPress } from '@dcloudio/uni-app'; import { onBackPress } from '@dcloudio/uni-app';
const data = computed(() => sheep.$store('app').template.basic?.floatMenu);
//
const props = defineProps({
data: {
type: Object,
default() {
return {
// horizontal vertical
direction: 'vertical',
showText: true,
list: [{
imgUrl: 'http://localhost/logo.gif',
url: '',
text: '客服',
textColor: '',
}],
}
},
}
})
// https://uniapp.dcloud.net.cn/component/uniui/uni-fab.html#fab-props
const state = reactive({ const state = reactive({
//
pattern: [], pattern: [],
//
content: [], content: [],
// horizontal-vertical-
direction: '', direction: '',
show: false,
}); });
//
const fabRef = ref(null); const fabRef = ref(null);
const vm = getCurrentInstance(); //
if (data.value?.mode === 1) { state.direction = props.data.direction;
state.direction = 'vertical'; props.data?.list.forEach((item) => {
} else { //
state.direction = 'horizontal'; const text = props.data?.showText ? item.text : ''
} //
data.value?.list.forEach((i) => { state.content.push({ iconPath: sheep.$url.cdn(item.imgUrl), url: item.url, text });
if (data.value?.isText === 0) { //
state.content.push({ iconPath: sheep.$url.cdn(i.src), url: i.url }); state.pattern.push({ color: item.textColor });
} else {
state.content.push({ iconPath: sheep.$url.cdn(i.src), text: i.title.text + '', url: i.url });
}
state.pattern.push({ color: i.title.color });
}); });
function trigger(e) {
//
function handleOpenLink(e) {
sheep.$router.go(e.item.url); sheep.$router.go(e.item.url);
} }
function onTap() {
if (state.show) { //
state.show = false; function handleCollapseFab() {
vm.refs.fabRef.close(); if (unref(fabRef)?.isShow) {
} else { unref(fabRef)?.close();
state.show = true;
vm.refs.fabRef.open();
} }
} }
function fabClick() {
state.show = !state.show; //
}
onBackPress(() => { onBackPress(() => {
if (unref(fabRef).isShow) { if (unref(fabRef)?.isShow) {
unref(fabRef).close(); unref(fabRef)?.close();
return true; return true;
} else {
return false;
} }
return false;
}); });
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.float-bg { /* 模态背景 */
.modal-bg {
position: fixed; position: fixed;
left: 0; left: 0;
top: 0; top: 0;

View File

@ -36,9 +36,6 @@
<!-- 页面内容插槽 --> <!-- 页面内容插槽 -->
<slot /> <slot />
<!-- 悬浮按钮 -->
<s-float-menu v-if="showFloatButton"></s-float-menu>
<!-- 底部导航 --> <!-- 底部导航 -->
<s-tabbar v-if="tabbar !== ''" :path="tabbar" /> <s-tabbar v-if="tabbar !== ''" :path="tabbar" />
</view> </view>
@ -130,11 +127,6 @@
type: String, type: String,
default: '', default: '',
}, },
//
showFloatButton: {
type: Boolean,
default: false,
},
// //
showLeftButton: { showLeftButton: {
type: Boolean, type: Boolean,

View File

@ -1,6 +1,6 @@
<template> <template>
<view> <view>
<view v-for="(item, index) in popupList" :key="item.src"> <view v-for="(item, index) in popupList" :key="index">
<su-popup <su-popup
v-if="index === currentIndex" v-if="index === currentIndex"
:show="item.isShow" :show="item.isShow"
@ -14,7 +14,7 @@
<view class="img-box"> <view class="img-box">
<image <image
class="modal-img" class="modal-img"
:src="sheep.$url.cdn(item.src)" :src="sheep.$url.cdn(item.imgUrl)"
mode="widthFix" mode="widthFix"
@tap.stop="onPopup(item.url)" @tap.stop="onPopup(item.url)"
/> />
@ -27,34 +27,46 @@
<script setup> <script setup>
import sheep from '@/sheep'; import sheep from '@/sheep';
import { computed, ref } from 'vue'; import { computed, ref } from 'vue';
import { onShow } from '@dcloudio/uni-app';
import { saveAdvHistory } from '@/sheep/hooks/useModal'; import { saveAdvHistory } from '@/sheep/hooks/useModal';
//
const props = defineProps({
data: {
type: Object,
default() {},
}
})
// const modalStore = sheep.$store('modal'); // const modalStore = sheep.$store('modal');
const modalStore = JSON.parse(uni.getStorageSync('modal-store') || '{}'); const modalStore = JSON.parse(uni.getStorageSync('modal-store') || '{}');
console.log(modalStore)
const advHistory = modalStore.advHistory || []; const advHistory = modalStore.advHistory || [];
const currentIndex = ref(0); const currentIndex = ref(0);
const popupList = computed(() => { const popupList = computed(() => {
const list = sheep.$store('app').template.basic?.popupImage?.list || []; const list = props.data.list || [];
const newList = []; const newList = [];
if (list.length > 0) { if (list.length > 0) {
list.forEach((adv) => { list.forEach((adv) => {
if (adv.show === 1 && advHistory.includes(adv.src)) { if (adv.showType === 'once' && advHistory.includes(adv.imgUrl)) {
adv.isShow = false; adv.isShow = false;
} else { } else {
adv.isShow = true; adv.isShow = true;
newList.push(adv); newList.push(adv);
} }
//
saveAdvHistory(adv); saveAdvHistory(adv);
}); });
} }
return newList; return newList;
}); });
//
function onPopup(path) { function onPopup(path) {
sheep.$router.go(path); sheep.$router.go(path);
} }
//
function onClose(index) { function onClose(index) {
currentIndex.value = index + 1; currentIndex.value = index + 1;
popupList.value[index].isShow = false; popupList.value[index].isShow = false;

View File

@ -4,7 +4,7 @@
<view class="menu-item ss-flex-1 ss-flex-col ss-row-center ss-col-center" <view class="menu-item ss-flex-1 ss-flex-col ss-row-center ss-col-center"
@tap="sheep.$router.go('/pages/user/wallet/money')"> @tap="sheep.$router.go('/pages/user/wallet/money')">
<view class="value-box ss-flex ss-col-bottom"> <view class="value-box ss-flex ss-col-bottom">
<view class="value-text ss-line-1">{{ userInfo.money }}</view> <view class="value-text ss-line-1">{{ userInfo.money || '0.00' }}</view>
<view class="unit-text ss-m-l-6"></view> <view class="unit-text ss-m-l-6"></view>
</view> </view>
<view class="menu-title ss-m-t-28">账户余额</view> <view class="menu-title ss-m-t-28">账户余额</view>
@ -12,7 +12,7 @@
<view class="menu-item ss-flex-1 ss-flex-col ss-row-center ss-col-center" <view class="menu-item ss-flex-1 ss-flex-col ss-row-center ss-col-center"
@tap="sheep.$router.go('/pages/user/wallet/score')"> @tap="sheep.$router.go('/pages/user/wallet/score')">
<view class="value-box ss-flex ss-col-bottom"> <view class="value-box ss-flex ss-col-bottom">
<view class="value-text">{{ userInfo.point }}</view> <view class="value-text">{{ userInfo.point || '0.00' }}</view>
<view class="unit-text ss-m-l-6"></view> <view class="unit-text ss-m-l-6"></view>
</view> </view>
<view class="menu-title ss-m-t-28">积分</view> <view class="menu-title ss-m-t-28">积分</view>
@ -23,7 +23,7 @@
}) })
"> ">
<view class="value-box ss-flex ss-col-bottom"> <view class="value-box ss-flex ss-col-bottom">
<view class="value-text">{{ numData.coupons_num }}</view> <view class="value-text">{{ numData.coupons_num || '0.00' }}</view>
<view class="unit-text ss-m-l-6"></view> <view class="unit-text ss-m-l-6"></view>
</view> </view>
<view class="menu-title ss-m-t-28">优惠券</view> <view class="menu-title ss-m-t-28">优惠券</view>
@ -91,4 +91,5 @@
} }
} }
} }
</style> </style>

View File

@ -121,8 +121,8 @@ export function saveAdvHistory(adv) {
const modal = $store('modal'); const modal = $store('modal');
modal.$patch((state) => { modal.$patch((state) => {
if (!state.advHistory.includes(adv.src)) { if (!state.advHistory.includes(adv.imgUrl)) {
state.advHistory.push(adv.src); state.advHistory.push(adv.imgUrl);
} }
}); });
} }