123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523 |
- <template>
- <view class="home-wrap base-container">
- <view class="home-top">
- <view class="home-search">
- <view class="search-wrap">
- <up-search placeholder="搜索品种" v-model="typeSearch"></up-search>
- </view>
- </view>
- <map
- id="mapId"
- :latitude="latitude"
- :longitude="longitude"
- @markertap="onMarkerTap"
- @callouttap="onCalloutTap"
- @labeltap="onLabelTap"
- :markers="markers"
- :include-points="includePoints"
- show-location
- style="width: 100%; height: 280rpx;"
- ></map>
- <view class="map-tips" @click="toPage('allGardenMap')">
- 飞鸟入驻管理果场详情,点击查看
- </view>
- </view>
- <view class="type-wrap">
- <up-scroll-list indicatorColor="#fae6a4" indicatorActiveColor="#F3C11D" :indicatorWidth="30" :indicatorBarWidth="13">
- <view class="item-type">
- <image class="type-img" :src="`${config.BASIC_IMG}home/type-icon.png`" alt="" />
- <view class="type-text">
- 全部
- </view>
- </view>
- <view class="item-type">
- <image class="type-img" :src="`${config.BASIC_IMG}home/type-icon-2.png`" alt="" />
- <view class="type-text">
- 龙眼
- </view>
- </view>
- <view class="item-type">
- <image class="type-img" :src="`${config.BASIC_IMG}home/type-icon-3.png`" alt="" />
- <view class="type-text">
- 葡萄
- </view>
- </view>
- <view class="item-type">
- <image class="type-img" :src="`${config.BASIC_IMG}home/type-icon.png`" alt="" />
- <view class="type-text">
- 水蜜桃
- </view>
- </view>
- <view class="item-type">
- <image class="type-img" :src="`${config.BASIC_IMG}home/type-icon-2.png`" alt="" />
- <view class="type-text">
- 龙眼
- </view>
- </view>
- <view class="item-type">
- <image class="type-img" :src="`${config.BASIC_IMG}home/type-icon-3.png`" alt="" />
- <view class="type-text">
- 葡萄
- </view>
- </view>
- <view class="item-type">
- <image class="type-img" :src="`${config.BASIC_IMG}home/type-icon-3.png`" alt="" />
- <view class="type-text">
- 葡萄1
- </view>
- </view>
- <view class="item-type">
- <image class="type-img" :src="`${config.BASIC_IMG}home/type-icon.png`" alt="" />
- <view class="type-text">
- 水蜜桃2
- </view>
- </view>
- <view class="item-type">
- <image class="type-img" :src="`${config.BASIC_IMG}home/type-icon-3.png`" alt="" />
- <view class="type-text">
- 葡萄
- </view>
- </view>
- <view class="item-type">
- <image class="type-img" :src="`${config.BASIC_IMG}home/type-icon.png`" alt="" />
- <view class="type-text">
- 水蜜桃
- </view>
- </view>
- <view class="item-type">
- <image class="type-img" :src="`${config.BASIC_IMG}home/type-icon-2.png`" alt="" />
- <view class="type-text">
- 龙眼
- </view>
- </view>
- </up-scroll-list>
- </view>
- <!-- 好味热卖 -->
- <hot-component-vue></hot-component-vue>
-
- <!-- 有味果园 -->
- <view class="garden-wrap">
- <view class="garden-content">
- <view class="hot-title">
- <view class="title-l">
- 有味果园
- </view>
- <view class="title-btn">
- 查看全部<up-icon size="10" name="arrow-right"></up-icon>
- </view>
- </view>
- <view class="garden-list">
- <view class="garden-item" @click="toPage('gardenItem')">
- <view class="garden-l">
- <image class="garden-img" :src="`${config.BASIC_IMG}home/garden.png`" mode=""></image>
- <text class="img-text">无人机实拍视频</text>
- </view>
- <view class="garden-r">
- <view class="garden-title">
- 从化荔枝博览园
- </view>
- <view class="garden-info">
- 品种:荔枝(井岗红糯、巨美人)
- </view>
- <view class="garden-info">
- 位置:广州市从化区
- </view>
- <view class="garden-btn-group">
- <view class="btn-second">
- 有味指数
- <text>4.5分</text>
- </view>
- <view class="btn-primary">
- 溯源报告
- </view>
- </view>
- </view>
- </view>
- <view class="garden-item">
- <view class="garden-l">
- <image class="garden-img" :src="`${config.BASIC_IMG}home/garden.png`" mode=""></image>
- <text class="img-text">无人机实拍视频</text>
- </view>
- <view class="garden-r">
- <view class="garden-title">
- 从化荔枝博览园
- </view>
- <view class="garden-info">
- 品种:荔枝(井岗红糯、巨美人)
- </view>
- <view class="garden-info">
- 位置:广州市从化区
- </view>
- <view class="garden-btn-group">
- <view class="btn-second">
- 有味指数
- <text>4.5分</text>
- </view>
- <view class="btn-primary">
- 溯源报告
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script setup>
- import { ref, onMounted } from 'vue'
- import config from "@/api/config.js"
- import hotComponentVue from './hotComponent.vue'
- const typeSearch = ref(null)
-
- function toPage(path) {
- uni.navigateTo({
- url: `/pages/tabBar/home/subPages/${path}`
- });
- }
-
-
- const latitude = ref(23.099994)
- const longitude = ref(113.324520)
- const markers = ref([])
- const includePoints = ref([])
- const mapCtx = ref(null)
- const img = ref('../../../static/map/point.png')
-
- onMounted(async () => {
- // #ifdef MP-WEIXIN
- mapCtx.value = uni.createMapContext('mapId')
-
- mapCtx.value.on('markerClusterClick', res => {
- console.log('markerClusterClick', res)
- })
-
- bindEvent()
- // #endif
- })
-
- const bindEvent = () => {
- // #ifdef MP-WEIXIN
- mapCtx.value.initMarkerCluster({
- enableDefaultStyle: false,
- zoomOnClick: true,
- gridSize: 60,
- complete(res) {
- console.log('initMarkerCluster', res)
- }
- })
-
- addMarkers()
-
- mapCtx.value.on('markerClusterCreate', res => {
- console.log('clusterCreate', res)
- const clusters = res.clusters
- const newMarkers = clusters.map(cluster => {
- const { center, clusterId, markerIds } = cluster
- return {
- ...center,
- width: 0,
- height: 0,
- clusterId, // 必须
- label: {
- content: markerIds.length + '',
- fontSize: 20,
- width: 30,
- height: 30,
- bgColor: '#FFCB3C',
- borderRadius: 30,
- textAlign: 'center',
- anchorX: 0,
- anchorY: -30,
- }
- }
- })
- mapCtx.value.addMarkers({
- markers: newMarkers,
- clear: false,
- complete(res) {
- console.log('clusterCreate addMarkers', res)
- }
- })
- })
- // #endif
- }
-
- const addMarkers = () => {
- const marker = {
- id: 1,
- iconPath: img.value,
- width: 30,
- height: 30,
- joinCluster: true, // 指定了该参数才会参与聚合
- label: {
- width: 50,
- height: 30,
- borderWidth: 1,
- borderRadius: 4,
- bgColor: '#FFCB3C88',
- anchorX: -26,
- anchorY: -60,
- content: ''
- }
- }
-
- const positions = [
- { latitude: 23.099994, longitude: 113.324520 },
- { latitude: 23.099994, longitude: 113.322520 },
- { latitude: 23.099994, longitude: 113.326520 },
- { latitude: 23.096994, longitude: 113.329520 }
- ]
-
- const newMarkers = []
- positions.forEach((p, i) => {
- const newMarker = {...marker, ...p}
- newMarker.id = i + 1
- newMarker.label.content = `果园 ${i + 1}`
- newMarkers.push(newMarker)
- })
-
- // #ifdef MP-WEIXIN
- mapCtx.value.addMarkers({
- markers: newMarkers,
- clear: false,
- complete(res) {
- console.log('addMarkers', res)
- }
- })
- // #else
- // 非微信平台直接设置 markers
- markers.value = markers.value.concat(newMarkers)
- // 更新包含的点
- includePoints.value = markers.value.map(marker => ({
- latitude: marker.latitude,
- longitude: marker.longitude
- }))
- // #endif
- }
-
- const removeMarkers = () => {
- // #ifdef MP-WEIXIN
- mapCtx.value.addMarkers({
- clear: true,
- markers: []
- })
- // #else
- markers.value = []
- // #endif
- }
- const onMarkerTap = (e) => {
- console.log('@@ markertap', e)
- }
- const onCalloutTap = (e) => {
- console.log('@@ onCalloutTap', e)
- }
- const onLabelTap = (e) => {
- console.log('@@ labletap', e)
- }
- </script>
- <style lang="scss" scoped>
- .home-wrap {
- background-color: #F2F3F5;
- padding: 0;
- .home-top {
- padding: 20rpx 24rpx;
- background: linear-gradient(#FFFFFF, rgba(242, 243, 245, 0));
- position: relative;
- }
- .map-tips {
- position: absolute;
- bottom: 0%;
- left: 24rpx;
- height: 70rpx;
- width: calc(100% - 48rpx);
- background: linear-gradient(rgba(102, 102, 102, 0), rgba(0, 0, 0, 0.55));
- display: flex;
- align-items: center;
- font-size: 24rpx;
- color: #FFFFFF;
- padding-left: 20rpx;
- box-sizing: border-box;
- border-radius: 0 0 16rpx 16rpx;
- }
- .home-search {
- display: flex;
- align-items: center;
- width: 100%;
- border: 2rpx solid #FFD95E;
- border-radius: 40rpx;
- margin-bottom: 40rpx;
- .search-wrap {
- flex: 1;
- // padding-left: 22rpx;
- ::v-deep {
- .u-search {
- .u-search__content {
- background-color: transparent !important;
- .u-search__content__input {
- background-color: transparent !important;
-
- }
- }
- .u-search__action {
- text-align: center;
- line-height: 52rpx;
- border-radius: 40rpx;
- font-size: 28rpx;
- background-color: #FFD95E;
- margin: 6rpx 8rpx;
- width: 112rpx;
- height: 52rpx;
- }
- }
- }
- }
- .search-btn {
- text-align: center;
- line-height: 52rpx;
- border-radius: 40rpx;
- font-size: 28rpx;
- background-color: #FFD95E;
- margin: 6rpx 8rpx;
- width: 112rpx;
- height: 52rpx;
- }
- }
- .type-wrap {
- margin: 20rpx;
- padding: 20rpx;
- background-color: #fff;
- border-radius: 16rpx;
- height: 200rpx;
- box-sizing: border-box;
-
- .item-type {
- text-align: center;
- font-size: 24rpx;
- .type-img {
- width: 92rpx;
- height: 92rpx;
- }
- }
- .item-type + .item-type {
- padding-left: 22rpx;
- }
- }
-
- .garden-wrap {
- margin: 0 20rpx 20rpx;
- background: linear-gradient(#FFFFFF, rgba(255, 255, 255, 0));
- padding: 2rpx;
- border-radius: 16rpx;
- .garden-content{
- background: linear-gradient(#fff6d8 4%, #FFFFFF 28%);
- border-radius: 16rpx;
- padding: 20rpx;
- box-sizing: border-box;
- .garden-list {
- .garden-item {
- display: flex;
- .garden-l {
- position: relative;
- .garden-img {
- width: 254rpx;
- height: 200rpx;
- object-fit: cover;
- border-radius: 10rpx;
- }
- .img-text {
- position: absolute;
- left: 0%;
- top: 0%;
- background: rgba(0, 0, 0, 0.3);
- backdrop-filter: 8rpx;
- border-radius: 10rpx 0 10rpx 0;
- font-size: 20rpx;
- color: #FFFFFF;
- padding: 6rpx 14rpx;
- }
- }
- .garden-r {
- padding-left: 20rpx;
- .garden-title {
- font-size: 28rpx;
- line-height: 42rpx;
- color: #000000;
- font-weight: 600;
- padding-bottom: 10rpx;
- }
- .garden-info {
- color: rgba(0, 0, 0, 0.5);
- font-size: 24rpx;
- line-height: 36rpx;
- }
- .garden-btn-group {
- padding-top: 20rpx;
- display: flex;
- align-items: center;
- .btn-second {
- padding: 0 20rpx;
- border-radius: 40rpx;
- font-size: 24rpx;
- color: #C49600;
- background: rgba(255, 217, 94, 0.2);
- height: 56rpx;
- line-height: 56rpx;
- }
- .btn-primary {
- padding: 0 20rpx;
- border-radius: 40rpx;
- font-size: 24rpx;
- color: #000000;
- background: #FFD95E;
- font-weight: bold;
- height: 56rpx;
- line-height: 56rpx;
- }
- }
- }
- }
- .garden-item + .garden-item {
- margin-top: 20rpx;
- }
- }
- }
-
- }
-
-
- .hot-title {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding-bottom: 20rpx;
- .title-l {
- font-family: 'PangMenZhengDao';
- font-size: 32rpx;
- .title-color {
- color: #F3C11D ;
- }
- }
- .title-btn {
- color: rgba(0, 0, 0, 0.6);
- font-size: 24rpx;
- display: inline-flex;
- align-items: center;
- }
- }
-
-
- ::v-deep {
- .u-scroll-list__indicator {
- margin-top: 20rpx;
- }
- }
- }
- </style>
|