Refactor(首页):优化渲染加载速度
This commit is contained in:
+21
-5
@@ -517,6 +517,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
|
console.clear()
|
||||||
console.time()
|
console.time()
|
||||||
// uni.hideTabBar()
|
// uni.hideTabBar()
|
||||||
const _this = this
|
const _this = this
|
||||||
@@ -553,7 +554,11 @@ export default {
|
|||||||
this.pageToHideHandle()
|
this.pageToHideHandle()
|
||||||
},
|
},
|
||||||
onPageScroll(e) {
|
onPageScroll(e) {
|
||||||
|
if (this.pageScrollTimer) return
|
||||||
|
this.pageScrollTimer = setTimeout(() => {
|
||||||
|
this.pageScrollTimer = null
|
||||||
this.scrollTop = e.scrollTop
|
this.scrollTop = e.scrollTop
|
||||||
|
}, 50)
|
||||||
},
|
},
|
||||||
onShareTimeline() {
|
onShareTimeline() {
|
||||||
uni.updateShareMenu({
|
uni.updateShareMenu({
|
||||||
@@ -636,8 +641,11 @@ export default {
|
|||||||
},
|
},
|
||||||
onscroll(e) {
|
onscroll(e) {
|
||||||
this.scrollViewWidth = e.detail.scrollWidth
|
this.scrollViewWidth = e.detail.scrollWidth
|
||||||
const imgs = []
|
if (this.scrollTimer) return
|
||||||
|
this.scrollTimer = setTimeout(() => {
|
||||||
|
this.scrollTimer = null
|
||||||
this.getElementData(`#${this.scrollView}`, res => {
|
this.getElementData(`#${this.scrollView}`, res => {
|
||||||
|
if (!res) return
|
||||||
this.setFunctionGuideData({
|
this.setFunctionGuideData({
|
||||||
imgs: this.imgs,
|
imgs: this.imgs,
|
||||||
btnGroupPosition: '20rpx',
|
btnGroupPosition: '20rpx',
|
||||||
@@ -650,6 +658,7 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
}, 100)
|
||||||
},
|
},
|
||||||
toEle(id, imgs) {
|
toEle(id, imgs) {
|
||||||
this.getElementData(`#${id}`, res=>{
|
this.getElementData(`#${id}`, res=>{
|
||||||
@@ -739,6 +748,9 @@ export default {
|
|||||||
getHomeData({ cityName: this.cityName }).then(res => {
|
getHomeData({ cityName: this.cityName }).then(res => {
|
||||||
const { success, data } = res
|
const { success, data } = res
|
||||||
if (success && data) {
|
if (success && data) {
|
||||||
|
console.timeEnd()
|
||||||
|
console.log('^^^^^^^^^^^^^^^^接口响应之后开始')
|
||||||
|
console.time()
|
||||||
_this.$set(_this, 'banner', data.banner || [])
|
_this.$set(_this, 'banner', data.banner || [])
|
||||||
_this.$set(_this, 'menus', data.menus || [])
|
_this.$set(_this, 'menus', data.menus || [])
|
||||||
_this.$set(_this, 'landmarkGoodsImage', data.landmarkGoodsImage || {})
|
_this.$set(_this, 'landmarkGoodsImage', data.landmarkGoodsImage || {})
|
||||||
@@ -758,28 +770,32 @@ export default {
|
|||||||
_this.lotteryCanDraw = data.lotteryCanDraw || false
|
_this.lotteryCanDraw = data.lotteryCanDraw || false
|
||||||
_this.initPosterPopupState(data)
|
_this.initPosterPopupState(data)
|
||||||
if (data.bastList) {
|
if (data.bastList) {
|
||||||
|
const newBastLeftList = []
|
||||||
|
const newBastRightList = []
|
||||||
for (let i = 0; i < data.bastList.length; i++) {
|
for (let i = 0; i < data.bastList.length; i++) {
|
||||||
if (i % 2 === 0) {
|
if (i % 2 === 0) {
|
||||||
// 店铺排名
|
// 店铺排名
|
||||||
if (i === 4 && data.hotelList.length > 0) {
|
if (i === 4 && data.hotelList.length > 0) {
|
||||||
_this.bastLeftList.push({
|
newBastLeftList.push({
|
||||||
type: 'hotel',
|
type: 'hotel',
|
||||||
list: data.hotelList
|
list: data.hotelList
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
_this.bastLeftList.push(data.bastList[i])
|
newBastLeftList.push(data.bastList[i])
|
||||||
}
|
}
|
||||||
if (i % 2 === 1) {
|
if (i % 2 === 1) {
|
||||||
// 尖货专题
|
// 尖货专题
|
||||||
if (i === 3 && data.contentBest.length > 0) {
|
if (i === 3 && data.contentBest.length > 0) {
|
||||||
_this.bastRightList.push({
|
newBastRightList.push({
|
||||||
type: 'swiper',
|
type: 'swiper',
|
||||||
list: data.contentBest
|
list: data.contentBest
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
_this.bastRightList.push(data.bastList[i])
|
newBastRightList.push(data.bastList[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_this.$set(_this, 'bastLeftList', newBastLeftList)
|
||||||
|
_this.$set(_this, 'bastRightList', newBastRightList)
|
||||||
}
|
}
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
console.timeEnd()
|
console.timeEnd()
|
||||||
|
|||||||
Reference in New Issue
Block a user