效果图
wxml代码
<view class
='fenlei'>
<!-- 左侧分类
-->
<view class
="zuo" style
="height:{{winHeight}}px">
<block wx
:for="{{navList}}" wx
:key
="*this">
<text class
="type-nav {{curNav == item.id ? 'selected' : ''}}" bindtap
="selectNav" data
-index
="{{index}}" data
-id
="{{item.id}}">{{item
.name
}}
</text
>
</block
>
</view
>
<scroll
-view
scroll
-y style
="height: {{winHeight}}px;" class
='zuixin' bindscrolltolower
="bottom"
>
<block wx
:for="{{zuixins}}" wx
:key
="*this">
<navigator url
='/pages/chanpin/xiangxi?cpid={{item.cp_id}}&cpmc={{item.cp_mingcheng}}' class
='paihang-item'>
<view class
='paihang-tupian'>
<image class
='paihang-img' src
='{{item.cp_tupian}}' mode
='widthFix'></image
>
</view
>
<view class
='paihang-xinxi'>
<text class
='paihang-mingcheng'>{{item
.cp_mingcheng
}}</text
>
<text class
='paihang-jianjie'>产品简介
</text
>
<view
>
<text class
='paihang-xuhao'>No
.{{index
+1}}</text
>
<text class
='paihang-xiaoshou'> | 456人付款
| </text
>
<text class
='paihang-jiage0'> ¥
</text
>
<text class
='paihang-jiage1'> {{item
.jiage
}}</text
>
</view
>
</view
>
</navigator
>
</block
>
</scroll
-view
>
</view
>
<loading hidden
="{{hidden}}">
加载中
...
</loading
>
wxss代码
.fenlei
{
height
: 100%;
box
-sizing
: border
-box
;
background
-color
: #f4f4f4
;
display
: flex
;
flex
-direction
: row
;
width
: 100%;
}
.zuo
{
width
:20%;
border
-right
: 1px solid #ddd
;
font
-size
: .85rem
; height
: 100%;
display
: flex
;
flex
-direction
: column
;
}
.type
-nav
{
position
: relative
;
text
-align
: center
;
padding
: 5px
0;
border
-bottom
: 1px solid #ddd
;
z
-index
: 10;
}
.selected
{
margin
-right
: -1px
;
padding
-left
:-1px
;
color
: #
333;
background
-color
: #fff
;
}
.zuixin
{width
: 80%; background
-color
: white
;}
.paihang
-item
{
display
: flex
;
padding
: 5px
;
width
: 100%;
}
.paihang
-tupian
{
width
: 30%;
}
.paihang
-img
{
width
: 100%;
border
: 1px solid gainsboro
;
border
-radius
: 5px
;
box
-shadow
: 0px
2px
2px gainsboro
;
}
.paihang
-xinxi
{
width
: 70%;
margin
-left
: 5px
;
margin
-right
: 10px
;
display
: flex
;
flex
-direction
: column
;
}
.paihang
-mingcheng
{
font
-size
: 13px
;
font
-weight
: bold
;
overflow
: hidden
;
white
-space
: nowrap
;
text
-overflow
: ellipsis
;
}
.paihang
-jianjie
{
font
-size
: 11px
;
color
: gray
;
margin
: 3px
0;
}
.paihang
-xuhao
{
color
: green
;
font
-size
: 13px
;
}
.paihang
-xiaoshou
{
font
-size
: 11px
;
color
: gray
;
}
.paihang
-jiage0
{
font
-size
: 10px
;
color
: red
;
}
.paihang
-jiage1
{
font
-size
: 13px
;
color
: red
;
}
js代码
var app
= getApp()
Page({
data
: {
hidden
: true,
winWidth
:0,
winHeight
:0,
navList
:[],
curNav
: 0,
zuixins
: [],
page_kaishi
:0,
page_zong
:0
},
selectNav
:function(event
){
var that
= this
;
var id
= event
.target
.dataset
.id
console
.log(id
)
that
.setData({ curNav
: id
})
that
.setData({
zuixins
:[],
page_kaishi
:0
})
wx
.request({
url
: app
.myapp
.php
+ '/wx_api_CpList_All.php',
data
: {
page
: that
.data
.page_kaishi
,
cs_lxid
:id
},
success
:function(res
)
{
that
.setData({
zuixins
: res
.data
,
page_zong
: res
.data
[0].yeshu
})
}
})
},
onLoad
: function (options
) {
var that
=this
;
wx
.getSystemInfo({
success
: function(res
) {
that
.setData({
winHeight
:res
.windowHeight
,
winWidth
:res
.windowWidth
})
},
})
wx
.request({
url
: app
.myapp
.php
+ '/wx_fenlei.php',
success
:function(res
){
that
.setData({ navList
: res
.data
})
}
})
wx
.request({
url
: app
.myapp
.php
+ '/wx_api_CpList_All.php',
data
:{
page
:that
.data
.page_kaishi
},
success
: function (res
) {
console
.log("总的页数:"+res
.data
[0].yeshu
)
that
.setData({
zuixins
: res
.data
,
page_zong
: res
.data
[0].yeshu
})
}
})
},
onReady
: function () {
},
onShow
: function () {
},
onHide
: function () {
},
onUnload
: function () {
},
onPullDownRefresh
: function () {
},
onReachBottom
: function () {
},
bottom
:function(){
var that
= this
;
console
.log("触底");
if(that
.data
.page_kaishi
< that
.data
.page_zong
-1){
that
.data
.page_kaishi
=that
.data
.page_kaishi
+1;
that
.fetchData(that
.data
.page_kaishi
);
}else{
console
.log("没有数据了")
wx
.showToast({
title
: '没有更多数据了',
})
}
},
fetchData
: function (yeshu
) {
var that
= this
;
console
.log("当前加载页数:" + yeshu
)
console
.log("当前类型id:" + that
.data
.curNav
)
that
.setData({ hidden
: false })
wx
.request({
url
: app
.myapp
.php
+ '/wx_api_CpList_All.php',
data
: {
page
: yeshu
,
cs_lxid
:that
.data
.curNav
},
success
: function (res
) {
console
.log("数组的长度:" + res
.data
.length
)
for (var i
= 0; i
< res
.data
.length
; i
++) {
var obj
= {};
obj
.cp_id
= res
.data
[i
].cp_id
;
obj
.cp_mingcheng
= res
.data
[i
].cp_mingcheng
;
obj
.jiage
= res
.data
[i
].jiage
;
obj
.cp_tupian
= res
.data
[i
].cp_tupian
;
obj
.yeshu
= res
.data
[i
].yeshu
;
let nodes
= that
.data
.zuixins
;
nodes
.push(obj
)
that
.setData({ zuixins
: nodes
})
}
setTimeout(function () {
that
.setData({
hidden
: true
})
}, 300)
}
})
},
onShareAppMessage
: function () {
}
})
转载请注明原文地址: https://lol.8miu.com/read-13974.html