app_tree_planting/pages/user/mine_duty_certif.vue

328 lines
7.0 KiB
Vue
Raw Normal View History

2023-02-01 19:25:51 +08:00
<template>
<view class="page">
<view class="title-box">
<text class="title">Hi,</text>
<text class="name">{{userName}}</text>
</view>
<view class="content">
<!-- 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">
2023-02-17 18:13:06 +08:00
<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.activityDTO.startTime}}</view>
2023-02-01 19:25:51 +08:00
<view class="btn">查看</view>
</view>
</view>
</view>
2023-02-17 18:13:06 +08:00
<!-- <view v-else>
<emptyView></emptyView>
</view> -->
2023-02-01 19:25:51 +08:00
</scroller>
</view>
2023-02-17 18:13:06 +08:00
2023-02-01 19:25:51 +08:00
<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,
2023-02-17 18:13:06 +08:00
list: [],
phone: "",
idcard: "",
token: "",
imgUrl: this.$api.common.imgUrl
2023-02-01 19:25:51 +08:00
}
},
2023-02-17 18:13:06 +08:00
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;
}
},
2023-02-01 19:25:51 +08:00
methods: {
2023-02-17 18:13:06 +08:00
showImg(fileId) {
if (fileId != "") {
var _self = this;
var url = _self.imgUrl + fileId
uni.previewImage({
urls: [url]
})
} else {
uni.showToast({
icon: "error",
title: "证书有误"
})
}
},
2023-02-01 19:25:51 +08:00
/*初始化滚动*/
initScroller(scroller) {
this.scroller = scroller;
this.loadData();
},
/*刷新数据*/
refreshData() {
uni.showLoading({
title: '刷新中'
});
this.scroller.resetUpScroll();
},
/*加载数据*/
loadData() {
this.list = [];
this.scroller.resetUpScroll();
},
/*滚动时导航栏浮动*/
navFloatShow(scroller) {
},
//获取列表数据
getData() {
2023-02-17 18:13:06 +08:00
var _self = this;
if (_self.phone == "") {
this.$app.request({
url: this.$api.duty.getMineCertif,
method: 'GET',
data: {
'rows': this.scroller.num,
'page': this.scroller.page,
},
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.num,
'page': this.scroller.page,
},
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;
}
});
}
2023-02-01 19:25:51 +08:00
}
}
}
</script>
<style lang="scss">
page {
height: 100%;
}
.page {
display: flex;
flex: 1;
flex-direction: column;
overflow: hidden;
height: 100%;
}
.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;
border-radius: 10rpx;
margin: 20rpx 0rpx;
width: 100%;
box-shadow: 0rpx 7rpx 33rpx 16rpx rgba(188, 226, 204, 0.15);
image {
2023-02-17 18:13:06 +08:00
width: 261rpx;
height: 182rpx;
2023-02-01 19:25:51 +08:00
}
.item-content {
display: flex;
flex-direction: column;
width: 100%;
padding: 20rpx 15rpx;
.title {
font-size: 30rpx;
display: -webkit-box;
text-overflow: ellipsis;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
overflow: hidden;
color: #000;
}
.time {
font-size: 20rpx;
color: #646464;
margin-top: 10rpx;
}
.btn {
font-size: 20rpx;
2023-02-17 18:13:06 +08:00
color: #ffffff;
margin-top: 10rpx;
margin-right: 15rpx;
2023-02-01 19:25:51 +08:00
align-self: flex-end;
2023-02-17 18:13:06 +08:00
background: #139847;
padding: 0rpx 60rpx;
border-radius: 20rpx;
2023-02-01 19:25:51 +08:00
}
}
}
}
</style>