<template>
|
<view class="rebar_index">
|
<scroll-view
|
scroll-y="true"
|
class="rebar_index_scroll"
|
:scroll-top="scrollTop"
|
refresher-enabled="true"
|
refresher-background="#EAEAEA"
|
:refresher-triggered="triggered"
|
@refresherpulling="refresherrefresh"
|
@scrolltolower="scrolltoLower">
|
<view class="rebar_card_lists" v-for="(item,index) in rebarDatas" :key="index">
|
<view class="rebar_card_left">
|
<u-image src="@/static/rebar_phone.png" width="120rpx" height="120rpx"></u-image>
|
</view>
|
<view class="rebar_card_right">
|
<view class="rebar_card_right_text">
|
<view class="rebar_card_titles">{{item.steelName}}:</view>
|
<view class="rebar_card_datas">{{item.steelModel}}</view>
|
</view>
|
<view class="rebar_card_right_text">
|
<view class="rebar_card_titles">实时库存:</view>
|
<view class="rebar_card_datas">{{item.stock}}{{item.unit}}</view>
|
</view>
|
</view>
|
</view>
|
<u-loadmore :status="status" :icon-type="iconType" :load-text="loadText" />
|
</scroll-view>
|
</view>
|
</template>
|
|
<script>
|
import { throttle } from '../../plugins/public.js';
|
export default{
|
data(){
|
return{
|
pageNum: 1,
|
pageSize: 10,
|
loadPage: 0,
|
scrollTop: 0,
|
triggered: true,
|
status: 'loading',
|
loadText: {
|
loading: '努力加载中',
|
nomore: '没有更多数据了'
|
},
|
rebarDatas:[]
|
}
|
},
|
onLoad() {
|
this.searchRebarList()
|
},
|
methods:{
|
//查询列表
|
searchRebarList(){
|
this.triggered = true;
|
this.rebarDatas = [];
|
let params = {
|
pageNum: this.pageNum,
|
pageSize:this.pageSize,
|
}
|
this.$api.reboSystem.getRebarLists(params).then(res=>{
|
if(res.statusMsg === 'ok'){
|
this.rebarDatas = res.data.list
|
this.loadPage = res.data.pages;
|
this.triggered = false;
|
this.status = 'nomore';
|
}else{
|
uni.$u.toast(res.statusMsg);
|
}
|
}).catch((err) => {
|
uni.$u.toast('请检查网络服务或联系管理员!')
|
})
|
},
|
//自定义下拉刷新
|
refresherrefresh: throttle(function() {
|
this.status = 'loading';
|
this.pageNum = 1;
|
this.searchRebarList();
|
uni.$u.toast('刷新成功');
|
}, 500),
|
//触底刷新
|
scrolltoLower: throttle(function() {
|
this.status = 'loading';
|
if(this.pageNum >= this.loadPage) {
|
setTimeout(() => {
|
this.status = 'nomore'
|
uni.$u.toast('没有更多数据了');
|
},1000)
|
return
|
} else {
|
this.pageNum+=1
|
let params = {
|
pageNum: this.pageNum,
|
pageSize:this.pageSize,
|
}
|
this.$api.reboSystem.getRebarLists(params).then(res=>{
|
if(res.statusMsg === 'ok'){
|
this.rebarDatas.push(...res.data.list)
|
this.loadPage = res.data.pages;
|
this.triggered = false;
|
this.status = 'nomore';
|
}else{
|
uni.$u.toast(res.statusMsg);
|
}
|
}).catch((err) => {
|
uni.$u.toast('请检查网络服务或联系管理员!')
|
})
|
}
|
}, 1500),
|
}
|
}
|
</script>
|
|
<style scoped lang="scss">
|
.rebar_index{
|
height: 100vh;
|
padding: 10px 15px;
|
background-color: #F6F6F6;
|
|
.rebar_index_scroll{
|
height: 90%;
|
.rebar_card_lists{
|
height: 100px;
|
background-color: #FFFFFF;
|
border-radius: 6px;
|
margin-bottom: 10px;
|
display: flex;
|
.rebar_card_left{
|
width: 30%;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
}
|
.rebar_card_right{
|
width: 70%;
|
display: flex;
|
flex-direction: column;
|
justify-content: space-around;
|
.rebar_card_right_text{
|
display: flex;
|
.rebar_card_titles{
|
color: #999999;
|
font-size: 15px;
|
}
|
.rebar_card_datas{
|
color: #363636;
|
font-size: 15px;
|
}
|
}
|
}
|
}
|
}
|
}
|
</style>
|