Commit 79be5da3 by 李嘉林

单品优惠问题修改

parent cc98ee00
......@@ -111,14 +111,14 @@ const componentOptions = {
datas: {
type: Object
},
k:{
type:String
k: {
type: String
}
},
// 组件数据
data: {
loaded:false,
isContain:false,
loaded: false,
isContain: false,
isPageHidden: false, // 页面是否处于隐藏状态
timeData: {},
isLoading: true,
......@@ -130,7 +130,8 @@ const componentOptions = {
hours: 0,
minute: 0,
second: 0,
goodsList:[],
goodsList: [],
selectActivityValue:"",
},
// 数据监听器
observers: {},
......@@ -183,6 +184,7 @@ const componentOptions = {
// this.setData({ isLoading: true });
// }, 100);
// }, 100);
this.setData({ isLoading: false });
copyData.goodsItems.forEach((item, index) => {
item.productImgUrl = DFSImg(item.imgUrl);
item.productImgUrl1 = DFSImg(item.imgUrl);
......@@ -193,6 +195,7 @@ const componentOptions = {
goodsList: copyData.goodsItems,
selectActivityValue: copyData.singleItemActivityName
});
console.log(_this.data.selectActivityValue, "--------------197");
}
});
},
......@@ -232,7 +235,10 @@ const componentOptions = {
new Date(item.endTime.replace(/-/g, "/")).getTime() -
new Date().getTime();
item.singleItemActivityCoverImage = DFSImg(
item.singleItemActivityCoverImage,400,400,1
item.singleItemActivityCoverImage,
400,
400,
1
);
item.isStart =
new Date(item.startTime.replace(/-/g, "/")).getTime() >
......@@ -240,9 +246,13 @@ const componentOptions = {
? true
: false;
});
let newList = list.filter((item) => {
return new Date(item.endTime.replace(/-/g, "/")).getTime() - new Date().getTime() > 0;
})
let newList = list.filter(item => {
return (
new Date(item.endTime.replace(/-/g, "/")).getTime() -
new Date().getTime() >
0
);
});
this.setData({ "datas.componentData.actList": newList });
if (hideNum == actList.length) {
this.setData({ hideAll: true });
......@@ -252,23 +262,26 @@ const componentOptions = {
}
});
},
getScroll(){
this.getEleInfo(()=>{
this.getData()
getScroll() {
this.getEleInfo(() => {
this.getData();
});
},
// 获取当前组件位置信息
getEleInfo(cb){
if(this.loaded || this.isContain) return
this.isContain=true;
let {windowHeight} = wx.getSystemInfoSync()
let query=wx.createSelectorQuery().in(this);
query.select('.time-limited-discount').boundingClientRect(rect=>{
if (rect.top<windowHeight && rect.top+rect.height>0) {
cb && cb()
}
this.isContain=false;
}).exec();
getEleInfo(cb) {
if (this.loaded || this.isContain) return;
this.isContain = true;
let { windowHeight } = wx.getSystemInfoSync();
let query = wx.createSelectorQuery().in(this);
query
.select(".time-limited-discount")
.boundingClientRect(rect => {
if (rect.top < windowHeight && rect.top + rect.height > 0) {
cb && cb();
}
this.isContain = false;
})
.exec();
},
onChange(e) {
this.setData({ timeData: e.detail });
......@@ -302,8 +315,8 @@ const componentOptions = {
});
},
getData() {
if(this.loaded) return
this.loaded=true
if (this.loaded) return;
this.loaded = true;
let { dimension } = this.data.datas.componentData;
if (dimension == 0) {
this.init();
......@@ -316,10 +329,10 @@ const componentOptions = {
lifetimes: {
created() {},
ready() {
this.loaded=false;
this.isContain=false;
this.getEleInfo(()=>{
this.getData()
this.loaded = false;
this.isContain = false;
this.getEleInfo(() => {
this.getData();
});
},
moved() {},
......@@ -330,10 +343,10 @@ const componentOptions = {
pageLifetimes: {
// 页面被展示
show() {
this.loaded=false;
this.isContain=false;
this.getEleInfo(()=>{
this.getData()
this.loaded = false;
this.isContain = false;
this.getEleInfo(() => {
this.getData();
});
const { isPageHidden } = this.data;
// show事件发生前,页面不是处于隐藏状态时
......
......@@ -4,7 +4,7 @@
<view class="tops {{datas.componentData['countDownShow']?'hideCountDown':''}}">
<view class="topInfo">
<view class="title">
{{datas.componentData.dimension ==0?datas.componentData.selectActivityValue:datas.componentData.actTitle}}
{{datas.componentData.dimension ==0?selectActivityValue:datas.componentData.actTitle}}
</view>
<view class="subheading" wx:if="{{datas.componentData['countDownShow']&&datas.componentData.dimension==0}}">
<view wx:if="{{datas.componentData['endTime']&&endTime>0}}">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment