|
|
@@ -3,28 +3,38 @@
|
|
|
<div class="garden-info" v-if="gardenObj && !enterSelectTree">
|
|
|
<div class="panel-title">
|
|
|
<div class="title-l">
|
|
|
- <div class="title-info">
|
|
|
- <div class="title-garden">{{ gardenObj.farmName || '果园地图' }}</div>
|
|
|
- <div class="btn-second" v-if="gardenObj.youweiIndex != null">
|
|
|
- 有味指数
|
|
|
- <text>{{ gardenObj.youweiIndex }}分</text>
|
|
|
- </div>
|
|
|
+ <div class="title-garden-box">
|
|
|
+ <img :src="farmAvatar" class="farm-avatar" alt="" />
|
|
|
+ <span class="title-garden">{{ gardenObj.farmName || '农场名称' }}</span>
|
|
|
</div>
|
|
|
+ <div class="btn-switch" @click="onSwitchFarm">切换农场</div>
|
|
|
</div>
|
|
|
<div class="title-r" v-if="gardenObj.people != null">
|
|
|
- <span class="guard-label">守护人数</span>
|
|
|
- <span class="guard-val">{{ gardenObj.people }}</span>
|
|
|
+ <div class="avatar-stack" v-if="adoptAvatars.length">
|
|
|
+ <img
|
|
|
+ v-for="(avatar, idx) in adoptAvatars"
|
|
|
+ :key="idx"
|
|
|
+ :src="avatar"
|
|
|
+ class="stack-avatar"
|
|
|
+ alt=""
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <span class="adopt-text">
|
|
|
+ 已有 <span class="adopt-val">{{ gardenObj.people }}</span> 人认养
|
|
|
+ </span>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
<div class="select-tips" v-if="enterSelectTree">请选择您要守护的农场区域</div>
|
|
|
+ <div class="select-btn" :class="{ active: selectedRegion }" v-if="enterSelectTree">我选好了</div>
|
|
|
+ <div class="select-btn invite-btn" v-if="!enterSelectTree">邀请好友守护</div>
|
|
|
|
|
|
<div ref="mapRef" class="map"></div>
|
|
|
|
|
|
<!-- <div class="top-mask"></div> -->
|
|
|
|
|
|
- <!-- <BaseFooter /> -->
|
|
|
+ <BaseFooter v-if="!enterSelectTree" :init-tab="2" />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
@@ -32,11 +42,12 @@
|
|
|
import IndexMap from './map/index.js'
|
|
|
import RegionLayer from './map/regionLayer.js'
|
|
|
import ClusterPointsLayer from './map/clusterPointsLayer.js'
|
|
|
-import { onMounted, onUnmounted, ref } from 'vue'
|
|
|
+import { onMounted, onUnmounted, ref, computed, watch } from 'vue'
|
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
|
import { useStore } from 'vuex'
|
|
|
import { SET_TOKEN } from '@/store/modules/app/type.js'
|
|
|
-// import BaseFooter from '@/components/BaseFooter.vue'
|
|
|
+import { _checkImgUrl } from '@/utils'
|
|
|
+import BaseFooter from '@/components/BaseFooter.vue'
|
|
|
|
|
|
const store = useStore()
|
|
|
const route = useRoute()
|
|
|
@@ -47,10 +58,43 @@ let regionLayer = null
|
|
|
let clusterPointsLayer = null
|
|
|
|
|
|
const enterSelectTree = ref(false)
|
|
|
+const selectedRegion = ref(null)
|
|
|
const gardenObj = ref(null)
|
|
|
const currenFarmId = ref(null)
|
|
|
|
|
|
const defaultCenter = 'POINT(111.0105596 21.77287165)'
|
|
|
+const DEFAULT_AVATAR = 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png'
|
|
|
+
|
|
|
+const farmAvatar = computed(() => {
|
|
|
+ const obj = gardenObj.value || {}
|
|
|
+ return _checkImgUrl(obj.farmImg || obj.farmPic || obj.cover || obj.pic) || DEFAULT_AVATAR
|
|
|
+})
|
|
|
+
|
|
|
+const adoptAvatars = computed(() => {
|
|
|
+ const obj = gardenObj.value || {}
|
|
|
+ const list = obj.userList || obj.avatarList || obj.buyUserList || obj.userAvatarList || []
|
|
|
+ if (Array.isArray(list) && list.length) {
|
|
|
+ return list.slice(0, 3).map((item) => {
|
|
|
+ if (typeof item === 'string') return _checkImgUrl(item) || DEFAULT_AVATAR
|
|
|
+ return _checkImgUrl(item.avatar || item.headImg || item.userAvatar) || DEFAULT_AVATAR
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (obj.people > 0) {
|
|
|
+ return [DEFAULT_AVATAR, DEFAULT_AVATAR, DEFAULT_AVATAR]
|
|
|
+ }
|
|
|
+ return []
|
|
|
+})
|
|
|
+
|
|
|
+function onSwitchFarm() {
|
|
|
+ router.push({
|
|
|
+ path: '/farm-select',
|
|
|
+ query: { ...route.query },
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+async function reloadMapData() {
|
|
|
+ await Promise.all([getGardenInfo(), getBlueRegionList(), getPointList()])
|
|
|
+}
|
|
|
|
|
|
function isEnterSelectTreeQuery(val) {
|
|
|
if (val === undefined || val === null || val === '') return false
|
|
|
@@ -262,19 +306,28 @@ onMounted(async () => {
|
|
|
regionLayer = new RegionLayer(indexMap.kmap, {
|
|
|
enterSelectTree: enterSelectTree.value,
|
|
|
onRegionSelect: (region) => {
|
|
|
- console.log('[adopt_map] 选中分区', region)
|
|
|
+ selectedRegion.value = region
|
|
|
},
|
|
|
})
|
|
|
if (!enterSelectTree.value) {
|
|
|
clusterPointsLayer = new ClusterPointsLayer(indexMap.kmap)
|
|
|
}
|
|
|
|
|
|
- await Promise.all([getGardenInfo(), getBlueRegionList(), getPointList()])
|
|
|
+ await reloadMapData()
|
|
|
|
|
|
regionLayer.setEnterSelectTree(enterSelectTree.value)
|
|
|
|
|
|
})
|
|
|
|
|
|
+watch(
|
|
|
+ () => route.query.farmId,
|
|
|
+ async (newId, oldId) => {
|
|
|
+ if (!newId || String(newId) === String(oldId)) return
|
|
|
+ currenFarmId.value = newId
|
|
|
+ await reloadMapData()
|
|
|
+ },
|
|
|
+)
|
|
|
+
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="less">
|
|
|
@@ -304,55 +357,140 @@ onMounted(async () => {
|
|
|
border-radius: 30px;
|
|
|
}
|
|
|
|
|
|
+ .select-btn {
|
|
|
+ position: absolute;
|
|
|
+ z-index: 3;
|
|
|
+ bottom: 60px;
|
|
|
+ left: 50%;
|
|
|
+ transform: translateX(-50%);
|
|
|
+ background: linear-gradient(141.52deg, #FFE6B2 7.21%, #FFA617 95.86%);
|
|
|
+ color: #000000;
|
|
|
+ font-size: 16px;
|
|
|
+ width: 152px;
|
|
|
+ text-align: center;
|
|
|
+ line-height: 40px;
|
|
|
+ border: 1px solid #FFFFFF;
|
|
|
+ box-sizing: border-box;
|
|
|
+ height: 40px;
|
|
|
+ border-radius: 20px;
|
|
|
+ font-family: "PangMenZhengDao";
|
|
|
+ opacity: 0.4;
|
|
|
+
|
|
|
+ &.active,
|
|
|
+ &.invite-btn {
|
|
|
+ opacity: 1;
|
|
|
+ }
|
|
|
+ &.invite-btn {
|
|
|
+ box-shadow: 0px 0px 8px 0px #F3CA88;
|
|
|
+ bottom: 120px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
.garden-info {
|
|
|
position: absolute;
|
|
|
z-index: 3;
|
|
|
- top: 0;
|
|
|
- left: 0;
|
|
|
- width: 100%;
|
|
|
+ top: 10px;
|
|
|
+ left: 12px;
|
|
|
+ right: 0;
|
|
|
+ width: auto;
|
|
|
|
|
|
.panel-title {
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
justify-content: space-between;
|
|
|
- padding: 12px;
|
|
|
+ min-width: 0;
|
|
|
+ gap: 8px;
|
|
|
|
|
|
.title-l {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ gap: 2px;
|
|
|
+ min-width: 0;
|
|
|
flex: 1;
|
|
|
+ overflow: hidden;
|
|
|
+ background: rgba(0, 0, 0, 0.5);
|
|
|
+ padding: 4px;
|
|
|
+ border-radius: 20px;
|
|
|
+ border: 0.5px solid rgba(255, 255, 255, 0.5);
|
|
|
+
|
|
|
+ .title-garden-box {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ gap: 4px;
|
|
|
+ min-width: 0;
|
|
|
+ flex: 1;
|
|
|
+ overflow: hidden;
|
|
|
+ }
|
|
|
+
|
|
|
+ .farm-avatar {
|
|
|
+ width: 32px;
|
|
|
+ height: 32px;
|
|
|
+ border-radius: 50%;
|
|
|
+ object-fit: cover;
|
|
|
+ flex-shrink: 0;
|
|
|
+ }
|
|
|
|
|
|
.title-garden {
|
|
|
color: #fff;
|
|
|
font-size: 14px;
|
|
|
- font-weight: 600;
|
|
|
- padding-bottom: 5px;
|
|
|
+ min-width: 0;
|
|
|
+ flex: 1;
|
|
|
+ white-space: nowrap;
|
|
|
+ overflow: hidden;
|
|
|
+ text-overflow: ellipsis;
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- .btn-second {
|
|
|
- padding: 0 15px;
|
|
|
- border-radius: 20px;
|
|
|
- font-size: 12px;
|
|
|
- color: #f3c11d;
|
|
|
- border: 1px solid #f3c11d;
|
|
|
- background: rgba(255, 217, 94, 0.28);
|
|
|
- height: 21px;
|
|
|
- line-height: 20px;
|
|
|
- width: fit-content;
|
|
|
- }
|
|
|
+ .btn-switch {
|
|
|
+ flex-shrink: 0;
|
|
|
+ width: 68px;
|
|
|
+ text-align: center;
|
|
|
+ height: 28px;
|
|
|
+ line-height: 28px;
|
|
|
+ background: #FFA617;
|
|
|
+ border-radius: 20px;
|
|
|
+ color: #fff;
|
|
|
+ font-size: 12px;
|
|
|
+ cursor: pointer;
|
|
|
}
|
|
|
|
|
|
.title-r {
|
|
|
+ background: rgba(0, 0, 0, 0.6);
|
|
|
+ padding: 4px;
|
|
|
+ border-radius: 20px 0 0 20px;
|
|
|
display: flex;
|
|
|
- flex-direction: column;
|
|
|
align-items: center;
|
|
|
- font-size: 12px;
|
|
|
- padding: 6px 12px;
|
|
|
- background: rgba(255, 255, 255, 0.9);
|
|
|
- border-radius: 8px;
|
|
|
-
|
|
|
- .guard-val {
|
|
|
- color: #f3c11d;
|
|
|
- font-weight: 600;
|
|
|
- font-size: 16px;
|
|
|
+ gap: 5px;
|
|
|
+ flex-shrink: 0;
|
|
|
+ margin-left: auto;
|
|
|
+
|
|
|
+ .avatar-stack {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+
|
|
|
+ .stack-avatar {
|
|
|
+ width: 22px;
|
|
|
+ height: 22px;
|
|
|
+ border-radius: 50%;
|
|
|
+ border: 1px solid #fff;
|
|
|
+ object-fit: cover;
|
|
|
+ margin-left: -8px;
|
|
|
+
|
|
|
+ &:first-child {
|
|
|
+ margin-left: 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .adopt-text {
|
|
|
+ font-size: 12px;
|
|
|
+ color: #fff;
|
|
|
+ white-space: nowrap;
|
|
|
+
|
|
|
+ .adopt-val {
|
|
|
+ color: #F9BE00;
|
|
|
+ font-weight: 500;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|