Ver código fonte

feat:对接每日海报接口和动态接口

wangsisi 1 mês atrás
pai
commit
a73c5d4aa4

+ 17 - 0
api/tree.js

@@ -0,0 +1,17 @@
+import http from '@/utils/http'
+import config from './config'
+
+export default {
+	//获取自己果树数据
+	getBySampleId(data) {
+		return http.get('mini/z_farm_buy/getBySampleId', data)
+	},
+	// 获取能量记录
+	getEnergyRecords(data) {
+		return http.get(`mini/z_farm_buy/getEnergyRecords/${data.page}/${data.limit}`, data)
+	},
+	//获取果树海报
+	getPoster(data) {
+		return http.get('mini/z_farm_buy/getPoster', data)
+	},
+}

+ 23 - 43
components/posterPopup/posterPopup.vue

@@ -58,7 +58,8 @@
 		ref,
 		watch
 	} from "vue";
-	// import savePhotoPopup from "@/components/common/savePhotoPopup.vue";
+	// import savePhotoPopup from "@/components/common/savePhotoPopup.vue";
+	import TREE from '@/api/tree.js'
 	import config from "@/api/config.js"
 	const resize = "?x-oss-process=image/resize,w_1000";
 
@@ -81,14 +82,14 @@
 		},
 	});
 
-	watch(
-		() => props.farmBuyId,
-		(newValue) => {
-			if (newValue && userInfo?.tel && props.showPoster) {
-				getPosterData(newValue);
-			}
-		}
-	);
+	// watch(
+	// 	() => props.farmBuyId,
+	// 	(newValue) => {
+	// 		if (newValue && userInfo?.tel && props.showPoster) {
+	// 			getPosterData(newValue);
+	// 		}
+	// 	}
+	// );
 
 	watch(
 		() => props.showPoster,
@@ -96,7 +97,7 @@
 			// if (newValue && userInfo?.tel && props.showPoster) {
 			// 	getPosterData(props.farmBuyId);
 			// }
-			getPosterData()
+			getPosterData(props.farmBuyId)
 		}
 	);
 
@@ -111,7 +112,7 @@
 	};
 
 	const showPopup = ref(false);
-	// const userInfo = JSON.parse(localStorage.getItem("localUserInfo"));
+	const userInfo = uni.getStorageSync('userInfo')
 	function formatDate(dateStr) {
 		const date = new Date(dateStr);
 		return {
@@ -132,38 +133,17 @@
 		savePhotoDom.value.handleDownload(contentDom.value);
 	};
 
-	const getPosterData = (farmBuyId) => {
-		// VE_API.lj_home.getPoster({ farmBuyId }).then((res) => {
-		//     if (res.code === 0) {
-		//         if(!props.isShow){
-		showPopup.value = true;
-		const data = {
-			"posterUrl": "https://birdseye-img-ali-cdn.sysuimars.com/562ba414-9517-4789-98f9-42fdae26cee4/bc27ee0c-8177-47fb-823c-c81d6f8b514c/DJI_202507281100_002_bc27ee0c-8177-47fb-823c-c81d6f8b514c/DJI_20250728110246_0016_Z_code-ws0y1mu3uwb2.jpeg",
-			"qrCodeUrl": "https://birdseye-img.sysuimars.com/birdseye-look-mini/temp/1751087233847.jpg",
-			"age": 2,
-			"countyName": "从化",
-			"pz": "井岗红糯",
-			"watermarkMsg": "山海皆可平,无处不风景",
-			"watermarkUrl": "",
-			"fosterCode": "LCJGHN-GZCH-LBY1003",
-			"countdown": -40,
-			"sampleId": 172055,
-			"posterId": "740994773711589376",
-			"ssDate": null,
-			"createDate": "2025-08-06",
-			"phenology": "秋梢期",
-			"howTxt": "梢期防虫"
-		}
-		treeObj.value = {
-			...data,
-			watermarkArr: data.watermarkMsg && data.watermarkMsg.split(","),
-			...formatDate(data.createDate)
-		};
-		//         }else{
-		//             closePopup()
-		//         }
-		//     }
-		// });
+	const getPosterData = (farmBuyId) => {
+		TREE.getPoster({farmBuyId}).then(({data,code}) =>{
+			if (code === 0) {
+				showPopup.value = true;
+				treeObj.value = {
+					...data,
+					watermarkArr: data.watermarkMsg && data.watermarkMsg.split(","),
+					...formatDate(data.createDate)
+				};
+			}
+		})
 	};
 
 	const closePopup = () => {

+ 95 - 59
pages/tabBar/tree/components/memberLevel.vue

@@ -1,51 +1,86 @@
 <template>
-	<view class="member-level">
+	<view class="member-level">
 		<!-- 用户会员信息 -->
 		<view class="user-wrap">
 			<view class="user-info">
-				<up-image class="avatar" :fade="false"
-					src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png" width="96rpx"
-					height="96rpx" shape="circle"></up-image>
+				<up-image class="avatar" :fade="false" :src="userInfo.icon" width="96rpx" height="96rpx"
+					shape="circle"></up-image>
 				<view class="level-wrap">
-					<text class="name">V1 青铜守护</text>
+					<text class="name">V{{userLevel.id}} {{levelStr[userLevel.id]}}守护</text>
 					<view class="progress-wrap">
 						<view class="progress-value">
 							<view class="total"></view>
 						</view>
 						<view class="progress-score">
-							<text class="cur-val">80</text>/100
+							<text class="cur-val">{{ userLevel.energy }}</text>/{{ userLevel.energyMax + 1 }}
 						</view>
 					</view>
 					<view class="level-desc">
-						再累计能量<text class="level-text"> 20分 </text>即可升级到 青铜等级
+						再累计能量<text class="level-text"> {{ userLevel.diffLevelEnergy }}分 </text>即可升级到 {{levelStr[Number(userLevel.id) + 1]}}等级
 					</view>
 				</view>
 			</view>
 			<slot></slot>
 		</view>
-		<!-- 树信息 -->
-		<view class="tree-info">
-			<view class="info-text">
-				<view>汕尾妙荔</view>
-				<text>现代农业产业园</text>
-			</view>
-			<view class="info-text">
-				<view>16年老树</view>
-				<text class="text">妃子笑荔枝</text>
-			</view>
-			<view class="info-text">
-				<view>成熟期</view>
-				<text class="text">温度适宜-梢期杀虫</text>
-			</view>
-		</view>
+		<!-- 树信息 -->
+		<view class="tree-info">
+			<view class="info-text">
+				<template v-if="treeData.farmName && treeData.farmName.length > 5">
+					<view>{{treeData.farmName.slice(0,4)}}</view>
+					<text>{{treeData.farmName.slice(4)}}</text>
+				</template>
+				<view v-else>{{treeData.farmName}}</view>
+			</view>
+			<view class="info-text">
+				<view>{{treeData.age}}年{{ treeData.age > 9 ? "老树" : "树龄" }}</view>
+				<text class="text">{{ treeData.pz }}</text>
+			</view>
+			<view class="info-text">
+				<view>{{treeData.phenologyName}}</view>
+				<text class="text">气候适宜-{{ treeData.howTxt || "果园采摘" }}</text>
+			</view>
+		</view>
 	</view>
 </template>
 
 <script setup>
+	import TREE from '@/api/tree.js'
+	import {
+		ref,
+		watch
+	} from "vue";
+
+	const props = defineProps({
+		treeData: {
+			type: Object,
+			defalut: {},
+		},
+	});
+	
+	const levelStr = {
+	    0: "平民",
+	    1: "青铜",
+	    2: "白银",
+	    3: "赤金",
+	    4: "星勋",
+	};
+
+	const userInfo = uni.getStorageSync('userInfo')
+	const userLevel = ref({})
+	watch(
+		() => props.treeData,
+		(newValue) => {
+			userLevel.value = {
+				...newValue.buyList[0].level,
+				energy:newValue.buyList[0].energy
+			}
+		}
+	);
 </script>
 
-<style lang="scss" scoped>
+<style lang="scss" scoped>
 	@import "@/static/style/mixin.scss";
+
 	.member-level {
 		.user-wrap {
 			display: flex;
@@ -116,41 +151,42 @@
 				}
 			}
 		}
-		.tree-info {
-			width: 95%;
-			height: 160rpx;
-			box-sizing: border-box;
-			padding: 0 50rpx 20rpx;
-			@include ossBg("treePage/tree-info-bg.png");
-			display: flex;
-			justify-content: space-around;
-			align-items: center;
-			font-size: 28rpx;
-			font-weight: 500;
-			margin: auto;
-		
-			.info-text {
-				text-align: center;
-				line-height: 32rpx;
-				font-family: 'SMILEYSANS';
-				position: relative;
-		
-				.text {
-					font-size: 22rpx;
-				}
-			}
-		
-			.info-text+.info-text {
-				&::before {
-					content: '';
-					position: absolute;
-					left: -34rpx;
-					top: 14rpx;
-					width: 1rpx;
-					height: 38rpx;
-					background: rgba(0, 0, 0, 0.26);
-				}
-			}
-		}
+
+		.tree-info {
+			width: 95%;
+			height: 160rpx;
+			box-sizing: border-box;
+			padding: 0 50rpx 20rpx;
+			@include ossBg("treePage/tree-info-bg.png");
+			display: flex;
+			justify-content: space-around;
+			align-items: center;
+			font-size: 28rpx;
+			font-weight: 500;
+			margin: auto;
+
+			.info-text {
+				text-align: center;
+				line-height: 32rpx;
+				font-family: 'SMILEYSANS';
+				position: relative;
+
+				.text {
+					font-size: 22rpx;
+				}
+			}
+
+			.info-text+.info-text {
+				&::before {
+					content: '';
+					position: absolute;
+					left: -34rpx;
+					top: 14rpx;
+					width: 1rpx;
+					height: 38rpx;
+					background: rgba(0, 0, 0, 0.26);
+				}
+			}
+		}
 	}
 </style>

+ 105 - 59
pages/tabBar/tree/subPages/dynamic.vue

@@ -2,54 +2,94 @@
 	<view class="sub-base-container">
 		<view class="messgae-list" v-for="(item,index) in messageList" :key="index">
 			<text class="date">{{item.date}}</text>
-			<view class="message-item" v-for="(ele,idx) in item.list" :key="idx">
-				<view class="messgae-info">
+			<view class="message-item" v-for="(ele,idx) in item.list" :key="idx">
+				<view class="messgae-info">
 					<view class="info-text">
-						<up-image class="avatar" :fade="false"
-							src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png" width="56rpx"
-							height="56rpx" shape="circle"></up-image>
-						<view><text class="my">励志人生</text> 向 <text class="name">茜茜荔</text> 留言 </view>
+						<up-image class="avatar" :fade="false" :src="ele.icon" width="56rpx" height="56rpx"
+							shape="circle"></up-image>
+						<view><text class="my">{{ele.nickname}}</text> 使用 <text
+								class="name">{{clockinTypeStr[ele.clockinType]}}</text> 能量增加 <text
+								class="name">{{ele.energy}}分</text></view>
+						<!-- <view><text class="my">励志人生</text> 向 <text class="name">茜茜荔</text> 留言 </view> -->
 					</view>
-					<text class="time">{{ele.date}}</text>
-				</view>
-				<text class="message-text">{{ele.desc}}</text>
+					<!-- <text class="time">{{ele.createTime}}</text> -->
+				</view>
+				<view class="time">{{ele.createTime}}</view>
+				<text class="message-text">{{ele.desc}}</text>
 			</view>
 		</view>
 	</view>
 </template>
 
 <script setup>
-	const messageList = [{
-			date: '今天',
-			list: [{
-					name: '茜茜荔',
-					date: '11:08',
-					desc: '记住,每一次挫折都是成功的垫脚石记住,每一次挫折都是成功的垫脚石'
-				},
-				{
-					name: '茜茜荔',
-					date: '11:08',
-					desc: '记住,每一次挫折都是成功的垫脚石记住,每一次挫折都是成功的垫脚石'
-				}
-			]
-		},
-		{
-			date: '昨天',
-			list: [{
-				name: '茜茜荔',
-				date: '11:08',
-				desc: '记住,每一次挫折都是成功的垫脚石记住,每一次挫折都是成功的垫脚石'
-			}]
-		},
-		{
-			date: '07/30',
-			list: [{
-				name: '茜茜荔',
-				date: '11:08',
-				desc: '记住,每一次挫折都是成功的垫脚石记住,每一次挫折都是成功的垫脚石'
-			}]
+	import {
+		ref,
+	} from 'vue';
+	import TREE from '@/api/tree.js'
+	import {
+		onLoad
+	} from '@dcloudio/uni-app'
+
+	const messageList = ref([{
+		date: '今天',
+		list: []
+	}])
+	const farmBuyIdData = ref('')
+
+	onLoad(({
+		farmBuyId
+	}) => {
+		farmBuyIdData.value = farmBuyId
+		getMessageList()
+	})
+
+	const clockinTypeStr = {
+		'1': '每日阳光',
+		"2": "分享守护",
+		"3": "每日祝福"
+	}
+
+	const getMessageList = () => {
+		const params = {
+			page: 1,
+			limit: 10,
+			farmBuyId: farmBuyIdData.value
 		}
-	]
+		TREE.getEnergyRecords(params).then(res => {
+			messageList.value[0].list = res.data || []
+		})
+	}
+	// const messageList = [{
+	// 		date: '今天',
+	// 		list: [{
+	// 				name: '茜茜荔',
+	// 				date: '11:08',
+	// 				desc: '记住,每一次挫折都是成功的垫脚石记住,每一次挫折都是成功的垫脚石'
+	// 			},
+	// 			{
+	// 				name: '茜茜荔',
+	// 				date: '11:08',
+	// 				desc: '记住,每一次挫折都是成功的垫脚石记住,每一次挫折都是成功的垫脚石'
+	// 			}
+	// 		]
+	// 	},
+	// 	{
+	// 		date: '昨天',
+	// 		list: [{
+	// 			name: '茜茜荔',
+	// 			date: '11:08',
+	// 			desc: '记住,每一次挫折都是成功的垫脚石记住,每一次挫折都是成功的垫脚石'
+	// 		}]
+	// 	},
+	// 	{
+	// 		date: '07/30',
+	// 		list: [{
+	// 			name: '茜茜荔',
+	// 			date: '11:08',
+	// 			desc: '记住,每一次挫折都是成功的垫脚石记住,每一次挫折都是成功的垫脚石'
+	// 		}]
+	// 	}
+	// ]
 </script>
 
 <style lang="scss" scoped>
@@ -63,33 +103,39 @@
 				margin-top: 24rpx;
 				background: #fff;
 				border-radius: 16rpx;
-				padding: 24rpx 32rpx;
+				padding: 24rpx 32rpx;
+				.time {
+					font-size: 28rpx;
+					color: #999999;
+					margin-left: 70rpx;
+				}
 
 				.messgae-info {
 					display: flex;
 					align-items: center;
-					justify-content: space-between;
-					margin-bottom: 16rpx;
-					.info-text{
-						display: flex;
-						align-items: center;
-						.my{
-							font-weight: 500;
-						}
-						.name{
-							color: #EAB400;
-						}
-					}
-					.time{
-						font-size: 24rpx;
-						color: #999999;
+					justify-content: space-between;
+					margin-bottom: 16rpx;
+
+					.info-text {
+						display: flex;
+						align-items: center;
+
+						.my {
+							font-weight: 500;
+						}
+
+						.name {
+							color: #EAB400;
+						}
 					}
+
 					.avatar {
 						margin-right: 16rpx;
-					}
-				}
-				.message-text{
-					font-size: 28rpx;
+					}
+				}
+
+				.message-text {
+					font-size: 28rpx;
 				}
 			}
 		}

+ 20 - 8
pages/tabBar/tree/tree.vue

@@ -1,6 +1,6 @@
 <template>
 	<view class="base-container">
-		<member-level>
+		<member-level :treeData="treeData">
 			<view class="toogle" @click="handleShow">切换 {{name}}<up-icon class="icon" name="arrow-down" color="#fff"
 					size="12"></up-icon></view>
 		</member-level>
@@ -36,7 +36,7 @@
 	<!-- 编辑树名称 -->
 	<editNamePopup></editNamePopup>
 	<!-- 海报弹窗 -->
-	<posterPopup :showPoster="showPoster"></posterPopup>
+	<posterPopup :showPoster="showPoster" :farmBuyId="farmBuyId"></posterPopup>
 	<!-- 果树成功弹窗 -->
 	<guardSuccessPopup :show="showGuardSuccess"></guardSuccessPopup>
 	<!-- 果树相册弹窗 -->
@@ -49,11 +49,11 @@
 	import config from "@/api/config.js"
 	import { onLoad } from '@dcloudio/uni-app'
 	import memberLevel from "./components/memberLevel.vue"
-	import treeAlbumPopup from "./components/treeAlbumPopup.vue"
+	import treeAlbumPopup from "./components/treeAlbumPopup.vue"
+	import TREE from '@/api/tree.js'
 	import {
 		ref,
 		reactive,
-		onMounted
 	} from 'vue';
 
 	const name = ref('荔枝')
@@ -105,7 +105,8 @@
 		{
 			name: "动态",
 			className: 'dynamic',
-			path: 'dynamic'
+			path: 'dynamic',
+			params:'farmBuyId'
 		}
 	]
 	
@@ -115,12 +116,23 @@
 		if(successTree){
 			showGuardSuccess.value = true
 		}
-	})
+		getBySampleId()
+	})
+	
+	const treeData = ref({})
+	const farmBuyId = ref('')
+	const getBySampleId = () =>{
+		//81317  88891
+		TREE.getBySampleId({sampleId:172055}).then(res =>{
+			treeData.value = res.data || {}
+			farmBuyId.value = res.data.buyList[0].id
+		})
+	}
 	
 	const showPoster = ref(false)
 	const showAlbum = ref(false)
 	const handleToolItem = ({
-		path,clickName
+		path,clickName,params
 	}) => {
 		if(clickName === 'album'){
 			showAlbum.value = !showAlbum.value
@@ -128,7 +140,7 @@
 			showPoster.value = !showPoster.value
 		}else{
 			uni.navigateTo({
-				url: `/pages/tabBar/tree/subPages/${path}`
+				url: `/pages/tabBar/tree/subPages/${path}?farmBuyId=${farmBuyId.value}`
 			});
 		}
 	}