You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

166 lines
3.8 KiB

<style lang="scss">
.transaction{
height:100%;
display:flex;
flex-direction: column;
&>.dateRange{
flex-shrink: 0;
display: flex;
align-items: center;
margin:30rpx;
text{
&.plant-youbian{
display: flex;
align-items: center;
flex-direction: row-reverse;
justify-content: space-between;
background:#fff;
height:48rpx;
font-size:24rpx;
color:#333;
border-radius: 8rpx;
padding:0 10rpx;
min-width:226rpx;
box-sizing: border-box;
&:before{
transform: rotate(90deg);
}
&.noDate{
color:#999;
}
}
&:nth-child(2){
color:#999;
padding:0 28rpx;
}
}
}
scroll-view{
flex-grow: 1;
height:1rpx;
.card{
margin-top:0;
display: flex;
.u-transition{
margin-right:20rpx;
}
.title{
font-weight: bold;
margin-bottom:6rpx;
}
.spec,.total{
font-size:24rpx;
color:#999;
margin-top:10rpx;
display:flex;
align-items: center;
text:first-child{
min-width:180rpx;
}
}
.total{
text:first-child{
color:#10C176;
font-weight: bold;
&:after{
content:"("attr(data-unit)")";
font-weight: normal;
}
}
}
}
}
}
</style>
<template>
<view class="transaction">
<view class="dateRange">
<text class="plant-youbian" :class="{noDate:!searchVal.startTime}" @click="dateType='startTime';show=true">{{searchVal.startTime||"请选择开始日期"}}</text>
<text>~</text>
<text class="plant-youbian" :class="{noDate:!searchVal.endTime}" @click="dateType='endTime';show=true">{{searchVal.endTime||"请选择结束日期"}}</text>
</view>
<scroll-view>
<view class="card">
<u-image radius="20rpx" width="130rpx" height="118rpx" mode="aspectFill" :src="`${host}/${1}`">
<text slot="error" style="font-size:45rpx;" class="plant-xiaopangchetupianjiazaishibai"/>
</u-image>
<view class="info">
<view class="title">精品小黄瓜</view>
<view class="spec">
<text>规格20kg/</text>
<text>云南云天化股份有限公司</text>
</view>
<view class="total">
<text data-unit="400kg">20</text>
<text>交易日期2022-12-12</text>
</view>
</view>
</view>
</scroll-view>
<u-datetime-picker
:show="show"
mode="date"
closeOnClickOverlay
@close="show=false"
@cancel="show=false"
:minDate="dateType=='endTime'&&searchVal.startTime?new Date(searchVal.startTime).getTime():new Date().set('y',-15).getTime()"
:maxDate="dateType=='startTime'&&searchVal.endTime?new Date(searchVal.endTime).getTime():new Date().set('y',15).getTime()"
:value="searchVal[dateType] || new Date().format('yyyy-MM-dd')"
@confirm="searchVal[dateType]=new Date($event.value).format('yyyy-MM-dd');clean();search();show=false"/>
</view>
</template>
<script>
import request,{host} from '@/common/request'
export default {
data(){
return{
show:false,
host:host('imgUrl'),
searchVal:{
startTime:"",
endTime:"",
pageNo:1,
pageSize:5,
harvestId:""
},
list:[],
total:0,
dateType:"startTime",
}
},
created(){
this.search()
},
methods:{
clean(){
this.list=[]
this.total=0
this.searchVal.pageNo=1
},
async search(){
if(this.total==0||this.list.length<this.total){
var res=await request("/api/plantTrade/list",{
method:"post",
body: this.searchVal
})
if(res.statu){
this.list=this.list.concat(res.data.records)
this.total=res.data.total
this.searchVal.pageNo++
if(this.list.length==this.total)uni.showToast({title:"加载完成!",icon:"none"})
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取交易记录失败!",
showCancel:false,
})
}
}
},
}
}
</script>