SmartBeehive/pages/Apiary.vue

325 lines
6.2 KiB
Vue
Raw Normal View History

2024-06-11 18:02:55 +08:00
<template>
<view class="page">
<u-navbar :is-back="false" title="蜂场" :border-bottom="false" :background="bgc" title-color='#3D3D3D '
2024-06-14 18:00:24 +08:00
title-size='36' height='45' id="navbar">
2024-06-11 18:02:55 +08:00
</u-navbar>
<view class="top_box">
<view class="search">
<image src="https://api.ccttiot.com/smartmeter/img/static/um5GxgXufKY8IK2qkaWR" mode=""></image>
<view class="search_center">
2024-07-03 18:03:01 +08:00
<input type="text" class="ips" v-model="code" @confirm="changserch" placeholder="请输入蜂场"
2024-06-14 18:00:24 +08:00
placeholder-class="my-placeholder" />
2024-06-11 18:02:55 +08:00
</view>
</view>
2024-06-14 18:00:24 +08:00
<view class="add" @click="addApiary()">
2024-06-11 18:02:55 +08:00
<image src="https://api.ccttiot.com/smartmeter/img/static/uR30yYn3IsHDu5qWV0ML" mode=""></image>
</view>
</view>
2024-07-03 18:03:01 +08:00
<view class="no_cont" v-if="logoflag">
2024-06-11 18:02:55 +08:00
<view class="img">
<image src="https://api.ccttiot.com/smartmeter/img/static/uUZ3MF84e3bKgwAei8Rz" mode=""></image>
</view>
<view class="txt">
当前还没有添加蜂场哦
</view>
</view>
2024-07-04 18:02:46 +08:00
<scroll-view v-else class="Apiary_box" scroll-y="true" @scrolltolower="loadMore">
2024-07-01 18:03:05 +08:00
<view class="Apiary_card" v-for="(item,index) in list" :key="index" @click="btnapiaryxq(item.apiaryId)">
<image :src="item.picture" mode=""></image>
2024-06-14 18:00:24 +08:00
<view class="weather">
<image src="https://api.ccttiot.com/smartmeter/img/static/u6wWpgZOuId6JSX8LGmz" mode=""></image>
<view class="txt1">
多云
</view>
<view class="txt2">
温度舒适湿润光照强空气优
</view>
</view>
<view class="info">
<view class="left">
2024-07-01 18:03:05 +08:00
{{item.name}}
2024-06-14 18:00:24 +08:00
</view>
<view class="right">
2024-07-01 18:03:05 +08:00
{{item.beehiveCount}}
2024-06-14 18:00:24 +08:00
</view>
</view>
<view class="address">
2024-07-01 18:03:05 +08:00
{{item.address}}
2024-06-14 18:00:24 +08:00
</view>
</view>
2024-07-01 18:03:05 +08:00
</scroll-view>
2024-06-11 18:02:55 +08:00
<tab-bar :indexs='1' style=""></tab-bar>
</view>
</template>
<script>
export default {
data() {
return {
bgc: {
backgroundColor: " #FAFDFD",
},
2024-07-01 18:03:05 +08:00
pagesum: 1,
list: [],
total: '',
2024-07-06 18:05:22 +08:00
pagesize: 10,
logoflag: false,
code: ''
2024-06-11 18:02:55 +08:00
}
},
onLoad() {
},
onShow() {
2024-07-01 18:03:05 +08:00
this.pagesum = 1
2024-07-04 18:02:46 +08:00
// this.list = []
2024-07-01 18:03:05 +08:00
this.ishave()
2024-06-11 18:02:55 +08:00
},
methods: {
2024-07-06 18:05:22 +08:00
changserch() {
2024-07-03 18:03:01 +08:00
let data = {
2024-07-06 18:05:22 +08:00
pageNum: this.pagesum,
pageSize: this.pagesize,
name: this.code,
2024-07-03 18:03:01 +08:00
}
this.$u.get('/farm/apiary/list', data).then(res => {
2024-07-06 18:05:22 +08:00
if (res.code == 200) {
2024-07-03 18:03:01 +08:00
this.list = []
this.total = res.total
this.list = res.rows
}
})
},
2024-07-06 18:05:22 +08:00
2024-07-01 18:03:05 +08:00
// 跳转蜂场详情
2024-07-06 18:05:22 +08:00
btnapiaryxq(id) {
2024-07-02 18:07:56 +08:00
uni.navigateTo({
2024-07-06 18:05:22 +08:00
url: '/pages/Apiary/Apiary_detail?id=' + id
2024-07-02 18:07:56 +08:00
})
2024-07-01 18:03:05 +08:00
},
loadMore() {
2024-07-06 18:05:22 +08:00
if (this.list.length < this.total) {
2024-07-01 18:03:05 +08:00
this.ishave();
} else {
uni.showToast({
title: '没有更多蜂场了',
icon: 'none',
duration: 1000
});
}
},
addApiary() {
2024-06-14 18:00:24 +08:00
uni.navigateTo({
2024-07-01 18:03:05 +08:00
url: '/pages/Apiary/AddApiary'
2024-06-14 18:00:24 +08:00
})
2024-07-01 18:03:05 +08:00
},
ishave() {
let data = {
pageNum: this.pagesum,
pageSize: this.pagesize
};
this.$u.get('/farm/apiary/list', data).then((res) => {
if (res.code === 200) {
2024-07-06 18:05:22 +08:00
this.total = res.total;
if (this.total < 1) {
this.logoflag = true;
} else {
if(this.pagesum > 1){
this.list = this.list.concat(res.rows)
}else{
this.list = res.rows
}
this.pagesum++;
this.logoflag = false;
// console.log(this.list);
2024-07-03 18:03:01 +08:00
}
2024-07-01 18:03:05 +08:00
} else {
2024-07-03 18:03:01 +08:00
this.logoflag = true
2024-07-01 18:03:05 +08:00
}
})
},
2024-06-11 18:02:55 +08:00
2024-07-06 18:05:22 +08:00
2024-06-11 18:02:55 +08:00
}
}
</script>
<style lang="scss">
page {
background-color: #FAFDFD;
}
.page {
// position: relative;
width: 750rpx;
2024-06-14 18:00:24 +08:00
.Apiary_box {
2024-07-01 18:03:05 +08:00
padding-left: 40rpx;
box-sizing: border-box;
padding-bottom: 300rpx;
overflow-y: auto;
height: 100vh;
2024-06-14 18:00:24 +08:00
.Apiary_card {
2024-07-01 18:03:05 +08:00
margin-top: 20rpx;
2024-06-14 18:00:24 +08:00
position: relative;
width: 674rpx;
height: 512rpx;
background: #FFFFFF;
box-shadow: 0rpx 0rpx 8rpx 0rpx rgba(0, 0, 0, 0.15);
border-radius: 20rpx 20rpx 20rpx 20rpx;
image {
width: 674rpx;
height: 360rpx;
}
2024-07-01 18:03:05 +08:00
.address {
2024-06-14 18:00:24 +08:00
margin-top: 18rpx;
padding: 0 24rpx;
font-weight: 500;
font-size: 28rpx;
color: #50565A;
white-space: nowrap;
/* 禁止换行 */
overflow: hidden;
/* 超出部分隐藏 */
text-overflow: ellipsis;
}
2024-07-01 18:03:05 +08:00
.info {
2024-06-14 18:00:24 +08:00
margin-top: 18rpx;
padding: 0 24rpx;
display: flex;
align-items: center;
flex-wrap: nowrap;
justify-content: space-between;
2024-07-01 18:03:05 +08:00
.left {
2024-06-14 18:00:24 +08:00
font-weight: 600;
font-size: 36rpx;
color: #3D3D3D;
}
2024-07-01 18:03:05 +08:00
.right {
2024-06-14 18:00:24 +08:00
font-weight: 600;
font-size: 32rpx;
color: #50565A;
}
}
2024-07-01 18:03:05 +08:00
2024-06-14 18:00:24 +08:00
.weather {
padding: 20rpx 24rpx;
position: absolute;
display: flex;
align-items: center;
flex-wrap: nowrap;
left: 0;
top: 0;
width: 674rpx;
height: 70rpx;
2024-07-01 18:03:05 +08:00
2024-06-14 18:00:24 +08:00
background: linear-gradient(to bottom, rgba(255, 255, 255, 0.8), transparent);
2024-07-01 18:03:05 +08:00
image {
2024-06-14 18:00:24 +08:00
width: 44rpx;
height: 44rpx;
}
2024-07-01 18:03:05 +08:00
.txt1 {
2024-06-14 18:00:24 +08:00
margin-left: 16rpx;
font-weight: 600;
font-size: 32rpx;
color: #3D3D3D;
}
2024-07-01 18:03:05 +08:00
.txt2 {
2024-06-14 18:00:24 +08:00
margin-left: 28rpx;
font-weight: 600;
font-size: 28rpx;
color: #3D3D3D;
}
}
}
}
2024-06-11 18:02:55 +08:00
.top_box {
margin: 42rpx auto;
display: flex;
flex-wrap: nowrap;
width: 664rpx;
.search {
display: flex;
flex-wrap: nowrap;
align-items: center;
padding: 20rpx 26rpx;
width: 566rpx;
height: 82rpx;
background: #FFFFFF;
box-shadow: 0rpx 0rpx 8rpx 0rpx rgba(0, 0, 0, 0.15);
border-radius: 20rpx 20rpx 20rpx 20rpx;
image {
width: 35.97rpx;
height: 35.97rpx;
}
.search_center {
margin-left: 34rpx;
width: 480rpx;
.ips {
// 基本样式设置
width: 100%; // 根据需要调整
2024-06-14 18:00:24 +08:00
2024-06-11 18:02:55 +08:00
// border: 1px solid #ccc; // 根据需要调整
2024-06-14 18:00:24 +08:00
2024-06-11 18:02:55 +08:00
// 设置 placeholder 样式
2024-06-14 18:00:24 +08:00
2024-06-11 18:02:55 +08:00
}
2024-06-14 18:00:24 +08:00
.my-placeholder {
2024-06-11 18:02:55 +08:00
font-weight: 400;
font-size: 32rpx;
color: #808080;
}
}
}
.add {
margin-left: 30rpx;
width: 66rpx;
height: 66rpx;
}
}
.no_cont {
margin: 152rpx auto 0;
width: 432rpx;
.img {
image {
width: 432rpx;
height: 432rpx;
}
}
.txt {
margin-top: 50rpx;
width: 100%;
text-align: center;
font-weight: 500;
font-size: 32rpx;
color: #808080;
}
}
}
</style>