310 lines
7.5 KiB
Vue
310 lines
7.5 KiB
Vue
<template>
|
|
<view class="content-two">
|
|
<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-view">
|
|
<view
|
|
class="tab-list"
|
|
@click="onTab(index)"
|
|
v-for="(item, index) in tabList"
|
|
:key="index"
|
|
>
|
|
<text
|
|
class="text-28 text-space"
|
|
:style="{
|
|
color: curTab == index ? '#7A35F6' : '#666',
|
|
}"
|
|
>{{ item.name }}</text
|
|
>
|
|
<view class="line" v-if="curTab == index"></view>
|
|
</view>
|
|
</view>
|
|
<view class="setting-view">
|
|
<view class="name-box">
|
|
<mescroll-uni
|
|
ref="mescrollRef"
|
|
@down="downCallback"
|
|
@up="upCallback"
|
|
:up="upOption"
|
|
:down="downOption"
|
|
@init="mescrollInit"
|
|
:fixed="false"
|
|
>
|
|
<!-- <view class="mescrollUniView">
|
|
|
|
<PingItem
|
|
@ok="onJumpShop"
|
|
style="margin-top: 24rpx"
|
|
:obj="item"
|
|
v-for="(item, index) in dataList"
|
|
:key="index"
|
|
></PingItem>
|
|
</view> -->
|
|
<!-- 原来单个 v-for 替换成两列 -->
|
|
<view class="mescrollUniView">
|
|
<view class="fall-col">
|
|
<PingItem
|
|
v-for="(item, i) in leftList"
|
|
:key="item.id"
|
|
:obj="item"
|
|
@ok="onJumpShop"
|
|
style="margin-top: 24rpx"
|
|
/>
|
|
</view>
|
|
<view class="fall-col">
|
|
<PingItem
|
|
v-for="(item, i) in rightList"
|
|
:key="item.id"
|
|
:obj="item"
|
|
@ok="onJumpShop"
|
|
style="margin-top: 24rpx"
|
|
/>
|
|
</view>
|
|
</view>
|
|
</mescroll-uni>
|
|
</view>
|
|
</view>
|
|
<!-- #ifndef H5 -->
|
|
<CustomTabBar :tabIndex="2" />
|
|
<!-- #endif -->
|
|
<up-toast ref="uToastRef"></up-toast>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import { toRaw } from "vue";
|
|
import { getCascadeCategory } from "@/api/common.js";
|
|
import Header from "@/components/common/header.vue";
|
|
import TopSafe from "@/components/common/top-safe.nvue";
|
|
import MyBtn from "@/components/common/my-btn.vue";
|
|
import PingItem from "@/components/shop/ping-item.vue";
|
|
import { searchList } 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, PingItem, CustomTabBar, MescrollUni },
|
|
data() {
|
|
return {
|
|
dataList: [],
|
|
tabList: [{ name: "推荐" }],
|
|
curTab: 0,
|
|
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: [],
|
|
};
|
|
},
|
|
onLoad() {
|
|
this.init();
|
|
},
|
|
methods: {
|
|
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,
|
|
};
|
|
if (this.curTab != 0) {
|
|
params["categoryId"] = this.tabList[this.curTab].id;
|
|
}
|
|
searchList(params).then((res) => {
|
|
let curPageLen = res.data.length;
|
|
if (page.num === 1) this.dataList = [];
|
|
this.dataList = this.dataList.concat(res.data);
|
|
console.log(this.dataList);
|
|
|
|
this.waterfall();
|
|
this.mescroll.endBySize(curPageLen, res.data.total);
|
|
});
|
|
},
|
|
downCallback() {
|
|
this.$nextTick(function () {
|
|
this.mescroll && this.mescroll.resetUpScroll();
|
|
});
|
|
},
|
|
async cascadeCategory() {
|
|
getCascadeCategory({ parentId: 0 }).then((res) => {
|
|
if (res && res.bizcode === 100) {
|
|
res.data.forEach((item) => {
|
|
this.tabList.push(item);
|
|
});
|
|
this.downCallback();
|
|
}
|
|
});
|
|
},
|
|
onTab(index) {
|
|
if (index != this.curTab) {
|
|
this.curTab = index;
|
|
this.dataList = [];
|
|
this.downCallback();
|
|
}
|
|
},
|
|
init() {
|
|
this.cascadeCategory();
|
|
},
|
|
async getSearchList() {
|
|
const params = {
|
|
type: 2,
|
|
page: 1,
|
|
pageSize: 10,
|
|
isPar: true,
|
|
};
|
|
if (this.curTab != 0) {
|
|
params["categoryId"] = this.tabList[this.curTab].id;
|
|
}
|
|
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/dongjian/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 {
|
|
height: calc(100vh);
|
|
|
|
background-color: $app-bj;
|
|
}
|
|
.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-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%;
|
|
height: calc(100vh - 88rpx - 80rpx - 100rpx - var(--status-bar-height));
|
|
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
overflow-y: auto;
|
|
padding: 0 32rpx;
|
|
box-sizing: border-box;
|
|
position: relative;
|
|
.name-box {
|
|
width: 100%;
|
|
height: calc(100vh - 88rpx - 80rpx - 100rpx - var(--status-bar-height));
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
|
|
.mescrollUniView {
|
|
width: calc(100vw - 48rpx);
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
justify-content: space-between;
|
|
|
|
.fall-col {
|
|
width: 332rpx; /* 与 PingItem 宽度一致 */
|
|
height: 100%;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</style>
|