流加载下拉分页以及移动端隐藏域复制功能(copyCode)
<template>
<div class="hello">
<div class="container">
<div class="mv-banner-comp" id="header-box"></div>
<!-- 复制用 -->
<input type="hidden" value="http://www.baidu.com" class="copyInput"/>
<span id="copy"></span>
<!-- v-loading="isLoading"style="height:4.1rem;" -->
<div class="cellex-boom-1v1-common-use-toc-wrap bk-1-column bk-column-1 J-bk-item JBKS_1-0-1"
id="list-box">
<div class="boom-item-box_container J_BK_click" v-for="(item,index) in mainDatas" :key="index">
<div class="boom-item-prod_wrap">
<div class="boom-item-hd"></div><span class="boom-item-bd boom-item-bd-two-line">{{item.title}}</span>
<div class="boom-item-main">
<div class="boom-item-group">
<div class="boom-item-market-block">
<div class="boom-item-wk_container">
<div class="boom-item-wk_outer"><span class="boom-item-wk_wrap">
<span class="boom-item-wk_wrap-circle"></span>券</span><span class="boom-item-wk_yuan">{{item.zk_final_price}}元</span></div>
</div>
<div class="boom-item-benifit-wrap"></div>
</div>
<div class="boom-item-outer"><span class="boom-item-dj_txt">券后价</span><span class="boom-item-dj_unit">¥</span><span class="boom-item-dj_yuan"
>{{item.reserve_price}}</span><span class="boom-item-xj_yuan">668</span></div>
</div>
</div>
<div class="boom-item-submain"><span class="boom-item-info_content">热销 {{item.coupon_remain_count}} 件</span></div>
<div class="boom-item-itemWrap"
style="top:-.3rem;box-shadow:6px 0px 5px -5px #9b9b9b, -6px 0px 5px -5px #9b9b9b;border:none;height:2.65rem;">
<div class="boom-item-rank1"><img class="boom-item-img"
src="https://gw.alicdn.com/tfs/TB1jC9TgVP7gK0jSZFjXXc5aXXa-63-72.png">
<div class="boom-item-icon"><span class="boom-item-num1">{{index+1}}</span></div>
</div> <img class="boom-item-item img-loaded"
:src="item.pict_url">
</div>
</div>
<div class="boom-item-row">
<div class="boom-item-color"></div>
</div>
<div class="boom-item-ft">
<div class="boom-item-ft-left"></div>
<div class="boom-item-priceWrap boom-item-snatch-coupon"
><span class="boom-item-share_unit" @click="copyCode(item.CopyString)">复制打开淘宝</span></div>
</div>
</div>
<span style="color:#fff;text-align:center;display:block;">{{tips}}</span>
</div>
</div>
</div>
</template>
<script>
import {getDataApi} from '@/api/api.js'
export default {
name: "HelloWorld",
data() {
return {
msg: "Welcome to Your Vue.js App",
// 分页所需要的参数流加载
returnTop: false,
below: false,
PageIndex: 1,
pageSize: 20,
mainDatas:[],
pageStatus:true,
tips:''
};
},
mounted(){
this.getData()
// 滚动页面时触发
this.$nextTick(()=>{
window.addEventListener("scroll", this.scrollBottom);
})
},
methods:{
// 分页响应
scrollBottom(){
//当前页面是否存在id = list-box
const element = document.getElementById("list-box");
//当前页面不否存在id =list-box或没有下一页时结束
if (element == null || !this.pageStatus) {
return false;
}
//浮动框变化的高度
const height1 =
document.documentElement.scrollTop || document.body.scrollTop;
//屏幕的高度
const height2 =
document.documentElement.clientHeight || document.body.clientHeight;
//id=list-box的高度(列表信息放在这个标签里)
const height3 =
document.getElementById("list-box").scrollHeight ||
document.documentElement.clientHeight ||
document.body.clientHeight;
//id=header-box的高度(列表信息外的其他高度)
const height4 = document.getElementById("header-box").scrollHeight || 100;
console.log(height1)
if (height1 + height2 > height3 + height4 && this.pageSum > 0) {
// 请求的数据未加载完成时,滚动到底部不再请求前一天的数据
this.loading = true;
let pageNumber = this.pageSum;
if (this.pageSum != 0) {
pageNumber = pageNumber + 1;
}
if (this.PageIndex < pageNumber) {
this.PageIndex += 1;
this.pageStatus = false;
} else {
this.tips = "没有数据可加载了";
this.pageStatus = false;
return false;
}
this.tips = "数据正在加载中...";
this.PageIndex++;
getDataApi.alldatas({
type: 4040,
PageIndex: this.PageIndex,
PageSize: this.pageSize
}).then((response) => {
const newList = response.AlibabaGoodsList;
for (var i = 0; i < newList.length; i++) {
this.mainDatas.push(newList[i]);
}
// 请求的数据执行完成后
this.$nextTick(() => {
this.loading = false;
this.pageStatus = true;
});
});
}
},
// 获取数据
getData() {
this.isLoading = true;
getDataApi.alldatas({
type: 4040,
PageIndex: this.PageIndex,
PageSize: this.pageSize
}).then((response) => {
if (response.AlibabaGoodsList.length > 0) {
this.pageSum = response.TotalCount/this.pageSize;
this.mainDatas=response.AlibabaGoodsList
if (this.pageSum == 0) {
this.pageStatus = false;
} else {
this.pageStatus = true;
}
}
});
},
// 复制隐藏域功能
copyCode(text){
try {
//追加内容
var copyURL ="<textarea class='url'>"+text+"</textarea>";
//追加
document.getElementById("copy").insertAdjacentHTML('afterbegin', copyURL);
// document.getElementsByClassName("copy")(copyURL);
//选中【复制内容】
document.getElementsByClassName("url")[0].select();
//window.document.execCommand【不能复制隐藏域】
window.document.execCommand("Copy");
let tmpcopy=document.getElementById("copy")
tmpcopy.removeChild(tmpcopy.childNodes[0]);
alert("复制成功");
}
catch (e) {
alert("系统繁忙!请刷新页面重试!");
//打印错误信息
console.log(e);
}
}
}
};
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.container {
position: relative;
margin: 0 auto;
width: 7.5rem;
overflow: hidden;
font-size: 0.31rem;
}
.boom-item-itemWrap {
position: absolute;
top: 0.16rem;
left: 0.3rem;
border-radius: 0.06rem;
background-color: #fff;
width: 2.5rem;
height: 2.5rem;
overflow: hidden;
}
.boom-item-rank1 {
display: -webkit-box;
display: -webkit-flex;
display: flex;
position: absolute;
top: 0;
left: 0.1rem;
-webkit-box-align: start;
-webkit-align-items: flex-start;
align-items: flex-start;
-webkit-box-pack: center;
-webkit-justify-content: center;
justify-content: center;
width: 0.62rem;
height: 0.48rem;
overflow: hidden;
}
img {
border-style: none;
width: auto;
height: auto;
max-width: 100%;
vertical-align: top;
-ms-interpolation-mode: bicubic;
}
a img {
border: 0;
}
.boom-item-item {
opacity: 1;
width: 2.4rem;
height: 2.4rem;
}
.boom-item-row {
display: -webkit-box;
display: -webkit-flex;
display: flex;
-webkit-box-pack: center;
-webkit-justify-content: center;
justify-content: center;
margin-top: 0.16rem;
width: 7.02rem;
}
.boom-item-color {
background-color: #f6f6f6;
width: 6.5rem;
height: 0.02rem;
}
.boom-item-ft {
-webkit-box-sizing: border-box;
box-sizing: border-box;
display: -webkit-box;
display: -webkit-flex;
display: flex;
-webkit-box-align: center;
-webkit-align-items: center;
align-items: center;
-webkit-box-pack: justify;
-webkit-justify-content: space-between;
justify-content: space-between;
margin-top: 0.09rem;
padding-left: 0.26rem;
width: 7.02rem;
height: 0.62rem;
}
.boom-item-priceWrap,
.boom-item-wk_yuan {
display: -webkit-box;
display: -webkit-flex;
display: flex;
-webkit-box-align: center;
-webkit-align-items: center;
align-items: center;
-webkit-box-pack: center;
-webkit-justify-content: center;
justify-content: center;
}
.boom-item-priceWrap {
border-top-left-radius: 0.31rem;
border-bottom-left-radius: 0.31rem;
background-color: #ff0036;
padding: 0 0.3rem;
height: 0.62rem;
text-align: center;
}
.boom-item-snatch-coupon {
width: 2.2rem;
padding: 0 0.1rem;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.boom-item-box_container {
outline: none;
cursor: pointer;
width: 7.02rem;
height: 3.8rem;
-webkit-box-shadow: 0 0 8px rgba(0, 0, 0, 0.13);
box-shadow: 0 0 8px rgba(0, 0, 0, 0.13);
margin-top:.5rem
}
.boom-item-box_container,
.boom-item-prod_wrap {
display: -webkit-box;
display: -webkit-flex;
display: flex;
position: relative;
-webkit-box-align: start;
-webkit-align-items: flex-start;
align-items: flex-start;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-webkit-flex-direction: column;
flex-direction: column;
background-color: #fff;
border-radius: 0.12rem;
}
.bk-1-column {
margin: auto;
margin-top: 0.18rem;
}
.bk-1-column:nth-child(-n + 1) {
margin-top: 0;
}
.cellex-boom-1v1-common-use-toc-wrap {
width: 7.02rem;
display: -webkit-box;
display: -webkit-flex;
display: flex;
position: relative;
-webkit-box-align: center;
-webkit-align-items: center;
align-items: center;
-webkit-box-pack: end;
-webkit-justify-content: flex-end;
justify-content: flex-end;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-webkit-flex-direction: column;
flex-direction: column;
margin-bottom: 0.18rem;
}
.boom-item-bd.boom-item-bd-two-line {
-webkit-line-clamp: 2;
}
.boom-item-bd {
display: inline-block;
position: relative;
margin-top: .08rem;
width: 3.61rem;
line-height: .37rem;
white-space: pre-wrap;
color: #434343;
font-size: .26rem;
text-overflow: ellipsis;
overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
}
.boom-item-main {
display: -webkit-box;
display: -webkit-flex;
display: flex;
position: relative;
-webkit-box-pack: end;
-webkit-justify-content: flex-end;
justify-content: flex-end;
margin-top: .07rem;
height: 1.03rem;
left: -.21rem;
}
.boom-item-submain {
display: -webkit-box;
display: -webkit-flex;
display: flex;
position: relative;
margin-top: .1rem;
-webkit-box-pack: center;
-webkit-justify-content: center;
justify-content: center;
-webkit-box-align: center;
-webkit-align-items: center;
align-items: center;
color: #4a4a4a;
font-size: .24rem;
line-height: .32rem;
white-space: pre;
height: .32rem;
}
.boom-item-hd {
display: -webkit-box;
display: -webkit-flex;
display: flex;
position: relative;
margin-top: .18rem;
height: .24rem;
}
.boom-item-prod_wrap {
width: 100%;
padding-left: 3.01rem;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.boom-item-box_container,.boom-item-prod_wrap {
display: -webkit-box;
display: -webkit-flex;
display: flex;
position: relative;
-webkit-box-align: start;
-webkit-align-items: flex-start;
align-items: flex-start;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-webkit-flex-direction: column;
flex-direction: column;
background-color: #fff;
border-radius: .12rem;
}
.boom-item-img {
position: absolute;
top: 0;
left: 0;
width: .62rem;
height: .5rem;
overflow: hidden;
}
.boom-item-icon {
display: -webkit-box;
display: -webkit-flex;
display: flex;
position: relative;
-webkit-box-align: start;
-webkit-align-items: flex-start;
align-items: flex-start;
-webkit-box-pack: center;
-webkit-justify-content: center;
justify-content: center;
width: .29rem;
height: .48rem;
}
.boom-item-num1 {
position: absolute;
top: .04rem;
/* left: .04rem; */
text-shadow: 0 0 4px #d0021b;
line-height: .43rem;
white-space: nowrap;
color: #fff;
font-size: .36rem;
font-weight: 700;
text-align: center;
}
.boom-item-group {
display: -webkit-box;
display: -webkit-flex;
display: flex;
-webkit-box-align: start;
-webkit-align-items: flex-start;
align-items: flex-start;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-webkit-flex-direction: column;
flex-direction: column;
border-radius: .04rem;
background-image: -webkit-gradient(linear,right top,left top,from(#fff),to(#ffe9f0));
background-image: -webkit-linear-gradient(right,#fff,#ffe9f0);
background-image: linear-gradient(270deg,#fff,#ffe9f0);
width: 4.22rem;
height: 1.03rem;
padding-left: .18rem;
padding-top: .16rem;
padding-bottom: .16rem;
-webkit-box-sizing: border-box;
box-sizing: border-box;
-webkit-box-pack: justify;
-webkit-justify-content: space-between;
justify-content: space-between;
}
.boom-item-market-block {
display: -webkit-box;
display: -webkit-flex;
display: flex;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
-webkit-flex-direction: row;
flex-direction: row;
-webkit-box-pack: center;
-webkit-justify-content: center;
justify-content: center;
-webkit-box-align: center;
-webkit-align-items: center;
align-items: center;
}
.boom-item-wk_container {
display: -webkit-box;
display: -webkit-flex;
display: flex;
-webkit-box-align: center;
-webkit-align-items: center;
align-items: center;
-webkit-box-pack: start;
-webkit-justify-content: flex-start;
justify-content: flex-start;
height: .32rem;
margin-right: .13rem;
}
.boom-item-wk_outer {
-webkit-box-sizing: border-box;
box-sizing: border-box;
display: -webkit-box;
display: -webkit-flex;
display: flex;
-webkit-box-align: start;
-webkit-align-items: flex-start;
align-items: flex-start;
background-color: #fff;
height: .32rem;
overflow: hidden;
border-radius: .04rem;
border: 1px solid #f63341;
}
.cellex-boom-1v1-common-use-toc-wrap .boom-item-wk_wrap {
display: -webkit-box;
display: -webkit-flex;
display: flex;
position: relative;
-webkit-box-align: center;
-webkit-align-items: center;
align-items: center;
-webkit-box-pack: center;
-webkit-justify-content: center;
justify-content: center;
width: .37rem;
height: .3rem;
color: #fff;
font-size: .24rem;
line-height: .32rem;
background: #f63341;
}
.boom-item-priceWrap, .boom-item-wk_yuan {
display: -webkit-box;
display: -webkit-flex;
display: flex;
-webkit-box-align: center;
-webkit-align-items: center;
align-items: center;
-webkit-box-pack: center;
-webkit-justify-content: center;
justify-content: center;
}
.boom-item-wk_yuan {
padding: 0 .1rem;
height: .3rem;
-webkit-box-sizing: border-box;
box-sizing: border-box;
line-height: .24rem;
white-space: nowrap;
color: #f63341;
font-size: .24rem;
font-weight: 600;
}
.boom-item-wk_wrap-circle {
display: inline-block;
height: .08rem;
width: .04rem;
background: #fff;
border-radius: .04rem 0 0 .04rem;
position: absolute;
right: 0;
top: .11rem;
}
.boom-item-benifit-wrap {
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
-webkit-flex-direction: row;
flex-direction: row;
height: .32rem;
}
.boom-item-benifit-wrap,.boom-item-itemWrap {
display: -webkit-box;
display: -webkit-flex;
display: flex;
-webkit-box-align: center;
-webkit-align-items: center;
align-items: center;
-webkit-box-pack: center;
-webkit-justify-content: center;
justify-content: center;
}
.boom-item-dj_txt {
line-height: .24rem;
white-space: nowrap;
color: #ff0036;
font-size: .24rem;
font-weight: 400;
}
.boom-item-dj_unit {
line-height: .24rem;
white-space: nowrap;
color: #ff0036;
font-size: .24rem;
font-weight: 600;
margin: 0 .05rem 0 .1rem;
}
.boom-item-dj_yuan {
line-height: .24rem;
letter-spacing: 0;
white-space: nowrap;
color: #ff0036;
font-size: .24rem;
font-weight: 600;
}
.boom-item-xj_yuan {
font-size: .24rem;
line-height: .24rem;
color: #9b9b9b;
text-decoration: line-through;
margin-left: .1rem;
}
.boom-item-info_content {
white-space: nowrap;
position: relative;
overflow: hidden;
text-overflow: ellipsis;
max-width: 3.5rem;
}
.boom-item-color {
background-color: #f6f6f6;
width: 6.5rem;
height: .02rem;
}
.boom-item-snatch-coupon {
width: 2.2rem;
padding: 0 .1rem;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.boom-item-priceWrap {
border-top-left-radius: .31rem;
border-bottom-left-radius: .31rem;
background-color: #ff0036;
padding: 0 .3rem;
height: .62rem;
text-align: center;
}
.boom-item-priceWrap,.boom-item-wk_yuan {
display: -webkit-box;
display: -webkit-flex;
display: flex;
-webkit-box-align: center;
-webkit-align-items: center;
align-items: center;
-webkit-box-pack: center;
-webkit-justify-content: center;
justify-content: center;
}
.boom-item-share_unit {
line-height: .4rem;
white-space: pre;
color: #fff;
font-size: .28rem;
font-weight: 600;
}
.mv-banner-comp {
position: relative;
width: 7.5rem;
margin: 0 auto .24rem;
background: no-repeat 50% 0;
background-size: 100% auto;
margin-bottom: 0.24rem;
height: 2.92rem;
background-image: url('../assets/TB1qj.JHFY7gK0jSZKzXXaikpXa-750-292.jpg_q75.jpg');
}
</style>