
<view class="search">
<view class="search-bar">
<view class="search-wrap">
<icon type="search" size="16" class="icon-search" />
<input type="text" placeholder="请输入关键字9" class="weui-search-bar__input" name="searchKeyword" bindinput="bindKeywordInput" value="{{searchKeyword}}" />
</view>
<view class="search-cancel" bindtap="keywordSearch">搜索</view>
</view>
<view class="search-result1">
<!-- 左边商品分类 -->
<scroll-view class="office-left" scroll-y scroll-top="{{scrollTops}}">
<view wx:for="{{goodsList}}" class="goodsTitle {{tabCur==index?'office-active':''}}" wx:key="index" bindtap="gl" id="{{index}}">
{{item.title}}
</view>
</scroll-view>
<!-- 右边商品列表 -->
<scroll-view class="office-right" scroll-y scroll-with-animation scroll-into-view="scroll-{{rightCur}}" bindscroll="scrollLink">
<view wx:for="{{goodsList}}" class="menu-con" wx:key="index" bindtap="gl" id="{{index}}" id="scroll-{{idxs}}">
<view class="office-title"> {{item.title}}</view>
<view wx:for="{{item.list}}" class="weui-cell weui-cell_access" wx:for-item="itemNames" wx:key="idxs" wx:for-index="idxs" >
<view class="weui-cell__bd">
<p>{{itemNames.name}}</p> </view>
<view class="weui-cell__ft"></view>
</view>
</view>
</scroll-view>
</view>
</view>
// pages/book/office/bigofficelist.js
Page({
/**
* 页面的初始数据
*/
data: {
tabCur: 0, //当前项
rightCur: 0, // 用于实现左边联动右边
goodsList: [{
title: '碳酸类型',
id: 1,
list:[{
name:'可口可乐',
img: 'https://img2.baidu.com/it/u=3616759465,2727399041&fm=253&fmt=auto&app=138&f=JPEG?w=375&h=500',
sell: '月售:108',
price: '4.8'
},
{
name:'雪碧',
img: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.51yuansu.com%2Fpic3%2Fcover%2F01%2F93%2F00%2F5982eed63cc27_610.jpg&refer=http%3A%2F%2Fpic.51yuansu.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1662339581&t=8bbd7f16e03512ff0e8c32100bbcfc86',
sell: '月售:88',
price: '4.8'
},
{
name:'可口可乐',
img: 'https://img2.baidu.com/it/u=3616759465,2727399041&fm=253&fmt=auto&app=138&f=JPEG?w=375&h=500',
sell: '月售:108',
price: '4.8'
},
{
name:'雪碧',
img: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.51yuansu.com%2Fpic3%2Fcover%2F01%2F93%2F00%2F5982eed63cc27_610.jpg&refer=http%3A%2F%2Fpic.51yuansu.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1662339581&t=8bbd7f16e03512ff0e8c32100bbcfc86',
sell: '月售:88',
price: '4.8'
},
{
name:'可口可乐',
img: 'https://img2.baidu.com/it/u=3616759465,2727399041&fm=253&fmt=auto&app=138&f=JPEG?w=375&h=500',
sell: '月售:108',
price: '4.8'
},
{
name:'雪碧',
img: 'https://img2.baidu.com/it/u=3616759465,2727399041&fm=253&fmt=auto&app=138&f=JPEG?w=375&h=500',
sell: '月售:88',
price: '4.8'
}
]
}, {
title: '奶茶类型',
id: 2,
list:[{
name:'阿萨姆奶茶',
img: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fcbu01.alicdn.com%2Fimg%2Fibank%2FO1CN01SHPIlm2GVfaCwHCfx_%21%212211349499021-0-cib.jpg&refer=http%3A%2F%2Fcbu01.alicdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1662285715&t=c575199b747c342d0844a1d8ab593a04',
sell: '月售:108',
price: '4.8'
},
{
name:'香飘飘奶茶',
img: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fcbu01.alicdn.com%2Fimg%2Fibank%2FO1CN01SHPIlm2GVfaCwHCfx_%21%212211349499021-0-cib.jpg&refer=http%3A%2F%2Fcbu01.alicdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1662285715&t=c575199b747c342d0844a1d8ab593a04',
sell: '月售:108',
price: '4.8'
},
{
name:'阿萨姆奶茶',
img: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fcbu01.alicdn.com%2Fimg%2Fibank%2FO1CN01SHPIlm2GVfaCwHCfx_%21%212211349499021-0-cib.jpg&refer=http%3A%2F%2Fcbu01.alicdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1662285715&t=c575199b747c342d0844a1d8ab593a04',
sell: '月售:108',
price: '4.8'
},
{
name:'香飘飘奶茶',
img: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fcbu01.alicdn.com%2Fimg%2Fibank%2FO1CN01SHPIlm2GVfaCwHCfx_%21%212211349499021-0-cib.jpg&refer=http%3A%2F%2Fcbu01.alicdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1662285715&t=c575199b747c342d0844a1d8ab593a04',
sell: '月售:108',
price: '4.8'
},
{
name:'阿萨姆奶茶',
img: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fcbu01.alicdn.com%2Fimg%2Fibank%2FO1CN01SHPIlm2GVfaCwHCfx_%21%212211349499021-0-cib.jpg&refer=http%3A%2F%2Fcbu01.alicdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1662285715&t=c575199b747c342d0844a1d8ab593a04',
sell: '月售:108',
price: '4.8'
},
{
name:'香飘飘奶茶',
img: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fcbu01.alicdn.com%2Fimg%2Fibank%2FO1CN01SHPIlm2GVfaCwHCfx_%21%212211349499021-0-cib.jpg&refer=http%3A%2F%2Fcbu01.alicdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1662285715&t=c575199b747c342d0844a1d8ab593a04',
sell: '月售:108',
price: '4.8'
}
]
},
{
title: '矿泉水',
id: 3,
list:[
{
name:'农夫山泉',
img: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.defanli.com%2Fi4%2F792547767%2FO1CN01HuwT1T27FKjNjeyQO_%21%21792547767.jpg_q90.jpg&refer=http%3A%2F%2Fimg.defanli.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1662285923&t=29d7244212e15dc78bb5bdf1d617a45f',
sell: '月售:108',
price: '4.8'
},
{
name:'怡宝',
img: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.yzcdn.cn%2Fupload_files%2F2018%2F11%2F05%2FFonL0_5VwTfHmiwQiAlBtIZiy3sq.jpg%3FimageView2%2F2%2Fw%2F580%2Fh%2F580%2Fq%2F75%2Fformat%2Fjpg&refer=http%3A%2F%2Fimg.yzcdn.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1662339509&t=e1988f3159060384664ce3de18e45aaf',
sell: '月售:108',
price: '4.8'
},
{
name:'农夫山泉',
img: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.defanli.com%2Fi4%2F792547767%2FO1CN01HuwT1T27FKjNjeyQO_%21%21792547767.jpg_q90.jpg&refer=http%3A%2F%2Fimg.defanli.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1662285923&t=29d7244212e15dc78bb5bdf1d617a45f',
sell: '月售:108',
price: '4.8'
},
{
name:'怡宝',
img: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.yzcdn.cn%2Fupload_files%2F2018%2F11%2F05%2FFonL0_5VwTfHmiwQiAlBtIZiy3sq.jpg%3FimageView2%2F2%2Fw%2F580%2Fh%2F580%2Fq%2F75%2Fformat%2Fjpg&refer=http%3A%2F%2Fimg.yzcdn.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1662339509&t=e1988f3159060384664ce3de18e45aaf',
sell: '月售:108',
price: '4.8'
},
{
name:'农夫山泉',
img: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.defanli.com%2Fi4%2F792547767%2FO1CN01HuwT1T27FKjNjeyQO_%21%21792547767.jpg_q90.jpg&refer=http%3A%2F%2Fimg.defanli.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1662285923&t=29d7244212e15dc78bb5bdf1d617a45f',
sell: '月售:108',
price: '4.8'
},
{
name:'怡宝'
},
{
name:'怡宝'
},
{
name:'怡宝'
},
{
name:'怡宝'
},
{
name:'怡宝'
},
{
name:'怡宝'
},
{
name:'怡宝'
},
{
name:'怡宝'
},
{
name:'怡宝'
},
{
name:'怡宝'
},
{
name:'怡宝'
}
]
},
]
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
gl(e) {
this.setData({
tabCur: e.currentTarget.id,
rightCur: e.currentTarget.id,
})
},
scrollLink(e) {
let list = this.data.goodsList
let itemHeight = 0;
for (let i = 0; i < list.length; i++) {
//拿到每个元素
let els = wx.createSelectorQuery().select("#scroll-" + i);
els.fields({
size: true
}, function (res) {
list[i].top = itemHeight;
itemHeight += res.height;
list[i].bottom = itemHeight
}).exec()
}
// 拿到滚动的高度
let scrollTop = e.detail.scrollTop;
for (let i = 0; i < list.length; i++) {
if (scrollTop > list[i].top && scrollTop < list[i].bottom) {
this.setData({
tabCur: i,
})
return false
}
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
.office-List{
width: 100%;
height: 100%;
display: flex;
}
.office-left{
float: left;
width: 30%;
background-color: #EEEEEE;
min-height: 1000vh;
}
.office-active {
background: #fff;
border-left: 5px solid #4dcd70;
color: #4dcd70;
font-weight: bold;
}
.office-title {
padding: 15px 8px;
background: #eee;
}
.office-left .goodsTitle{
line-height: 100rpx;
text-align: center;
}
.office-active{
background-color: #fff;
}
.office-right{
float: left;
width: 70%;
height: 100%;
}
.office-con {
width: 100%;
overflow: hidden;
}
.goodsItem{
padding: 20rpx;
}
.goodstitle{
padding: 20rpx;
}
.goodsName{
text-align: center;
}