Files
frontend-app/pages/supply_chain/supply_chain.vue
T
2026-08-17 11:32:40 +08:00

442 lines
12 KiB
Vue

<template>
<view class="content-two">
<view class="top-header-container">
<TopSafe></TopSafe>
<view class="head-view">
<view class="head-search" @click="onJumpSearch">
<u-icon size="24" name="search" color="#999"></u-icon>
<text class="text-28 text-fu" style="margin-left: 12rpx">搜索</text>
</view>
</view>
<view class="tab-box">
<view class="tab-item" v-for="(item, index) in tabArr" :key="item.id" @click="onTab(item.id)">
<image :src="curTab == item.id ? item.iconActive : item.icon" mode="aspectFill" class="tab-img">
</image>
<view class="tab-name" :style="{
color: curTab == item.id ? getTabColor(item) : '#999',
fontWeight: curTab == item.id ? 'bold' : 'normal'
}">{{ item.name }}</view>
</view>
</view>
</view>
<mescroll-uni ref="mescrollRef" :top="mescrollTop" :bottom="mescrollBottom" :safearea="isApp" @down="downCallback"
@up="upCallback" :up="upOption" :down="downOption" @init="mescrollInit">
<view class="setting-view">
<view class="name-box">
<!-- 传1: 图2单列展示 / 传2: 图1双列瀑布流 -->
<view class="single-col" v-if="itemType == 1">
<ParityProductItem v-for="(item, i) in dataList" :key="item.id" :obj="item" :type="itemType"
:tag-name="curTabName" :tag-color="curTabColor" @ok="onJumpShop" style="margin-top: 24rpx" />
</view>
<view class="mescrollUniView" v-else>
<view class="fall-col">
<ParityProductItem v-for="(item, i) in leftList" :key="item.id" :obj="item" :type="itemType"
:tag-name="curTabName" :tag-color="curTabColor" @ok="onJumpShop" style="margin-top: 24rpx" />
</view>
<view class="fall-col">
<ParityProductItem v-for="(item, i) in rightList" :key="item.id" :obj="item" :type="itemType"
:tag-name="curTabName" :tag-color="curTabColor" @ok="onJumpShop" style="margin-top: 24rpx" />
</view>
</view>
</view>
</view>
</mescroll-uni>
<!-- #ifndef H5 || MP-WEIXIN-->
<CustomTabBar :tabIndex="2" />
<!-- #endif -->
<up-toast ref="uToastRef"></up-toast>
<qiaobao-assistant page-key="pages/supply_chain/supply_chain" title="平价专区" />
</view>
</template>
<script>
import Header from "@/components/common/header.vue";
import TopSafe from "@/components/common/top-safe.nvue";
import MyBtn from "@/components/common/my-btn.vue";
import ParityProductItem from "@/components/shop/parity-product-item.vue";
import { searchList, getGoodsTags } from "@/api/product.js";
import CustomTabBar from "@/components/custom-tab-bar.vue";
import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
import MescrollUni from "@/components/mescroll-uni/mescroll-uni.vue";
export default {
mixins: [MescrollMixin],
components: { Header, TopSafe, MyBtn, ParityProductItem, CustomTabBar, MescrollUni },
computed: {
curTabItem() {
return this.tabArr.find(item => item.id == this.curTab) || this.tabArr[0] || {};
},
curTabName() {
return this.curTabItem.name || '信任精选';
},
curTabColor() {
return this.getTabColor(this.curTabItem);
},
isApp() {
// #ifdef APP-PLUS
return true;
// #endif
// #ifndef APP-PLUS
return false;
// #endif
},
mescrollTop() {
// #ifdef MP-WEIXIN
return '400rpx';
// #endif
// #ifdef H5
return '260rpx';
// #endif
// #ifdef APP-PLUS
const statusBarHeight = uni.getSystemInfoSync().statusBarHeight || 0;
return (statusBarHeight * 2 + 248) + 'rpx';
// #endif
},
mescrollBottom() {
// #ifdef APP-PLUS
return '100rpx';
// #endif
// #ifndef APP-PLUS
return '0rpx';
// #endif
},
},
data() {
return {
itemType: 1, // 1: 图2样式, 2: 图1样式
dataList: [],
tabArr: [
{
id: 7,
name: '信任精选',
color: '#7A35F6',
icon: 'https://static.tbmall.xin/static/new-home/xinren.png',
iconActive: 'https://static.tbmall.xin/static/new-home/xinren_active.png',
}, {
id: 15,
name: '全网爆款',
color: '#FF2A2A',
icon: 'https://static.tbmall.xin/static/new-home/baokuan.png',
iconActive: 'https://static.tbmall.xin/static/new-home/baokuan_active.png',
}, {
id: 16,
name: '低价好物',
color: '#FF9800',
icon: 'https://static.tbmall.xin/static/new-home/cart.png',
iconActive: 'https://static.tbmall.xin/static/new-home/cart_active.png',
}, {
id: 6,
name: '品牌特卖',
color: '#333333',
icon: 'https://static.tbmall.xin/static/new-home/huiyuan.png',
iconActive: 'https://static.tbmall.xin/static/new-home/huiyuan_active.png',
},
],
curTab: 7,
upOption: {
auto: false,
page: {
size: 10, // 每页数据的数量,默认10
},
noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
empty: {
tip: `空空如也`,
},
textColor: "#333",
bgColor: "rgba(0,0,0,0)",
},
downOption: {
auto: false,
textColor: "#333",
bgColor: "rgba(0,0,0,0)",
},
leftList: [],
rightList: [],
mescroll: null,
};
},
onLoad(options) {
console.log("+++++", options)
if (options.index) {
this.curTab = options.index;
}
this.getSearchList()
},
onShow() {
/*#ifdef APP-PLUS*/
uni.hideTabBar({
animation: false,
});
/*#endif*/
if (this.tabArr.length > 0) {
const sortParams = uni.getStorageSync('sortParams');
if (sortParams) {
const targetIndex = this.tabArr.find(item => item.name === sortParams.value)?.id;
uni.removeStorageSync('sortParams');
if (targetIndex) {
this.curTab = targetIndex;
this.dataList = [];
this.downCallback();
}
} else {
this.getSearchList();
}
}
},
methods: {
getTabColor(item) {
if (!item) return '#7A35F6';
if (item.color) return item.color;
const name = item.name || '';
if (name.includes('信任')) return '#7A35F6';
if (name.includes('爆款')) return '#FF2A2A';
if (name.includes('低价') || name.includes('好物')) return '#FF9800';
if (name.includes('品牌') || name.includes('特卖')) return '#333333';
return '#7A35F6';
},
/**
* 查询分类列表
*/
async getSortList() {
const resp = await getGoodsTags({ type: 5 });
if (resp && resp.bizcode === 100) {
this.tabArr = resp.data.sort((a, b) => a.sort - b.sort);
this.$nextTick(() => {
this.applySortParams();
this.downCallback();
});
}
},
applySortParams() {
const sortParams = uni.getStorageSync('sortParams');
if (sortParams && this.tabArr.length > 0) {
uni.removeStorageSync('sortParams');
const targetIndex = this.tabArr.findIndex(item => item.name === sortParams.value);
if (targetIndex !== -1 && targetIndex !== this.curTab) {
this.curTab = targetIndex;
this.dataList = [];
}
}
},
mescrollInit(mescroll) {
this.mescroll = mescroll;
},
upCallback(page) {
let pageNum = page.num;
let pageSize = page.size;
let params = {
type: 2,
page: page.num,
pageSize: page.size,
isPar: true,
tag: this.curTab
};
searchList(params).then((res) => {
let curPageLen = res.data.length;
if (page.num === 1) this.dataList = [];
this.dataList = this.dataList.concat(res.data);
this.waterfall();
this.mescroll.endBySize(curPageLen, res.data.total);
});
},
downCallback() {
this.mescroll && this.mescroll.resetUpScroll();
},
onTab(index) {
if (index != this.curTab) {
this.curTab = index;
console.log("----", this.curTab)
this.dataList = [];
this.mescroll && this.mescroll.scrollTo(0, 0);
this.downCallback();
}
},
async getSearchList() {
const params = {
page: 1,
pageSize: 10,
isPar: true,
tag: this.curTab
};
const resp = await searchList(params);
if (resp && resp.bizcode === 100) {
this.dataList = resp.data || [];
this.waterfall();
}
},
waterfall() {
this.leftList = this.dataList
.map((item, index) => {
if (index % 2 == 0) return item;
return null;
})
.filter(Boolean);
this.rightList = this.dataList
.map((item, index) => {
if (index % 2 != 0) return item;
return null;
})
.filter(Boolean);
console.log(this.leftList, this.rightList);
},
onJumpSearch() {
uni.navigateTo({
url: "/pages/rwa_package/insights/search",
});
},
onJumpShop(id) {
uni.navigateTo({
url: "/pages/other_package/productInfo/productInfo?id=" + id,
});
},
onShare() {
uni.navigateTo({
url: "/pages/other_package/invite_friends/invite_friends",
});
},
},
};
</script>
<style lang="scss" scoped>
.content-two {
min-height: 100vh;
background-color: #f5f5f5;
}
.top-header-container {
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 99;
background-color: #fff;
/* #ifdef MP-WEIXIN */
padding-top: 40rpx;
/* #endif */
}
.head-view {
width: 100%;
min-height: 88rpx;
height: 88rpx;
display: flex;
align-items: center;
padding: 0 32rpx;
box-sizing: border-box;
background-color: #fff;
.head-search {
width: 100%;
height: 76rpx;
padding: 0 24rpx;
flex-direction: row;
display: flex;
background-color: #f7f7f7;
align-items: center;
border-radius: 16rpx;
}
}
.tab-box {
width: 100%;
height: 160rpx;
min-height: 80rpx;
display: flex;
flex-direction: row;
align-items: center;
padding: 0 32rpx;
box-sizing: border-box;
background-color: #fff;
overflow-x: auto;
.tab-item {
display: flex;
flex: 1;
flex-direction: column;
align-items: center;
.tab-img {
width: 56rpx;
height: 56rpx;
}
.tab-name {
font-size: 28rpx;
margin-top: 24rpx;
}
}
}
.tab-view {
width: 100%;
height: 80rpx;
min-height: 80rpx;
display: flex;
flex-direction: row;
padding: 0 32rpx;
box-sizing: border-box;
background-color: #fff;
overflow-x: auto;
.tab-list {
margin-right: 24rpx;
display: flex;
flex-direction: column;
height: 60rpx;
min-height: 60rpx;
align-items: center;
justify-content: space-between;
margin-top: 22rpx;
}
.line {
width: 48rpx;
height: 6rpx;
background-color: #7a35f6;
}
}
.setting-view {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
padding: 0 32rpx 40rpx;
box-sizing: border-box;
.name-box {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
.single-col {
width: 100%;
display: flex;
flex-direction: column;
}
.mescrollUniView {
width: calc(100vw - 48rpx);
display: flex;
flex-wrap: wrap;
justify-content: space-between;
.fall-col {
width: 332rpx;
/* 与 ParityProductItem 宽度一致 */
height: 100%;
}
}
}
}
</style>