|
@@ -1,52 +1,154 @@
|
1
|
1
|
<template>
|
2
|
|
- <a-layout>
|
3
|
|
- <view class="v-flex container index-contariner">
|
4
|
|
- <banner class="flex-0" />
|
5
|
|
- <avatar-change class="flex-1" />
|
|
2
|
+ <view class="page index-page">
|
|
3
|
+ <map
|
|
4
|
+ class="index-map"
|
|
5
|
+ longitude="104.142597"
|
|
6
|
+ latitude="35.068215"
|
|
7
|
+ scale="3"
|
|
8
|
+ subkey="E4UBZ-2H265-WEMI5-QUMH5-VCCVZ-XPBHO"
|
|
9
|
+ layer-style="1"
|
|
10
|
+ :enable-zoom="false"
|
|
11
|
+ :enable-scroll="false"
|
|
12
|
+ :enable-poi="false"
|
|
13
|
+ ></map>
|
|
14
|
+
|
|
15
|
+ <view class="index-ad">
|
|
16
|
+ <banner-ad></banner-ad>
|
|
17
|
+ </view>
|
|
18
|
+
|
|
19
|
+ <view class="index-head">
|
|
20
|
+ <view class="index-title">全国庆生接力图</view>
|
|
21
|
+ <view class="index-tab flex">
|
|
22
|
+ <view class="index-tab-item flex-0" @tap="toNav('/pages/avatar/index')">换头像</view>
|
|
23
|
+ <view class="index-tab-item flex-0" @tap="toNav('/pages/rank/index')">排行榜</view>
|
|
24
|
+ </view>
|
6
|
25
|
</view>
|
7
|
|
- </a-layout>
|
|
26
|
+ </view>
|
8
|
27
|
</template>
|
9
|
28
|
|
10
|
29
|
<script>
|
11
|
|
-import { ref } from 'vue';
|
12
|
|
-import Taro, { useReady } from '@tarojs/taro';
|
13
|
|
-import { useModel } from '@zjxpcyc/vue-tiny-store';
|
14
|
|
-import banner from './components/banner.vue';
|
15
|
|
-import avatarChange from './components/avatar-change.vue';
|
16
|
|
-
|
17
|
|
-export default {
|
18
|
|
- components: {
|
19
|
|
- 'avatar-change': avatarChange,
|
20
|
|
- banner,
|
21
|
|
- },
|
22
|
|
- onShareAppMessage() {
|
23
|
|
- return {
|
24
|
|
- title: '庆国庆, 邀请好友一起换头像吧~',
|
25
|
|
- path: `/pages/index/index?recommender=${this.user.personId}`,
|
26
|
|
- imageUrl: 'https://yz-h5.oss-cn-shanghai.aliyuncs.com/assets/guoqing-miniapp/avatar_share.jpg',
|
27
|
|
- }
|
28
|
|
- },
|
29
|
|
- onShareTimeline() {
|
30
|
|
- return {
|
31
|
|
- title: '庆国庆, 邀请好友一起换头像吧~',
|
32
|
|
- query: `recommender=${this.user.personId}`
|
33
|
|
- }
|
34
|
|
- },
|
35
|
|
- setup () {
|
36
|
|
- const { user } = useModel('user');
|
|
30
|
+ import { ref } from 'vue';
|
|
31
|
+ import Taro, { useReady } from '@tarojs/taro';
|
|
32
|
+ import { useModel } from '@zjxpcyc/vue-tiny-store';
|
|
33
|
+ import { onShareAppMessage, onShareTimeline } from '@/utils/share';
|
|
34
|
+ import circleImg from '@/assets/images/star.png';
|
|
35
|
+
|
|
36
|
+ export default {
|
|
37
|
+ onShareAppMessage,
|
|
38
|
+ onShareTimeline,
|
|
39
|
+
|
|
40
|
+ setup () {
|
|
41
|
+ let markerAdded = false;
|
|
42
|
+ let drawing = false;
|
|
43
|
+ const mapCtx = ref();
|
|
44
|
+ const { list, getList } = useModel('rank');
|
37
|
45
|
|
38
|
|
- return {
|
39
|
|
- user,
|
|
46
|
+ const addMarkers = () => {
|
|
47
|
+ if (!list.value.length) return;
|
|
48
|
+ if (!mapCtx.value) return;
|
|
49
|
+ if (markerAdded) return;
|
|
50
|
+ if (drawing) return;
|
|
51
|
+
|
|
52
|
+ drawing = true;
|
|
53
|
+ const markers = list.value.map((it, inx) => ({
|
|
54
|
+ id: inx + 1,
|
|
55
|
+ longitude: it.location[0],
|
|
56
|
+ latitude: it.location[1],
|
|
57
|
+ iconPath: circleImg,
|
|
58
|
+ width: 12,
|
|
59
|
+ height: 12,
|
|
60
|
+ label: {
|
|
61
|
+ content: it.shorName,
|
|
62
|
+ }
|
|
63
|
+ }));
|
|
64
|
+
|
|
65
|
+ mapCtx.value.addMarkers({
|
|
66
|
+ markers,
|
|
67
|
+ clear: true,
|
|
68
|
+ success: () => {
|
|
69
|
+ markerAdded = true;
|
|
70
|
+ },
|
|
71
|
+ fail: (err) => {
|
|
72
|
+ console.error(err);
|
|
73
|
+ },
|
|
74
|
+ complete: () => {
|
|
75
|
+ drawing = false;
|
|
76
|
+ }
|
|
77
|
+ })
|
|
78
|
+ }
|
|
79
|
+
|
|
80
|
+ useReady(() => {
|
|
81
|
+ if (!list.value.length) {
|
|
82
|
+ getList().then(() => {
|
|
83
|
+ addMarkers();
|
|
84
|
+ });
|
|
85
|
+ }
|
|
86
|
+
|
|
87
|
+ wx.createSelectorQuery().select('.index-map').context(res => {
|
|
88
|
+ mapCtx.value = res.context;
|
|
89
|
+ addMarkers();
|
|
90
|
+ }).exec()
|
|
91
|
+ });
|
|
92
|
+
|
|
93
|
+ const toNav = (url) => {
|
|
94
|
+ Taro.navigateTo({ url })
|
|
95
|
+ };
|
|
96
|
+
|
|
97
|
+ return {
|
|
98
|
+ toNav,
|
|
99
|
+ }
|
40
|
100
|
}
|
41
|
|
- },
|
42
|
|
-}
|
|
101
|
+
|
|
102
|
+ }
|
|
103
|
+
|
43
|
104
|
</script>
|
44
|
105
|
|
|
106
|
+
|
45
|
107
|
<style lang="less">
|
46
|
|
- .index-contariner {
|
47
|
|
- background-repeat: no-repeat;
|
48
|
|
- background-image: url(http://yz-h5.oss-cn-shanghai.aliyuncs.com/assets/guoqing-miniapp/back.jpg);
|
49
|
|
- background-position: center bottom;
|
50
|
|
- background-size: 100% auto;
|
|
108
|
+.index-page {
|
|
109
|
+ position: relative;
|
|
110
|
+
|
|
111
|
+ map {
|
|
112
|
+ width: 100%;
|
|
113
|
+ height: 100%;
|
51
|
114
|
}
|
52
|
|
-</style>
|
|
115
|
+
|
|
116
|
+ .index-head {
|
|
117
|
+ position: absolute;
|
|
118
|
+ width: 100vw;
|
|
119
|
+ top: 0;
|
|
120
|
+ left: 0;
|
|
121
|
+ z-index: 10;
|
|
122
|
+
|
|
123
|
+ .index-title {
|
|
124
|
+ text-align: center;
|
|
125
|
+ margin-top: 50rpx;
|
|
126
|
+ font-size: 1.4em;
|
|
127
|
+ }
|
|
128
|
+
|
|
129
|
+ .index-tab {
|
|
130
|
+ width: 80vw;
|
|
131
|
+ margin: auto;
|
|
132
|
+ margin-top: 50rpx;
|
|
133
|
+ justify-content: space-around;
|
|
134
|
+
|
|
135
|
+ .index-tab-item {
|
|
136
|
+ text-align: center;
|
|
137
|
+ width: 200rpx;
|
|
138
|
+ border: 2px solid #fffd00;
|
|
139
|
+ box-sizing: border-box;
|
|
140
|
+ border-radius: 16rpx;
|
|
141
|
+ line-height: 2em;
|
|
142
|
+ color: #fffd00;
|
|
143
|
+ }
|
|
144
|
+ }
|
|
145
|
+ }
|
|
146
|
+
|
|
147
|
+ .index-ad {
|
|
148
|
+ position: absolute;
|
|
149
|
+ bottom: 0;
|
|
150
|
+ left: 0;
|
|
151
|
+ width: 100vw;
|
|
152
|
+ }
|
|
153
|
+}
|
|
154
|
+</style>
|