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

feat:对接朋友树页面接口

wangsisi пре 1 месец
родитељ
комит
2c5aa1b1b4

+ 1 - 1
api/tree.js

@@ -64,6 +64,6 @@ export default {
 	},
 	//根据样点ID查询日记列表
 	getSampleDiary(data) {
-		return http.get(`mini/z_sample_diary/listBySample/${data.sampleId}`,data)
+		return http.get(`/site/z_sample_diary/page`,data)
 	},
 }

+ 3 - 3
pages/tabBar/tree/components/memberLevel.vue

@@ -3,7 +3,7 @@
 		<!-- 用户会员信息 -->
 		<view class="user-wrap">
 			<view class="user-info">
-				<up-image class="avatar" :fade="false" :src="userInfo.icon" width="96rpx" height="96rpx"
+				<up-image class="avatar" :fade="false" :src="userLevel.icon" width="96rpx" height="96rpx"
 					shape="circle"></up-image>
 				<view class="level-wrap">
 					<text class="name">V{{userLevel.id}} {{levelStr[userLevel.id]}}守护</text>
@@ -74,14 +74,14 @@
 		4: "星勋",
 	};
 
-	const userInfo = uni.getStorageSync('userInfo')
 	const userLevel = ref({})
 	watch(
 		() => props.treeData,
 		(newValue) => {
 			userLevel.value = {
 				...newValue.buyList[0].level,
-				energy: newValue.buyList[0].energy
+				energy: newValue.buyList[0].energy,
+				icon: newValue.buyList[0].icon
 			}
 		}
 	);

+ 116 - 54
pages/tabBar/tree/subPages/friendTree.vue

@@ -1,57 +1,106 @@
 <template>
-	<view class="sub-base-container">
-		<member-level></member-level>
-		<view class="tree-cont">
-			<image class="drone-icon" :src="`${config.BASIC_IMG}img/treePage/drone-icon.png`"></image>
-			<view class="tool-wrap">
-				<view class="tool-left">
-					<view :class="['tool-item',item.className]" v-for="(item,index) in toolList" :key="index">
-						<image class="icon" :src="`${config.BASIC_IMG}img/treePage/${item.icon}.png`"></image>
-						<view class="name">{{item.name}}</view>
+	<view class="base-template">
+		<view class="sub-base-container">
+			<member-level :treeData="treeData"></member-level>
+			<view class="tree-cont">
+				<view class="tree-name">
+					<view>{{treeName}}</view>
+				</view>
+				<image class="drone-icon" :src="`${config.BASIC_IMG}img/treePage/drone-icon.png`"></image>
+				<view class="tool-wrap">
+					<view class="tool-left">
+						<view :class="['tool-item',item.className]" v-for="(item,index) in toolList" :key="index">
+							<image class="icon" :src="`${config.BASIC_IMG}img/treePage/${item.icon}.png`"></image>
+							<view class="name">{{item.name}}</view>
+						</view>
 					</view>
 				</view>
 			</view>
+			<view class="tree-footer">
+				<view class="blessing" @click="handleBlessing">
+					<image class="icon" :src="`${config.BASIC_IMG}img/treePage/b-tree-icon-2.png`"></image>
+					<text>送ta祝福</text>
+				</view>
+				<view class="button" @click="handlePage">{{userInfo.tel?'去看看我的树':'开启我的守护'}}</view>
+			</view>
 		</view>
-		<view class="tree-footer">
-			<view class="blessing" @click="handleBlessing">
-				<image class="icon" :src="`${config.BASIC_IMG}img/treePage/b-tree-icon-2.png`"></image>
-				<text>送ta祝福</text>
-			</view>
-			<view class="button">去看看我的树</view>
-		</view>
+		<!-- 祝福弹窗 -->
+		<blessingsPopup :show="showBlessingsPopup" clockinType="3" :farmBuyId="farmBuyId" @clockinCallback="getBySampleId"></blessingsPopup>
 	</view>
-	<!-- 编辑树名称 -->
-	<editNamePopup></editNamePopup>
-	<!-- 祝福弹窗 -->
-	<blessingsPopup :show="showBlessingsPopup"></blessingsPopup>
 </template>
 
 <script setup>
 	import config from "@/api/config.js"
-	import memberLevel from "../components/memberLevel.vue"
+	import memberLevel from "../components/memberLevel.vue"
 	import blessingsPopup from "../components/blessingsPopup.vue"
 	import {
+		onLoad
+	} from '@dcloudio/uni-app'
+	import TREE from '@/api/tree.js'
+	import {
 		ref,
 		reactive,
-		onMounted
-	} from 'vue';
-	
-	const showBlessingsPopup = ref(false)
+	} from 'vue';
+
+	const userInfo = uni.getStorageSync('userInfo')
+	const handlePage = () => {
+		if (userInfo.tel) {
+			uni.switchTab({
+				url: '/pages/tabBar/tree/tree'
+			})
+		} else {
+			uni.navigateTo({
+				url: `/pages/tabBar/home/subPages/gardenMap?enterSelectTree=true`
+			});
+		}
+	}
+
+	const sampleId = ref('')
+	onLoad((options) => {
+		sampleId.value = options.sampleId
+		getBySampleId()
+	})
+
+	const treeData = ref({})
+	const treeName = ref('')
+	const farmBuyId = ref('')
+	const getBySampleId = () => {
+		TREE.getBySampleId({
+			sampleId: sampleId.value
+		}).then(({
+			data
+		}) => {
+			treeData.value = data || {}
+			treeName.value = data.buyList[0].treeName || (data.buyList[0].nickname.length ? data.buyList[0]
+				.nickname.slice(0, 3) + "荔" : data.buyList[0].owner.slice(0, 3) + "荔")
+			farmBuyId.value = data.buyList[0].id
+		})
+	}
+
+	const showBlessingsPopup = ref(false)
 	const handleBlessing = () => {
-		showBlessingsPopup.value = !showBlessingsPopup.value
+		if(treeData.value.buyList[0].level.clockinMap['3']){
+			uni.showToast({
+				title: '今日已送过祝福',
+				icon: 'none',
+				duration: 2000
+			});
+		}else{
+			showBlessingsPopup.value = !showBlessingsPopup.value
+		}
 	}
 
 	const toolList = [{
-			name: "相册",
-			icon:'l-tree-icon-1'
+			name: "相册",
+			icon: 'l-tree-icon-1'
 		},
 		{
-			name: "日记",
-			icon:'l-tree-icon-2'
+			name: "日记",
+			icon: 'l-tree-icon-2'
 		},
 		{
-			name: "果园",
-			icon:'r-tree-icon-3'
+			name: "果园",
+			icon: 'r-tree-icon-3'
 		}
 	]
 
@@ -75,6 +124,17 @@
 			width: 100%;
 			margin-top: 10rpx;
 
+			.tree-name {
+				position: absolute;
+				top: 60.45%;
+				left: calc(50% - 32rpx);
+				z-index: 2;
+				font-size: 22rpx;
+				font-family: 'SweiSpringCJKtc';
+				text-align: center;
+				width: 88rpx;
+			}
+
 			.drone-icon {
 				width: 376rpx;
 				height: 384rpx;
@@ -90,7 +150,7 @@
 				display: flex;
 				justify-content: space-between;
 
-				.tool-left{
+				.tool-left {
 					.tool-item {
 						color: #fff;
 						font-size: 24rpx;
@@ -126,30 +186,32 @@
 			left: 0;
 			bottom: 130rpx;
 			width: 100%;
-			display: flex;
+			display: flex;
 			flex-direction: column;
-			align-items: center;
-			color: #fff;
-			.blessing{
-				display: flex;
-				align-items: center;
-				background: rgba(0, 0, 0, 0.3);
-				border-radius: 50rpx;
-				padding: 6rpx 60rpx;
-				border: 1rpx solid rgba(255, 255, 255, 0.6);
-				.icon{
-					width: 86rpx;
-					height: 86rpx;
-					margin-right: 10rpx;
-				}
+			align-items: center;
+			color: #fff;
+
+			.blessing {
+				display: flex;
+				align-items: center;
+				background: rgba(0, 0, 0, 0.3);
+				border-radius: 50rpx;
+				padding: 6rpx 60rpx;
+				border: 1rpx solid rgba(255, 255, 255, 0.6);
+
+				.icon {
+					width: 86rpx;
+					height: 86rpx;
+					margin-right: 10rpx;
+				}
 			}
 
-			.button{
-				padding: 26rpx 80rpx;
-				border-radius: 50rpx;
-				border: 2rpx solid #fff;
-				background-image: linear-gradient(120deg,#FFD887,#ED9E1E);
-				margin-top: 20rpx;
+			.button {
+				padding: 26rpx 80rpx;
+				border-radius: 50rpx;
+				border: 2rpx solid #fff;
+				background-image: linear-gradient(120deg, #FFD887, #ED9E1E);
+				margin-top: 20rpx;
 			}
 		}
 	}

+ 13 - 7
pages/tabBar/tree/subPages/rank.vue

@@ -27,7 +27,7 @@
 							<text class="nickname ellipsis-l1">昵称:{{item.nickname}}</text>
 						</view>
 					</view>
-					<view class="button" @click="handlePage">去看看</view>
+					<view class="button" @click="handlePage(item)">去看看</view>
 				</view>
 				<!-- 加载更多提示 -->
 				<view class="loading-more" v-if="loading">
@@ -55,12 +55,18 @@
 	onLoad(() => {
 		getCategoryList()
 		getRankingList()
-	})
-	
-	const handlePage = () =>{
-		uni.navigateTo({
-			url: `/pages/tabBar/tree/subPages/friendTree?`
-		});
+	})
+	
+	const userInfo = uni.getStorageSync('userInfo')
+	
+	const handlePage = ({miniUserId,sampleId}) =>{
+		if(miniUserId === userInfo.id){
+			uni.navigateBack()
+		}else{
+			uni.navigateTo({
+				url: `/pages/tabBar/tree/subPages/friendTree?sampleId=${sampleId}`
+			});
+		}
 	}
 	
 	const active = ref(null)