active.vue 3.66 KB
<template>
	<view>
		<view class="search-area">
			<uni-easyinput prefixIcon="search" v-model="query.activityName" placeholder="搜索活动名称"
			 @clear="getList" @change="getList">
			</uni-easyinput>
		</view>
		<view class="imageFlowBox">
			<view class="imageFlow">
				<view v-for="(b,index) in alist" :key="b.activityId" @click="goDetail(b)">
					<image mode="aspectFit" :src="config.baseUrl_api+b.activityPic" class="cover"></image>
				</view>
			</view>
		</view>
		<view class="tbar">
			全部活动
		</view>
		<view class="list">
			<view class="acitem" v-for="n in list" :key="n.activityId" @click="goDetail(n)">
				<view class="acbody">
					<image :src="config.baseUrl_api+n.activityPic" mode="aspectFit"></image>
					<view class="info">
						<view class="tt">{{n.activityName}}</view>
						<view class="pp">
							<uni-icons type="notification" size="12" />
							{{n.startTime}} ~ {{n.endTime}}
						</view>
						<view class="pp mt20">
							<uni-icons type="location" size="12" />
							{{n.address}}
						</view>
						<view class="text-warning" v-if="n.isFree==1">金币{{n.allGold}}/积分{{n.allScore}}</view>
						<view class="text-warning" v-else>免费</view>
					</view>
				</view>
				<view class="acfoot">
					<view>
						<!-- <uni-icons type="person" size="12"></uni-icons> -->
						<!-- 已有 222人报名参加 -->
					</view>
					<button class="btn btn1">我要报名</button>
				</view>
			</view>
		</view>
		<view class="nodata" v-if="list.length==0">
			<image mode="aspectFit" src="/static/nodata.png"></image>
		</view>
	</view>
</template>

<script setup>
	import {
		onLoad,
		onShow,onShareAppMessage
	} from '@dcloudio/uni-app';
	import config from '@/config.js';
	import {
		ref,
		getCurrentInstance
	} from 'vue';
	import * as api from '@/common/api.js';
	const list = ref([])
	const alist = ref([])
	const query = ref({
		activityName: ''
	})
	const system = uni.getStorageSync('systemType');
	onShow(() => {
		init()
	})
	function init() {
		uni.showLoading({
			title: `加载中`
		})
		getList()
		getHotList()
	}
	function getHotList(){
		api.getHomePageHotActive().then(res => {
			alist.value = res.data
			uni.hideLoading()
		})
	}
	function getList() {
		api.getActivityList(query.value).then(res => {
			list.value = res.rows
			uni.hideLoading()
		})
	}

	function goDetail(item) {
		let path = `/course/activeDetail?id=${item.activityId}`;
		uni.navigateTo({
			url: path
		});

	}
</script>
<style lang="scss" scoped>
	.imageFlowBox {
		position: relative;
		height: 300rpx;
		overflow: auto;
	}

	.imageFlow {
		display: flex;
		position: absolute;
		left: 0;
		padding: 0 10rpx;

		&>view {
			border-radius: 10px;
			overflow: hidden;
			width: 630rpx;
			height: 300rpx;
			margin: 0 10rpx;
			position: relative;
		}

		image {
			width: 630rpx;
			height: 300rpx;
		}

		.info {
			position: absolute;
			color: #fff;
			top: 0;
			width: 100%;
			height: 100%;
			padding: 30rpx 40rpx;
			overflow: hidden;
			box-sizing: border-box;

			.name {
				font-size: 34rpx;
				color: #fff;
				padding-bottom: 20rpx;
				margin-bottom: 20rpx;
				border-bottom: 1px solid RGBA(255, 255, 255, 0.7);
			}
		}

		.esp_2 {
			font-size: 28rpx;
			margin-bottom: 26rpx;
		}

		.timeblock {
			background: rgba(27, 27, 27, 0.1);
			border-radius: 25rpx;
			font-size: 22rpx;
			padding: 12rpx 17rpx;
			display: inline-flex;
			align-items: center;

			image {
				width: 28rpx;
				height: 28rpx;
				margin-left: 22rpx;
			}
		}

	}

	.list {
		padding: 24rpx 0 0 24rpx;
		overflow: hidden;
	}
</style>