Преглед изворни кода

feat:添加相册弹窗和等级升级弹窗,添加日记02、03模版

wangsisi пре 1 месец
родитељ
комит
0348a626e1

+ 1 - 1
components/guardSuccessPopup/guardSuccessPopup.vue

@@ -1,5 +1,5 @@
 <template>
-	<up-popup :show="showPopup" @close="handleClose" mode="center" bgColor="transparent" overlayOpacity="0.75">
+	<up-popup :show="showPopup" @close="handleClose" mode="center" bgColor="transparent" overlayOpacity="0.8">
 		<view class="success-popup">
 			<view class="success-title">恭喜你,已守护成功!</view>
 			<view class="success-content">

+ 145 - 0
components/levelSuccessPopup/levelSuccessPopup.vue

@@ -0,0 +1,145 @@
+<template>
+	<up-popup :show="showPopup" mode="center" @close="handleClose" bgColor="transparent" overlayOpacity="0.8">
+		<view class="level-popup" @click="handleClose">
+			<image class="medal-icon" :src="`${config.BASIC_IMG}img/medal-icon-1.png`"></image>
+			<view class="level-cont">
+				<view class="level-text">
+					<view class="text">V1-青铜等级</view>
+					<text>您的能量已达到 100分</text>
+				</view>
+				<view class="award-cont">
+					<view class="title">奖励明细</view>
+					<view class="gift">
+						<image class="icon" :src="`${config.BASIC_IMG}img/biscuits.png`"></image>
+						<text>曲奇饼干兑换券一份</text>
+					</view>
+					<view class="tips">
+						已发放到 <text>个人中心-优惠券</text>
+					</view>
+				</view>
+				<view class="button-group">
+					<view class="btn">开心收下</view>
+					<up-icon class="close" name="close-circle-fill" size="30" color="rgba(255, 255, 255, 0.7)"></up-icon>
+				</view>
+			</view>
+		</view>
+	</up-popup>>
+</template>
+
+<script setup>
+	import config from "@/api/config.js"
+	import {
+		ref,
+		watch
+	} from "vue";
+	
+	const props = defineProps({
+		show: {
+			type: Boolean,
+			defalut: false,
+		},
+	});
+	
+	const showPopup = ref(false);
+	const handleClose = ()=>{
+		showPopup.value = false
+	}
+	
+	watch(
+		() => props.show,
+		() => {
+			showPopup.value = true;
+		}
+	);
+</script>
+
+<style lang="scss" scoped>
+.level-popup{
+	width: 100vw;
+	.medal-icon{
+		min-width: 750rpx;
+		height: 750rpx;
+	}
+	.level-cont{
+		margin-top: -200rpx;
+		.level-text{
+			text-align: center;
+			font-size: 28rpx;
+			color: #fff;
+			
+			.text{
+				font-size: 52rpx;
+				font-family: 'PangMenZhengDao';
+			}
+		}
+		.award-cont{
+			text-align: center;
+			.title{
+				font-size: 28rpx;
+				margin: 46rpx 0;
+				color: #fff;
+				position: relative;
+				&::before{
+					content: '';
+					position: absolute;
+					top: 50%;
+					left: calc(50% - 168rpx);
+					width: 100rpx;
+					height: 2rpx;
+					background-image: linear-gradient(90deg,#000,#fff);
+				}
+				&::after{
+					content: '';
+					position: absolute;
+					top: 50%;
+					right: calc(50% - 168rpx);
+					width: 100rpx;
+					height: 2rpx;
+					background-image: linear-gradient(90deg,#fff,#000);
+				}
+			}
+			.gift{
+				margin: 20rpx auto;
+				font-family: 'PangMenZhengDao';
+				background: rgba(255, 255, 255, 0.26);
+				border-radius: 10rpx;
+				color: #fff;
+				width: 472rpx;
+				padding: 14rpx 0;
+				display: flex;
+				align-items: center;
+				justify-content: center;
+				.icon{
+					width: 108rpx;
+					height: 74rpx;
+					margin-right: 20rpx;
+				}
+			}
+			.tips{
+				font-size: 24rpx;
+				color: #999999;
+				text{
+					color: #EE8F00;
+				}
+			}
+		}
+		.button-group {
+			margin: 64rpx auto;
+			width: 312rpx;
+			.btn {
+				font-size: 44rpx;
+				padding: 20rpx 0;
+				border-radius: 50rpx;
+				font-family: "PangMenZhengDao";
+				color: #954600;
+				background: linear-gradient(120deg, #FFE6B2, #FFC339);
+				text-align: center;
+			}
+			.close{
+				margin-top: 64rpx;
+				justify-content: center;
+			}
+		}
+	}
+}
+</style>

+ 171 - 0
pages/tabBar/tree/components/treeAlbumPopup.vue

@@ -0,0 +1,171 @@
+<template>
+	<up-popup :show="showPopup" mode="center" round="20" @close="handleClose">
+		<view class="album-popup">
+			<view class="album-title">
+				<view class="name">
+					果树相册
+					<view class="sub-name">无人机实时监测生长情况</view>
+				</view>
+				<image class="icon" :src="`${config.BASIC_IMG}img/treePage/drone-icon-popup.png`"></image>
+			</view>
+			<view class="album-cont">
+				<view class="time-line">
+					<view class="time-item" v-for="item in 6" :key="item">
+						<text :style="{color:item==6?'#2199F8':'#DBDBDB'}">07/28</text>
+						<view class="dot" :style="{background:item==6?'#2199F8':'#DBDBDB'}"></view>
+						<text class="today" v-if="item==6">今</text>
+					</view>
+				</view>
+				<view class="swiper-wrap">
+					<swiper class="swiper">
+						<swiper-item v-for="(item,index) in list1">
+							<image class="img" :src="item"></image>
+						</swiper-item>
+					</swiper>
+					<view class="arrow left">
+						<up-icon name="arrow-left" bold color="#F0D09C" size="22"></up-icon>
+					</view>
+					<view class="arrow right">
+						<up-icon name="arrow-right" bold color="#F0D09C" size="22"></up-icon>
+					</view>
+				</view>
+			</view>
+		</view>
+	</up-popup>
+</template>
+
+<script setup>
+	import config from "@/api/config.js"
+	import {
+		ref,
+		watch
+	} from "vue";
+
+	const props = defineProps({
+		show: {
+			type: Boolean,
+			defalut: false,
+		},
+	});
+	
+	const showPopup = ref(false);
+	const handleClose = ()=>{
+		showPopup.value = false
+	}
+	const list1 = ref([
+		'https://cdn.uviewui.com/uview/album/1.jpg',
+		'https://cdn.uviewui.com/uview/album/2.jpg',
+		'https://cdn.uviewui.com/uview/album/3.jpg',
+	]);
+	
+	watch(
+		() => props.show,
+		() => {
+			showPopup.value = true;
+		}
+	);
+</script>
+
+<style lang="scss" scoped>
+	.album-popup {
+		width: 92vw;
+
+		.album-title {
+			padding: 30rpx 0 46rpx 30rpx;
+			position: relative;
+			background-image: linear-gradient(120deg, #79C4FF 13%, #FFFFFF 66%);
+			border-radius: 40rpx 40rpx 0 0;
+			line-height: 44rpx;
+
+			.name {
+				color: #004275;
+				font-size: 48rpx;
+				font-family: 'PangMenZhengDao';
+
+				.sub-name {
+					font-size: 24rpx;
+				}
+			}
+
+			.icon {
+				position: absolute;
+				top: -100rpx;
+				right: -26rpx;
+				width: 364rpx;
+				height: 300rpx;
+			}
+		}
+
+		.album-cont {
+			position: relative;
+			z-index: 2;
+			margin-top: -34rpx;
+			padding: 32rpx 0 20rpx;
+			background: #fff;
+			border-radius: 40rpx;
+			.time-line{
+				margin-bottom: 16rpx;
+				display: flex;
+				.time-item{
+					flex: 1;
+					font-size: 24rpx;
+					color: #DBDBDB;
+					display: flex;
+					flex-direction: column;
+					align-items: center;
+					position: relative;
+					&::before{
+						content: '';
+						position: absolute;
+						top: 44%;
+						width: 100%;
+						height: 2rpx;
+						background: rgba(136, 136, 136, 0.1);
+					}
+					
+					.dot{
+						width: 14rpx;
+						height: 14rpx;
+						background: #DBDBDB;
+						border-radius: 50%;
+					}
+					.today{
+						color: #2199F8;
+						margin-top: 8rpx;
+					}
+				}
+			}
+			.swiper-wrap{
+				position: relative;
+				padding: 0 20rpx;
+				.swiper {
+					width: 100%;
+					height: 496rpx;
+					
+					.img{
+						width: 100%;
+						height: 100%;
+						border-radius: 16rpx;
+					}
+				}
+				.arrow{
+					position: absolute;
+					top: calc(50% - 40rpx);
+					width: 80rpx;
+					height: 80rpx;
+					display: flex;
+					align-items: center;
+					justify-content: center;
+					border-radius: 50%;
+					background: rgba(0, 0, 0, .6);
+				}
+				.left{
+					left: 32rpx;
+				}
+				.right{
+					right: 32rpx;
+				}
+			}
+		}
+	}
+</style>

+ 119 - 13
pages/tabBar/tree/subPages/diary.vue

@@ -28,31 +28,49 @@
 			<view class="diary-head">
 				<view class="date" @click="handleDate">
 					<image class="img" :src="`${config.BASIC_IMG}img/subTreePage/date-icon.png`"></image>
-					<text>2025年7月28日</text>
+					<text>{{formatDate(dateVal)}}</text>
 				</view>
 				<view class="arrow-group">
-					<view class="arrow-icon">
+					<view class="arrow-icon" @click="changeDay(-1)">
 						<up-icon name="arrow-left" size="17" bold color="#fff"></up-icon>
 					</view>
-					<view class="arrow-icon">
+					<view class="arrow-icon" @click="changeDay(+1)">
 						<up-icon name="arrow-right" size="17" bold color="#fff"></up-icon>
 					</view>
 				</view>
 			</view>
 			<view class="diary-cont">
-				<view class="text">今天是我开花的日子今天是我开花的日子今天是我开花的日子今天是我开花的日子</view>
-				<view class="photo">
-					<image class="img" src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"></image>
+				<template v-if="active === 0">
+					<view class="text">今天是我开花的日子今天是我开花的日子今天是我开花的日子今天是我开花的日子</view>
+					<view class="photo">
+						<image class="img" src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"></image>
+					</view>
+				</template>
+				<view class="template-1" v-else-if="active === 1">
+					<view class="photo-group">
+						<image class="img" src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"></image>
+						<image class="img float" src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"></image>
+					</view>
+					<view class="text">今天是我开花的日子今天是我开花的日子今天是我开花的日子今天是我开花的日子</view>
+				</view>
+				<view class="template-2" v-else="active === 2">
+					<view class="photo-group">
+						<image class="img" src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"></image>
+						<image class="img float" src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"></image>
+					</view>
+					<view class="text">今天是我开花的日子今天是我开花的日子今天是我开花的日子今天是我开花的日子</view>
 				</view>
 			</view>
 		</view>
 	</view>
 	<up-datetime-picker
 		:show="showDatetim"
-		v-model="date"
+		v-model="dateVal"
 		mode="date"
+		:maxDate="Date.now()"
+		:formatter="formatter"
 		@cancel="cancel"
-		@confirm="cancel"
+		@confirm="confirm"
 	></up-datetime-picker>
 </template>
 
@@ -60,15 +78,56 @@
 	import config from "@/api/config.js"
 	import {ref} from "vue"
 	
+	function formatDate(timestamp,type) {
+	  const date = new Date(timestamp);
+	  const year = date.getFullYear();
+	  const month = String(date.getMonth() + 1)
+	  const day = String(date.getDate()).padStart(2, '0');         // 日期补零
+	  return `${year}${type || '年'}${month}${type || '月'}${day}${type?'':'日'}`;
+	}
+	
+	const currentDate = ref(new Date())
+	function changeDay(type) {
+		currentDate.value = new Date(currentDate.value);
+		currentDate.value.setDate(currentDate.value.getDate() + type);
+		if(currentDate.value > new Date()){
+			currentDate.value.setDate(currentDate.value.getDate() - 1);
+			return
+		}
+		dateVal.value = Date.parse(currentDate.value);
+		//获取 0-2 的随机整数
+		const randomInt = Math.floor(Math.random() * 3);
+		active.value = randomInt
+	}
+	
 	const showDatetim = ref(false)
-	const date = ref('')
+	const dateVal = ref(Date.now())
 	
 	const handleDate = () =>{
 		showDatetim.value = true
 	}
 	const cancel = () =>{
 		showDatetim.value = false
-	}
+	}
+	const confirm = ()=>{
+		const aaa = formatDate(date.value,'-')
+		console.log(date.value,aaa)
+		cancel()
+	}
+	
+	const active = ref(2)
+	const formatter = (type, value) => {
+	  if (type === 'year') {
+	    return `${value}年`;
+	  }
+	  if (type === 'month') {
+	    return `${value}月`;
+	  }
+	  if (type === 'day') {
+	    return `${value}日`;
+	  }
+	  return value;
+	};
 </script>
 
 <style lang="scss" scoped>
@@ -128,7 +187,7 @@
 			width: 100%;
 			min-height: 960rpx;
 			box-sizing: border-box;
-			padding: 70rpx 0 56rpx 34rpx;
+			padding: 70rpx 0 56rpx 30rpx;
 			@include ossBg("subTreePage/diary-bg.png");
 			.diary-head{
 				display: flex;
@@ -162,10 +221,10 @@
 				}
 			}
 			.diary-cont{
-				padding: 120rpx 60rpx 0 26rpx;
+				padding: 80rpx 60rpx 0 26rpx;
 				.text{
 					width: 72%;
-					margin: auto;
+					margin: 60rpx auto;
 					font-weight: 500;
 					position: relative;
 					&::before{
@@ -209,6 +268,53 @@
 						object-fit: cover;
 					}
 				}
+				.template-1{
+					.photo-group{
+						margin:0 -14rpx 240rpx 10rpx;
+						.img{
+							width: 354rpx;
+							height: 240rpx;
+							border: 10rpx solid rgba(255, 255, 255, 0.6);
+							box-shadow:  0 4rpx 8rpx 0 rgba(0, 0, 0, 0.1);
+						}
+						.float{
+							width: 400rpx;
+							height: 264rpx;
+							float: right;
+							margin-top: -130rpx;
+						}
+					}
+					.text{
+						width: 55%;
+						margin: 0 auto;
+					}
+				}
+				.template-2{
+					.photo-group{
+						margin:0 -10rpx 220rpx 10rpx;
+						.img{
+							position: relative;
+							z-index: 2;
+							width: 440rpx;
+							height: 300rpx;
+							border: 10rpx solid rgba(255, 255, 255, 0.3);
+							box-shadow:  0 4rpx 8rpx 0 rgba(0, 0, 0, 0.1);
+						}
+						.float{
+							width: 332rpx;
+							height: 222rpx;
+							float: right;
+							margin-top: -100rpx;
+							transform: rotate(10deg);
+							position: relative;
+							z-index: 1;
+						}
+					}
+					.text{
+						width: 66%;
+						margin: 0 auto;
+					}
+				}
 			}
 		}
 	}

+ 14 - 5
pages/tabBar/tree/tree.vue

@@ -38,13 +38,18 @@
 	<!-- 海报弹窗 -->
 	<posterPopup :showPoster="showPoster"></posterPopup>
 	<!-- 果树成功弹窗 -->
-	<guardSuccessPopup :show="showGuardSuccess"></guardSuccessPopup>
+	<guardSuccessPopup :show="showGuardSuccess"></guardSuccessPopup>
+	<!-- 果树相册弹窗 -->
+	<tree-album-popup :show="showAlbum"></tree-album-popup>
+	<!-- 等级升级成功弹窗 -->
+	<levelSuccessPopup></levelSuccessPopup>
 </template>
 
 <script setup>
 	import config from "@/api/config.js"
 	import { onLoad } from '@dcloudio/uni-app'
-	import memberLevel from "./components/memberLevel.vue"
+	import memberLevel from "./components/memberLevel.vue"
+	import treeAlbumPopup from "./components/treeAlbumPopup.vue"
 	import {
 		ref,
 		reactive,
@@ -68,7 +73,8 @@
 	}
 
 	const toolLeftList = [{
-			name: "相册",
+			name: "相册",
+			clickName:'album'
 		},
 		{
 			name: "日记",
@@ -111,11 +117,14 @@
 		}
 	})
 	
-	const showPoster = ref(false)
+	const showPoster = ref(false)
+	const showAlbum = ref(false)
 	const handleToolItem = ({
 		path,clickName
 	}) => {
-		if(clickName){
+		if(clickName === 'album'){
+			showAlbum.value = !showAlbum.value
+		}else if(clickName === 'poster'){
 			showPoster.value = !showPoster.value
 		}else{
 			uni.navigateTo({