Commit 99bac123 by 程智春

Merge branch 'nativehome_tst' of http://code.mayi888.com/chengmo/mayi-mp-shop into nativehome_tst

parents 1fcfbad1 27241d6a
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<cube-nav :datas="item"></cube-nav> <cube-nav :datas="item"></cube-nav>
</div> </div>
<div v-else-if="item.componentCode == 'time-limited-discount' && item.componentInfo.visible == 1"> <div v-else-if="item.componentCode == 'time-limited-discount' && item.componentInfo.visible == 1">
<time-limited-discount :datas="item"></time-limited-discount> <time-limited-discount :class="'time-limited-discount'+index" :datas="item" :k="index"></time-limited-discount>
</div> </div>
<div v-if="item.componentCode == 'links' && item.componentInfo.visible == 1"> <div v-if="item.componentCode == 'links' && item.componentInfo.visible == 1">
<links :datas="item"></links> <links :datas="item"></links>
...@@ -106,6 +106,7 @@ import imgText from '@/components/content/imgText' ...@@ -106,6 +106,7 @@ import imgText from '@/components/content/imgText'
import coupon from '@/components/activity/coupon' import coupon from '@/components/activity/coupon'
import integralTurntable from '@/components/activity/integralTurntable' import integralTurntable from '@/components/activity/integralTurntable'
import { setTabBarActive, checkTabbarPage,themeColor } from "../../utils/mayi.js"; import { setTabBarActive, checkTabbarPage,themeColor } from "../../utils/mayi.js";
import { throttle } from "../../utils/index.js"
const app = getApp(); const app = getApp();
export default { export default {
...@@ -182,17 +183,7 @@ export default { ...@@ -182,17 +183,7 @@ export default {
this.changeLocation = options.changeLocation || '' this.changeLocation = options.changeLocation || ''
if(this.changeLocation == 1){ if(this.changeLocation == 1){
// let extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {};
// console.log(extConfig, "-----------extConfig");
// if (
// process.env.NODE_ENV == "development" ||
// JSON.stringify(extConfig) == "{}"
// ) {
// extConfig = { mixid: "antgood", shopid: 67 };
// }
console.log('this.$store.state.extConfig',this.$store.state.extConfig) console.log('this.$store.state.extConfig',this.$store.state.extConfig)
app.getShopInfo(this.$store.state.extConfig); app.getShopInfo(this.$store.state.extConfig);
app.getThemePage(this.$store.state.extConfig); app.getThemePage(this.$store.state.extConfig);
} }
...@@ -233,10 +224,11 @@ export default { ...@@ -233,10 +224,11 @@ export default {
onShow() { onShow() {
setTabBarActive.bind(this)(checkTabbarPage('/')); setTabBarActive.bind(this)(checkTabbarPage('/'));
this.$mp.page.onPageScroll= (el)=>{ this.$mp.page.onPageScroll= (el)=>{
this.scrolls(el); throttle(this.scrolls(el),100)
}; };
}, },
methods: { methods: {
init(pageList) { init(pageList) {
setTabBarActive.bind(this)(checkTabbarPage('/')); setTabBarActive.bind(this)(checkTabbarPage('/'));
...@@ -252,10 +244,22 @@ export default { ...@@ -252,10 +244,22 @@ export default {
wx.stopPullDownRefresh() wx.stopPullDownRefresh()
}, },
scrolls(el){ scrolls(el){
this.setFooterShow(el); // this.setFooterShow(el);
if(this.$mp.page && this.$mp.page.selectComponent(".goodsListItem")){ if(this.$mp.page && this.$mp.page.selectComponent(".goodsListItem")){
this.$mp.page.selectComponent(".goodsListItem").getScroll(el); this.$mp.page.selectComponent(".goodsListItem").getScroll(el);
} }
if (this.pageData) {
for (let i = 0; i < this.pageData.length; i++) {
const element = this.pageData[i]
if(element.componentCode=="time-limited-discount"){
let com=this.$mp.page.selectComponent(".time-limited-discount"+i) ;
com && com.getScroll(el);
}
}
}
}, },
setFooterShow(el){ setFooterShow(el){
let afterScrollTop = el.scrollTop; let afterScrollTop = el.scrollTop;
......
...@@ -51,7 +51,7 @@ export default { ...@@ -51,7 +51,7 @@ export default {
if (!this.ss && ss) { if (!this.ss && ss) {
this.ss = `&sessionid=${ss}`; this.ss = `&sessionid=${ss}`;
}else if(!ss){ }else if(!ss){
!this.params.includes('logOut=true') && (this.params+="&logOut=true") // !this.params.includes('logOut=true') && (this.params+="&logOut=true")
}else{ }else{
this.params+=`&timestamp=${new Date().getTime()}` this.params+=`&timestamp=${new Date().getTime()}`
} }
......
...@@ -50,7 +50,7 @@ export default { ...@@ -50,7 +50,7 @@ export default {
if (!this.ss && ss) { if (!this.ss && ss) {
this.ss = `&sessionid=${ss}`; this.ss = `&sessionid=${ss}`;
}else if(!ss){ }else if(!ss){
this.params+="&logOut=true" // this.params+="&logOut=true"
}else{ }else{
this.params+=`&timestamp=${new Date().getTime()}` this.params+=`&timestamp=${new Date().getTime()}`
} }
......
...@@ -56,7 +56,7 @@ export default { ...@@ -56,7 +56,7 @@ export default {
if (!this.ss && ss) { if (!this.ss && ss) {
this.ss = `&sessionid=${ss}`; this.ss = `&sessionid=${ss}`;
}else if(!ss){ }else if(!ss){
this.params+="&logOut=true" // this.params+="&logOut=true"
}else{ }else{
this.params+=`&timestamp=${new Date().getTime()}` this.params+=`&timestamp=${new Date().getTime()}`
} }
......
...@@ -56,7 +56,7 @@ export default { ...@@ -56,7 +56,7 @@ export default {
if (!this.ss && ss) { if (!this.ss && ss) {
this.ss = `&sessionid=${ss}`; this.ss = `&sessionid=${ss}`;
}else if(!ss){ }else if(!ss){
this.params+="&logOut=true" // this.params+="&logOut=true"
}else{ }else{
this.params+=`&timestamp=${new Date().getTime()}` this.params+=`&timestamp=${new Date().getTime()}`
} }
......
...@@ -2,6 +2,29 @@ function formatNumber(n) { ...@@ -2,6 +2,29 @@ function formatNumber(n) {
const str = n.toString() const str = n.toString()
return str[1] ? str : `0${str}` return str[1] ? str : `0${str}`
} }
// 防抖
export function debounce(fn, wait) {
var timeout = null;
return function() {
if (timeout !== null)
clearTimeout(timeout);
timeout = setTimeout(fn, wait);
}
}
// 节流
export function throttle(func, delay) {
var prev = Date.now();
return function() {
var context = this;
var args = arguments;
var now = Date.now();
if (now - prev >= delay) {
func.apply(context, args);
prev = Date.now();
}
}
}
//格式时间 //格式时间
export function formatTime(date) { export function formatTime(date) {
......
...@@ -29,7 +29,7 @@ export function $themeToLink(data, option) { ...@@ -29,7 +29,7 @@ export function $themeToLink(data, option) {
let type = data.type; let type = data.type;
// 点击底部栏-- // 点击底部栏--
// if (option) { if (type!=2) {
// 登录拦截 // 登录拦截
let parseLink = getUrlofLink(data); let parseLink = getUrlofLink(data);
let aa=noLoginListPath.includes(parseLink) || parseLink.substr(0,7)=="/goods/" let aa=noLoginListPath.includes(parseLink) || parseLink.substr(0,7)=="/goods/"
...@@ -52,7 +52,7 @@ export function $themeToLink(data, option) { ...@@ -52,7 +52,7 @@ export function $themeToLink(data, option) {
} }
// console.log(option, data,'---',parseLink == '/' ? '/pages/home/main' : `/pages/tabBar${isTabbarIndex}/main`) // console.log(option, data,'---',parseLink == '/' ? '/pages/home/main' : `/pages/tabBar${isTabbarIndex}/main`)
// return // return
// } }
// 历史数据 // 历史数据
......
...@@ -39,6 +39,7 @@ xcsoft.countdown = function(a, b, c) { ...@@ -39,6 +39,7 @@ xcsoft.countdown = function(a, b, c) {
d.minute = 0; d.minute = 0;
d.second = 0; d.second = 0;
d.t = setInterval(function() { d.t = setInterval(function() {
console.log('倒计时')
e = new Date().getTime(); e = new Date().getTime();
f = parseInt(e / 1000 + x); f = parseInt(e / 1000 + x);
var l = d.time - f; var l = d.time - f;
...@@ -109,10 +110,15 @@ const componentOptions = { ...@@ -109,10 +110,15 @@ const componentOptions = {
properties: { properties: {
datas: { datas: {
type: Object type: Object
},
k:{
type:String
} }
}, },
// 组件数据 // 组件数据
data: { data: {
loaded:false,
isContain:false,
isPageHidden: false, // 页面是否处于隐藏状态 isPageHidden: false, // 页面是否处于隐藏状态
timeData: {}, timeData: {},
isLoading: true, isLoading: true,
...@@ -243,6 +249,24 @@ const componentOptions = { ...@@ -243,6 +249,24 @@ const componentOptions = {
} }
}); });
}, },
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();
},
onChange(e) { onChange(e) {
this.setData({ timeData: e.detail }); this.setData({ timeData: e.detail });
}, },
...@@ -275,6 +299,8 @@ const componentOptions = { ...@@ -275,6 +299,8 @@ const componentOptions = {
}); });
}, },
getData() { getData() {
if(this.loaded) return
this.loaded=true
let { dimension } = this.data.datas.componentData; let { dimension } = this.data.datas.componentData;
if (dimension == 0) { if (dimension == 0) {
this.init(); this.init();
...@@ -287,7 +313,11 @@ const componentOptions = { ...@@ -287,7 +313,11 @@ const componentOptions = {
lifetimes: { lifetimes: {
created() {}, created() {},
ready() { ready() {
this.getData(); this.loaded=false;
this.isContain=false;
this.getEleInfo(()=>{
this.getData()
});
}, },
moved() {}, moved() {},
detached() {} detached() {}
...@@ -297,7 +327,11 @@ const componentOptions = { ...@@ -297,7 +327,11 @@ const componentOptions = {
pageLifetimes: { pageLifetimes: {
// 页面被展示 // 页面被展示
show() { show() {
this.getData(); this.loaded=false;
this.isContain=false;
this.getEleInfo(()=>{
this.getData()
});
const { isPageHidden } = this.data; const { isPageHidden } = this.data;
// show事件发生前,页面不是处于隐藏状态时 // show事件发生前,页面不是处于隐藏状态时
if (!isPageHidden) { if (!isPageHidden) {
......
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