This commit is contained in:
HongRun Liu
2026-05-26 15:52:30 +08:00
commit b0744c8ab6
849 changed files with 130587 additions and 0 deletions
+304
View File
@@ -0,0 +1,304 @@
<!-- 首页,支持店铺装修 -->
<template>
<s-pages title="首页" :showLeftButton="false">
<view class="pagesIndex">
<s-custom-navbarIndex />
<view class="pages">
<s-banner v-if="template?.components[0]?.property.items?.length" :data="template.components[0].property"
:styles="template.components[0].property.style" />
<!-- 文字滚动 -->
<view class="noticeBar flex-center bg24 m-b-22" v-if="informText">
<image class="noticeImg shrink" src="/static/index/notice.png" mode="scaleToFill" />
<uni-notice-bar class="flex1" scrollable background-color="#ffffff" :text="informText"
color="#333333" :speed="100" />
</view>
<!-- <view class="navList flex-center ju-between">
<view v-for="(v, i) in nav" :key="i" class="navItem flex-center flex-column" @click="go(v.url)">
<image class="navImg shrink" :src="`/static/index/${v.icon}`" mode="scaleToFill" />
<view class="size26 f500">{{ v.title }}</view>
</view>
</view> -->
<view class="activeList flex-row wrap ju-between" v-if="activeList?.length">
<view class="activeItem" :style="{
height: 160 + 'rpx',
width: `${activeList?.length === 1
? '100%'
: activeList?.length === 2
? 'calc((100% - 16rpx) / 2)'
: i === 0
? '100%'
: 'calc((100% - 16rpx) / 2)'
}`,
}" v-for="(v, i) in activeList" :key="i" @click="go(v)">
<image :src="sheep.$url.cdn(v.bannerImage)" mode="scaleToFill" />
</view>
</view>
</view>
<su-sticky top="100rpx">
<view class="goodsIndex">
<goods :list="tagList" v-if="tagList?.length" />
</view>
</su-sticky>
</view>
</s-pages>
</template>
<script setup>
import {
ref,
computed
} from 'vue';
import {
onLoad,
onPageScroll,
onPullDownRefresh
} from '@dcloudio/uni-app';
import goods from '@/components/goods/goods.vue';
import sheep from '@/sheep';
import $share from '@/sheep/platform/share';
import * as api from '@/sheep/api/index/index';
let template = ref({
page: {
backgroundColor: '#F2F4F7',
padding: '0 32rpx',
boxSiziong: 'border-box',
},
navigationBar: {},
components: [{
id: 'Banner',
property: {
autoplay: true,
indicator: 'number',
interval: 3000,
circular: true,
indicatorDots: false,
indicatorColor: '#D6D6D6', //点颜色
indicatorActiveColor: '#FE4246', //当前点颜色
items: [],
style: {
bgType: 'color',
bgColor: '#fff',
margin: '12rpx 0rpx',
marginBottom: '42rpx',
borderRadius: '24rpx',
height: '240rpx',
},
bgColor: '',
bgType: 'color',
marginBottom: 8,
type: 'default',
},
},],
});
let nav = ref([
{
icon: 'i1.png',
title: '大健康',
url: '',
},
{
icon: 'i2.png',
title: '大农业',
url: '',
},
{
icon: 'i3.png',
title: '大文旅',
url: '',
},
{
icon: 'i4.png',
title: '本地生活',
url: '',
},
{
icon: 'i5.png',
title: '数据处理',
url: '',
},
{
icon: 'i6.png',
title: '跨境电商',
url: '',
},
]);
const getBanner = () => {
api.getbannerlist({
position: 1,
}).then((res) => {
let data = res.data;
template.value.components[0].property.items = data;
});
};
// 商品标签列表
let tagList = ref([]);
const getproducttaglist = () => {
api.getproducttaglist({
categoryId: 1,
}).then((res) => {
tagList.value = res.data;
});
};
// 消息通知
let informText = ref('');
const getnotification = () => {
api.getnotification({}).then((res) => {
if (res?.code === 0) {
let data = res.data;
if (!data?.length) return;
// 拼接文案content
informText.value = data.map((item) => item.content).join(' ');
}
});
};
// 活动banner
let activeList = ref([]);
// 列数
let activeCol = ref(2);
const getappbanner = () => {
api.getappbanner({}).then((res) => {
if (res.data) {
activeList.value = res.data.list;
activeCol.value = res.data.bannerDisplayNum;
}
});
};
const getData = () => {
// banner
getBanner();
// 标签列表
getproducttaglist();
getnotification();
getappbanner();
};
onLoad((options) => {
getData();
// #ifdef MP
// 小程序识别二维码
if (options.scene) {
const sceneParams = decodeURIComponent(options.scene).split('=');
options[sceneParams[0]] = sceneParams[1];
}
// #endif
// 预览模板
// if (options.templateId) {
// sheep.$store('app').init(options.templateId);
// }
// 解析分享信息
if (options.spm) {
$share.decryptSpm(options.spm);
}
// 进入指定页面(完整页面路径)
if (options.page) {
sheep.$router.go(decodeURIComponent(options.page));
}
});
//跳转浏览器
const openExternal = (url) => {
if (!url) return;
if (typeof plus !== 'undefined' && plus.runtime && typeof plus.runtime.openURL === 'function') {
plus.runtime.openURL(url);
return;
}
if (typeof window !== 'undefined' && typeof window.open === 'function') {
window.open(url, '_blank');
return;
}
};
const go = (e) => {
// console.log(e);
if (!e.linkUrl) {
uni.showToast({
title: '功能开发中, 敬请期待',
icon: 'none',
});
return;
} else if (e.title === '华贸专区') {
openExternal(e.linkUrl);
} else {
uni.navigateTo({
url: e.linkUrl,
});
}
};
// 下拉刷新
onPullDownRefresh(() => {
// sheep.$store('app').init();
getData();
setTimeout(function () {
uni.stopPullDownRefresh();
}, 1000);
});
onPageScroll(() => { });
</script>
<style scoped lang="scss">
.pages {
padding: 0 32rpx;
box-sizing: border-box;
}
.noticeBar {
background-color: #fff;
border-radius: 12rpx;
overflow: hidden;
padding-left: 12rpx;
box-sizing: border-box;
}
.noticeImg {
width: 52rpx;
height: 52rpx;
}
:deep(.uni-noticebar) {
height: 92rpx;
border-radius: 12rpx;
overflow: hidden;
margin: 0;
font-weight: 500;
}
.navList {
margin-top: 40rpx;
margin-bottom: 52rpx;
.navItem {
width: 120rpx;
}
.navImg {
width: 84rpx;
height: 84rpx;
margin-bottom: 12rpx;
}
}
/* .noticeBar{
border-radius: 12rpx;
overflow: hidden;
} */
.activeList {
.activeItem {
// width: calc((100% - 10rpx) / 2 - 10rpx);
margin-bottom: 16rpx;
image {
width: 100%;
height: 100%;
}
}
}
.pagesIndex {
position: relative;
}
</style>