2024-08-07 10:31:42 +08:00
|
|
|
|
<!-- 首页,支持店铺装修 -->
|
|
|
|
|
<template>
|
2024-10-29 11:14:45 +08:00
|
|
|
|
<view v-if="template">
|
|
|
|
|
|
|
|
|
|
<s-layout title="首页" navbar="normal" tools="search" tabbar="/pages/index/index" :bgStyle="template.page"
|
2025-04-16 16:00:51 +08:00
|
|
|
|
:navbarStyle="template.navigationBar" navbarbackgroundColor="transparent" onShareAppMessage @search="(e) => { console.log(e,'eeeeeeeeeeee') }"
|
|
|
|
|
headerBtns='headerBtns' backgroundColor="transparent" opacityBgUi='ll' :navBg="true">
|
|
|
|
|
<view class="new-bg" :style="{backgroundImage:'url('+ stateData.backgroundImage +')'}"></view>
|
2024-10-29 11:14:45 +08:00
|
|
|
|
|
|
|
|
|
<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" :fl="true" />
|
|
|
|
|
</s-block>
|
|
|
|
|
</s-layout>
|
|
|
|
|
</view>
|
2024-08-07 10:31:42 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
2024-10-29 11:14:45 +08:00
|
|
|
|
import {
|
2025-04-16 16:00:51 +08:00
|
|
|
|
computed,ref,nextTick,onMounted,watchEffect, reactive,watch
|
2024-10-29 11:14:45 +08:00
|
|
|
|
} from 'vue';
|
|
|
|
|
import {
|
|
|
|
|
onLoad,
|
|
|
|
|
onPageScroll,
|
|
|
|
|
onPullDownRefresh
|
|
|
|
|
} from '@dcloudio/uni-app';
|
|
|
|
|
import sheep from '@/sheep';
|
2025-04-16 16:00:51 +08:00
|
|
|
|
const app = sheep.$store('app');
|
|
|
|
|
|
|
|
|
|
|
2024-10-29 11:14:45 +08:00
|
|
|
|
import $share from '@/sheep/platform/share';
|
|
|
|
|
// 隐藏原生tabBar
|
|
|
|
|
uni.hideTabBar();
|
2024-08-07 10:31:42 +08:00
|
|
|
|
|
2024-10-29 11:14:45 +08:00
|
|
|
|
const template = computed(() => sheep.$store('app').template?.home);
|
|
|
|
|
// 在此处拦截改变一下首页轮播图 此处先写死后期复活 放到启动函数里
|
|
|
|
|
// (async function() {
|
|
|
|
|
// console.log('原代码首页定制化数据',template)
|
|
|
|
|
// let {
|
|
|
|
|
// data
|
|
|
|
|
// } = await index2Api.decorate();
|
|
|
|
|
// console.log('首页导航配置化过高无法兼容',JSON.parse(data[1].value))
|
|
|
|
|
// 改变首页底部数据 但是没有通过数组id获取商品数据接口
|
|
|
|
|
// let {
|
|
|
|
|
// data: datas
|
|
|
|
|
// } = await index2Api.spids();
|
|
|
|
|
// template.value.data[9].data.goodsIds = datas.list.map(item => item.id);
|
|
|
|
|
// template.value.data[0].data.list = JSON.parse(data[0].value).map(item => {
|
|
|
|
|
// return {
|
|
|
|
|
// src: item.picUrl,
|
|
|
|
|
// url: item.url,
|
|
|
|
|
// title: item.name,
|
|
|
|
|
// type: "image"
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
// }())
|
2025-04-16 16:00:51 +08:00
|
|
|
|
const stateData = reactive({
|
|
|
|
|
imgindexArr: [] ,
|
|
|
|
|
backgroundImage:''
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
() => template.value,
|
|
|
|
|
(newValue) => {
|
|
|
|
|
if (newValue) {
|
|
|
|
|
console.log('Template is now available:', newValue);
|
|
|
|
|
// 在这里执行后续操作
|
|
|
|
|
stateData.imgindexArr = template.value.components[2].property.items
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{ immediate: true, once: true } // immediate 确保立即检查当前值,once 确保仅触发一次
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
app.$subscribe((mutation, state) => {
|
|
|
|
|
console.log('State changed:',state.indexSwiperCurr,'图片数组',stateData.imgindexArr);
|
|
|
|
|
|
|
|
|
|
stateData.backgroundImage = stateData.imgindexArr[state.indexSwiperCurr].imgUrl
|
|
|
|
|
});
|
|
|
|
|
// onMounted(()=>{
|
|
|
|
|
|
|
|
|
|
// backgroundImage.value = template.value.components[2]?.property.items[0].imgUrl
|
|
|
|
|
// })
|
2024-08-07 10:31:42 +08:00
|
|
|
|
|
2024-10-29 11:14:45 +08:00
|
|
|
|
onLoad((options) => {
|
|
|
|
|
// #ifdef MP
|
|
|
|
|
// 小程序识别二维码
|
|
|
|
|
if (options.scene) {
|
|
|
|
|
const sceneParams = decodeURIComponent(options.scene).split('=');
|
|
|
|
|
console.log('sceneParams=>', sceneParams);
|
|
|
|
|
options[sceneParams[0]] = sceneParams[1];
|
|
|
|
|
}
|
|
|
|
|
// #endif
|
2024-08-07 10:31:42 +08:00
|
|
|
|
|
2024-10-29 11:14:45 +08:00
|
|
|
|
// 预览模板
|
|
|
|
|
if (options.templateId) {
|
|
|
|
|
sheep.$store('app').init(options.templateId);
|
|
|
|
|
}
|
2025-04-16 16:00:51 +08:00
|
|
|
|
// backgroundImage.value = template.value.components[2]?.property.items[0].imgUrl
|
|
|
|
|
|
2024-10-29 11:14:45 +08:00
|
|
|
|
// 解析分享信息
|
|
|
|
|
if (options.spm) {
|
|
|
|
|
$share.decryptSpm(options.spm);
|
|
|
|
|
}
|
2024-08-07 10:31:42 +08:00
|
|
|
|
|
2024-10-29 11:14:45 +08:00
|
|
|
|
// 进入指定页面(完整页面路径)
|
|
|
|
|
if (options.page) {
|
|
|
|
|
sheep.$router.go(decodeURIComponent(options.page));
|
|
|
|
|
}
|
|
|
|
|
});
|
2024-08-07 10:31:42 +08:00
|
|
|
|
|
2024-10-29 11:14:45 +08:00
|
|
|
|
// 下拉刷新
|
|
|
|
|
onPullDownRefresh(() => {
|
|
|
|
|
sheep.$store('app').init();
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
uni.stopPullDownRefresh();
|
|
|
|
|
}, 800);
|
|
|
|
|
});
|
2024-08-07 10:31:42 +08:00
|
|
|
|
|
2024-10-29 11:14:45 +08:00
|
|
|
|
onPageScroll(() => {});
|
2024-08-07 10:31:42 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
2024-10-11 16:07:43 +08:00
|
|
|
|
<style lang="scss">
|
2024-10-29 11:14:45 +08:00
|
|
|
|
.new-bg {
|
2025-04-16 16:00:51 +08:00
|
|
|
|
// background: #e93422;
|
|
|
|
|
filter: blur(5px);
|
|
|
|
|
width: 100%;
|
|
|
|
|
transform: scale(1.1);
|
|
|
|
|
height: 550rpx;
|
|
|
|
|
position: absolute;
|
|
|
|
|
top: -210rpx;
|
2024-10-11 16:07:43 +08:00
|
|
|
|
}
|
2024-10-29 11:14:45 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</style>
|