app_tree_planting/pages/user/mine_duty_certif.vue
2023-03-03 19:29:04 +08:00

392 lines
8.5 KiB
Vue

<template>
<view class="page">
<view class="content">
<view style="background: #ECECEC;">
<view class="search">
<view class="search-content">
<image src="/static/images/ic_search.png" type="text" class="icon" mode="aspectFill"></image>
<input @input="onSearchInput" confirm-type="search" @confirm="doSearch" placeholder="搜索证书" />
</view>
<view class="btn" @click="doSearch">搜索</view>
</view>
</view>
<!-- Banner -->
<scroller @init="initScroller" @down="refreshData" @up="getData" :up="optUp"
@scroll="navFloatShow(scroller)" :fixed="false">
<!-- <view class="num-box">
<image src="../../static/images/ic_notify_icon.png" mode="aspectFill"></image>
<text>您一共有{{totalNum}}张国土绿化荣誉证书</text>
</view> -->
<!-- 列表 -->
<view class="content-box">
<view class="item" v-for="(item,index) in list" :key="index">
<image :src="imgUrl+item.fileId" mode="scaleToFill"></image>
<view class="item-content" @click="showImg(item.fileId)">
<view class="title">{{item.activityDTO.name}}</view>
<view class="time">证书编号:{{item.cardNum}}</view>
<view class="btn">查看详情</view>
</view>
</view>
</view>
</scroller>
</view>
<pageLoading v-if="showPageLoading"></pageLoading>
</view>
</template>
<script>
import scroller from '@/components/scroller/scroller.vue';
import pageLoading from '@/components/loading/pageLoading.vue';
export default {
components: {
pageLoading,
scroller
},
data() {
return {
userName: "昵称",
scroller: {},
optUp: {
auto: true,
onScroll: true,
page: {
num: 0, //当前页 默认0,回调之前会加1; 即callback(page)会从1开始
size: 10 //每页数据条数,默认10
},
empty: {
tip: '暂无数据~'
}
},
totalNum: 0,
showPageLoading: true,
list: [],
phone: "",
idcard: "",
token: "",
imgUrl: this.$api.common.imgUrl
}
},
onLoad(res) {
this.userName = getApp().globalData.userInfo.name;
this.token = getApp().globalData.token;
console.log(this.token)
if (res.name) {
this.userName = res.name;
this.phone = res.phone;
this.idcard = res.idcard;
}
},
methods: {
showImg(fileId) {
if (fileId != "") {
var _self = this;
var url = _self.imgUrl + fileId
uni.previewImage({
urls: [url]
})
} else {
uni.showToast({
icon: "error",
title: "证书有误"
})
}
},
onSearchInput(event) {
this.searchContent = event.target.value
console.log(event.target.value)
if (event.target.value == "") {
uni.hideKeyboard();
this.refreshData();
}
},
doSearch() {
uni.hideKeyboard()
if (this.searchContent == "") {
this.$alert("请输入关键字");
}
this.refreshData()
},
/*初始化滚动*/
initScroller(scroller) {
this.scroller = scroller;
this.loadData();
},
/*刷新数据*/
refreshData() {
uni.showLoading({
title: '刷新中'
});
this.scroller.resetUpScroll();
},
/*加载数据*/
loadData() {
this.list = [];
this.scroller.resetUpScroll();
},
/*滚动时导航栏浮动*/
navFloatShow(scroller) {
},
//获取列表数据
getData() {
var _self = this;
if (_self.phone == "") {
this.$app.request({
url: this.$api.duty.getMineCertif,
method: 'GET',
data: {
'rows': this.scroller.size,
'page': this.scroller.num,
'keywords': this.searchContent
},
header: {
token: this.token
},
dataType: 'json',
success: res => {
console.log(res)
if (res.rows != undefined) {
if (this.scroller.num == 1) {
this.list = [];
}
var tempList = []
tempList = res.rows
this.list = this.list.concat(tempList);
console.log(this.list)
this.totalNum = res.total
this.scroller.endBySize(res.rows.length, res.total);
this.showPageLoading = false;
} else {
this.scroller.endSuccess();
this.$alert(res.msg);
}
},
fail: res => {
console.log(res)
this.scroller.endErr();
},
complete: res => {
uni.stopPullDownRefresh();
uni.hideLoading();
this.showPageLoading = false;
}
});
} else {
this.$app.request({
url: this.$api.duty.doSearchCerif,
method: 'GET',
data: {
'cardNum': _self.idcard,
'name': _self.userName,
'phone': _self.phone,
'rows': this.scroller.size,
'page': this.scroller.num,
'keywords': this.searchContent
},
dataType: 'json',
success: res => {
console.log(res)
if (res.rows != undefined) {
if (this.scroller.num == 1) {
this.list = [];
}
var tempList = []
tempList = res.rows
this.list = this.list.concat(tempList);
this.totalNum = res.total
this.scroller.endBySize(res.rows.length, res.total);
this.showPageLoading = false;
} else {
this.scroller.endSuccess();
this.$alert(res.msg);
}
},
fail: res => {
console.log(res)
this.scroller.endErr();
},
complete: res => {
uni.stopPullDownRefresh();
uni.hideLoading();
this.showPageLoading = false;
}
});
}
}
}
}
</script>
<style lang="scss">
page {
height: 100%;
background: #F6F6F6;
}
.page {
display: flex;
flex: 1;
flex-direction: column;
overflow: hidden;
height: 100%;
background: #F6F6F6;
}
.content {
flex: 1;
width: 100%;
height: 100rpx;
}
.title-box {
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
padding: 20rpx;
.title {
font-size: 40rpx;
font-weight: 300;
color: black;
}
.name {
font-size: 30rpx;
font-weight: 200;
color: #139847;
}
}
.num-box {
display: flex;
flex-direction: row;
align-items: center;
background: #15A652;
justify-content: flex-start;
box-shadow: 0rpx 7rpx 33rpx 16rpx rgba(188, 226, 204, 0.15);
border-radius: 40rpx;
padding: 65rpx;
margin: 0rpx 20rpx;
image {
width: 40rpx;
height: 40rpx;
}
text {
color: #fff;
font-size: 30rpx;
text-align: center;
width: 85%;
}
}
.content-box {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: flex-start;
padding: 20rpx;
.item {
display: flex;
flex-direction: row;
background: #fff;
width: 95%;
padding: 20rpx;
image {
width: 500rpx;
height: 218rpx;
}
.item-content {
display: flex;
flex-direction: column;
width: 100%;
height: 218rpx;
margin-left: 20rpx;
justify-content: space-between;
.title {
display: -webkit-box;
text-overflow: ellipsis;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
overflow: hidden;
font-size: 27rpx;
font-family: Microsoft YaHei UI;
font-weight: bold;
color: #3A3B3E;
line-height: 52rpx;
}
.time {
font-size: 20rpx;
font-family: Microsoft YaHei UI;
font-weight: 400;
color: #797979;
line-height: 52rpx;
}
.btn {
margin-top: 10rpx;
margin-right: 15rpx;
align-self: flex-end;
background: #53B584;
padding: 0rpx 60rpx;
border-radius: 20rpx;
font-size: 24rpx;
font-family: Microsoft YaHei UI;
font-weight: 400;
color: #FFFFFF;
line-height: 52rpx;
}
}
}
}
/*搜索*/
.search {
display: flex;
justify-content: space-between;
align-items: center;
padding: 35rpx 28rpx 30rpx 35rpx;
.search-content {
background: #f2f2f2;
height: 67rpx;
flex: 1;
display: flex;
align-items: center;
border-radius: 29rpx;
}
input {
font-size: 27rpx;
font-family: Microsoft YaHei;
font-weight: 400;
color: #B3B3B3;
margin-left: 16rpx;
}
.icon {
width: 30rpx;
height: 30rpx;
margin-left: 26rpx;
}
.btn {
color: #b3b3b3;
margin-left: 25rpx;
}
}
</style>