TraceabilityAPP/pages/index/index.vue

210 lines
3.9 KiB
Vue

<template>
<view class="">
<view class="content">
<view class="serch">
<u-search bgColor="white" :show-action="false" margin='0 30rpx' placeholder="搜索你的土地信息"
v-model="fomData.keyword" shape="round"></u-search>
<u-button class="custom-style" @click="search">搜索</u-button>
</view>
<view class="card" v-for="(item,index) in datalist" :key="index" @click="navgo(item)">
<view class="tit card-li">
<view class="">
{{item.title}}
</view>
<view class="" style="color: #00A15E;" v-if="item.residual_area!=item.total_area">
已种植
</view>
<view class="" style="color: #00A15E;" v-if="item.residual_area==item.total_area">
未种植
</view>
</view>
<view class="card-li" v-if="item.residual_area!=item.total_area">
<view class="">
种植面积:{{item.total_area-item.residual_area}}亩
</view>
</view>
<view class="card-li" v-if="item.residual_area==item.total_area">
<view class="">
未种植面积:{{item.total_area}}亩
</view>
</view>
<view class="card-li tit">
<view class="" style="font-weight: normal;">
地址: {{item.town_name}}{{item.village_name}}{{item.group_name}}
</view>
</view>
</view>
<!-- <view class="land" @click="navgo('/pages/addLand/addLand')">
土地
</view> -->
</view>
</view>
</template>
<script setup>
import {
onLoad,
onShow,
onReachBottom,
onPullDownRefresh
} from "@dcloudio/uni-app"
import {
ref,
reactive,
onMounted
} from "vue"
import {
landlist
} from '@/api/file.js'
onShow(() => {
console.log(11)
list()
})
onPullDownRefresh(() => {
console.log(11)
uni.stopPullDownRefresh()
})
onReachBottom(() => {
console.log(11)
getlist()
})
const datalist = reactive([])
const fomData = reactive({
page_no: 1,
page_size: 15,
keyword: ''
})
// 获取位置
const getPositionFn = () => {
uni.getLocation({
type: 'gcj02',
geocode: true,
isHighAccuracy: true,
success: function(res) {
uni.request({
url: `https://restapi.amap.com/v3/geocode/regeo?output=JSON&location=${res.longitude},${res.latitude}&key=b0c21bc6b220aa882bad8ffb6bce8829&radius=1000&extensions=all`,
success: (res) => {
console.log(res)
}
})
}
});
}
const list = () => {
fomData.page_no = 1
getlist()
}
const getlist = () => {
landlist(fomData).then((res) => {
if (res.code == 1) {
datalist.splice(0, datalist.length, ...res.data);
fomData.page_no += fomData.page_no
}
})
}
const search = () => {
console.log('111111')
}
const navgo = (item) => {
uni.navigateTo({
url: '/pages/landDetail/index?id=' + item.id
})
}
onMounted(() => {
// console.log('22222222')
})
</script>
<style lang="scss">
.content {
min-height: 100vh;
position: relative;
background-color: #EAF2EF;
padding-top: 180rpx;
.land {
width: 100rpx;
height: 100rpx;
line-height: 100rpx;
text-align: center;
background-color: #fff;
border-radius: 50%;
position: absolute;
right: 60rpx;
bottom: 130rpx;
position: fixed;
}
.serch {
width: 100%;
height: 100rpx;
background-color: #EAF2EF;
position: absolute;
position: fixed;
display: flex;
top: 0;
padding-top: 70rpx;
padding-right: 20rpx;
.custom-style {
color: #606266;
width: 120rpx;
border-radius: 30rpx;
margin-top: 10rpx;
margin-right: 20rpx;
}
z-index: 8888 !important;
}
.border-bgc {
height: 200rpx;
background-color: #34D190;
border-radius: 0 0 40rpx 40rpx;
position: absolute;
width: 750rpx;
}
.card {
position: relative;
width: 693.93rpx;
margin: auto;
background-color: #fff;
box-sizing: border-box;
border-radius: 21.03rpx 21.03rpx 21.03rpx 21.03rpx;
margin-bottom: 40rpx;
.tit {
display: flex;
font-size: 33.29rpx;
font-weight: bold;
justify-content: space-between;
}
}
}
</style>