| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 |
- <template>
- <view class="container">
- <!-- 顶部区域 -->
- <view class="top">
- <view class="top_search">
- <uni-icons type="search" size="30" color="#999999"></uni-icons>
- <input class="input" type="text" placeholder="请输入活动关键字" v-model="inputValue" @blur="handleBlur" />
- </view>
- <view class="top_btn" @click="handleSet">
- <uni-icons type="plus" size="20" color="#fff"></uni-icons>
- <view class="btn_text">发起活动</view>
- </view>
- </view>
- <!-- 分段器区域 -->
- <view class="control">
- <common-controlTag :tagList="tagList" type="between" @change="handleChange"></common-controlTag>
- </view>
- <!-- 活动列表区域 -->
- <view class="list">
- <!-- 每一个活动区域 -->
- <view class="list_box" v-for="item in dataList" :key="item.id" @click="clickItem(item.id)">
- <view class="box_top">
- <img v-if="item.poster" class="img" :src="item.poster" mode="aspectFill" />
- <img v-else class="img" src="@/static/images/3.png" mode="aspectFill" />
- <view class="top_msg">
- <view class="msg_title">{{ item.theme }}</view>
- <view class="msg_name">{{ item.orgName }}</view>
- <view class="">{{ item.startTime }} 至 {{ item.endTime }}</view>
- </view>
- </view>
- <view v-if="item.activityStatuName == 1" class="box_bottom nostart">活动未开始</view>
- <view v-if="item.activityStatuName == 2" class="box_bottom on">活动进行中</view>
- <view v-if="item.activityStatuName == 3" class="box_bottom off">活动已结束</view>
- </view>
- <!-- 没有数据时展示的页面 -->
- <noData v-if="!dataList.length"></noData>
- </view>
- </view>
- </template>
- <script setup>
- import { onLoad, onReachBottom } from '@dcloudio/uni-app'
- import { ref } from 'vue'
- import { getActivityPages } from '@/api/index.js'
- const tagList = ['全部', '未开始', '进行中', '已结束']
- // 搜索框绑定数据
- const inputValue = ref('')
- // 分段器当前索引
- const currentIndex = ref(0)
- // 当前页
- const currentPage = ref(1)
- // 每页多少条
- const pageCount = ref(6)
- // 总条数
- const total = ref(0)
- // 列表数据
- const dataList = ref([])
- onLoad(() => {
- // 获取活动分页数据
- getData()
- })
- // 页面触底触发回调
- onReachBottom(() => {
- if (total.value > dataList.value.length) {
- currentPage.value++
- getData()
- } else {
- uni.showToast({
- title: '没有更多数据了~~',
- icon: 'none'
- })
- }
- })
- // 获取活动分页数据
- const getData = async () => {
- let data = {
- currentPage: currentPage.value,
- pageCount: pageCount.value,
- statuId: currentIndex.value,
- theme: inputValue.value
- }
- const res = await getActivityPages(data)
- // console.log(res)
- dataList.value = [...dataList.value, ...res.data.list]
- total.value = res.data.totalCount
- }
- // 切换分段器回调
- const handleChange = (e) => {
- // console.log(e)
- currentIndex.value = e
- currentPage.value = 1
- dataList.value = []
- getData()
- }
- // 输入框失去焦点回调 搜索回调
- const handleBlur = () => {
- currentPage.value = 1
- dataList.value = []
- getData()
- }
- // 点击发起活动按钮回调
- const handleSet = () => {
- uni.navigateTo({
- url: '/pages/set_act/set_act'
- })
- }
- // 点击每一个活动的回调
- const clickItem = (id) => {
- uni.navigateTo({
- url: `/pages/act_detail/act_detail?id=${id}`
- })
- }
- </script>
- <style lang="scss" scoped>
- .container {
- padding: 20rpx 18rpx;
- min-height: 100vh;
- font-size: 28rpx;
- .top {
- display: flex;
- justify-content: space-between;
- .top_search {
- display: flex;
- align-items: center;
- padding: 0 25rpx;
- width: 491rpx;
- height: 80rpx;
- border-radius: 145rpx;
- border: 2rpx solid #e5e5e5;
- background-color: #f5f5f5;
- .input {
- margin-left: 20rpx;
- font-size: 28rpx;
- }
- }
- .top_btn {
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 18rpx;
- width: 196rpx;
- height: 70rpx;
- color: #fff;
- font-size: 20rpx;
- border-radius: 68rpx;
- background-color: #007aff;
- .btn_text {
- margin-left: 10rpx;
- }
- }
- }
- .control {
- margin-top: 15rpx;
- }
- .list {
- margin-top: 20rpx;
- .list_box {
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- padding: 30rpx 25rpx;
- margin-bottom: 20rpx;
- width: 714rpx;
- height: 344rpx;
- border-radius: 28rpx;
- box-shadow: 0 4rpx 35rpx #d3d3d3;
- background-color: #fff;
- .box_top {
- display: flex;
- justify-content: space-between;
- .img {
- margin-right: 24rpx;
- width: 249rpx;
- height: 168rpx;
- border-radius: 8rpx;
- }
- .top_msg {
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- flex: 1;
- font-size: 24rpx;
- color: #808080;
- overflow: hidden;
- .msg_title {
- font-size: 28rpx;
- font-weight: bold;
- color: #000;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- overflow: hidden;
- }
- .msg_name {
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- }
- }
- .box_bottom {
- display: flex;
- justify-content: center;
- align-items: center;
- width: 661rpx;
- height: 80rpx;
- border-radius: 8rpx;
- }
- .on {
- color: #fff;
- background-color: #007aff;
- }
- .off {
- color: #a6a6a6;
- background-color: #e5e5e5;
- }
- .nostart {
- color: #fff;
- background-color: #007aff;
- opacity: 0.3;
- }
- }
- }
- }
- </style>
|