Fix:【商城小程序】商品足迹—点击顶部日期切换数据无响应
This commit is contained in:
@@ -1,13 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<view>
|
<view class="v12-pb-10">
|
||||||
<view class="v12-justify-around v12-pa-2 v12-white">
|
<view class="v12-justify-around v12-pa-2 v12-white data-nav">
|
||||||
<view
|
<view
|
||||||
v-for="(day, i) in currentWeek"
|
v-for="(day, i) in currentWeek"
|
||||||
:key="i"
|
:key="i"
|
||||||
class="v12-font-26"
|
class="v12-font-26"
|
||||||
>
|
>
|
||||||
<view style="color:#BCBCBC" class="day-wrap">{{ getDate(day) }}</view>
|
<view style="color:#BCBCBC" class="day-wrap">{{ getDate(day) }}</view>
|
||||||
<view class="v12-dark-text day-wrap" :class="{'active': actived === i}">{{ getDay(day) }}</view>
|
<view class="v12-dark-text day-wrap" :class="{'active': actived === i, 'disabled': disabled(day)}" @click="handle(day, i)">{{ getDay(day) }}</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view v-if="isLoad" class="history-wrap">
|
<view v-if="isLoad" class="history-wrap">
|
||||||
@@ -15,8 +15,10 @@
|
|||||||
v-for="(item, index) in items"
|
v-for="(item, index) in items"
|
||||||
:key="index"
|
:key="index"
|
||||||
class="v12-mt-3"
|
class="v12-mt-3"
|
||||||
|
:id="`history-${item.historyDate}`"
|
||||||
>
|
>
|
||||||
<view>
|
<view class="" style="height: 56px; width: 100%" v-if="isSrcoll"></view>
|
||||||
|
<view >
|
||||||
<text class="v12-font-bold v12-font-32">{{ item.historyDate }}</text>
|
<text class="v12-font-bold v12-font-32">{{ item.historyDate }}</text>
|
||||||
<view class="wrapper">
|
<view class="wrapper">
|
||||||
<view
|
<view
|
||||||
@@ -83,17 +85,28 @@ export default {
|
|||||||
actived: 0,
|
actived: 0,
|
||||||
webUrl: this.$VUE_APP_RESOURCES_URL,
|
webUrl: this.$VUE_APP_RESOURCES_URL,
|
||||||
isLoad: false,
|
isLoad: false,
|
||||||
items: []
|
items: [],
|
||||||
|
isSrcoll: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
this.queryHistory()
|
this.queryHistory()
|
||||||
},
|
},
|
||||||
mounted() {
|
onShow() {
|
||||||
|
this.$nextTick(() => {
|
||||||
this.currentWeek = this.getWeek()
|
this.currentWeek = this.getWeek()
|
||||||
this.actived = this.getActived()
|
this.actived = this.getActived()
|
||||||
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
disabled(day) {
|
||||||
|
const dayItems = this.items.filter(item => {
|
||||||
|
return item.historyDate === day
|
||||||
|
}).map(e => {
|
||||||
|
return e.histories
|
||||||
|
}).flat()
|
||||||
|
return dayItems.length === 0
|
||||||
|
},
|
||||||
getActived() {
|
getActived() {
|
||||||
const weekMap = this.currentWeek.map(e => new Date(e).getDay())
|
const weekMap = this.currentWeek.map(e => new Date(e).getDay())
|
||||||
const today = new Date().getDay()
|
const today = new Date().getDay()
|
||||||
@@ -137,8 +150,20 @@ export default {
|
|||||||
return dateMap[d]
|
return dateMap[d]
|
||||||
},
|
},
|
||||||
handle(day, i) {
|
handle(day, i) {
|
||||||
|
if(this.disabled(day)) return
|
||||||
this.actived = i
|
this.actived = i
|
||||||
|
this.isSrcoll = true
|
||||||
|
uni.pageScrollTo({
|
||||||
|
selector:`#history-${day}`,
|
||||||
|
duration:200,
|
||||||
|
success:(success)=>{
|
||||||
|
this.isSrcoll = false
|
||||||
|
},
|
||||||
|
})
|
||||||
|
},
|
||||||
|
formatStr(str) {
|
||||||
|
const regx = /-/g
|
||||||
|
return str.replace(regx, '')
|
||||||
},
|
},
|
||||||
goodsDetail (item) {
|
goodsDetail (item) {
|
||||||
this.$yrouter.push({
|
this.$yrouter.push({
|
||||||
@@ -154,13 +179,14 @@ export default {
|
|||||||
getHistory().then(res => {
|
getHistory().then(res => {
|
||||||
const { data = [] } = res
|
const { data = [] } = res
|
||||||
if (data.length > 0) {
|
if (data.length > 0) {
|
||||||
data.map(item => {
|
this.items = data.filter(e => e.histories && e.histories.length > 0).reverse()
|
||||||
if (item.histories) {
|
// data.map(item => {
|
||||||
if (item.histories.length > 0) {
|
// if (item.histories) {
|
||||||
this.items.push(item)
|
// if (item.histories.length > 0) {
|
||||||
}
|
// this.items.push(item)
|
||||||
}
|
// }
|
||||||
})
|
// }
|
||||||
|
// })
|
||||||
}
|
}
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
this.isLoad = true
|
this.isLoad = true
|
||||||
@@ -172,6 +198,15 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
|
.data-nav{
|
||||||
|
position: sticky;
|
||||||
|
width: 100%;
|
||||||
|
top: 0;
|
||||||
|
z-index: 9;
|
||||||
|
}
|
||||||
|
.disabled{
|
||||||
|
color: #CBCBCB !important;
|
||||||
|
}
|
||||||
.history-wrap {
|
.history-wrap {
|
||||||
padding: 0 20rpx;
|
padding: 0 20rpx;
|
||||||
.img-nodata {
|
.img-nodata {
|
||||||
|
|||||||
Reference in New Issue
Block a user