|
@@ -8,16 +8,16 @@
|
|
|
</view>
|
|
|
|
|
|
<view class="type-wrap">
|
|
|
- <up-scroll-list :indicator="typeList.length>5" indicatorColor="#FF770033" indicatorActiveColor="#FF7700" :indicatorWidth="30"
|
|
|
+ <up-scroll-list :indicator="typeList && typeList.length>5" indicatorColor="#FF770033" indicatorActiveColor="#FF7700" :indicatorWidth="30"
|
|
|
:indicatorBarWidth="15">
|
|
|
- <view class="item-type" :class="{'active': activeType === 0}" @click="handleSelectType(null, 0)">
|
|
|
+ <view class="item-type" :class="{'active': activeType === 0}" @click="handleSelectType(0)">
|
|
|
<image class="type-img" :src="`${config.BASIC_IMG}home/type-icon.png`" alt="" />
|
|
|
<view class="type-text">
|
|
|
全部
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="item-type" v-for="(item, index) in typeList"
|
|
|
- :class="{'active': activeType === index+1}" :key="index" @click="handleSelectType(item.id, index+1)">
|
|
|
+ :class="{'active': activeType === item.id}" :key="index" @click="handleSelectType(item.id)">
|
|
|
<image class="type-img" :src="item.image" alt="" />
|
|
|
<view class="type-text">
|
|
|
{{item.name}}
|
|
@@ -77,6 +77,10 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
+
|
|
|
+ <view class="no-data" v-if="!discoverData||!discoverData.length">
|
|
|
+ 暂未上架商品,请耐心等候
|
|
|
+ </view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</template>
|
|
@@ -88,6 +92,7 @@
|
|
|
} from "vue";
|
|
|
import config from "@/api/config.js"
|
|
|
import HOME from "@/api/home.js"
|
|
|
+ import { onShow } from "@dcloudio/uni-app"
|
|
|
|
|
|
const typeSearch = ref(null)
|
|
|
|
|
@@ -111,8 +116,18 @@
|
|
|
orderType.value = !orderType.value
|
|
|
getGoodsList()
|
|
|
}
|
|
|
+
|
|
|
+ onShow(() => {
|
|
|
+ const selectedType = uni.getStorageSync('selectedCategoryType');
|
|
|
+ if (selectedType) {
|
|
|
+ activeType.value = selectedType
|
|
|
+ uni.setStorageSync('selectedCategoryType', 0);
|
|
|
+ handleSelectType(selectedType||0)
|
|
|
+ }
|
|
|
+ })
|
|
|
|
|
|
onMounted(() => {
|
|
|
+ console.log('onMounted')
|
|
|
getTypeList()
|
|
|
getGoodsList()
|
|
|
})
|
|
@@ -124,7 +139,7 @@
|
|
|
HOME.fetchTypeList().then(({
|
|
|
data
|
|
|
}) => {
|
|
|
- typeList.value = [...data, ...data]
|
|
|
+ typeList.value = data
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -140,12 +155,12 @@
|
|
|
HOME.fetchGoodsList(params).then(({
|
|
|
data
|
|
|
}) => {
|
|
|
- discoverData.value = [...data, ...data]
|
|
|
+ discoverData.value = data
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- function handleSelectType(id, index) {
|
|
|
- activeType.value = index
|
|
|
+ function handleSelectType(id) {
|
|
|
+ activeType.value = id
|
|
|
let params = {}
|
|
|
if (id) {
|
|
|
params = {
|
|
@@ -216,10 +231,10 @@
|
|
|
}
|
|
|
|
|
|
.type-wrap {
|
|
|
- padding: 0 20rpx 20rpx;
|
|
|
+ padding: 0 20rpx 0 20rpx;
|
|
|
background-color: #fff;
|
|
|
border-radius: 16rpx;
|
|
|
- height: 200rpx;
|
|
|
+ height: 186rpx;
|
|
|
box-sizing: border-box;
|
|
|
|
|
|
// 覆盖 up-scroll-list 的默认样式,实现两端对齐
|
|
@@ -230,6 +245,11 @@
|
|
|
width: 100%;
|
|
|
min-width: 100%;
|
|
|
}
|
|
|
+ ::v-deep {
|
|
|
+ .u-scroll-list__indicator {
|
|
|
+ margin-top: 16rpx;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
.item-type {
|
|
|
text-align: center;
|
|
@@ -262,11 +282,16 @@
|
|
|
|
|
|
.discover-content {
|
|
|
padding: 0rpx 24rpx 24rpx;
|
|
|
- height: calc(100% - 352rpx);
|
|
|
+ height: calc(100% - 320rpx);
|
|
|
overflow: auto;
|
|
|
background: #F2F3F5;
|
|
|
box-sizing: border-box;
|
|
|
|
|
|
+ .no-data {
|
|
|
+ text-align: center;
|
|
|
+ color: rgba(0, 0, 0, 0.6);
|
|
|
+ font-size: 28rpx;
|
|
|
+ }
|
|
|
.discover-filter {
|
|
|
color: #A6A6A6;
|
|
|
font-size: 28rpx;
|