Index bug fixed

This commit is contained in:
Vion 2022-01-18 22:57:23 +08:00
parent a1f6e32213
commit 37a7e4706d
3 changed files with 458 additions and 335 deletions

View File

@ -8,17 +8,35 @@ body{
.fade-leave-active {
opacity: 0;
}
.userloding {
.ts-mask{
width:100%;
height:100%;
position: fixed;
left: 50%;
margin-left: -1.56rem;
top: 50%;
margin-top: -3.75rem;
top:0;
left:0;
display:flex;
flex-direction: column;
justify-content: center;
align-items: center;
z-index:99;
.ts-mask-bg{
background-color:#000;
opacity:.6;
width:100%;
height:100%;
z-index:0;
position:absolute;
left:0;
top:0;
}
}
.userloding {
background: url(../image/onloading.png) center center no-repeat;
width: 3.12rem;
background-size: contain;
height: 7.5rem;
z-index: 1000;
height: 3.12rem;
animation: rolling 4s infinite;
-webkit-animation:rolling 4s infinite;
}
@ -229,13 +247,12 @@ img, picture {
right: 0;
top: 30%;
background: #FFFFFF;
box-shadow: 0px 0px .62rem rgba(0, 0, 0, 0.16);
box-shadow: 0 0 10px rgba(0, 0, 0, 0.16);
border-radius: .25rem;
z-index:3;
ul{
width: 60px;
height: 181px;
box-shadow: 0px 0px 6px rgb(0 0 0 / 10%);
background-color: white;
display: flex;
flex-direction: column;
@ -323,9 +340,7 @@ img, picture {
margin-top: 90px;
}
.rc-list__header {
background: none;
padding: .5rem 0;
border-bottom: none;
}
.ts-right-arr {
border-bottom:1px solid #E1001A;

View File

@ -18,9 +18,12 @@
text-align: center;
}
}
.ts-position-identifier{
li{
background: unset;;
}
.ul-zhuan,.ul-dog{
li{
background: unset;
img{
border-radius: 50%;
}
@ -37,9 +40,9 @@ li{
border: 3px solid #D7D7D7;
}
}
}
}
.uservideo{
overflow: hidden;
video{
@ -47,9 +50,40 @@ li{
width:auto;
}
}
.ul-dog{
width: 100%;
display: flex;
justify-content: center;
flex-wrap: wrap;
flex-direction: row;
span{
margin-top: .5rem;
display: block;
}
img{
width: 9.5rem;
height: auto;
display: block;
}
li{
cursor: pointer;
font-size: 16px;
text-align: center;
margin-top:3rem;
margin-left:3rem;
}
}
@media screen and (max-width:768px){
.ul-dog{
display: none;
justify-content: space-evenly;
img{
width:4rem;
height:auto;
}
li{
margin-top:1.875rem;
}
}
.ts-banner-swiper-container{
margin-bottom:2.5rem;
@ -57,9 +91,9 @@ li{
.searchBara{
width: 100%;
position: fixed;
top:66px;
top:3.75rem;
background: white;
z-index: 9999;
z-index: 60;
overflow-x: auto;
white-space: nowrap;
overflow-y:hidden;
@ -76,7 +110,6 @@ li{
display: inline-block;
margin-left: 0.20rem;
text-align: center;
background: #F6F6F6;
border-radius: 50%;
opacity: 1;
}
@ -203,7 +236,7 @@ li{
width: 100%;
display: flex;
flex-direction: column;
justify-content: center;
justify-content: flex-start;
align-items: center;
}
img{
@ -560,30 +593,7 @@ img{
}
.usermain{
.ul-dog{
width: 100%;
display: flex;
justify-content: center;
flex-wrap: wrap;
flex-direction: row;
span{
margin-top: .5rem;
display: block;
}
img{
width: 9.5rem;
height: 9.5rem;
display: block;
}
li{
cursor: pointer;
font-size: 16px;
text-align: center;
margin-top:3rem;
margin-left:3rem;
}
}
}
.rc-main{
width: 100%;

View File

@ -37,7 +37,7 @@
<div class="online bold rc-md-up" v-show="catproduct"></div>
<div class="rc-full-width">
<div class="rc-lunbo rc-full-width">
<div class="rc-lunbo rc-full-width ts-position-identifier" data-rel="明星猫粮">
<!-- <h2>明星猫粮</h2> -->
<div class="pageFullScreen" id="xxxFullScreen" v-show="catproduct" ref="mingxing">
<!-- 内容 -->
@ -91,8 +91,8 @@
<div class="online bold" v-show="onemao"></div>
<div class="selectionswitch rc-full-width rc-max-width--xl rc-padding-y--md" ref="usercontent" v-show="onemao">
<h2 class="rc-beta rc-text--center" >全价猫湿粮</h2>
<van-tabs @change='catclick' class="van-tabs" v-if="onemao">
<h2 class="rc-beta rc-text--center ts-position-identifier" data-rel="猫湿粮" >全价猫湿粮</h2>
<van-tabs @click='catclickShi' class="van-tabs" v-if="onemao" v-model="maoshiCurIndex">
<van-tab v-for="(item,index) in discoun" :key="index" :title="item.title">
<div class="rc-contair">
<ul class="ts-product-list rc-margin-bottom--lg">
@ -165,22 +165,18 @@
</div>
</li>
</ul>
<nuxt-link :to="`/productdetails/productlist/`">
<div class="userserlect">
<span class="ts-standard-btn center">查看更多</span>
</div>
</nuxt-link>
</div>
</div>
</div>
<div class="online bold" v-show="twomao"></div>
<div class="selectionswitch rc-full-width rc-max-width--xl rc-padding-y--md" v-show="twomao" ref="catgan">
<h2 class="rc-beta rc-text--center">全价猫干粮</h2>
<van-tabs @change='catclick' class="van-tabs" v-if="twomao">
<h2 class="rc-beta rc-text--center ts-position-identifier" data-rel="猫干粮">全价猫干粮</h2>
<van-tabs @click='catclickGan' class="van-tabs" v-if="twomao" v-model="maoganCurIndex">
<van-tab v-for="(item,index) in discoun" :key="index" :title="item.title">
<div class="rc-contair">
<ul class="ts-product-list rc-margin-bottom--lg">
@ -275,7 +271,7 @@
<!-- 内容 -->
<div class="swiper-container rc-full-width rc-padding-y--md" id="swiper2">
<div class="oc-top">
<h2 class="rc-beta rc-text--center">{{dogtitle}}</h2>
<h2 class="rc-beta rc-text--center ts-position-identifier" data-rel="明星犬粮">{{dogtitle}}</h2>
</div>
<!-- 轮播图 -->
<div class="ts-carousel-container">
@ -328,21 +324,20 @@
<div class="selectionswitch rc-full-width rc-max-width--xl rc-padding-y--md" v-show="threemao" ref="doggshi">
<h2 class="rc-beta rc-text--center">全价犬湿粮</h2>
<van-tabs @change='userdog' class="van-tabs" v-if="threemao">
<div class="online bold rc-md-down" v-show="threemao"></div>
<h2 class="rc-beta rc-text--center ts-position-identifier" data-rel="犬湿粮">全价犬湿粮</h2>
<van-tabs @click='userdogShi' class="van-tabs" v-if="threemao" v-model="quanshiCurIndex">
<van-tab v-for="(item,index) in dogtype" :key="index" :title="item.title">
<div class="online bold" v-show="threemao"></div>
<div class="online bold rc-md-up" v-show="threemao"></div>
<div class="usermain">
<ul class="ul-dog usermain">
<li
v-for="(item, index) in userdoglist"
:key="index"
@click="quanshi(item, index)"
:class="activeIndex5 == index ? 'active' : 'unactive'"
v-for="(dogListitem, dogListIndex) in userdoglist"
:key="dogListIndex"
@click="quanshi(dogListitem, dogListIndex)"
:class="activeIndex5 == dogListIndex ? 'active' : 'unactive'"
>
<img :src="item.catimage" alt="">
<span>{{ item.title }}</span>
<img :src="dogListitem.catimage" alt="">
<span>{{ dogListitem.title }}</span>
</li>
</ul>
</div>
@ -425,7 +420,6 @@
</li>
</ul>
<nuxt-link :to="`/productdetails/productlist/`">
<div class="userserlect">
<span class="ts-standard-btn center">查看更多</span>
@ -445,20 +439,20 @@
<div class="online bold" v-show="fourmao"></div>
<div class="selectionswitch rc-full-width rc-max-width--xl rc-padding-y--md" v-show="fourmao" ref="dogan">
<h2 class="rc-beta rc-text--center">全价犬干粮</h2>
<van-tabs @change='userdog' class="van-tabs" v-if="fourmao">
<div class="online bold" v-show="fourmao"></div>
<h2 class="rc-beta rc-text--center ts-position-identifier" data-rel="犬干粮">全价犬干粮</h2>
<van-tabs @click='userdogGan' class="van-tabs" v-if="fourmao" v-model="quanganCurIndex">
<div class="online bold rc-md-up" v-show="fourmao"></div>
<van-tab v-for="(item,index) in dogtype" :key="index" :title="item.title">
<div class="usermain">
<ul class="ul-dog usermain">
<li
v-for="(item, index) in userdoglist"
:key="index"
@click="userdoghot(item, index)"
:class="activeIndex6 == index ? 'active' : 'unactive'"
v-for="(userDogListItem, userDogListIndex) in userdoglist"
:key="userDogListIndex"
@click="userdoghot(userDogListItem, userDogListIndex)"
:class="activeIndex6 == userDogListIndex ? 'active' : 'unactive'"
>
<img :src="item.catimage" alt="">
<span>{{ item.title }}</span>
<img :src="userDogListItem.catimage" alt="">
<span>{{ userDogListItem.title }}</span>
</li>
</ul>
</div>
@ -538,7 +532,6 @@
</div>
</li>
</ul>
<nuxt-link :to="`/productdetails/productlist/`">
<div class="userserlect">
<span class="ts-standard-btn center">查看更多</span>
@ -556,8 +549,8 @@
<div class="online bold" v-show="fivemao"></div>
<div class="selectionswitch rc-full-width rc-max-width--xl rc-padding-y--md" v-show="fivemao" ref="chufang">
<h2 class="rc-beta rc-text--center">处方用粮</h2>
<van-tabs @change='userclick' class="van-tabs" v-if="fivemao">
<h2 class="rc-beta rc-text--center ts-position-identifier" data-rel="处方用粮">处方用粮</h2>
<van-tabs @click='userclick' class="van-tabs" v-if="fivemao">
<van-tab v-for="(item,index) in discounchufang" :key="index" :title="item.title">
<div class="rc-contair">
<ul class="ts-product-list rc-margin-bottom--lg">
@ -701,7 +694,11 @@
<span>回到顶部</span>
</div>
</div>
<div v-if="!dataLoaded" class="ts-mask">
<div class="ts-mask-bg"></div>
<div class="userloding"></div>
<span>数据加载中</span>
</div>
<Myfooter v-on:litentop='showmesg'></Myfooter>
</div>
</template>
@ -718,6 +715,8 @@
meta: {title: '首页'},
data(){
return{
fixedHeader:false,
dataLoaded:true,
useraindex:0,
usertitle:'明星猫粮',
dogtitle:'明星犬粮',
@ -742,7 +741,6 @@
dogtype:[
{
title: "幼犬",
},
{
title: "成犬",
@ -750,7 +748,12 @@
{
title: "老年犬",
},
{
title: "品种犬",
},
{
title: "亚健康",
}
],
anchor:'',
dogshi:[],
@ -800,6 +803,10 @@
]
},
showingBanners:[],
maoganCurIndex:0,
maoshiCurIndex:0,
quanshiCurIndex:0,
quanganCurIndex:0,
userdoglist: [
{
title: "小型犬",
@ -813,7 +820,6 @@
title: "大型犬",
catimage: "/images/dog/big.png",
},
],
discoun: [
{
@ -831,11 +837,8 @@
},
{
title: "亚健康猫",
title: "亚健康猫"
},
],
discountlist: [
@ -1147,8 +1150,14 @@
}
window.addEventListener("scroll", this.handleScroll, true);
this.userchufang();//
this.catmessage();//
this.catclickGan();
this.catclickShi();
this.dogmessage();//
this.userdogShi();
this.userdogGan();
},
destroyed () {
window.removeEventListener('scroll', this.scrollToTop);
@ -1200,8 +1209,6 @@
ifadroind(item,index,order){
//console.log(item,index,order);
var sUserAgent = navigator.userAgent.toLowerCase();
var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
@ -1298,6 +1305,30 @@
let dogtop=document.querySelector('.oc-top');
//console.log(dogtop);
//console.log(mingxin.offsetTop);
let positionIdentifier=document.querySelectorAll('.ts-position-identifier');
let tmpTitle='';
let scrollToTop=0;
let _self=this;
let transition = 230;
positionIdentifier.forEach(function(ele,index){
tmpTitle = ele.getAttribute("data-rel");
if(item.title==tmpTitle)
{
if(_self.fixedHeader && item.title!='明星猫粮')
{
transition+=130;
}
scrollToTop = _self.heightToTop(positionIdentifier[index]) - transition;
//positionIdentifier[index].scrollIntoView(true);
window.scrollTo({
top:scrollToTop,
behavior:'smooth'
})
//document.body.scrollTop = oPos;
}
})
/*
if(item.title=='犬湿粮'||item.title=='犬干粮'||item.title=='处方用粮'){
userindex=userindex-2
}else{
@ -1320,30 +1351,62 @@
// }
//console.log("")
*/
}
},
userdog(item,index){
heightToTop(ele){
//eleDOM
let root = document.body;
let height = 0;
do{
height += ele.offsetTop;
ele = ele.offsetParent;
}while( ele !== root )
return height;
},
userdogShi(){
this.activeIndex5=(this.activeIndex5?this.activeIndex5:0);
let apiDogSize=this.userdoglist[this.activeIndex5].title;
let apiDogFoodType=this.dogtype[this.quanshiCurIndex].title;
this.userstype=1;
let petType={
petType:1,
name:index,
categoryName:"皇家犬湿粮",
name:apiDogFoodType,
}
for(let i =0;i<this.userserachlist.length;i++){
if(!this.userserachlist.includes(petType)){
this.userserachlist.push(petType)
}
}
this.dogmessage(this.userserachlist)
//TODO how to combine "apiName" here?
this.dogmessage(this.userserachlist,"Shi");
},
userdogGan(){
this.activeIndex6=(this.activeIndex6?this.activeIndex6:0);
let apiDogSize=this.userdoglist[this.activeIndex6].title;
let apiDogFoodType=this.dogtype[this.quanganCurIndex].title;
this.userstype=1;
let petType={
petType:1,
name:apiDogFoodType,
}
for(let i =0;i<this.userserachlist.length;i++){
if(!this.userserachlist.includes(petType)){
this.userserachlist.push(petType)
}
}
//TODO how to combine "apiName" here?
this.dogmessage(this.userserachlist,"Gan");
},
userlook(order){
if(order==0){
this.catshi=this.catlist;
}
if(order==1){
this.catgan=this.catlist;
}else if(order==2){
this.dogshi=this.doglist
}
@ -1353,10 +1416,7 @@
else if(order==4){
this.processinformation=this.chufanlist
}
},
showmesg(){
this.toTop();
},
@ -1370,11 +1430,13 @@
let scrolltop = document.documentElement.scrollTop || document.body.scrollTop;
if((scrolltop-fixedCatbarSeperator.offsetTop)>0)
{
this.fixedHeader=false;
this.gotop = true
this.searchBar=false
}
else
{
this.fixedHeader=true;
this.gotop = false;
this.searchBar=true
}
@ -1390,13 +1452,16 @@
}, 10);
},
async courseId(item) {
this.dataLoaded=false;
let data = await postCourseId(this.productCode,1,this.usermessage.data.id,this.usermessage.data.mobile,item.picFile,item.name,item.basePrice,item.specifications);
if(data){
this.productlist=data;
this.dataLoaded=true;
}
},
//
async catmessage(stype) {
async catmessage(stype,dataType) {
this.dataLoaded=false;
let data=[];
if(stype==undefined||stype==null){
data = await biaomessage(0,'',1,6);
@ -1404,29 +1469,51 @@
data = await biaomessage(this.userserachlist,'',1,6);
}
if(data){
this.catlist=data;
let userlist=[];
userlist=data.slice(0,6);
this.catshi=userlist;
this.catgan=userlist;
//userlist=data.slice(0,6);
if(dataType)
{
if(dataType=='Shi')
this.catshi=data;
else if(dataType=='Gan')
this.catgan=data;
}
else
{
this.catlist=data;
//this.catgan=userlist;
//this.catshi=userlist;
}
this.dataLoaded=true;
}
},
//
async dogmessage(stype) {
async dogmessage(stype,dataType) {
this.dataLoaded=false;
let data=[];
if(stype==undefined||stype==null){
data = await biaomessage(1);
data = await biaomessage(1,'',1,6);
}else{
data = await biaomessage(this.userserachlist);
data = await biaomessage(this.userserachlist,'',1,6);
}
if(data){
let userlist=[];
userlist=data.slice(0,6);
//userlist=data.slice(0,6);
if(dataType)
{
if(dataType=='Shi')
this.dogshi=data;
else if(dataType=='Gan')
this.doggan=data;
}
else
{
this.doglist=data;
this.doggan=userlist;
this.dogshi=userlist;
//this.doggan=userlist;
//this.dogshi=userlist;
}
this.dataLoaded=true;
}
},
@ -1448,42 +1535,60 @@
//
async userchufang() {
this.dataLoaded=false;
let list=[];
let data = await userque();
if(data){
list=data.slice(0,6);
this.processinformation=list;
this.chufanlist=data;
this.dataLoaded=true;
}
},
//
async userquery(item) {
this.dataLoaded=false;
let data = await userquery(item);
if(data){
this.processinformation=data;
this.dataLoaded=true;
}
},
//
userclick(item,index){
this.userquery(index)
},
//湿
catclick(item,index){
//
catclickGan(){
this.userstype=0;
this.maoganCurIndex=this.maoganCurIndex?this.maoganCurIndex:0;
let apiCatType=this.discoun[this.maoganCurIndex].title;
let petType={
petType:0,
name:index,
name:apiCatType,
}
for(let i =0;i<this.userserachlist.length;i++){
if(!this.userserachlist.includes(petType)){
this.userserachlist.push(petType)
}
}
this.catmessage(this.userserachlist)
this.catmessage(this.userserachlist,'Gan')
},
catclickShi(){
this.userstype=0;
this.maoshiCurIndex=this.maoshiCurIndex?this.maoshiCurIndex:0;
let apiCatType=this.discoun[this.maoshiCurIndex].title;
let petType={
petType:0,
categoryName:"皇家猫湿粮",
name:apiCatType,
}
for(let i =0;i<this.userserachlist.length;i++){
if(!this.userserachlist.includes(petType)){
this.userserachlist.push(petType)
}
}
this.catmessage(this.userserachlist,'Shi')
},
@ -1498,7 +1603,6 @@
if(item.title=='购物车'){
this.$router.push({
path: "/myorder/userrecord",
});
}
if(item.title=='营养专家'){
@ -1514,36 +1618,30 @@
this.courseId(item)
this.$router.push({
path: "/myorder/userrecord",
});
},
selectGoods(item,index){
console.log(item,index);
selectGoods(item,index){
//console.log(item,index);
this.activeIndex=index;
console.log(item.title);
//console.log(item.title);
this.ifadroind(item,index,this.useraindex)
// this.ifAdoid(item,index);
},
quanshi(item,index){
console.log(item,index);
this.activeIndex5=index
console.log(this.activeIndex5);
},
userdoghot(item,index){
this.activeIndex6=index
},
selectGo(item,index){
this.activeInde2=index;
},
selectGoo(item,index){
this.activeInde3=index;
}
// this.ifAdoid(item,index);
},
quanshi(item,index){
this.activeIndex5=index;
this.userdogShi();
},
userdoghot(item,index){
this.activeIndex6=index;
this.userdogGan();
},
selectGo(item,index){
this.activeInde2=index;
},
selectGoo(item,index){
this.activeInde3=index;
}
},