首页
This commit is contained in:
@@ -1,7 +1,124 @@
|
||||
<template>
|
||||
<view>
|
||||
<Nav />
|
||||
<view class="content">页面内容</view>
|
||||
<view class="content">
|
||||
<!-- 轮播图 -->
|
||||
<swipers :carousel='hometoplist.carousel'></swipers>
|
||||
<!-- 广告 -->
|
||||
<advertisement :bannervo='hometoplist.bannerVO' :itemStyle='advertisementStyle'></advertisement>
|
||||
<!-- 金刚区 -->
|
||||
<diamond :district='hometoplist.district'></diamond>
|
||||
<!-- 今日上线 -->
|
||||
<todaylist :todayList='hometoplist.todayList' :salesList='hometoplist.salesList'></todaylist>
|
||||
<!-- 类目 -->
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<!-- 只有小程序需要加height -->
|
||||
<up-sticky :offset-top="store.height">
|
||||
<!-- #endif -->
|
||||
<!-- #ifndef MP-WEIXIN -->
|
||||
<up-sticky>
|
||||
<!-- #endif -->
|
||||
<view class="fourcontent" id="fourcontent">
|
||||
<view class="flex-between" style="flex-wrap: inherit;">
|
||||
<view class="fourcontent_item flex-start" v-for="(item,index) in hometoplist.menu"
|
||||
:key="index" @click="viewHistory(item,index)"
|
||||
:class="!item.isChild && index ? 'fourcontent_itemactev':''">
|
||||
<!-- <view class="fourcontent_item flex-start" v-for="(item,index) in hometoplist.menu" :key="index"
|
||||
@click="viewHistory(item,index)"
|
||||
:class="!item.isChild && viewHistoryindex == index ? 'fourcontent_itemactev':''"> -->
|
||||
<text style="margin-right: 10rpx;">{{item.name}}</text>
|
||||
<up-icon v-if="item.isChild" style="margin-left: 10rpx;" name="arrow-down-fill"
|
||||
color="#333333" size="12"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</up-sticky>
|
||||
|
||||
<!-- 首页抢购区域 -->
|
||||
<view class="fivecontent">
|
||||
<view class="fivecontent_item" v-for="(item,index) in homelist" :key="index"
|
||||
@click="fivecontentclick(item)">
|
||||
<view class="fivecontent_item_nav flex-start">
|
||||
<image :src="item.shopImage" mode="aspectFill"></image>
|
||||
<view class="fivecontent_item_nav_left">
|
||||
<view class="fivecontent_item_nav_lefttop flex-between">
|
||||
<view>
|
||||
{{item.shopName}}
|
||||
</view>
|
||||
<view>
|
||||
{{item.districts}} {{item.distances}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="fivecontent_item_nav_lefttopstart flex-start">
|
||||
<view class="fivecontent_item_nav_leftlang flex-start"
|
||||
v-for="(s,index1) in item.shopTag" :key="index1"
|
||||
:style="{'background':s.backColor,'color':s.backColor}">
|
||||
<image class="fivecontent_item_nav_leftlangimage" v-if="s.shareImg"
|
||||
:src="s.shareImg" mode="aspectFill"></image>
|
||||
<text class="fivecontent_item_nav_leftlangtext">{{s.name}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="fivecontent_item_box">
|
||||
<view class="fivecontent_item_boxitem flex-between">
|
||||
<image :src="`${item.image}?x-oss-process=image/resize,m_lfit,w_192,h_192`"
|
||||
mode="aspectFill"></image>
|
||||
<view class="fivecontent_item_boxitemleft flex-colum-start">
|
||||
<view class="fivecontent_item_boxitemleftone flex-between"
|
||||
style="display: flex;justify-content: space-between;align-items: center;">
|
||||
<view>
|
||||
{{item.productName.length>7?item.productName.substring(0,7)+'...':item.productName}}
|
||||
</view>
|
||||
<text>已抢{{item.realSalesNumber}}份</text>
|
||||
</view>
|
||||
<view class="flex-start flexstartboxfttow">
|
||||
<view class="fivecontent_item_boxitemlefttow flex-start"
|
||||
v-for="(c,index2) in item.proTag" :key="index2"
|
||||
:style="{'background':c.backColor,'color':c.backColor}">
|
||||
<image class="fivecontent_item_boxitemlefttowimage" v-if="c.shareImg"
|
||||
:src="c.shareImg" mode="aspectFill"></image>
|
||||
<text class="fivecontent_item_boxitemlefttowtext">{{c.name}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="indexboxitemleftthere flex-colum-start">
|
||||
<view class="indexboxitemleftthereabsolute">
|
||||
马上抢
|
||||
</view>
|
||||
<view class="indexboxitemlefttheretext flex-start">
|
||||
<view class="fivecontent_item_boxitemlefthere_one flex-start">
|
||||
<text class="flex_startone">到手</text>
|
||||
<text class="flex_starttow">¥{{item.salePrice}}</text>
|
||||
</view>
|
||||
<view class="fivecontent_item_boxitemlefthere_tow">
|
||||
{{item.discount || ''}}折
|
||||
</view>
|
||||
<view class="fivecontent_item_boxitemlefthere_there">
|
||||
¥{{item.originPrice}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="indexboxitemleftthere_countdown flex-between">
|
||||
<text class="indexboxitemleftthere_countdowntext">共省{{item.save}}元</text>
|
||||
<view class="indexboxitemleftthere_countdowntexts">
|
||||
<!-- <uni-countdown @timeup="updateCity" :show-day="false"
|
||||
:day="item.end_times.d" :hour="item.end_times.h"
|
||||
:minute="item.end_times.m" :second="item.end_times.s" :indexs='index'
|
||||
color="#FFFFFF" border-color="#00B26A" splitorColor="#FFFFFF"
|
||||
:font-size="10"></uni-countdown> -->
|
||||
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<up-loadmore height='40' :status="form.status" iconSize='16' fontSize='16' />
|
||||
<!-- </scroll-view> -->
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -9,42 +126,437 @@
|
||||
import {
|
||||
ref,
|
||||
computed,
|
||||
onMounted
|
||||
onMounted,
|
||||
reactive
|
||||
} from "vue";
|
||||
import {
|
||||
onLoad,
|
||||
onReady,
|
||||
onShow
|
||||
onShow,
|
||||
onPageScroll
|
||||
} from '@dcloudio/uni-app'
|
||||
import Nav from '@/components/indexnav.vue';
|
||||
import swipers from './components/swiper.vue' //引入轮播
|
||||
import advertisement from './components/advertisement.vue' //广告
|
||||
import diamond from './components/diamond.vue' //金刚区
|
||||
import todaylist from './components/todaylist.vue' //今日上线
|
||||
// import popupad from '@/components/popupad.vue'
|
||||
// import productlist from './components/productlist.vue'
|
||||
// import category from '@/components/qiyue-category/qiyue-category.vue';
|
||||
// import indexs from './indexs.vue';
|
||||
import Nav from '@/components/indexnav.vue'; //导航栏
|
||||
import API from "@/common/js/api.js"
|
||||
import {
|
||||
useNavbarStore
|
||||
} from '@/stores/navbarStore';
|
||||
|
||||
const store = useNavbarStore();
|
||||
|
||||
// 动态更新导航栏配置
|
||||
store.updateNavbarConfig({
|
||||
showBack: false,
|
||||
rightText: '',
|
||||
showSearch: true,
|
||||
title: '我的页面',
|
||||
isTransparent: false,
|
||||
hasPlaceholder: true
|
||||
showBack: true, //左边返回键
|
||||
rightText: '', //右边文字
|
||||
showSearch: true, //true是标题其他事文字
|
||||
title: '我的页面',
|
||||
isTransparent: false,
|
||||
hasPlaceholder: false //是否要占位符
|
||||
});
|
||||
//数据
|
||||
const hometoplist = reactive({})
|
||||
// 首页抢购数据
|
||||
const form = ref({
|
||||
address: '', //地址
|
||||
type: '', //品类
|
||||
orderBy: '', //1.理我最近 2.销量优先 3.价格优先
|
||||
other: '', //附近1KM 1选中 0不选中
|
||||
page: 1, //页数
|
||||
size: 10, //页容量
|
||||
status: 'loadmore'
|
||||
})
|
||||
const homelist = ref([{
|
||||
endRow: 1,
|
||||
firstPage: 1,
|
||||
hasNextPage: false,
|
||||
hasPreviousPage: false,
|
||||
isFirstPage: true,
|
||||
isLastPage: true,
|
||||
lastPage: 1,
|
||||
list: [{
|
||||
discount: 9,
|
||||
distances: "1.1km",
|
||||
districts: "未央区",
|
||||
endTime: 1739059199999,
|
||||
id: 661,
|
||||
image: "https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240612/0c07e1f79a244ed498dfe4a70848c479.jpeg",
|
||||
originPrice: 200,
|
||||
proTag: [],
|
||||
productName: "鸡尾酒套餐",
|
||||
realSalesNumber: 0,
|
||||
salePrice: 180,
|
||||
save: 20,
|
||||
shopImage: "https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240612/6f3618a31d2a4b489215647871ae732e.jpg",
|
||||
shopName: "漫巷咖啡",
|
||||
shopTag: [],
|
||||
}],
|
||||
discount: 9,
|
||||
distances: "1.1km",
|
||||
districts: "未央区",
|
||||
endTime: 1739059199999,
|
||||
id: 661,
|
||||
image: "https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240612/0c07e1f79a244ed498dfe4a70848c479.jpeg",
|
||||
originPrice: 200,
|
||||
proTag: [],
|
||||
productName: "鸡尾酒套餐",
|
||||
realSalesNumber: 0,
|
||||
salePrice: 180,
|
||||
save: 20,
|
||||
shopImage: "https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240612/6f3618a31d2a4b489215647871ae732e.jpg",
|
||||
shopName: "漫巷咖啡",
|
||||
shopTag: [],
|
||||
navigateFirstPage: 1,
|
||||
navigateLastPage: 1,
|
||||
navigatePages: 8,
|
||||
navigatepageNums: [1],
|
||||
nextPage: 0,
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
pages: 1,
|
||||
prePage: 0,
|
||||
size: 1,
|
||||
startRow: 1,
|
||||
total: 1,
|
||||
}])
|
||||
//计算广告图片的重合尺寸是位移
|
||||
const getStyle = (e) => {
|
||||
if (e > hometoplist.bannerVO.counponsInfo.length / 2) {
|
||||
var right = hometoplist.bannerVO.counponsInfo.length - e
|
||||
return {
|
||||
transform: 'scale(' + (1) + ') translate(-' + (right * 20) + '%,0px)',
|
||||
zIndex: 9999 - right,
|
||||
opacity: 1
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
transform: 'scale(' + (1) + ') translate(' + (e * 20) + '%,0px)',
|
||||
zIndex: 9999 - e,
|
||||
opacity: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
const advertisementStyle = ref([{
|
||||
transform: 'scale(' + (1) + ') translate(-' + (0 * 20) + '%,0px)',
|
||||
zIndex: 9999,
|
||||
opacity: 1
|
||||
}])
|
||||
// 广告数据
|
||||
const hometop = async () => {
|
||||
// try {
|
||||
let res = await API.homehomePageUp()
|
||||
console.log(res.data)
|
||||
Object.assign(hometoplist, res.data)
|
||||
// hometoplist = Object.assign(res.data)
|
||||
if (hometoplist.bannerVO.counponsInfo) {
|
||||
hometoplist.bannerVO.counponsInfo.forEach((item, index) => {
|
||||
advertisementStyle.value.push(getStyle(index))
|
||||
})
|
||||
}
|
||||
// 计算swiper样式
|
||||
|
||||
// } catch (e) {}
|
||||
}
|
||||
// 存储每个元素距离顶部的距离
|
||||
const elementTop = ref(0);
|
||||
// 存储是否吸顶的状态
|
||||
const isSticky = ref(true);
|
||||
// 点击滑动元素
|
||||
const viewHistory = async (item, index) => {
|
||||
if (isSticky) {
|
||||
uni.pageScrollTo({
|
||||
scrollTop: elementTop.value,
|
||||
duration: 300
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
// 滑动
|
||||
onPageScroll((res) => {
|
||||
isSticky.value = res.scrollTop > elementTop.value ? true : false
|
||||
uni.$u.debounce(store.scrollTop = res.scrollTop, 500)
|
||||
});
|
||||
onShow(() => {})
|
||||
onMounted(() => {
|
||||
hometop()
|
||||
// 初始化
|
||||
const query = uni.createSelectorQuery().select('#fourcontent');
|
||||
query.boundingClientRect((rect) => {
|
||||
elementTop.value = rect.top - store.height
|
||||
}).exec();
|
||||
});
|
||||
// store.updateNavbarConfig({
|
||||
// showBack: true,//左边返回键
|
||||
// rightText: '',//右边文字
|
||||
// showSearch: true,//true是标题其他事文字
|
||||
// title: '我的页面',
|
||||
// isTransparent: false,
|
||||
// height: 44,
|
||||
// hasPlaceholder: false//是否要占位符
|
||||
// });
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.content {
|
||||
height: 1000vh;
|
||||
background: #F9F9F9;
|
||||
|
||||
.fourcontent {
|
||||
padding: 32rpx 28rpx;
|
||||
overflow-x: auto;
|
||||
flex-wrap: nowrap;
|
||||
background: #f9f9f9;
|
||||
|
||||
.fourcontent_item {
|
||||
flex-wrap: nowrap;
|
||||
margin-left: 22rpx;
|
||||
padding: 11rpx 31rpx;
|
||||
background: #FFFFFF;
|
||||
border-radius: 8rpx 8rpx 8rpx 8rpx;
|
||||
|
||||
text {
|
||||
width: max-content;
|
||||
}
|
||||
}
|
||||
|
||||
.fourcontent_itemactev {
|
||||
background: #fee06a;
|
||||
}
|
||||
|
||||
.fourcontent_item:nth-child(1) {
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.fivecontent {
|
||||
padding: 0 28rpx;
|
||||
height: 100vh;
|
||||
|
||||
.fivecontent_item:nth-child(1) {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.fivecontent_item {
|
||||
margin-top: 32rpx;
|
||||
padding: 24rpx 32rpx;
|
||||
width: 100%;
|
||||
background: #FFFFFF;
|
||||
border-radius: 18rpx 18rpx 18rpx 18rpx;
|
||||
|
||||
.fivecontent_item_nav {
|
||||
image {
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.fivecontent_item_nav_left {
|
||||
flex: auto;
|
||||
margin-left: 12rpx;
|
||||
|
||||
.fivecontent_item_nav_lefttop {
|
||||
font-family: Source Han Sans CN, Source Han Sans CN;
|
||||
font-weight: 400;
|
||||
font-size: 24rpx;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.fivecontent_item_nav_lefttopstart {
|
||||
margin-top: 8rpx;
|
||||
|
||||
.fivecontent_item_nav_leftlang {
|
||||
margin-left: 12rpx;
|
||||
width: max-content;
|
||||
padding: 4rpx 10rpx;
|
||||
background: #FFF9E1;
|
||||
border-radius: 4rpx 4rpx 4rpx 4rpx;
|
||||
|
||||
.fivecontent_item_nav_leftlangtext {
|
||||
margin-left: 6rpx;
|
||||
font-family: Source Han Sans CN, Source Han Sans CN;
|
||||
font-weight: 400;
|
||||
font-size: 16rpx;
|
||||
color: #F9A511;
|
||||
}
|
||||
|
||||
.fivecontent_item_nav_leftlangimage {
|
||||
width: 10.82rpx;
|
||||
height: 14.06rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.fivecontent_item_nav_leftlang:nth-child(1) {
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
.fivecontent_item_box {
|
||||
margin-top: 20rpx;
|
||||
border-top: 2rpx solid #E5E5E5;
|
||||
padding-top: 14rpx;
|
||||
|
||||
.fivecontent_item_boxitem {
|
||||
image {
|
||||
width: 192rpx;
|
||||
height: 192rpx;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
.fivecontent_item_boxitemleft {
|
||||
margin-left: 24rpx;
|
||||
flex: 1;
|
||||
|
||||
.fivecontent_item_boxitemleftone {
|
||||
width: 100%;
|
||||
|
||||
text {
|
||||
font-family: Source Han Sans CN, Source Han Sans CN;
|
||||
// font-weight: 700;
|
||||
font-size: 24rpx;
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
view {
|
||||
// width: 300rpx;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap; //溢出不换行white-space:nowrap; //溢出不换行
|
||||
font-family: Source Han Sans CN, Source Han Sans CN;
|
||||
font-weight: 500;
|
||||
font-size: 32rpx;
|
||||
color: #333333;
|
||||
}
|
||||
}
|
||||
|
||||
.flexstartboxfttow {
|
||||
.fivecontent_item_boxitemlefttow {
|
||||
margin-left: 16rpx;
|
||||
margin-top: 8rpx;
|
||||
width: max-content;
|
||||
padding: 4rpx 10rpx;
|
||||
background: #FFF9E1;
|
||||
border-radius: 4rpx 4rpx 4rpx 4rpx;
|
||||
|
||||
.fivecontent_item_boxitemlefttowtext {
|
||||
margin-left: 6rpx;
|
||||
font-family: Source Han Sans CN, Source Han Sans CN;
|
||||
font-weight: 400;
|
||||
font-size: 16rpx;
|
||||
color: #F9A511;
|
||||
}
|
||||
|
||||
.fivecontent_item_boxitemlefttowimage {
|
||||
width: 10.82rpx;
|
||||
height: 14.06rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.fivecontent_item_boxitemlefttow:nth-child(1) {
|
||||
margin-left: 0;
|
||||
background: #FFD6D7;
|
||||
border-radius: 4rpx 4rpx 4rpx 4rpx;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.indexboxitemleftthere {
|
||||
position: relative;
|
||||
margin-top: 30rpx;
|
||||
padding-left: 16rpx;
|
||||
width: 100%;
|
||||
background: url(https://czg-qr-order.oss-cn-beijing.aliyuncs.com/index/qinggou.png) no-repeat;
|
||||
background-size: 100% 100%;
|
||||
|
||||
|
||||
|
||||
.indexboxitemleftthereabsolute {
|
||||
position: absolute;
|
||||
top: 14rpx;
|
||||
right: 12rpx;
|
||||
font-family: Source Han Sans CN, Source Han Sans CN;
|
||||
font-weight: bold;
|
||||
font-size: 24rpx;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
.indexboxitemlefttheretext {
|
||||
// width: 100%;
|
||||
margin-top: 12rpx;
|
||||
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
.fivecontent_item_boxitemlefthere_one {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
.flex_startone {
|
||||
font-family: Source Han Sans CN, Source Han Sans CN;
|
||||
font-weight: 500;
|
||||
font-size: 16rpx;
|
||||
color: #FF7127;
|
||||
}
|
||||
|
||||
.flex_starttow {
|
||||
font-family: Source Han Sans CN, Source Han Sans CN;
|
||||
font-weight: 500;
|
||||
font-size: 24rpx;
|
||||
color: #FF7127;
|
||||
}
|
||||
}
|
||||
|
||||
.fivecontent_item_boxitemlefthere_tow {
|
||||
margin-left: 4rpx;
|
||||
padding: 2rpx 10rpx;
|
||||
border-radius: 4rpx 4rpx 4rpx 4rpx;
|
||||
border: 2rpx solid #FF7127;
|
||||
font-family: Source Han Sans CN, Source Han Sans CN;
|
||||
font-weight: 500;
|
||||
font-size: 16rpx;
|
||||
color: #FF7127;
|
||||
}
|
||||
|
||||
.fivecontent_item_boxitemlefthere_there {
|
||||
margin-left: 6rpx;
|
||||
line-height: 24rpx;
|
||||
font-family: Source Han Sans CN, Source Han Sans CN;
|
||||
font-weight: 400;
|
||||
font-size: 16rpx;
|
||||
color: #999999;
|
||||
text-decoration-line: line-through;
|
||||
}
|
||||
}
|
||||
|
||||
.indexboxitemleftthere_countdown {
|
||||
width: 100%;
|
||||
padding-right: 7rpx;
|
||||
margin-top: 2rpx;
|
||||
|
||||
.indexboxitemleftthere_countdowntext {
|
||||
font-family: Source Han Sans CN, Source Han Sans CN;
|
||||
font-weight: 400;
|
||||
font-size: 24rpx;
|
||||
color: #999999;
|
||||
padding-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.indexboxitemleftthere_countdowntexts {
|
||||
font-family: Roboto, Roboto;
|
||||
font-weight: 400;
|
||||
color: #333333;
|
||||
font-family: Source Han Sans CN, Source Han Sans CN;
|
||||
font-weight: bold;
|
||||
font-size: 16rpx;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user