提交 80311c69 编写于 作者: I iotjin

add topTab

上级 628ec892
......@@ -33,7 +33,8 @@
"pages/demoList/UI/main",
"pages/demoList/UI/examination",
"pages/one/details",
"pages/three/mine"
"pages/three/mine",
"pages/demoList/UI/topTab2"
],
"subpackages": [
{
......
......@@ -20,6 +20,10 @@ Page({
text: 'topTab',
pathUrl: '/pages/demoList/UI/topTab'
},
{
text: 'topTab2',
pathUrl: '/pages/demoList/UI/topTab2'
},
{
text: '登录',
pathUrl: '/pages/demoList/UI/login'
......
var API = require('../../../JhHttpUtils/APICongfig.js'); //相对路径
var currentPage = 0;
Page({
/**
* 页面的初始数据
*/
data: {
active: 0,
isLoadAll: false, //已经加载全部数据
dataArr: [],
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.requestData()
},
//切换tab
onChange(event) {
if (event.detail.name == "0") {
this.setData({
active: 0,
})
}
if (event.detail.name == "1") {
this.setData({
active: 1,
})
}
this.requestData()
},
//点击cell
ClickCell: function (event) {
let model = event.currentTarget.dataset.selectdata;
console.log(model);
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
this.requestData()
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
this.requestData(true)
},
//请求数据
requestData: function (isLoadMore) {
var that = this
if (isLoadMore) {
if (this.data.isLoadAll) {
wx.showToast({
title: '暂无更多数据',
icon: 'none',
})
return
}
currentPage++;
} else {
currentPage = 0;
that.setData({
dataArr: [],
isLoadAll: false
})
}
var prams = {
page: currentPage
}
wx.showNavigationBarLoading()
API.getPageArrDic2(prams).then(res => {
wx.hideNavigationBarLoading()
wx.stopPullDownRefresh()
if (isLoadMore) {
if (res.data) {
that.setData({
dataArr: this.data.dataArr.concat(res.data),
})
}
} else {
// console.log(res.data);
that.setData({
dataArr: res.data,
})
}
if (res.data.length < 10) {
that.setData({
isLoadAll: true
})
}
}).catch(error => {
wx.hideNavigationBarLoading()
wx.stopPullDownRefresh()
currentPage--
currentPage = currentPage < 0 ? 0 : currentPage
that.setData({
isLoadAll: false
})
});
},
})
\ No newline at end of file
{
"navigationBarTitleText": "topTab",
"enablePullDownRefresh": true,
"backgroundTextStyle": "dark",
"usingComponents": {}
}
\ No newline at end of file
<view class='header'>
<van-tabs active="{{ active }}" bind:change="onChange" color="#FFB90F" tab-active-class="tab-active-class" nav-class="nav-class">
<van-tab title="标签一"></van-tab>
<van-tab title="标签二"></van-tab>
</van-tabs>
</view>
<view class="cellBg">
<view id="cell" class="cell" wx:for="{{dataArr}}" wx:key="index" bindtap="ClickCell" data-selectdata="{{item}}">
<view class="left-view">
<image class="img" src="https://img.yzcdn.cn/vant/cat.jpeg"> </image>
</view>
<view class="right-view">
<view class="name">{{item.name2}}</view>
<view class="content">{{item.content}}</view>
</view>
</view>
</view>
\ No newline at end of file
.header {
height: 90rpx;
width: 100%;
position: fixed;
top: 0;
}
.nav-class {
background: #F7FAFC;
}
.tab-active-class {
color: #FFB90F !important;
}
.cellBg {
padding-top: 90rpx;
}
.cell {
display: flex;
width: 100%;
/* height: 140rpx; */
background-color: white;
border-bottom: 1px solid rgb(230, 230, 230);
}
.left-view {
width: 140rpx;
text-align: center;
line-height: 140rpx;
}
.img {
width: 100rpx;
height: 100rpx;
vertical-align: middle;
}
.right-view {
flex: 1;
}
.name {
margin-top: 20rpx;
margin-left: 15rpx;
font-size: 35rpx;
}
.content {
margin-top: 15rpx;
margin-left: 15rpx;
margin-right: 20rpx;
margin-bottom: 20rpx;
color: gray;
font-size: 30rpx;
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册