app_tree_planting/pages/duty/activitynewlist.vue
2023-12-13 10:20:14 +08:00

936 lines
20 KiB
Vue

<template>
<view class="page">
<view class="content">
<scroller @init="initScroller" @down="refreshData" @up="getData" :up="optUp"
@scroll="navFloatShow(scroller)" :fixed="true">
<!-- <view class="state-bar" v-if="!fixedSearch">
<image src="../../static/images/ic_arrow_left.png" mode="aspectFill" @click="closePage()"></image>
<text>劳动尽责</text>
</view> -->
<image src="/static/images/ic_activity_new_bg.png" mode="aspectFill" class="swiper-item"></image>
<view class="rule-desc">公民选择劳动参与义务植树,实际劳动工作量按照<全名义务植树尽责形式管理办法(试行)>规定折算植树株数</view>
<view class="explain" @click="openExplain()">尽责形式说明</view>
<view :class="fixedSearch? 'fixed-box':'nofixed-box'">
<!-- <view v-if="fixedSearch" class="hide-state-bar">
<image src="../../static/images/ic_arrow_left_black.png" mode="aspectFill" @click="closePage()">
</image>
<text>劳动尽责</text>
</view> -->
<view class="list-title-box">
<view class="list-title">劳动尽责活动</view>
<view class="list-mine" @click="openMine">我参与的</view>
</view>
<view class="search">
<input type="text" confirm-type="search" @input="onSearchInput" placeholder="请输入要收搜的内容"
@confirm="doSearch" class="search-content" />
<image src="../../static/images/ic_search.png" mode="scaleToFill" class="search-icon"></image>
</view>
</view>
<!-- 列表 -->
<view class="list-box">
<view class="area-box">
<view class="area-title">当前地区:</view>
<!-- <view class="area-content">{{areaName}}</view> -->
<picker mode="selector" :value="areaName" @change="bindChangeArea" :range="areaList"
range-key="areaName">
<view class="area-content">{{areaName}}</view>
</picker>
</view>
<!-- 列表内容 -->
<view class="item" v-for="(item,index) in list" :key="index" @click="openDetail(item.activityId)">
<rich-text class="item-title" :nodes="item.name"></rich-text>
<view class="item-content">
<image :src="imgUrl+item.img" mode="scaleToFill" class="img"></image>
<view class="item-desc">
<view class="item-time">
<text class="title">活动时间:</text>
<text class="content">{{item.startTime}}至{{item.endTime}}</text>
</view>
<view class="item-time">
<text class="title">参与人数:</text>
<view class="content">
<text class="col">{{item.joinedCount}}</text>
<text>/{{item.joinCount}}</text>
</view>
</view>
<view class="item-bottom">
<view class="item-icon">
<image src="../../static/images/ic_location_marker.png" mode="scaleToFill">
</image>
<view class="icon-text">{{item.areaName}}</view>
</view>
<view class="item-status">{{item.status}}</view>
</view>
</view>
</view>
<view class="dotted-line"></view>
</view>
</view>
</scroller>
</view>
</view>
</template>
<script>
import {
mapState,
mapMutations
} from 'vuex';
import scroller from '@/components/scroller/scroller.vue';
export default {
components: {
scroller
},
data() {
return {
currentIndex: 1,
list: [],
list2: [],
scroller: {},
scroller2: {},
optUp: {
auto: true,
onScroll: true,
page: {
num: 0, //当前页 默认0,回调之前会加1; 即callback(page)会从1开始
size: 10 //每页数据条数,默认10
},
empty: {
tip: '暂无数据~'
}
},
token: "",
imgUrl: this.$api.common.imgUrl,
searchContent: "",
fixedSearch: false,
activityType: '',
areaName: '选择地区',
areaList: [],
area: {}
}
},
onLoad(res) {
if (res.index) {
this.currentIndex = res.index
}
if (res.type) {
this.activityType = res.type
}
this.getAreaList()
},
onShow(res) {
this.token = getApp().globalData.token
},
methods: {
...mapMutations(['login']),
tabChange(i) {
this.currentIndex = i;
if (i == 1) {
this.bg = this.bg1
} else {
this.bg = this.bg2
}
if (this.currentIndex == 2) {
if (this.token == "") {
uni.setStorageSync("loginOriginUrl", "/pages/duty/activitylist");
uni.navigateTo({
url: "/pages/user/login"
})
} else {
console.log(this.list2)
this.getData2()
}
}
},
closePage() {
uni.navigateBack()
},
openExplain() {
uni.navigateTo({
url: "/pages/duty/dutyexplain"
})
},
openMine() {
if (this.token == '') {
uni.setStorageSync("loginOriginUrl", "/pages/duty/activitynewlist");
uni.navigateTo({
url: "/pages/user/login"
})
} else {
uni.navigateTo({
url: '/pages/duty/activityminelist'
})
}
},
bindChangeArea(e) {
var index = e.detail.value
this.area = this.areaList[index]
this.areaName = this.areaList[index].areaName
this.refreshData()
},
closePage() {
uni.navigateBack()
},
/*收搜*/
doSearch() {
uni.hideKeyboard()
if (this.searchContent == "") {
this.$alert("请输入关键字");
}
this.refreshData()
},
/*初始化滚动*/
initScroller(scroller) {
this.scroller = scroller;
this.loadData();
},
/*刷新数据*/
refreshData() {
uni.showLoading({
title: '刷新中'
});
this.scroller.resetUpScroll();
},
onSearchInput: function(event) {
this.searchContent = event.target.value
console.log(event.target.value)
if (event.target.value == "") {
uni.hideKeyboard();
this.refreshData();
}
},
/*加载数据*/
loadData() {
this.list = [];
this.scroller.resetUpScroll();
},
/*滚动时导航栏浮动*/
navFloatShow(scroller) {
if (scroller) {
if (scroller.scrollTop > 200) {
if (!this.fixedSearch) {
this.fixedSearch = true;
}
} else {
if (this.fixedSearch) {
this.fixedSearch = false;
}
}
}
},
getAreaList() {
var _self = this
_self.$app.request({
url: _self.$api.common.getAreaByPid + '110889',
method: 'GET',
dataType: 'json',
success: res => {
res.unshift({
areaCode: '',
areaName: '选择地区'
})
this.areaList = res
},
fail: res => {
uni.showToast({
icon: 'error',
title: "系统错误"
})
},
complete: res => {
uni.hideLoading()
}
});
},
//获取列表数据
getData() {
this.$app.request({
url: this.$api.duty.getActivityList,
method: 'GET',
data: {
page: this.scroller.num,
rows: this.scroller.size,
activityType: this.activityType,
keywords: this.searchContent,
areaCode: this.area.areaCode ? this.area.areaCode : '',
},
dataType: 'json',
success: res => {
if (res.rows != undefined) {
if (this.scroller.num == 1) {
this.list = [];
}
var tempList = []
tempList = res.rows
if (tempList.length > 0) {
for (var i = 0; i < tempList.length; i++) {
if (tempList[i].photo) {
var index = tempList[i].photo.indexOf(",")
if (index != -1) {
tempList[i].img = tempList[i].photo.substring(0, index)
} else {
tempList[i].img = tempList[i].photo
}
}
}
this.list = this.list.concat(tempList);
}
this.scroller.endBySize(res.rows.length, res.rows.total);
this.showPageLoading = false;
} else {
this.scroller.endSuccess();
this.$alert(res.msg);
}
},
fail: res => {
this.scroller.endErr();
},
complete: res => {
uni.stopPullDownRefresh();
uni.hideLoading();
}
});
},
//获取列表数据
// getData2() {
// this.$app.request({
// url: this.$api.duty.getMineActivity,
// method: 'GET',
// dataType: 'json',
// header: {
// token: this.token
// },
// success: res => {
// console.log(res.status)
// if (res != undefined && res.status == undefined) {
// for (var i = 0; i < res.length; i++) {
// if (res[i].activityDTO.photo) {
// var index = res[i].activityDTO.photo.indexOf(",")
// if (index != -1) {
// res[i].img = res[i].activityDTO.photo.substring(0, index)
// }
// res[i].img = res[i].activityDTO.photo
// }
// }
// this.list2 = res;
// } else {
// this.list2 = []
// }
// },
// fail: res => {
// uni.showToast({
// icon: "error",
// title: "加载失败"
// })
// },
// complete: res => {}
// });
// },
openDetail(id) {
console.log("跳转")
uni.navigateTo({
url: "/pages/duty/activitydetail?id=" + id + "&type=-1"
})
},
}
}
</script>
<style scoped lang="scss">
page {
height: 100%;
}
.page {
display: flex;
flex: 1;
flex-direction: column;
overflow: auto;
height: 100%;
background: #F5F6FA;
}
.content {
width: 100%;
position: relative;
height: 100%;
}
.swiper-item {
width: 100%;
height: 382rpx;
margin: 0rpx;
}
.rule-desc {
font-size: 31rpx;
font-family: Microsoft YaHei UI;
font-weight: 400;
color: #3A3B3E;
line-height: 53rpx;
padding: 34rpx 32rpx 30rpx 30rpx;
background: #ffffff;
margin-top: -10rpx;
}
.explain {
width: 100%;
margin-top: 27rpx;
background: #ffffff;
padding: 32rpx;
font-size: 27rpx;
font-family: Microsoft YaHei UI;
font-weight: 400;
color: #3A3B3E;
margin-bottom: 32rpx;
}
.area-box {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
padding: 47rpx 0rpx 35rpx 32rpx;
.area-title {
font-size: 24rpx;
font-family: Microsoft YaHei UI;
font-weight: 400;
color: #8A8A8A;
line-height: 52rpx;
}
.area-content {
font-size: 24rpx;
font-family: Microsoft YaHei UI;
font-weight: 400;
color: #696969;
margin-left: 36rpx;
line-height: 52rpx;
background: rgba(231, 231, 231, 0.45);
padding: 10rpx 21rpx 9rpx 18rpx;
}
}
.hide-state-bar {
width: 100%;
height: 100rpx;
display: flex;
flex-direction: row;
align-items: center;
z-index: 10;
color: #000;
image {
width: 50rpx;
height: 50rpx;
margin-left: 20rpx;
}
text {
font-size: 40rpx;
align-self: center;
text-align: center;
width: 100%;
margin-left: -70rpx;
}
}
.list-title-box {
display: flex;
flex-direction: row;
justify-content: space-between;
}
.list-title {
flex: 2;
font-size: 27rpx;
font-weight: 400;
color: #40B344;
background: #ffffff;
line-height: 52rpx;
padding: 31rpx;
}
.list-mine {
flex: 1;
padding: 31rpx;
background: white;
margin-left: 18rpx;
font-size: 27rpx;
font-weight: 400;
color: #393A3D;
line-height: 52rpx;
font-family: Microsoft YaHei UI;
}
.fixed-box {
position: fixed;
top: 0;
left: 0;
width: 100%;
padding-top: 40rpx;
background: #f4f4f4;
z-index: 10;
padding-bottom: 10rpx;
}
.nofixed-box {
position: static;
}
.box {
display: flex;
flex-direction: column;
justify-content: flex-start;
height: 100%;
width: 98%;
position: absolute;
top: 170rpx;
left: 50%;
transform: translate(-50%, 0);
-webkit-transform: translate(-50%, 0);
box-shadow: 0rpx 7rpx 33rpx 16rpx rgba(188, 226, 204, 0.15);
border-radius: 30rpx;
.title-img {
width: 443rpx;
height: 203rpx;
align-self: center;
}
.title-text {
color: white;
text-align: center;
align-self: center;
display: flex;
flex-direction: column;
font-size: 30rpx;
font-weight: 400;
}
}
.tab-bar {
width: 100%;
display: flex;
flex-direction: row;
justify-content: space-around;
padding-top: 15rpx;
.tab-active {
text-align: center;
font-size: 40rpx;
font-weight: bold;
color: #00821E;
}
.tab-default {
text-align: center;
font-size: 40rpx;
font-weight: 200;
color: #00821E;
}
}
.title-box {
width: 100%;
height: 800rpx;
background-image: url('../../static/images/ic_activity_bg.png');
background-size: 100% 100%;
background-repeat: no-repeat;
}
.state-bar {
position: fixed;
top: 0;
left: 0;
width: 100%;
margin: 45rpx 0rpx;
height: 100rpx;
display: flex;
flex-direction: row;
align-items: center;
z-index: 10;
color: white;
image {
width: 50rpx;
height: 50rpx;
margin-left: 20rpx;
}
text {
font-size: 40rpx;
align-self: center;
text-align: center;
width: 100%;
margin-left: -70rpx;
}
}
.container-box {
display: flex;
flex-direction: column;
background-color: white;
justify-content: center;
align-items: flex-start;
margin: 20rpx;
padding: 30rpx 0rpx;
border-top-left-radius: 30rpx;
border-top-right-radius: 30rpx;
height: 100%;
.area-box {
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-start;
margin: 30rpx;
.area-title {
font-size: 30rpx;
color: #747474;
}
.area-picker {
background-color: #E8F6EE;
margin-left: 20rpx;
color: #b3b3b3;
padding: 10rpx 30rpx;
}
}
}
/*搜索*/
.search {
position: relative;
display: flex;
flex-direction: row;
align-items: center;
margin: 19rpx 29rpx 0rpx 30rpx;
align-self: center;
background: #FFFFFF;
box-shadow: 9rpx 13rpx 27rpx 5rpx rgba(140, 140, 140, 0.17);
border-radius: 31rpx;
.search-content {
margin: 18rpx 0rpx 18rpx 39rpx;
flex: 1;
display: flex;
align-items: center;
// font-size: 30rpx;
// font-family: PingFang SC;
// font-weight: 400;
// color: rgba(153, 153, 153, 0.58);
// line-height: 52rpx;
font-size: 20rpx;
font-family: Microsoft YaHei UI;
font-weight: 400;
color: rgba(138, 138, 138, 0.58);
line-height: 52rpx;
}
/deep/.input {
color: #8cc7b5;
}
.search-icon {
width: 38rpx;
height: 38rpx;
margin-right: 35rpx;
}
}
.list-box {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: flex-start;
height: 100%;
background: #ffffff;
.item {
display: flex;
flex-direction: column;
background: white;
justify-content: center;
align-items: flex-start;
box-sizing: border-box;
width: 100%;
.dotted-line {
border-bottom: 2rpx dashed #C7C7C7;
width: 88%;
margin: 35rpx 0rpx 35rpx 0rpx;
align-self: center;
}
.item-title {
display: -webkit-box;
text-overflow: ellipsis;
word-break: break-all;
-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;
margin: 0rpx 25rpx 26rpx 39rpx;
}
.item-content {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
box-sizing: border-box;
width: 100%;
.img {
width: 203rpx;
height: 147rpx;
border-radius: 13rpx;
margin-left: 39rpx;
}
.item-desc {
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
width: calc(100% - 203rpx);
margin-left: 28rpx;
height: 147rpx;
.item-time {
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
width: 100%;
.title {
font-size: 24rpx;
font-family: Microsoft YaHei UI;
font-weight: 400;
color: #8A8A8A;
line-height: 52rpx;
flex-shrink: 0;
flex: 0.3;
}
.content {
font-size: 24rpx;
font-family: Microsoft YaHei UI;
font-weight: 400;
color: #8A8A8A;
line-height: 52rpx;
flex-shrink: 0;
flex: 0.7;
.col {
color: #40B344;
}
}
}
.item-bottom {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
width: 100%;
.item-icon {
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
width: calc(100% - 130rpx);
image {
width: 26rpx;
height: 29rpx;
}
.icon-text {
font-size: 24rpx;
font-family: Microsoft YaHei UI;
font-weight: 400;
color: #4A4949;
line-height: 52rpx;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;
overflow: hidden;
text-overflow: ellipsis;
}
}
.item-status {
width: 130rpx;
height: 40rpx;
font-size: 24rpx;
color: #00821E;
text-align: center;
border: 1rpx solid #00821E;
line-height: 40rpx;
margin-right: 45rpx;
}
}
}
}
}
}
// .activity-item-box {
// width: 163rpx;
// height: 163rpx;
// position: relative;
// .activity-item-num {
// color: white;
// background: #0DB77E;
// width: fit-content;
// max-width: fit-content;
// padding: 0rpx 10rpx;
// border-top-right-radius: 20rpx;
// border-bottom-right-radius: 20rpx;
// position: absolute;
// top: 15rpx;
// font-size: 18rpx;
// left: 0;
// z-index: 2;
// }
// .img {
// width: 163rpx;
// height: 163rpx;
// position: relative;
// top: 0;
// border-radius: 10rpx;
// }
// }
// .activity-content {
// display: flex;
// flex-direction: column;
// justify-content: space-between;
// align-items: flex-start;
// margin-left: 21rpx;
// height: 163rpx;
// .activity-time {
// font-size: 24rpx;
// font-family: Microsoft YaHei UI;
// font-weight: 400;
// color: #A8A8A8;
// line-height: 52rpx;
// }
// .activity-desc {
// display: -webkit-box;
// text-overflow: ellipsis;
// word-break: break-all;
// -webkit-line-clamp: 1;
// -webkit-box-orient: vertical;
// overflow: hidden;
// font-size: 24rpx;
// font-family: Microsoft YaHei UI;
// font-weight: 400;
// color: #707070;
// line-height: 52rpx;
// }
// }
// .activity-item {
// display: flex;
// flex-direction: row;
// justify-content: flex-start;
// align-items: flex-start;
// padding: 20rpx 40rpx;
// .activity-img {
// width: 163rpx;
// height: 163rpx;
// min-width: 163rpx;
// min-height: 163rpx;
// }
// }
.empty-data {
align-items: center;
align-self: center;
}
// .item-type {
// display: flex;
// flex-direction: row;
// .type-theme {
// display: -webkit-box;
// background: #ECFFF9;
// font-size: 28rpx;
// padding: 0rpx 15rpx;
// margin-left: 10rpx;
// text-overflow: ellipsis;
// word-break: break-all;
// text-align: center;
// -webkit-line-clamp: 1;
// -webkit-box-orient: vertical;
// overflow: hidden;
// font-size: 20rpx;
// font-family: Microsoft YaHei UI;
// font-weight: 400;
// color: #12D577;
// line-height: 52rpx;
// }
// .type-type {
// display: -webkit-box;
// background: #E9F7FF;
// text-overflow: ellipsis;
// word-break: break-all;
// text-align: center;
// -webkit-line-clamp: 1;
// -webkit-box-orient: vertical;
// overflow: hidden;
// padding: 0rpx 15rpx;
// font-size: 20rpx;
// font-family: Microsoft YaHei UI;
// font-weight: 400;
// color: #009FFF;
// line-height: 52rpx;
// }
// }
</style>