ReedawFoodApp/pageTwo/history/history.vue

244 lines
5.2 KiB
Vue

<template>
<view class="common">
<view class="tagList">
<scroll-view class="scroll-view_H" scroll-x="true">
<text class="scroll-view-item_H" v-for="(ite,ind) in publicRecordInfo"
@click="handlePageScrollTo(ite.id,ind)" :class="[ind == index?'active':'']">
{{ite.name}}
</text>
</scroll-view>
</view>
<view class="history" v-if="ranklist.length">
<view class="list" v-for="(item, index) in ranklist" :key="index" @click="clickItemMethod(item)">
<uni-swipe-action>
<uni-swipe-action-item :right-options="item.options" @click="swipeClick($event, index)">
<view class="time">
<icon class="t-icon t-icon-shijian-mianxing-0"></icon>
<text>{{item.record_time}}</text>
</view>
<view class="item">
<view>{{item.v1}}<text>{{item.v1_name}}</text></view>
<view v-if="item.v2">{{item.v2}}<text>{{item.v2_name}}</text></view>
<view v-if="item.v3">{{item.v3}}<text>{{item.v3_name}}</text></view>
<uni-icons type="right" v-if="acd_id!=6"></uni-icons>
</view>
</uni-swipe-action-item>
</uni-swipe-action>
</view>
<view class="endtext" v-if="!lastPage || page >= lastPage">—— 到底了,看看别的吧 ——</view>
</view>
<view class="nolist" v-if="!lastPage">
<image src="../../static/none.png"></image>
<text>暂无数据</text>
</view>
</view>
</template>
<script>
import {
mapState
} from "vuex";
export default {
computed: {
...mapState(['user', 'PublicRecord']),
publicRecordInfo() {
let that = this
return that.PublicRecord
},
},
data() {
return {
ranklist: [],
page: 1,
index: 0,
lastPage: '',
active: 0,
}
},
onLoad() {
let that = this
that.$nextTick(() => {
that.getList()
})
},
onReachBottom() {
let that = this
console.log("onReachBottom", this.lastPage)
if (!this.lastPage || this.page >= this.lastPage) {
uni.showToast({
title: '没有更多数据!',
icon: 'none'
})
return
}
this.page++
this.getList()
},
methods: {
swipeClick(e, index) {
let that = this
let id = that.ranklist[index].id
uni.showModal({
title: '友情提示',
content: '是否删除当前测量记录?',
success: function(res) {
if (res.confirm) {
that.$model.getPublicHistoryDel({
id: id,
type: that.publicRecordInfo[that.index].key_word,
}).then((res) => {
if (res.code != 0) {
that.$tools.msg(res.msg)
return
}
that.ranklist.splice(index, 1)
that.$tools.msg("删除成功")
})
} else if (res.cancel) {
that.$tools.msg("您已取消操作!");
}
},
})
},
handlePageScrollTo(id, ind) {
let that = this
that.index = ind
that.active = 1
that.ranklist = []
that.page = 1
that.lastPage = ''
that.getList()
},
clickItemMethod(item) {
let that = this
if (item.is_have_details == 'no') return
uni.navigateTo({
url: "/pageTwo/history/historyDetail?id=" + item.id + "&type=" + that.publicRecordInfo[that
.index].key_word
})
},
getList() {
let that = this
that.$model.getPublicHistory({
aud_id: that.user.aud_id,
page: that.page,
type: that.publicRecordInfo[that.index].key_word,
}).then((res) => {
console.log("历史记录", res)
if (res.code != 0) return
let options = [{
text: '删除',
style: {
backgroundColor: '#dd524d'
}
}]
res.data.rows.forEach(item => {
item.options = options
})
this.ranklist = this.ranklist.concat(res.data.rows)
this.lastPage = res.data.totalpage
})
},
}
}
</script>
<style scoped="scoped" lang="scss">
.common {
width: 100%;
min-height: 100.5vh; // 重点
overflow-y: scroll;
background-color: #f7f7f7;
}
.tagList {
width: 100%;
height: 45px;
line-height: 45px;
background: #fff;
box-shadow: 0px 1px 5px 2px #dfe2e1fc;
position: fixed;
top: 0;
z-index: 999;
.active {
color: $maincolor;
font-weight: bold;
font-size: 16px;
}
.scroll-view_H {
white-space: nowrap;
width: 100%;
.scroll-view-item_H {
display: inline-block;
height: 45rpx;
line-height: 45rpx;
text-align: center;
}
}
text {
color: #666;
padding: 0 15px;
}
}
.history {
width: calc(100% - 30px);
height: auto;
margin: 50px 15px 0;
padding-bottom: 40px;
.list {
width: 100%;
margin-top: 12px;
position: relative;
.item {
width: calc(100% - 20px);
height: auto;
background: #fff;
padding: 10px;
display: flex;
justify-content: space-between;
border-radius: 10px;
align-items: center;
font-weight: 700;
font-size: 30rpx !important;
text {
width: 100%;
display: block;
color: #666;
text-align: center;
font-weight: 500;
font-size: 28rpx;
}
view {
width: 28%;
display: flex;
flex-wrap: wrap;
justify-content: center;
}
}
.time {
width: 100%;
font-size: 28rpx;
color: #666;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
icon {
width: 40rpx;
height: 40rpx;
margin-right: 5px;
}
}
}
}
</style>