├── LICENSE
├── README.md
├── cloudfunctions.zip
├── miniprogram
├── app.js
├── app.json
├── app.wxss
├── colorui
│ ├── animation.wxss
│ ├── components
│ │ ├── cu-custom.js
│ │ ├── cu-custom.json
│ │ ├── cu-custom.wxml
│ │ └── cu-custom.wxss
│ ├── icon.wxss
│ └── main.wxss
├── config.js
├── images
│ ├── building.png
│ ├── coffee.png
│ ├── eat.png
│ ├── getLocation.png
│ ├── poster_l.png
│ ├── poster_r.png
│ ├── power.png
│ ├── printer.png
│ ├── store.png
│ ├── vending.png
│ ├── water.png
│ └── youpu.png
├── pages
│ ├── add
│ │ ├── add.js
│ │ ├── add.json
│ │ ├── add.wxml
│ │ └── add.wxss
│ ├── info
│ │ ├── info.js
│ │ ├── info.json
│ │ ├── info.wxml
│ │ └── info.wxss
│ ├── list
│ │ ├── list.js
│ │ ├── list.json
│ │ ├── list.wxml
│ │ └── list.wxss
│ ├── search
│ │ ├── search.js
│ │ ├── search.json
│ │ ├── search.wxml
│ │ └── search.wxss
│ ├── type1
│ │ ├── map.js
│ │ ├── map.json
│ │ ├── map.wxml
│ │ └── map.wxss
│ ├── type10
│ │ ├── map.js
│ │ ├── map.json
│ │ ├── map.wxml
│ │ └── map.wxss
│ ├── type11
│ │ ├── map.js
│ │ ├── map.json
│ │ ├── map.wxml
│ │ └── map.wxss
│ ├── type12
│ │ ├── map.js
│ │ ├── map.json
│ │ ├── map.wxml
│ │ └── map.wxss
│ ├── type13
│ │ ├── map.js
│ │ ├── map.json
│ │ ├── map.wxml
│ │ └── map.wxss
│ ├── type14
│ │ ├── map.js
│ │ ├── map.json
│ │ ├── map.wxml
│ │ └── map.wxss
│ ├── type2
│ │ ├── map.js
│ │ ├── map.json
│ │ ├── map.wxml
│ │ └── map.wxss
│ ├── type3
│ │ ├── map.js
│ │ ├── map.json
│ │ ├── map.wxml
│ │ └── map.wxss
│ ├── type4
│ │ ├── map.js
│ │ ├── map.json
│ │ ├── map.wxml
│ │ └── map.wxss
│ ├── type5
│ │ ├── map.js
│ │ ├── map.json
│ │ ├── map.wxml
│ │ └── map.wxss
│ ├── type6
│ │ ├── map.js
│ │ ├── map.json
│ │ ├── map.wxml
│ │ └── map.wxss
│ ├── type7
│ │ ├── map.js
│ │ ├── map.json
│ │ ├── map.wxml
│ │ └── map.wxss
│ ├── type8
│ │ ├── map.js
│ │ ├── map.json
│ │ ├── map.wxml
│ │ └── map.wxss
│ └── type9
│ │ ├── map.js
│ │ ├── map.json
│ │ ├── map.wxml
│ │ └── map.wxss
├── sitemap.json
├── tools
│ └── tools.wxs
└── vendor
│ └── fontawesome.wxss
└── project.config.json
/README.md:
--------------------------------------------------------------------------------
1 | # 菜狗识途
2 | 
3 |
4 | 校园导航导览微信小程序,扫描下方二维码体验
5 |

6 |
7 | 
8 |
9 | ## Table of Contents
10 | - [Background](#background)
11 | - [Install](#install)
12 | - [Contributors](#Contributors)
13 | - [License](#license)
14 |
15 | ## Background
16 | “西浦在哪”已经上线一年了,当时答应同学的很多功能都鸽到了现在,趁着复习周和期中周有些空闲把他完善一下。这次最大的更新是把数据放在了云开发中而不是包里(感谢[宦成](https://github.com/bestony)的美食图鉴),然后有了详情页、搜索、导航、查看全部...
17 | 还有许多可以完善的地方,比如详情页没有用富文本...
18 | ## Install
19 | - 将代码下载到本地,可以直接点击下载压缩包,也可以clone项目。请将cloudfunctions.zip解压到和miniprogram一个目录下
20 |
21 | 
22 |
23 | - 注册一个[小程序账号](https://kf.qq.com/faq/170109iQBJ3Q170109JbQfiu.html)然后下载[微信开发者工具](https://developers.weixin.qq.com/miniprogram/dev/devtools/download.html)
24 | - 开通腾讯位置服务如下图进入后开始[个性化地图](https://lbs.qq.com/product/miniapp/guide/)
25 |
26 | -0e097d10d1ed44abac1918ed1f8e4cf9.png)
27 |
28 | - 导入项目:选择解压后的文件,然后填入appid(注册小程序账号后获得),最后选择[云开发](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/basis/getting-started.html)
29 |
30 | -18ba328f19cf4b71bc34af5f22fdf7e7.png)
31 |
32 | - 云开发设置:进入云开发控制台后点击数据库后添加集合 `store`和 `userInfo`
33 | `store`为所有用户可读,仅创建者可读写
34 | `userInfo`为仅创建者可读写
35 |
36 | -37eaa0ab46b8457a8fce11e689a81608.png)
37 |
38 | 选择好云环境后将checkUserAuth,getStore和getUserOpenId都上传部署一下
39 |
40 | 
41 |
42 | - 配置config.js
43 | ```
44 | module.exports = {
45 | "appName":"小程序的名字",
46 | "envID":"云开发的环境ID",
47 | "mapSubKey":"腾讯位置服务中的subkey",
48 | "center_longitude": 初始经度,
49 | "center_latitude": 初始纬度,
50 | "dynamic_title":false,//动态详情页标题
51 | "show_admin":false,//是否显示管理员入口
52 | }
53 | ```
54 | - 设置管理员:获取openid(一种长按管理入口可复制到粘贴板,另一种可以使用[接口测试账号](https://blog.csdn.net/HezhezhiyuLe/article/details/109352740))
55 | 获取openid后,进入云开发控制台,点击云函数,找到checkUserAuth,点击版本与配置后再点击配置,出现如下图所示内容Key中填入 `ADMIN `,Value中填入 `你的openid`,如设置多名管理员则用|隔开
56 |
57 | -bd124c37972442cda02b41dfffd377c5.png)
58 |
59 | ## Contributors
60 |
66 |
67 | ## License
68 | GNU General Public License v2.0
69 |
--------------------------------------------------------------------------------
/cloudfunctions.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscga1/miniprogram-CampusMap/385225f123874267f9afdfed62221d764630bc20/cloudfunctions.zip
--------------------------------------------------------------------------------
/miniprogram/app.js:
--------------------------------------------------------------------------------
1 | const config = require('config.js');
2 | App({
3 | onLaunch: function (options) {
4 | /**
5 | * 初始化云开发
6 | */
7 | if (!wx.cloud) {
8 | console.error('请使用 2.2.3 或以上的基础库以使用云能力')
9 | } else {
10 | wx.cloud.init({
11 | traceUser: true,
12 | env: config.envID
13 | })
14 | }
15 | /**
16 | * 获取屏幕高度
17 | */
18 | let { windowHeight } = wx.getSystemInfoSync();
19 | let showAdmin = wx.getStorageSync('showAdmin');
20 | if (showAdmin == ""){
21 | showAdmin = false;
22 | }
23 | this.globalData = { windowHeight, is_administrator: false, showAdmin: showAdmin}
24 | }
25 | })
26 |
--------------------------------------------------------------------------------
/miniprogram/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "pages": [
3 | "pages/type1/map",
4 | "pages/type2/map",
5 | "pages/type3/map",
6 | "pages/type4/map",
7 | "pages/type5/map",
8 | "pages/type6/map",
9 | "pages/type7/map",
10 | "pages/type8/map",
11 | "pages/type9/map",
12 | "pages/type10/map",
13 | "pages/type11/map",
14 | "pages/type12/map",
15 | "pages/type13/map",
16 | "pages/type14/map",
17 | "pages/list/list",
18 | "pages/info/info",
19 | "pages/add/add",
20 | "pages/search/search"
21 | ],
22 | "window": {
23 | "backgroundColor": "#3ecf8e",
24 | "backgroundTextStyle": "light",
25 | "navigationBarBackgroundColor": "#3ecf8e",
26 | "navigationBarTitleText": "菜狗识途",
27 | "navigationBarTextStyle": "white"
28 | },
29 |
30 |
31 | "permission": {
32 | "scope.userLocation": {
33 | "desc": "您的位置信息仅在使用小程序时被获取"
34 | }
35 | },
36 | "sitemapLocation": "sitemap.json"
37 | }
--------------------------------------------------------------------------------
/miniprogram/app.wxss:
--------------------------------------------------------------------------------
1 | @import "vendor/fontawesome.wxss";
2 | .button {
3 | color: #fff;
4 | height: 100rpx;
5 | width: 220rpx;
6 | line-height: 100rpx;
7 | font-size: 35rpx;
8 | text-align: center;
9 | background-color: rgb(62, 207, 142);
10 | border-radius: 50rpx;
11 | box-shadow: 0 4px 6px rgba(50,50,93,.11), 0 1px 3px rgba(0,0,0,.08);
12 | }
13 |
--------------------------------------------------------------------------------
/miniprogram/colorui/animation.wxss:
--------------------------------------------------------------------------------
1 | /*
2 | Animation 微动画
3 | 基于ColorUI组建库的动画模块 by 文晓港 2019年3月26日19:52:28
4 | */
5 |
6 | /* css 滤镜 控制黑白底色gif的 */
7 | .gif-black{
8 | mix-blend-mode: screen;
9 | }
10 | .gif-white{
11 | mix-blend-mode: multiply;
12 | }
13 |
14 |
15 | /* Animation css */
16 | [class*=animation-] {
17 | animation-duration: .5s;
18 | animation-timing-function: ease-out;
19 | animation-fill-mode: both
20 | }
21 |
22 | .animation-fade {
23 | animation-name: fade;
24 | animation-duration: .8s;
25 | animation-timing-function: linear
26 | }
27 |
28 | .animation-scale-up {
29 | animation-name: scale-up
30 | }
31 |
32 | .animation-scale-down {
33 | animation-name: scale-down
34 | }
35 |
36 | .animation-slide-top {
37 | animation-name: slide-top
38 | }
39 |
40 | .animation-slide-bottom {
41 | animation-name: slide-bottom
42 | }
43 |
44 | .animation-slide-left {
45 | animation-name: slide-left
46 | }
47 |
48 | .animation-slide-right {
49 | animation-name: slide-right
50 | }
51 |
52 | .animation-shake {
53 | animation-name: shake
54 | }
55 |
56 | .animation-reverse {
57 | animation-direction: reverse
58 | }
59 |
60 | @keyframes fade {
61 | 0% {
62 | opacity: 0
63 | }
64 |
65 | 100% {
66 | opacity: 1
67 | }
68 | }
69 |
70 | @keyframes scale-up {
71 | 0% {
72 | opacity: 0;
73 | transform: scale(.2)
74 | }
75 |
76 | 100% {
77 | opacity: 1;
78 | transform: scale(1)
79 | }
80 | }
81 |
82 | @keyframes scale-down {
83 | 0% {
84 | opacity: 0;
85 | transform: scale(1.8)
86 | }
87 |
88 | 100% {
89 | opacity: 1;
90 | transform: scale(1)
91 | }
92 | }
93 |
94 | @keyframes slide-top {
95 | 0% {
96 | opacity: 0;
97 | transform: translateY(-100%)
98 | }
99 |
100 | 100% {
101 | opacity: 1;
102 | transform: translateY(0)
103 | }
104 | }
105 |
106 | @keyframes slide-bottom {
107 | 0% {
108 | opacity: 0;
109 | transform: translateY(100%)
110 | }
111 |
112 | 100% {
113 | opacity: 1;
114 | transform: translateY(0)
115 | }
116 | }
117 |
118 | @keyframes shake {
119 |
120 | 0%,
121 | 100% {
122 | transform: translateX(0)
123 | }
124 |
125 | 10% {
126 | transform: translateX(-9px)
127 | }
128 |
129 | 20% {
130 | transform: translateX(8px)
131 | }
132 |
133 | 30% {
134 | transform: translateX(-7px)
135 | }
136 |
137 | 40% {
138 | transform: translateX(6px)
139 | }
140 |
141 | 50% {
142 | transform: translateX(-5px)
143 | }
144 |
145 | 60% {
146 | transform: translateX(4px)
147 | }
148 |
149 | 70% {
150 | transform: translateX(-3px)
151 | }
152 |
153 | 80% {
154 | transform: translateX(2px)
155 | }
156 |
157 | 90% {
158 | transform: translateX(-1px)
159 | }
160 | }
161 |
162 | @keyframes slide-left {
163 | 0% {
164 | opacity: 0;
165 | transform: translateX(-10%)
166 | }
167 |
168 | 100% {
169 | opacity: 1;
170 | transform: translateX(0)
171 | }
172 | }
173 |
174 | @keyframes slide-right {
175 | 0% {
176 | opacity: 0;
177 | transform: translateX(100%)
178 | }
179 |
180 | 100% {
181 | opacity: 1;
182 | transform: translateX(0)
183 | }
184 | }
--------------------------------------------------------------------------------
/miniprogram/colorui/components/cu-custom.js:
--------------------------------------------------------------------------------
1 | const app = getApp()
2 | Component({
3 | /**
4 | * 组件的一些选项
5 | */
6 | options: {
7 | addGlobalClass: true,
8 | multipleSlots: true
9 | },
10 | /**
11 | * 组件的对外属性1
12 | */
13 | properties: {
14 | bgColor: {
15 | type: String,
16 | default: ''
17 | },
18 | isCustom: {
19 | type: [Boolean, String],
20 | default: false
21 | },
22 | isBack: {
23 | type: [Boolean, String],
24 | default: false
25 | },
26 | bgImage: {
27 | type: String,
28 | default: ''
29 | },
30 | },
31 | /**
32 | * 组件的初始数据
33 | */
34 | data: {
35 | StatusBar: app.globalData.StatusBar,
36 | CustomBar: app.globalData.CustomBar,
37 | Custom: app.globalData.Custom
38 | },
39 | /**
40 | * 组件的方法列表
41 | */
42 | methods: {
43 | BackPage() {
44 | wx.navigateBack({
45 | delta: 1
46 | }).catch(error => {
47 | console.info("error", error)
48 | wx.reLaunch({
49 | url: '/pages/index/index',
50 | })
51 | });
52 | },
53 | toHome(){
54 | wx.reLaunch({
55 | url: '/pages/index/index',
56 | })
57 | }
58 | }
59 | })
60 |
--------------------------------------------------------------------------------
/miniprogram/colorui/components/cu-custom.json:
--------------------------------------------------------------------------------
1 | {
2 | "component": true,
3 | "usingComponents": {}
4 | }
--------------------------------------------------------------------------------
/miniprogram/colorui/components/cu-custom.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/miniprogram/colorui/components/cu-custom.wxss:
--------------------------------------------------------------------------------
1 | /* colorui/components/cu-custom.wxss */
2 | .gif-black {
3 | display: block;
4 | }
5 |
6 |
--------------------------------------------------------------------------------
/miniprogram/config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | "appName":"菜狗识途",
3 | "envID":"caigoushitu-5g2d1wlb5789dc4d",
4 | "mapSubKey":"6FEBZ-TTVWU-VCYVZ-2EORN-R3HKF-D2FKP",
5 | "center_longitude": 120.74038982,
6 | "center_latitude": 31.27141370,
7 | "dynamic_title":false,
8 | "show_admin":false,
9 | // "default_scale":16
10 | }
--------------------------------------------------------------------------------
/miniprogram/images/building.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscga1/miniprogram-CampusMap/385225f123874267f9afdfed62221d764630bc20/miniprogram/images/building.png
--------------------------------------------------------------------------------
/miniprogram/images/coffee.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscga1/miniprogram-CampusMap/385225f123874267f9afdfed62221d764630bc20/miniprogram/images/coffee.png
--------------------------------------------------------------------------------
/miniprogram/images/eat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscga1/miniprogram-CampusMap/385225f123874267f9afdfed62221d764630bc20/miniprogram/images/eat.png
--------------------------------------------------------------------------------
/miniprogram/images/getLocation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscga1/miniprogram-CampusMap/385225f123874267f9afdfed62221d764630bc20/miniprogram/images/getLocation.png
--------------------------------------------------------------------------------
/miniprogram/images/poster_l.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscga1/miniprogram-CampusMap/385225f123874267f9afdfed62221d764630bc20/miniprogram/images/poster_l.png
--------------------------------------------------------------------------------
/miniprogram/images/poster_r.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscga1/miniprogram-CampusMap/385225f123874267f9afdfed62221d764630bc20/miniprogram/images/poster_r.png
--------------------------------------------------------------------------------
/miniprogram/images/power.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscga1/miniprogram-CampusMap/385225f123874267f9afdfed62221d764630bc20/miniprogram/images/power.png
--------------------------------------------------------------------------------
/miniprogram/images/printer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscga1/miniprogram-CampusMap/385225f123874267f9afdfed62221d764630bc20/miniprogram/images/printer.png
--------------------------------------------------------------------------------
/miniprogram/images/store.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscga1/miniprogram-CampusMap/385225f123874267f9afdfed62221d764630bc20/miniprogram/images/store.png
--------------------------------------------------------------------------------
/miniprogram/images/vending.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscga1/miniprogram-CampusMap/385225f123874267f9afdfed62221d764630bc20/miniprogram/images/vending.png
--------------------------------------------------------------------------------
/miniprogram/images/water.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscga1/miniprogram-CampusMap/385225f123874267f9afdfed62221d764630bc20/miniprogram/images/water.png
--------------------------------------------------------------------------------
/miniprogram/images/youpu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscga1/miniprogram-CampusMap/385225f123874267f9afdfed62221d764630bc20/miniprogram/images/youpu.png
--------------------------------------------------------------------------------
/miniprogram/pages/add/add.js:
--------------------------------------------------------------------------------
1 | const app = getApp();
2 | const db = wx.cloud.database()
3 | const store = db.collection('store');
4 | Page({
5 |
6 | /**
7 | * 页面的初始数据
8 | */
9 | data: {
10 |
11 | },
12 |
13 | /**
14 | * 生命周期函数--监听页面加载
15 | */
16 | onLoad: function (options) {
17 | },
18 | chooseLocation: function (event) {
19 | wx.getSetting({
20 | success: res => {
21 | if (!res.authSetting['scope.userLocation']){
22 | wx.authorize({
23 | scope: 'scope.userLocation',
24 | success:res => {
25 | wx.chooseLocation({
26 | success: res => {
27 | this.setData({
28 | address: res.address,
29 | latitude: res.latitude,
30 | longitude: res.longitude,
31 | name: res.name
32 | })
33 | }
34 | })
35 | }
36 | })
37 | }else{
38 | wx.chooseLocation({
39 | success: res => {
40 | this.setData({
41 | address: res.address,
42 | latitude: res.latitude,
43 | longitude: res.longitude,
44 | name: res.name
45 | })
46 | }
47 | })
48 | }
49 | }
50 | })
51 |
52 | },
53 | createItem: function (event) {
54 | wx.showLoading({
55 | title: '上传数据中...',
56 | })
57 | let value = event.detail.value
58 | store.add({
59 | data: {
60 | ...value,
61 | thumbs_up: 1,
62 | iconPath: "/images/power.png",
63 | longitude: this.data.longitude,
64 | latitude: this.data.latitude,
65 | width: 23, //icon显示宽度
66 | height: 23,
67 | label: {
68 | content: value.label,
69 | textAlign:"center",
70 | color:"#787878"
71 | },
72 | images: this.data.images
73 | }
74 | }).then(res => {
75 | wx.hideLoading();
76 | wx.showToast({
77 | title: '创建成功!',
78 | icon: 'success',
79 | success: res => {
80 | wx.navigateBack({
81 | })
82 | }
83 | })
84 | }).catch(error => {
85 | console.error(error);
86 | })
87 | },
88 | uploadImage: function (e) {
89 | wx.chooseImage({
90 | count: 9,
91 | sizeType: ['original', 'compressed'],
92 | sourceType: ['album', 'camera'],
93 | success: res => {
94 |
95 | wx.showLoading({ title: '上传中' })
96 | let tempFilePaths = res.tempFilePaths
97 | let items = [];
98 | for (const tempFilePath of tempFilePaths) {
99 | items.push({
100 | src: tempFilePath
101 | })
102 | }
103 | const uploadTask = items.map(item => this.uploadPhoto(item.src))
104 |
105 | Promise.all(uploadTask).then(result => {
106 |
107 | let urls = [];
108 | for (const file of result) {
109 | urls.push(file.fileID);
110 | }
111 | this.setData({
112 | images: urls
113 | }, res => {
114 | wx.hideLoading();
115 | wx.showToast({ title: '上传图片成功', icon: 'success' })
116 | })
117 | }).catch(() => {
118 | wx.hideLoading()
119 | wx.showToast({ title: '上传图片错误', icon: 'error' })
120 | })
121 |
122 | this.setData({ tempPhoto: items })
123 | }
124 | })
125 | },
126 | uploadPhoto(filePath) {
127 | return wx.cloud.uploadFile({
128 | cloudPath: `${Date.now()}-${Math.floor(Math.random(0, 1) * 10000000)}.png`,
129 | filePath
130 | })
131 | }
132 | })
--------------------------------------------------------------------------------
/miniprogram/pages/add/add.json:
--------------------------------------------------------------------------------
1 | {
2 | "usingComponents": {}
3 | }
--------------------------------------------------------------------------------
/miniprogram/pages/add/add.wxml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/miniprogram/pages/add/add.wxss:
--------------------------------------------------------------------------------
1 | page{
2 | background-color: #eee;
3 | }
4 |
5 | .desc{
6 | padding: 20rpx;
7 | }
8 | .loactionGroup{
9 | padding: 10rpx;
10 | display: flex;
11 | flex-direction: row;
12 | }
13 | input{
14 | background-color: #fff;
15 | padding: 20rpx;
16 | }
17 | textarea{
18 | background-color: #fff;
19 | padding: 20rpx;
20 | width: 710rpx;
21 | }
22 | .submit{
23 | margin-top: 40rpx;
24 | }
--------------------------------------------------------------------------------
/miniprogram/pages/info/info.js:
--------------------------------------------------------------------------------
1 | const app = getApp();
2 | const db = wx.cloud.database()
3 | const store = db.collection('store');
4 | const config = require('../../config.js');
5 | Page({
6 |
7 | /**
8 | * 页面的初始数据
9 | */
10 | data: {
11 |
12 | },
13 |
14 | /**
15 | * 生命周期函数--监听页面加载
16 | */
17 | onLoad: function (options) {
18 | wx.showLoading({
19 | title: '加载中...',
20 | })
21 | store.doc(options.id).get().then(res => {
22 | if (config.dynamic_title){
23 | wx.setNavigationBarTitle({
24 | title: res.data.title,
25 | });
26 | }
27 | // 两次切割以适配中英文逗号
28 | let keywords_array = res.data.keywords.split(',').map(item => { return item.split(',') })
29 | // 将数组压平
30 | let keywords = [].concat.apply([], keywords_array);
31 | res.data.keywords = keywords
32 | this.setData({
33 | store: res.data,
34 | is_administrator: app.globalData.is_administrator
35 | },res => {
36 | wx.hideLoading();
37 | })
38 | })
39 | },
40 | tapImage:function(e){
41 | wx.previewImage({
42 | urls: this.data.store.images,
43 | current: e.currentTarget.dataset.url
44 | })
45 | },
46 | copyPath:function(e){
47 | let path = this.route + "?id="+ this.data.store._id
48 | wx.setClipboardData({
49 | data: path,
50 | success: res => {
51 | wx.showToast({
52 | title: '路径复制成功',
53 | icon:"success"
54 | })
55 | }
56 | })
57 | },
58 | /**
59 | * 用户点击右上角分享
60 | */
61 | onShareAppMessage: function () {
62 | let path = '/pages/info/info?id=' + this.data.store._id;
63 | let image = "/images/poster_l.png";
64 | if (this.data.store.images[0]){
65 | wx.cloud.getTempFileURL({
66 | fileList: [this.data.store.images[0]],
67 | success: res =>{
68 | return {
69 | title: '菜狗识途,为你带路!',
70 | path: path,
71 | imageUrl: res.fileList[0].tempFileURL
72 | }
73 | },
74 | fail: error => {
75 | console.error("出现Bug了",error)
76 | }
77 | })
78 | }else{
79 | return {
80 | title: '菜狗识途,为你带路!',
81 | path: path,
82 | imageUrl: image
83 | }
84 | }
85 |
86 | },
87 |
88 |
89 | callContact:function(event){
90 | wx.makePhoneCall({
91 | phoneNumber: this.data.store.contact
92 | })
93 | },
94 | navigate:function(e){
95 | wx.openLocation({
96 | latitude: this.data.store.latitude,
97 | longitude: this.data.store.longitude,
98 | name: this.data.store.title,
99 | address: this.data.store.address
100 | })
101 | },
102 | deleteItem:function(e){
103 | wx.showModal({
104 | title: '删除确认',
105 | content: '您真的要删除' + this.data.store.title + "么?",
106 | success: res => {
107 | if (res.confirm) {
108 | store.doc(this.data.store._id).remove().then(res => {
109 | wx.showToast({
110 | title: '删除成功',
111 | icon:'success',
112 | success:res => {
113 | wx.navigateBack({
114 | delta: 2
115 | })
116 | }
117 | })
118 | }).catch(error => {
119 | wx.showToast({
120 | title: '删除失败!请排查问题',
121 | })
122 | })
123 | } else if (res.cancel) {
124 | console.log('用户点击取消')
125 | }
126 | }
127 | })
128 | }
129 | })
--------------------------------------------------------------------------------
/miniprogram/pages/info/info.json:
--------------------------------------------------------------------------------
1 | {
2 | "usingComponents": {
3 | },
4 | "navigationBarTitleText": "详情"
5 | }
--------------------------------------------------------------------------------
/miniprogram/pages/info/info.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | {{tools.replaceLine(store.title)}}
15 |
16 |
17 |
18 |
19 |
31 |
32 |
33 |
34 |
35 | 位置:
36 |
37 |
38 | {{tools.replaceLine(store.address)}}
39 |
40 |
41 |
42 |
43 | 详情信息:
44 |
45 |
46 | {{tools.replaceLine(store.notes)}}
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/miniprogram/pages/info/info.wxss:
--------------------------------------------------------------------------------
1 | .slide-image {
2 | width: 750rpx;
3 | height: 240px;
4 | }
5 |
6 | .contact {
7 | padding: 20rpx;
8 | }
9 |
10 | .star {
11 | padding: 20rpx;
12 | }
13 |
14 | .keywords {
15 | padding: 20rpx;
16 | }
17 |
18 | .notes {
19 | padding: 20rpx;
20 | color: rgb(62, 207, 142);
21 | font-size: 35rpx;
22 | font-weight: 700;
23 | }
24 | .notes1 {
25 | padding: 20rpx;
26 | color: #292421;
27 | }
28 |
29 |
30 | .per {
31 | padding: 20rpx;
32 | }
33 |
34 | .address {
35 | padding: 20rpx;
36 | }
37 |
38 | .thumbs_up {
39 | padding: 20rpx;
40 | }
41 |
42 | .title {
43 | padding: 20rpx;
44 | font-size: 50rpx;
45 | font-weight: 700;
46 | color: rgb(62, 207, 142);
47 | }
48 |
49 | swiper {
50 | height: 240px;
51 | background-color: #eee;
52 | }
53 |
54 | .two_column {
55 | display: flex;
56 | flex-direction: row;
57 | justify-content: space-between;
58 | }
59 |
60 | .copy_path{
61 | position: absolute;
62 | right: 100rpx;
63 | bottom: 50rpx;
64 | color: #7795f8;
65 | background-color: rgb(255, 255, 255);
66 | box-shadow: 0 4px 6px rgba(50,50,93,.11), 0 1px 3px rgba(0,0,0,.08);
67 | }
68 | .delete_item{
69 | position: absolute;
70 | left: 100rpx;
71 | bottom: 50rpx;
72 | color: #ff0000;
73 | background-color: rgb(255, 255, 255);
74 | box-shadow: 0 4px 6px rgba(50,50,93,.11), 0 1px 3px rgba(0,0,0,.08);
75 | }
76 | .navigateBox{
77 | display: flex;
78 | flex-direction: row;
79 | justify-content: center;
80 | margin: 20rpx;
81 | }
82 | .navigate{
83 | margin:20rpx 0rpx;
84 | }
--------------------------------------------------------------------------------
/miniprogram/pages/list/list.js:
--------------------------------------------------------------------------------
1 | const app = getApp();
2 | const db = wx.cloud.database()
3 | const store = db.collection('store');
4 | Page({
5 |
6 | /**
7 | * 页面的初始数据
8 | */
9 | data: {
10 | numbers: 0,
11 | stores: []
12 | },
13 |
14 | /**
15 | * 生命周期函数--监听页面加载
16 | */
17 | onLoad: function(options) {
18 | this.loadData();
19 | },
20 | loadData: function() {
21 | store.skip(this.data.numbers).get().then(res => {
22 | /**
23 | * 如果没有数据,就提示没有商户了,并返回。
24 | */
25 | if (res.data.length == 0) {
26 | wx.showToast({
27 | title: '没有数据了',
28 | icon: 'none'
29 | });
30 | return;
31 | }
32 | this.setData({
33 | stores: this.data.stores.concat(res.data),
34 | numbers: this.data.numbers + res.data.length
35 | });
36 | })
37 | },
38 | /**
39 | * 页面上拉触底事件的处理函数
40 | */
41 | onReachBottom: function() {
42 | this.loadData();
43 | },
44 | navigateToSearch:function(e){
45 | wx.redirectTo({
46 | url: '../search/search',
47 | })
48 | }
49 | })
--------------------------------------------------------------------------------
/miniprogram/pages/list/list.json:
--------------------------------------------------------------------------------
1 | {
2 | "usingComponents": {},
3 | "navigationBarTitleText": "全部"
4 | }
--------------------------------------------------------------------------------
/miniprogram/pages/list/list.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {{item.title}}
6 |
7 | {{item.address}}
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/miniprogram/pages/list/list.wxss:
--------------------------------------------------------------------------------
1 | .card{
2 | border-bottom: 1rpx solid #cecece;
3 | display: flex;
4 | flex-direction: column;
5 | justify-content: space-around;
6 | padding:10rpx;
7 | }
8 | .card_title{
9 | font-size: 32rpx;
10 | font-weight: 700;
11 | color: rgb(62, 207, 142);
12 | }
13 | .card_infobar{
14 | display: flex;
15 | flex-direction: row;
16 | justify-content: space-between;
17 | color: #292421;
18 | }
19 | .card_address{
20 | font-size: 30rpx;
21 | font-weight: 300;
22 | width: 600rpx;
23 | overflow: hidden;
24 | white-space:nowrap;
25 |
26 | }
27 | .card_thumbsup{
28 | font-size: 30rpx;
29 | font-weight: 700;
30 |
31 | }
32 | .search_input{
33 | background-color: #eee;
34 | margin:5px;
35 | width: 730rpx;
36 | height: 80rpx;
37 | text-align: center;
38 | border-radius: 100px;
39 |
40 | }
41 | .input-placeholder{
42 | text-align: center;
43 | }
--------------------------------------------------------------------------------
/miniprogram/pages/search/search.js:
--------------------------------------------------------------------------------
1 | const app = getApp();
2 | const db = wx.cloud.database()
3 | const store = db.collection('store');
4 | Page({
5 |
6 | /**
7 | * 页面的初始数据
8 | */
9 | data: {
10 | numbers: 0,
11 | stores: [],
12 | focus:false,
13 | searched:false
14 | },
15 |
16 | /**
17 | * 生命周期函数--监听页面加载
18 | */
19 | onLoad: function (options) {
20 | this.setData({
21 | focus:true
22 | })
23 | },
24 |
25 | /**
26 | * 生命周期函数--监听页面初次渲染完成
27 | */
28 | onReady: function () {
29 |
30 | },
31 | onReachBottom: function () {
32 | this.loadData();
33 | },
34 | loadData:function(keywords){
35 | store.skip(this.data.numbers).where({
36 | title: db.RegExp({
37 | regexp: this.data.keywords,
38 | options: 'i',
39 | })
40 | }).get().then(res => {
41 | /**
42 | * 如果没有数据,就提示没有商户了,并返回。
43 | */
44 | if (res.data.length == 0) {
45 | this.setData({
46 | searched:true
47 | })
48 | }
49 | this.setData({
50 | stores: this.data.stores.concat(res.data),
51 | numbers: this.data.numbers + res.data.length
52 | });
53 | })
54 | },
55 | search:function(e){
56 | this.setData({
57 | keywords: e.detail.value
58 | },res => {
59 | this.loadData();
60 | })
61 | },
62 |
63 | })
--------------------------------------------------------------------------------
/miniprogram/pages/search/search.json:
--------------------------------------------------------------------------------
1 | {
2 | "usingComponents": {},
3 | "navigationBarTitleText": "搜索"
4 | }
--------------------------------------------------------------------------------
/miniprogram/pages/search/search.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | {{item.title}}
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | 如果问题没有解决 请查看全部或进入有浦
17 |
18 |
19 |
20 |
21 | 查看全部
22 |
23 |
24 | 有浦
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/miniprogram/pages/search/search.wxss:
--------------------------------------------------------------------------------
1 | .search_box{
2 | background-color: #eee;
3 | margin:5px;
4 | width: 730rpx;
5 | height: 80rpx;
6 | text-align: center;
7 | border-radius: 100px;
8 | }
9 | .search_title{
10 | font-size: 32rpx;
11 | font-weight: 700;
12 | color: rgb(62, 207, 142);
13 | }
14 | .search_input{
15 | background-color: #eee;
16 | margin:5px;
17 | width: 730rpx;
18 | height: 80rpx;
19 | text-align: center;
20 | border-radius: 100px;
21 | }
22 | .input-placeholder{
23 | text-align: center;
24 | }
25 | .not_found{
26 | display: flex;
27 | width: 100%;
28 | height: 750rpx;
29 | justify-content: center;
30 | line-height: 750rpx;
31 | }
32 | .card{
33 | border-bottom: 1rpx solid #cecece;
34 | display: flex;
35 | flex-direction: column;
36 | justify-content: space-around;
37 | padding:10rpx;
38 | }
39 | .card_title{
40 | font-size: 32rpx;
41 | font-weight: 700;
42 | color: rgb(62, 207, 142);
43 | }
44 | .card_infobar{
45 | display: flex;
46 | flex-direction: row;
47 | justify-content: space-between;
48 | }
49 | .card_address{
50 | font-size: 30rpx;
51 | font-weight: 300;
52 | width:750rpx;
53 | overflow: hidden;
54 | white-space:nowrap;
55 | }
56 | .no_result_button{
57 | display:flex;
58 | flex-direction:column;
59 | justify-content:center;
60 | height:700rpx;
61 | width:750rpx;
62 | align-items:center;
63 | font-size: 30rpx;
64 | }
65 | .view_all{
66 | margin-top: 40rpx;
67 | }
68 | .carousel-img {
69 | height: 380rpx;
70 | width: 95%;
71 | /* margin: 20rpx; */
72 | }
73 |
74 | /* =========== */
75 | /* Home键 */
76 | /* =========== */
77 |
78 | @keyframes scaleDraw {
79 | 0% {
80 | transform: scale(1);
81 | }
82 | 25% {
83 | transform: scale(1.3);
84 | }
85 | 50% {
86 | transform: scale(1);
87 | }
88 | 75% {
89 | transform: scale(1.3);
90 | }
91 | }
92 |
93 | .home {
94 | /* -webkit-animation: scaleDraw 5s ease-in-out infinite; */
95 | position: fixed;
96 | left: 5%;
97 | top: 4%;
98 | z-index: 10000;
99 | }
100 |
101 | .home-btn {
102 | width: 60rpx !important;
103 | height: 60rpx !important;
104 | }
105 |
106 |
107 |
108 | /* =========== */
109 | /* 全屏抽屉 */
110 | /* =========== */
111 |
112 | page {
113 | background-image: var(--gradualShadow);
114 | width: 100vw;
115 | overflow: hidden;
116 | }
117 |
118 | .DrawerPage {
119 | position: fixed;
120 | width: 100vw;
121 | height: 100vh;
122 | left: 0vw;
123 | background-color: #f1f1f1;
124 | transition: all 0.4s;
125 | overflow-y: auto;
126 | }
127 |
128 | .DrawerPage.show {
129 | transform: scale(0.9, 0.9);
130 | left: 85vw;
131 | box-shadow: 0 0 60rpx rgba(0, 0, 0, 0.2);
132 | transform-origin: 0;
133 | }
134 |
135 | .DrawerWindow {
136 | position: absolute;
137 | width: 85vw;
138 | height: 100vh;
139 | left: 0;
140 | top: 0;
141 | transform: scale(0.9, 0.9) translateX(-100%);
142 | opacity: 0;
143 | pointer-events: none;
144 | transition: all 0.4s;
145 | }
146 |
147 | .DrawerWindow.show {
148 | transform: scale(1, 1) translateX(0%);
149 | opacity: 1;
150 | pointer-events: all;
151 | }
152 |
153 | .DrawerClose {
154 | position: absolute;
155 | width: 40vw;
156 | height: 100vh;
157 | right: 0;
158 | top: 0;
159 | color: transparent;
160 | padding-bottom: 30rpx;
161 | display: flex;
162 | align-items: flex-end;
163 | justify-content: center;
164 | background-image: linear-gradient(90deg, rgba(0, 0, 0, 0.01), rgba(0, 0, 0, 0.6));
165 | letter-spacing: 5px;
166 | font-size: 50rpx;
167 | opacity: 0;
168 | pointer-events: none;
169 | transition: all 0.4s;
170 | }
171 |
172 | .DrawerClose.show {
173 | opacity: 1;
174 | pointer-events: all;
175 | width: 15vw;
176 | color: #fff;
177 | }
178 |
179 | .DrawerPage .cu-bar.tabbar .action button.icon {
180 | width: 64rpx;
181 | height: 64rpx;
182 | line-height: 64rpx;
183 | margin: 0;
184 | display: inline-block;
185 | }
186 |
187 | .DrawerPage .cu-bar.tabbar .action .cu-avatar {
188 | margin: 0;
189 | }
190 |
191 | .DrawerPage .nav {
192 | flex: 1;
193 | }
194 |
195 | .DrawerPage .nav .cu-item.cur {
196 | border-bottom: 0;
197 | position: relative;
198 |
199 | }
200 |
201 | .DrawerPage .nav .cu-item.cur::after {
202 | content: "";
203 | width: 10rpx;
204 | height: 10rpx;
205 | background-color: currentColor;
206 | position: absolute;
207 | bottom: 10rpx;
208 | border-radius: 10rpx;
209 | left: 0;
210 | right: 0;
211 | margin: auto;
212 | }
213 |
214 | .DrawerPage .cu-bar.tabbar .action {
215 | flex: initial;
216 | }
217 |
218 |
219 | .menu-img {
220 | display:inline-block;
221 | margin-right:10rpx;
222 | width:1.6em;
223 | text-align:center;
224 | }
225 |
226 | .mdl-layout__title {
227 | display: block;
228 | position: relative;
229 | font-family: "Roboto","Helvetica","Arial",sans-serif;
230 | font-size: 20px;
231 | line-height: 1;
232 | letter-spacing: .02em;
233 | font-weight: 400;
234 | box-sizing: border-box;
235 | }
236 |
237 |
238 |
239 | /* =========== */
240 | /* 波浪动画 */
241 | /* =========== */
242 | @import "../../colorui/animation.wxss";
243 |
244 | image[class*="gif-"] {
245 | /* border-radius: 6rpx; */
246 | display: block;
247 | }
248 |
249 | .gif-wave{
250 | /* position: absolute; */
251 | width: 100%;
252 | bottom: -2rpx;
253 | left: 0;
254 | z-index: 99;
255 | mix-blend-mode: screen;
256 | height: 100rpx;
257 | }
258 |
259 | .fall-container {
260 | width: 100%;
261 | display: flex;
262 | }
263 |
264 | .fall-left {
265 | display: flex;
266 | flex-direction: column;
267 | }
268 |
269 | .fall-right {
270 | display: flex;
271 | flex-direction: column;
272 | }
273 |
274 | /*
275 | 搜索和分类间的滚动栏
276 | */
277 | .notice {
278 | display: flex;
279 | align-content: center;
280 | justify-content: space-between;
281 | padding: 10rpx 25rpx;
282 | background: #ffffff;
283 | }
284 |
285 | .left {
286 | display: flex;
287 | align-items: center;
288 | }
289 |
290 | .voice {
291 | margin-right: 5rpx;
292 | margin-top: 2rpx;
293 | color: #fa6016;
294 | }
295 |
296 | .left-box {
297 | position: relative;
298 | display: flex;
299 | align-items: center;
300 | }
301 |
302 | .left-text {
303 | position: absolute;
304 | left: 0;
305 | width: 40rpx;
306 | height: 100%;
307 | background: linear-gradient(to left,rgba(241,241,241,0),#ffffff);
308 | z-index: 99;
309 | }
310 |
311 | .right-text {
312 | position: absolute;
313 | right: -1rpx;
314 | width: 40rpx;
315 | height: 100%;
316 | background: linear-gradient(to left,rgb(252, 3, 3),rgba(241,241,241,0));
317 | z-index: 99;
318 | }
319 | /*文字出现范围的宽度*/
320 | .content-box {
321 | overflow: hidden;
322 | width: 23%;
323 | }
324 | /*文字颜色*/
325 | .content-text {
326 | color: #b1b1b1;
327 | white-space: nowrap;
328 | font-size: 32rpx;
329 | }
330 |
331 | .right {
332 | display: flex;
333 | align-items: center;
334 | }
335 |
336 | .app {
337 | height: 48rpx;
338 | }
339 |
340 | .more {
341 | margin-left: 5rpx;
342 | color: #aaa;
343 | font-size: 32rpx;
344 | }
345 | /*首页右下角按钮*/
346 | .list {
347 | position:fixed;
348 | bottom:5%;
349 | left:85%;
350 | }
351 | .cuIcon-more{
352 | font-size:45rpx;
353 | }
354 | .wujieguo{
355 | color: grey;
356 | }
357 |
358 |
--------------------------------------------------------------------------------
/miniprogram/pages/type1/map.js:
--------------------------------------------------------------------------------
1 | const app = getApp();
2 | const config = require('../../config.js');
3 | const db = wx.cloud.database()
4 | const store = db.collection('store').where({
5 | type:'楼体',
6 | });
7 | const userInfo = db.collection('userInfo');
8 |
9 | Page({
10 |
11 | /**
12 | * 页面的初始数据
13 | */
14 | data: {
15 | longitude:120.74038982,
16 | latitude:31.27141370,
17 | windowHeight: 600,
18 | mapSubKey: config.mapSubKey,
19 | hideMe: true,
20 | showAdmin: false,
21 | },
22 |
23 | /**
24 | * 生命周期函数--监听页面加载
25 | */
26 | onLoad: function (options) {
27 |
28 | let showAdmin = config.show_admin ? true : false;
29 |
30 | if (app.globalData.showAdmin) {
31 | showAdmin = true;
32 | }
33 |
34 | wx.showLoading({
35 | title: '数据载入中...',
36 | })
37 | store.get().then(res => {
38 | let data = res.data;
39 | // 将 _id 给 id ,确保 marker 事件的正确触发
40 | data.map(item => {
41 | item.id = item._id
42 | });
43 | this.setData({
44 | longitude:120.74038982, //默认定位经度
45 | latitude: 31.27141370, //默认定位纬度
46 | markers: res.data,
47 | windowHeight: app.globalData.windowHeight,
48 | hideMe: false,
49 | showAdmin: showAdmin,
50 | defaultScale: config.default_scale
51 | },
52 | () => {
53 | wx.hideLoading();
54 | // wx.showToast({
55 | // title: '菜狗识途,为你带路!',
56 | // icon: 'none'
57 | // })
58 | })
59 | })
60 |
61 | // 获取用户经纬度
62 | this.getCenterLocation();
63 | },
64 |
65 | onShow: function () {
66 | // #10 添加完成后更新一下 map
67 | store.get().then(res => {
68 | let data = res.data;
69 | data.map(item => {
70 | item.id = item._id
71 | });
72 | this.setData({
73 | markers: res.data
74 | })
75 | })
76 | },
77 |
78 | viewAll: function () {
79 | wx.navigateTo({
80 | url: '../list/list',
81 | })
82 | },
83 | getUserInfo: function (e) {
84 | if (e.detail.userInfo) {
85 | userInfo.get().then(res => {
86 | if (!res.data.length) {
87 | userInfo.add({
88 | data: e.detail.userInfo
89 | })
90 | }
91 | wx.cloud.callFunction({
92 | name: 'checkUserAuth'
93 | }).then(res => {
94 | if (res.result.data.is_administrator) {
95 | app.globalData.is_administrator = true;
96 | wx.showModal({
97 | title: '管理员登陆成功',
98 | content: '是否要进入新增界面?',
99 | success: res => {
100 | if (res.cancel == false && res.confirm == true) {
101 | wx.navigateTo({
102 | url: '../add/add',
103 | })
104 | } else {
105 | wx.showToast({
106 | title: '您可以点击下方查看全部按钮管理已有数据',
107 | icon: 'none'
108 | });
109 | }
110 | }
111 | })
112 | } else {
113 | wx.showToast({
114 | title: '您不是管理员,无法进入管理入口!',
115 | icon: 'none'
116 | });
117 | }
118 | })
119 | })
120 | } else {
121 | // 处理未授权的场景
122 | wx.showModal({
123 | title: '授权失败',
124 | content: '您尚未授权获取您的用户信息,是否开启授权界面?',
125 | success: res => {
126 | if (res.confirm) {
127 | wx.openSetting({})
128 | }
129 | }
130 | })
131 | }
132 | },
133 | /**
134 | * 获取用户经纬度
135 | */
136 | getCenterLocation: function () {
137 | wx.getLocation({
138 | type: "gcj02",
139 | success: (res) => {
140 | this.setData({
141 | longitude:120.74038982,
142 | latitude:31.27141370,
143 | });
144 | console.log(
145 | "当前中心点的位置:",
146 | this.data.longitude,
147 | this.data.latitude
148 | );
149 | },
150 | fail: (err) => {
151 | wx.showToast({
152 | title: "GPS定位失败",
153 | icon: "fail",
154 | });
155 | console.log("err", err);
156 | },
157 | });
158 | },
159 | onMarkerTap: function (event) {
160 | wx.navigateTo({
161 | url: '../info/info?id=' + event.markerId,
162 | })
163 | },
164 |
165 | getOpenID: function (event) {
166 | wx.cloud.callFunction({
167 | name: "getUserOpenId"
168 | }).then(res => {
169 | wx.setClipboardData({
170 | data: res.result.openid,
171 | success: res => {
172 | wx.showToast({
173 | title: 'openID已复制',
174 | })
175 | }
176 | })
177 | })
178 | },
179 | hideMe: function (res) {
180 | this.setData({
181 | hideMe: true
182 | })
183 | },
184 | showAdmin: function (res) {
185 | wx.setStorage({
186 | key: 'showAdmin',
187 | data: !this.data.showAdmin,
188 | })
189 | this.setData({
190 | showAdmin: !this.data.showAdmin
191 | })
192 | },
193 | search: function () {
194 | wx.navigateTo({
195 | url: '../search/search',
196 | })
197 | },
198 | /**
199 | * 用户点击右上角分享
200 | */
201 | onShareAppMessage: function () {
202 | return {
203 | title: '菜狗识途,为你带路!',
204 | path: '/pages/type1/map',
205 | imageUrl: "/images/poster_l.png"
206 | }
207 | },
208 | /**
209 | * 用户分享到朋友圈
210 | */
211 | onShareTimeline: function () {
212 | return {
213 | title: '菜狗识途,为你带路!',
214 | path: '/pages/type1/map',
215 | imageUrl: "/images/poster_r.png"
216 | }
217 | },
218 | /*去type1*/
219 | toType1: function () {
220 | wx.reLaunch({
221 | url: '/pages/type1/map'
222 | })
223 | },
224 | /*去type2*/
225 | toType2: function () {
226 | wx.reLaunch({
227 | url: '/pages/type2/map'
228 | })
229 | },
230 | })
--------------------------------------------------------------------------------
/miniprogram/pages/type1/map.json:
--------------------------------------------------------------------------------
1 | {
2 | "usingComponents": {
3 |
4 | }
5 | }
--------------------------------------------------------------------------------
/miniprogram/pages/type1/map.wxml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/miniprogram/pages/type1/map.wxss:
--------------------------------------------------------------------------------
1 | map {
2 | width: 750rpx;
3 | }
4 |
5 | .show_all {
6 | position: absolute;
7 | right: 100rpx;
8 | bottom: 100rpx;
9 | color: rgb(62, 207, 142);
10 | background-color: rgb(255, 255, 255);
11 | box-shadow: 0 4px 6px rgba(50, 50, 93, .11), 0 1px 3px rgba(0, 0, 0, .08);
12 | }
13 |
14 | .cover {
15 | color: #fff;
16 | height: 100rpx;
17 | width: 220rpx;
18 | line-height: 100rpx;
19 | font-size: 35rpx;
20 | text-align: center;
21 | position: absolute;
22 | left: 100rpx;
23 | bottom: 100rpx;
24 | border-radius: 50rpx;
25 | text-shadow: 0 1px 3px rgba(36, 180, 126, .4);
26 | }
27 |
28 | .add_me {
29 | font-size: 30rpx;
30 | color: #fff;
31 | background-color: rgb(62, 207, 142);
32 | width: 450rpx;
33 | padding: 20rpx;
34 | position: absolute;
35 | right: 10rpx;
36 | top: 20rpx;
37 | text-align: center;
38 | }
39 |
40 | .up {
41 | position: absolute;
42 | right: 150rpx;
43 | top: 5rpx;
44 | border-right: 20rpx solid transparent;
45 | border-left: 20rpx solid transparent;
46 | border-bottom: 20rpx solid rgb(62, 207, 142);
47 | }
48 |
49 | .getLocation {
50 | position: absolute;
51 | left: 20rpx;
52 | bottom: 250rpx;
53 | text-align: center;
54 | width: 20px;
55 | background-color:rgb(255, 255, 255,0.9);
56 | padding: 13px;
57 | box-shadow: 1px 2px 3px #999999;
58 | border-radius: 100px;
59 | }
60 |
61 | .list {
62 | position: absolute;
63 | left: 20rpx;
64 | bottom: 360rpx;
65 | text-align: center;
66 | width: 20px;
67 | background-color: rgb(62, 207, 142,0.9);
68 | padding: 13px;
69 | box-shadow: 1px 2px 3px #999999;
70 | border-radius: 100px;
71 | }
72 |
73 | .tab-h{
74 | height: 400rpx;
75 | width: 140rpx;
76 | bottom:250rpx;
77 | right: 12px;
78 | box-sizing: border-box;
79 | overflow: hidden;
80 | line-height: 80rpx;
81 | background: rgba(255, 255, 255, 0.9);
82 | font-size: 16px;
83 | white-space: nowrap;
84 | position: fixed;
85 | z-index: 99;
86 | border-radius: 10px;
87 | }
88 | .chouse_type {
89 | font-size: 32rpx;
90 | color: rgb(62, 207, 142);
91 | text-align: center;
92 | }
93 | .type {
94 | font-size: 32rpx;
95 |
96 | color: rgb(192, 192, 192);
97 | text-align: center;
98 | }
99 | scroll-view ::-webkit-scrollbar {
100 | width: 0;
101 | height: 0;
102 | color: transparent;
103 | display: none;
104 | }
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/miniprogram/pages/type10/map.js:
--------------------------------------------------------------------------------
1 | const app = getApp();
2 | const config = require('../../config.js');
3 | const db = wx.cloud.database()
4 | const store = db.collection('store').where({
5 | type:'交通',
6 | });
7 | const userInfo = db.collection('userInfo');
8 |
9 | Page({
10 |
11 | /**
12 | * 页面的初始数据
13 | */
14 | data: {
15 | longitude: config.center_longitude,
16 | latitude: config.center_latitude,
17 | windowHeight: 600,
18 | mapSubKey: config.mapSubKey,
19 | hideMe: true,
20 | showAdmin: false,
21 | },
22 |
23 | /**
24 | * 生命周期函数--监听页面加载
25 | */
26 | onLoad: function (options) {
27 |
28 | let showAdmin = config.show_admin ? true : false;
29 |
30 | if (app.globalData.showAdmin) {
31 | showAdmin = true;
32 | }
33 |
34 | wx.showLoading({
35 | title: '数据载入中...',
36 | })
37 | store.get().then(res => {
38 | let data = res.data;
39 | // 将 _id 给 id ,确保 marker 事件的正确触发
40 | data.map(item => {
41 | item.id = item._id
42 | });
43 | this.setData({
44 | longitude:120.74038982, //默认定位经度
45 | latitude: 31.27141370, //默认定位纬度
46 | markers: res.data,
47 | windowHeight: app.globalData.windowHeight,
48 | hideMe: false,
49 | showAdmin: showAdmin,
50 | defaultScale: config.default_scale
51 | },
52 | () => {
53 | wx.hideLoading();
54 | // wx.showToast({
55 | // title: '菜狗识途,为你带路!',
56 | // icon: 'none'
57 | // })
58 | })
59 | })
60 |
61 | // 获取用户经纬度
62 | this.getCenterLocation();
63 | },
64 |
65 | onShow: function () {
66 | // #10 添加完成后更新一下 map
67 | store.get().then(res => {
68 | let data = res.data;
69 | data.map(item => {
70 | item.id = item._id
71 | });
72 | this.setData({
73 | markers: res.data
74 | })
75 | })
76 | },
77 |
78 | viewAll: function () {
79 | wx.navigateTo({
80 | url: '../list/list',
81 | })
82 | },
83 | getUserInfo: function (e) {
84 | if (e.detail.userInfo) {
85 | userInfo.get().then(res => {
86 | if (!res.data.length) {
87 | userInfo.add({
88 | data: e.detail.userInfo
89 | })
90 | }
91 | wx.cloud.callFunction({
92 | name: 'checkUserAuth'
93 | }).then(res => {
94 | if (res.result.data.is_administrator) {
95 | app.globalData.is_administrator = true;
96 | wx.showModal({
97 | title: '管理员登陆成功',
98 | content: '是否要进入新增界面?',
99 | success: res => {
100 | if (res.cancel == false && res.confirm == true) {
101 | wx.navigateTo({
102 | url: '../add/add',
103 | })
104 | } else {
105 | wx.showToast({
106 | title: '您可以点击下方查看全部按钮管理已有数据',
107 | icon: 'none'
108 | });
109 | }
110 | }
111 | })
112 | } else {
113 | wx.showToast({
114 | title: '您不是管理员,无法进入管理入口!',
115 | icon: 'none'
116 | });
117 | }
118 | })
119 | })
120 | } else {
121 | // 处理未授权的场景
122 | wx.showModal({
123 | title: '授权失败',
124 | content: '您尚未授权获取您的用户信息,是否开启授权界面?',
125 | success: res => {
126 | if (res.confirm) {
127 | wx.openSetting({})
128 | }
129 | }
130 | })
131 | }
132 | },
133 | /**
134 | * 获取用户经纬度
135 | */
136 | getCenterLocation: function () {
137 | wx.getLocation({
138 | type: "gcj02",
139 | success: (res) => {
140 | this.setData({
141 | longitude: res.longitude,
142 | latitude: res.latitude,
143 | });
144 | console.log(
145 | "当前中心点的位置:",
146 | this.data.longitude,
147 | this.data.latitude
148 | );
149 | },
150 | fail: (err) => {
151 | wx.showToast({
152 | title: "GPS定位失败",
153 | icon: "fail",
154 | });
155 | console.log("err", err);
156 | },
157 | });
158 | },
159 | onMarkerTap: function (event) {
160 | wx.navigateTo({
161 | url: '../info/info?id=' + event.markerId,
162 | })
163 | },
164 |
165 | getOpenID: function (event) {
166 | wx.cloud.callFunction({
167 | name: "getUserOpenId"
168 | }).then(res => {
169 | wx.setClipboardData({
170 | data: res.result.openid,
171 | success: res => {
172 | wx.showToast({
173 | title: 'openID已复制',
174 | })
175 | }
176 | })
177 | })
178 | },
179 | hideMe: function (res) {
180 | this.setData({
181 | hideMe: true
182 | })
183 | },
184 | showAdmin: function (res) {
185 | wx.setStorage({
186 | key: 'showAdmin',
187 | data: !this.data.showAdmin,
188 | })
189 | this.setData({
190 | showAdmin: !this.data.showAdmin
191 | })
192 | },
193 | search: function () {
194 | wx.navigateTo({
195 | url: '../search/search',
196 | })
197 | },
198 | /**
199 | * 用户点击右上角分享
200 | */
201 | onShareAppMessage: function () {
202 | return {
203 | title: '菜狗识途,为你带路!',
204 | path: '/pages/type1/map',
205 | imageUrl: "/images/poster_l.png"
206 | }
207 | },
208 | /**
209 | * 用户分享到朋友圈
210 | */
211 | onShareTimeline: function () {
212 | return {
213 | title: '菜狗识途,为你带路!',
214 | path: '/pages/type1/map',
215 | imageUrl: "/images/poster_r.png"
216 | }
217 | },
218 | /*去type1*/
219 | toType1: function () {
220 | wx.reLaunch({
221 | url: '/pages/type1/map'
222 | })
223 | },
224 | /*去type2*/
225 | toType2: function () {
226 | wx.reLaunch({
227 | url: '/pages/type2/map'
228 | })
229 | },
230 | })
--------------------------------------------------------------------------------
/miniprogram/pages/type10/map.json:
--------------------------------------------------------------------------------
1 | {
2 | "usingComponents": {
3 |
4 | }
5 | }
--------------------------------------------------------------------------------
/miniprogram/pages/type10/map.wxml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/miniprogram/pages/type10/map.wxss:
--------------------------------------------------------------------------------
1 | map {
2 | width: 750rpx;
3 | }
4 |
5 | .show_all {
6 | position: absolute;
7 | right: 100rpx;
8 | bottom: 100rpx;
9 | color: rgb(62, 207, 142);
10 | background-color: rgb(255, 255, 255);
11 | box-shadow: 0 4px 6px rgba(50, 50, 93, .11), 0 1px 3px rgba(0, 0, 0, .08);
12 | }
13 |
14 | .cover {
15 | color: #fff;
16 | height: 100rpx;
17 | width: 220rpx;
18 | line-height: 100rpx;
19 | font-size: 35rpx;
20 | text-align: center;
21 | position: absolute;
22 | left: 100rpx;
23 | bottom: 100rpx;
24 | border-radius: 50rpx;
25 | text-shadow: 0 1px 3px rgba(36, 180, 126, .4);
26 | }
27 |
28 | .add_me {
29 | font-size: 30rpx;
30 | color: #fff;
31 | background-color: rgb(62, 207, 142);
32 | width: 450rpx;
33 | padding: 20rpx;
34 | position: absolute;
35 | right: 10rpx;
36 | top: 20rpx;
37 | text-align: center;
38 | }
39 |
40 | .up {
41 | position: absolute;
42 | right: 150rpx;
43 | top: 5rpx;
44 | border-right: 20rpx solid transparent;
45 | border-left: 20rpx solid transparent;
46 | border-bottom: 20rpx solid rgb(62, 207, 142);
47 | }
48 |
49 | .getLocation {
50 | position: absolute;
51 | left: 20rpx;
52 | bottom: 250rpx;
53 | text-align: center;
54 | width: 20px;
55 | background-color:rgb(255, 255, 255,0.9);
56 | padding: 13px;
57 | box-shadow: 1px 2px 3px #999999;
58 | border-radius: 100px;
59 | }
60 |
61 | .list {
62 | position: absolute;
63 | left: 20rpx;
64 | bottom: 360rpx;
65 | text-align: center;
66 | width: 20px;
67 | background-color: rgb(62, 207, 142,0.9);
68 | padding: 13px;
69 | box-shadow: 1px 2px 3px #999999;
70 | border-radius: 100px;
71 | }
72 |
73 | .tab-h{
74 | height: 400rpx;
75 | width: 140rpx;
76 | bottom:250rpx;
77 | right: 12px;
78 | box-sizing: border-box;
79 | overflow: hidden;
80 | line-height: 80rpx;
81 | background: rgba(255, 255, 255, 0.9);
82 | font-size: 16px;
83 | white-space: nowrap;
84 | position: fixed;
85 | z-index: 99;
86 | border-radius: 10px;
87 | }
88 | .chouse_type {
89 | font-size: 32rpx;
90 | color: rgb(62, 207, 142);
91 | text-align: center;
92 | }
93 | .type {
94 | font-size: 32rpx;
95 |
96 | color: rgb(192, 192, 192);
97 | text-align: center;
98 | }
99 | scroll-view ::-webkit-scrollbar {
100 | width: 0;
101 | height: 0;
102 | color: transparent;
103 | display: none;
104 | }
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/miniprogram/pages/type11/map.js:
--------------------------------------------------------------------------------
1 | const app = getApp();
2 | const config = require('../../config.js');
3 | const db = wx.cloud.database()
4 | const store = db.collection('store').where({
5 | type:'饮水机',
6 | });
7 | const userInfo = db.collection('userInfo');
8 |
9 | Page({
10 |
11 | /**
12 | * 页面的初始数据
13 | */
14 | data: {
15 | longitude: config.center_longitude,
16 | latitude: config.center_latitude,
17 | windowHeight: 600,
18 | mapSubKey: config.mapSubKey,
19 | hideMe: true,
20 | showAdmin: false,
21 | },
22 |
23 | /**
24 | * 生命周期函数--监听页面加载
25 | */
26 | onLoad: function (options) {
27 |
28 | let showAdmin = config.show_admin ? true : false;
29 |
30 | if (app.globalData.showAdmin) {
31 | showAdmin = true;
32 | }
33 |
34 | wx.showLoading({
35 | title: '数据载入中...',
36 | })
37 | store.get().then(res => {
38 | let data = res.data;
39 | // 将 _id 给 id ,确保 marker 事件的正确触发
40 | data.map(item => {
41 | item.id = item._id
42 | });
43 | this.setData({
44 | longitude:120.74038982, //默认定位经度
45 | latitude: 31.27141370, //默认定位纬度
46 | markers: res.data,
47 | windowHeight: app.globalData.windowHeight,
48 | hideMe: false,
49 | showAdmin: showAdmin,
50 | defaultScale: config.default_scale
51 | },
52 | () => {
53 | wx.hideLoading();
54 | // wx.showToast({
55 | // title: '菜狗识途,为你带路!',
56 | // icon: 'none'
57 | // })
58 | })
59 | })
60 |
61 | // 获取用户经纬度
62 | this.getCenterLocation();
63 | },
64 |
65 | onShow: function () {
66 | // #10 添加完成后更新一下 map
67 | store.get().then(res => {
68 | let data = res.data;
69 | data.map(item => {
70 | item.id = item._id
71 | });
72 | this.setData({
73 | markers: res.data
74 | })
75 | })
76 | },
77 |
78 | viewAll: function () {
79 | wx.navigateTo({
80 | url: '../list/list',
81 | })
82 | },
83 | getUserInfo: function (e) {
84 | if (e.detail.userInfo) {
85 | userInfo.get().then(res => {
86 | if (!res.data.length) {
87 | userInfo.add({
88 | data: e.detail.userInfo
89 | })
90 | }
91 | wx.cloud.callFunction({
92 | name: 'checkUserAuth'
93 | }).then(res => {
94 | if (res.result.data.is_administrator) {
95 | app.globalData.is_administrator = true;
96 | wx.showModal({
97 | title: '管理员登陆成功',
98 | content: '是否要进入新增界面?',
99 | success: res => {
100 | if (res.cancel == false && res.confirm == true) {
101 | wx.navigateTo({
102 | url: '../add/add',
103 | })
104 | } else {
105 | wx.showToast({
106 | title: '您可以点击下方查看全部按钮管理已有数据',
107 | icon: 'none'
108 | });
109 | }
110 | }
111 | })
112 | } else {
113 | wx.showToast({
114 | title: '您不是管理员,无法进入管理入口!',
115 | icon: 'none'
116 | });
117 | }
118 | })
119 | })
120 | } else {
121 | // 处理未授权的场景
122 | wx.showModal({
123 | title: '授权失败',
124 | content: '您尚未授权获取您的用户信息,是否开启授权界面?',
125 | success: res => {
126 | if (res.confirm) {
127 | wx.openSetting({})
128 | }
129 | }
130 | })
131 | }
132 | },
133 | /**
134 | * 获取用户经纬度
135 | */
136 | getCenterLocation: function () {
137 | wx.getLocation({
138 | type: "gcj02",
139 | success: (res) => {
140 | this.setData({
141 | longitude: res.longitude,
142 | latitude: res.latitude,
143 | });
144 | console.log(
145 | "当前中心点的位置:",
146 | this.data.longitude,
147 | this.data.latitude
148 | );
149 | },
150 | fail: (err) => {
151 | wx.showToast({
152 | title: "GPS定位失败",
153 | icon: "fail",
154 | });
155 | console.log("err", err);
156 | },
157 | });
158 | },
159 | onMarkerTap: function (event) {
160 | wx.navigateTo({
161 | url: '../info/info?id=' + event.markerId,
162 | })
163 | },
164 |
165 | getOpenID: function (event) {
166 | wx.cloud.callFunction({
167 | name: "getUserOpenId"
168 | }).then(res => {
169 | wx.setClipboardData({
170 | data: res.result.openid,
171 | success: res => {
172 | wx.showToast({
173 | title: 'openID已复制',
174 | })
175 | }
176 | })
177 | })
178 | },
179 | hideMe: function (res) {
180 | this.setData({
181 | hideMe: true
182 | })
183 | },
184 | showAdmin: function (res) {
185 | wx.setStorage({
186 | key: 'showAdmin',
187 | data: !this.data.showAdmin,
188 | })
189 | this.setData({
190 | showAdmin: !this.data.showAdmin
191 | })
192 | },
193 | search: function () {
194 | wx.navigateTo({
195 | url: '../search/search',
196 | })
197 | },
198 | /**
199 | * 用户点击右上角分享
200 | */
201 | onShareAppMessage: function () {
202 | return {
203 | title: '菜狗识途,为你带路!',
204 | path: '/pages/type1/map',
205 | imageUrl: "/images/poster_l.png"
206 | }
207 | },
208 | /**
209 | * 用户分享到朋友圈
210 | */
211 | onShareTimeline: function () {
212 | return {
213 | title: '菜狗识途,为你带路!',
214 | path: '/pages/type1/map',
215 | imageUrl: "/images/poster_r.png"
216 | }
217 | },
218 | /*去type1*/
219 | toType1: function () {
220 | wx.reLaunch({
221 | url: '/pages/type1/map'
222 | })
223 | },
224 | /*去type2*/
225 | toType2: function () {
226 | wx.reLaunch({
227 | url: '/pages/type2/map'
228 | })
229 | },
230 | })
--------------------------------------------------------------------------------
/miniprogram/pages/type11/map.json:
--------------------------------------------------------------------------------
1 | {
2 | "usingComponents": {
3 |
4 | }
5 | }
--------------------------------------------------------------------------------
/miniprogram/pages/type11/map.wxml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/miniprogram/pages/type11/map.wxss:
--------------------------------------------------------------------------------
1 | map {
2 | width: 750rpx;
3 | }
4 |
5 | .show_all {
6 | position: absolute;
7 | right: 100rpx;
8 | bottom: 100rpx;
9 | color: rgb(62, 207, 142);
10 | background-color: rgb(255, 255, 255);
11 | box-shadow: 0 4px 6px rgba(50, 50, 93, .11), 0 1px 3px rgba(0, 0, 0, .08);
12 | }
13 |
14 | .cover {
15 | color: #fff;
16 | height: 100rpx;
17 | width: 220rpx;
18 | line-height: 100rpx;
19 | font-size: 35rpx;
20 | text-align: center;
21 | position: absolute;
22 | left: 100rpx;
23 | bottom: 100rpx;
24 | border-radius: 50rpx;
25 | text-shadow: 0 1px 3px rgba(36, 180, 126, .4);
26 | }
27 |
28 | .add_me {
29 | font-size: 30rpx;
30 | color: #fff;
31 | background-color: rgb(62, 207, 142);
32 | width: 450rpx;
33 | padding: 20rpx;
34 | position: absolute;
35 | right: 10rpx;
36 | top: 20rpx;
37 | text-align: center;
38 | }
39 |
40 | .up {
41 | position: absolute;
42 | right: 150rpx;
43 | top: 5rpx;
44 | border-right: 20rpx solid transparent;
45 | border-left: 20rpx solid transparent;
46 | border-bottom: 20rpx solid rgb(62, 207, 142);
47 | }
48 |
49 | .getLocation {
50 | position: absolute;
51 | left: 20rpx;
52 | bottom: 250rpx;
53 | text-align: center;
54 | width: 20px;
55 | background-color:rgb(255, 255, 255,0.9);
56 | padding: 13px;
57 | box-shadow: 1px 2px 3px #999999;
58 | border-radius: 100px;
59 | }
60 |
61 | .list {
62 | position: absolute;
63 | left: 20rpx;
64 | bottom: 360rpx;
65 | text-align: center;
66 | width: 20px;
67 | background-color: rgb(62, 207, 142,0.9);
68 | padding: 13px;
69 | box-shadow: 1px 2px 3px #999999;
70 | border-radius: 100px;
71 | }
72 |
73 | .tab-h{
74 | height: 400rpx;
75 | width: 140rpx;
76 | bottom:250rpx;
77 | right: 12px;
78 | box-sizing: border-box;
79 | overflow: hidden;
80 | line-height: 80rpx;
81 | background: rgba(255, 255, 255, 0.9);
82 | font-size: 16px;
83 | white-space: nowrap;
84 | position: fixed;
85 | z-index: 99;
86 | border-radius: 10px;
87 | }
88 | .chouse_type {
89 | font-size: 32rpx;
90 | color: rgb(62, 207, 142);
91 | text-align: center;
92 | }
93 | .type {
94 | font-size: 32rpx;
95 |
96 | color: rgb(192, 192, 192);
97 | text-align: center;
98 | }
99 | scroll-view ::-webkit-scrollbar {
100 | width: 0;
101 | height: 0;
102 | color: transparent;
103 | display: none;
104 | }
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/miniprogram/pages/type12/map.js:
--------------------------------------------------------------------------------
1 | const app = getApp();
2 | const config = require('../../config.js');
3 | const db = wx.cloud.database()
4 | const store = db.collection('store').where({
5 | type:'校园设施',
6 | });
7 | const userInfo = db.collection('userInfo');
8 |
9 | Page({
10 |
11 | /**
12 | * 页面的初始数据
13 | */
14 | data: {
15 | longitude: config.center_longitude,
16 | latitude: config.center_latitude,
17 | windowHeight: 600,
18 | mapSubKey: config.mapSubKey,
19 | hideMe: true,
20 | showAdmin: false,
21 | },
22 |
23 | /**
24 | * 生命周期函数--监听页面加载
25 | */
26 | onLoad: function (options) {
27 |
28 | let showAdmin = config.show_admin ? true : false;
29 |
30 | if (app.globalData.showAdmin) {
31 | showAdmin = true;
32 | }
33 |
34 | wx.showLoading({
35 | title: '数据载入中...',
36 | })
37 | store.get().then(res => {
38 | let data = res.data;
39 | // 将 _id 给 id ,确保 marker 事件的正确触发
40 | data.map(item => {
41 | item.id = item._id
42 | });
43 | this.setData({
44 | longitude:120.74038982, //默认定位经度
45 | latitude: 31.27141370, //默认定位纬度
46 | markers: res.data,
47 | windowHeight: app.globalData.windowHeight,
48 | hideMe: false,
49 | showAdmin: showAdmin,
50 | defaultScale: config.default_scale
51 | },
52 | () => {
53 | wx.hideLoading();
54 | // wx.showToast({
55 | // title: '菜狗识途,为你带路!',
56 | // icon: 'none'
57 | // })
58 | })
59 | })
60 |
61 | // 获取用户经纬度
62 | this.getCenterLocation();
63 | },
64 |
65 | onShow: function () {
66 | // #10 添加完成后更新一下 map
67 | store.get().then(res => {
68 | let data = res.data;
69 | data.map(item => {
70 | item.id = item._id
71 | });
72 | this.setData({
73 | markers: res.data
74 | })
75 | })
76 | },
77 |
78 | viewAll: function () {
79 | wx.navigateTo({
80 | url: '../list/list',
81 | })
82 | },
83 | getUserInfo: function (e) {
84 | if (e.detail.userInfo) {
85 | userInfo.get().then(res => {
86 | if (!res.data.length) {
87 | userInfo.add({
88 | data: e.detail.userInfo
89 | })
90 | }
91 | wx.cloud.callFunction({
92 | name: 'checkUserAuth'
93 | }).then(res => {
94 | if (res.result.data.is_administrator) {
95 | app.globalData.is_administrator = true;
96 | wx.showModal({
97 | title: '管理员登陆成功',
98 | content: '是否要进入新增界面?',
99 | success: res => {
100 | if (res.cancel == false && res.confirm == true) {
101 | wx.navigateTo({
102 | url: '../add/add',
103 | })
104 | } else {
105 | wx.showToast({
106 | title: '您可以点击下方查看全部按钮管理已有数据',
107 | icon: 'none'
108 | });
109 | }
110 | }
111 | })
112 | } else {
113 | wx.showToast({
114 | title: '您不是管理员,无法进入管理入口!',
115 | icon: 'none'
116 | });
117 | }
118 | })
119 | })
120 | } else {
121 | // 处理未授权的场景
122 | wx.showModal({
123 | title: '授权失败',
124 | content: '您尚未授权获取您的用户信息,是否开启授权界面?',
125 | success: res => {
126 | if (res.confirm) {
127 | wx.openSetting({})
128 | }
129 | }
130 | })
131 | }
132 | },
133 | /**
134 | * 获取用户经纬度
135 | */
136 | getCenterLocation: function () {
137 | wx.getLocation({
138 | type: "gcj02",
139 | success: (res) => {
140 | this.setData({
141 | longitude: res.longitude,
142 | latitude: res.latitude,
143 | });
144 | console.log(
145 | "当前中心点的位置:",
146 | this.data.longitude,
147 | this.data.latitude
148 | );
149 | },
150 | fail: (err) => {
151 | wx.showToast({
152 | title: "GPS定位失败",
153 | icon: "fail",
154 | });
155 | console.log("err", err);
156 | },
157 | });
158 | },
159 | onMarkerTap: function (event) {
160 | wx.navigateTo({
161 | url: '../info/info?id=' + event.markerId,
162 | })
163 | },
164 |
165 | getOpenID: function (event) {
166 | wx.cloud.callFunction({
167 | name: "getUserOpenId"
168 | }).then(res => {
169 | wx.setClipboardData({
170 | data: res.result.openid,
171 | success: res => {
172 | wx.showToast({
173 | title: 'openID已复制',
174 | })
175 | }
176 | })
177 | })
178 | },
179 | hideMe: function (res) {
180 | this.setData({
181 | hideMe: true
182 | })
183 | },
184 | showAdmin: function (res) {
185 | wx.setStorage({
186 | key: 'showAdmin',
187 | data: !this.data.showAdmin,
188 | })
189 | this.setData({
190 | showAdmin: !this.data.showAdmin
191 | })
192 | },
193 | search: function () {
194 | wx.navigateTo({
195 | url: '../search/search',
196 | })
197 | },
198 | /**
199 | * 用户点击右上角分享
200 | */
201 | onShareAppMessage: function () {
202 | return {
203 | title: '菜狗识途,为你带路!',
204 | path: '/pages/type1/map',
205 | imageUrl: "/images/poster_l.png"
206 | }
207 | },
208 | /**
209 | * 用户分享到朋友圈
210 | */
211 | onShareTimeline: function () {
212 | return {
213 | title: '菜狗识途,为你带路!',
214 | path: '/pages/type1/map',
215 | imageUrl: "/images/poster_r.png"
216 | }
217 | },
218 | /*去type1*/
219 | toType1: function () {
220 | wx.reLaunch({
221 | url: '/pages/type1/map'
222 | })
223 | },
224 | /*去type2*/
225 | toType2: function () {
226 | wx.reLaunch({
227 | url: '/pages/type2/map'
228 | })
229 | },
230 | })
--------------------------------------------------------------------------------
/miniprogram/pages/type12/map.json:
--------------------------------------------------------------------------------
1 | {
2 | "usingComponents": {
3 |
4 | }
5 | }
--------------------------------------------------------------------------------
/miniprogram/pages/type12/map.wxml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/miniprogram/pages/type12/map.wxss:
--------------------------------------------------------------------------------
1 | map {
2 | width: 750rpx;
3 | }
4 |
5 | .show_all {
6 | position: absolute;
7 | right: 100rpx;
8 | bottom: 100rpx;
9 | color: rgb(62, 207, 142);
10 | background-color: rgb(255, 255, 255);
11 | box-shadow: 0 4px 6px rgba(50, 50, 93, .11), 0 1px 3px rgba(0, 0, 0, .08);
12 | }
13 |
14 | .cover {
15 | color: #fff;
16 | height: 100rpx;
17 | width: 220rpx;
18 | line-height: 100rpx;
19 | font-size: 35rpx;
20 | text-align: center;
21 | position: absolute;
22 | left: 100rpx;
23 | bottom: 100rpx;
24 | border-radius: 50rpx;
25 | text-shadow: 0 1px 3px rgba(36, 180, 126, .4);
26 | }
27 |
28 | .add_me {
29 | font-size: 30rpx;
30 | color: #fff;
31 | background-color: rgb(62, 207, 142);
32 | width: 450rpx;
33 | padding: 20rpx;
34 | position: absolute;
35 | right: 10rpx;
36 | top: 20rpx;
37 | text-align: center;
38 | }
39 |
40 | .up {
41 | position: absolute;
42 | right: 150rpx;
43 | top: 5rpx;
44 | border-right: 20rpx solid transparent;
45 | border-left: 20rpx solid transparent;
46 | border-bottom: 20rpx solid rgb(62, 207, 142);
47 | }
48 |
49 | .getLocation {
50 | position: absolute;
51 | left: 20rpx;
52 | bottom: 250rpx;
53 | text-align: center;
54 | width: 20px;
55 | background-color:rgb(255, 255, 255,0.9);
56 | padding: 13px;
57 | box-shadow: 1px 2px 3px #999999;
58 | border-radius: 100px;
59 | }
60 |
61 | .list {
62 | position: absolute;
63 | left: 20rpx;
64 | bottom: 360rpx;
65 | text-align: center;
66 | width: 20px;
67 | background-color: rgb(62, 207, 142,0.9);
68 | padding: 13px;
69 | box-shadow: 1px 2px 3px #999999;
70 | border-radius: 100px;
71 | }
72 |
73 | .tab-h{
74 | height: 400rpx;
75 | width: 140rpx;
76 | bottom:250rpx;
77 | right: 12px;
78 | box-sizing: border-box;
79 | overflow: hidden;
80 | line-height: 80rpx;
81 | background: rgba(255, 255, 255, 0.9);
82 | font-size: 16px;
83 | white-space: nowrap;
84 | position: fixed;
85 | z-index: 99;
86 | border-radius: 10px;
87 | }
88 | .chouse_type {
89 | font-size: 32rpx;
90 | color: rgb(62, 207, 142);
91 | text-align: center;
92 | }
93 | .type {
94 | font-size: 32rpx;
95 |
96 | color: rgb(192, 192, 192);
97 | text-align: center;
98 | }
99 | scroll-view ::-webkit-scrollbar {
100 | width: 0;
101 | height: 0;
102 | color: transparent;
103 | display: none;
104 | }
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/miniprogram/pages/type13/map.js:
--------------------------------------------------------------------------------
1 | const app = getApp();
2 | const config = require('../../config.js');
3 | const db = wx.cloud.database()
4 | const store = db.collection('store').where({
5 | type:'周边设施',
6 | });
7 | const userInfo = db.collection('userInfo');
8 |
9 | Page({
10 |
11 | /**
12 | * 页面的初始数据
13 | */
14 | data: {
15 | longitude: config.center_longitude,
16 | latitude: config.center_latitude,
17 | windowHeight: 600,
18 | mapSubKey: config.mapSubKey,
19 | hideMe: true,
20 | showAdmin: false,
21 | },
22 |
23 | /**
24 | * 生命周期函数--监听页面加载
25 | */
26 | onLoad: function (options) {
27 |
28 | let showAdmin = config.show_admin ? true : false;
29 |
30 | if (app.globalData.showAdmin) {
31 | showAdmin = true;
32 | }
33 |
34 | wx.showLoading({
35 | title: '数据载入中...',
36 | })
37 | store.get().then(res => {
38 | let data = res.data;
39 | // 将 _id 给 id ,确保 marker 事件的正确触发
40 | data.map(item => {
41 | item.id = item._id
42 | });
43 | this.setData({
44 | longitude:120.74038982, //默认定位经度
45 | latitude: 31.27141370, //默认定位纬度
46 | markers: res.data,
47 | windowHeight: app.globalData.windowHeight,
48 | hideMe: false,
49 | showAdmin: showAdmin,
50 | defaultScale: config.default_scale
51 | },
52 | () => {
53 | wx.hideLoading();
54 | // wx.showToast({
55 | // title: '菜狗识途,为你带路!',
56 | // icon: 'none'
57 | // })
58 | })
59 | })
60 |
61 | // 获取用户经纬度
62 | this.getCenterLocation();
63 | },
64 |
65 | onShow: function () {
66 | // #10 添加完成后更新一下 map
67 | store.get().then(res => {
68 | let data = res.data;
69 | data.map(item => {
70 | item.id = item._id
71 | });
72 | this.setData({
73 | markers: res.data
74 | })
75 | })
76 | },
77 |
78 | viewAll: function () {
79 | wx.navigateTo({
80 | url: '../list/list',
81 | })
82 | },
83 | getUserInfo: function (e) {
84 | if (e.detail.userInfo) {
85 | userInfo.get().then(res => {
86 | if (!res.data.length) {
87 | userInfo.add({
88 | data: e.detail.userInfo
89 | })
90 | }
91 | wx.cloud.callFunction({
92 | name: 'checkUserAuth'
93 | }).then(res => {
94 | if (res.result.data.is_administrator) {
95 | app.globalData.is_administrator = true;
96 | wx.showModal({
97 | title: '管理员登陆成功',
98 | content: '是否要进入新增界面?',
99 | success: res => {
100 | if (res.cancel == false && res.confirm == true) {
101 | wx.navigateTo({
102 | url: '../add/add',
103 | })
104 | } else {
105 | wx.showToast({
106 | title: '您可以点击下方查看全部按钮管理已有数据',
107 | icon: 'none'
108 | });
109 | }
110 | }
111 | })
112 | } else {
113 | wx.showToast({
114 | title: '您不是管理员,无法进入管理入口!',
115 | icon: 'none'
116 | });
117 | }
118 | })
119 | })
120 | } else {
121 | // 处理未授权的场景
122 | wx.showModal({
123 | title: '授权失败',
124 | content: '您尚未授权获取您的用户信息,是否开启授权界面?',
125 | success: res => {
126 | if (res.confirm) {
127 | wx.openSetting({})
128 | }
129 | }
130 | })
131 | }
132 | },
133 | /**
134 | * 获取用户经纬度
135 | */
136 | getCenterLocation: function () {
137 | wx.getLocation({
138 | type: "gcj02",
139 | success: (res) => {
140 | this.setData({
141 | longitude: res.longitude,
142 | latitude: res.latitude,
143 | });
144 | console.log(
145 | "当前中心点的位置:",
146 | this.data.longitude,
147 | this.data.latitude
148 | );
149 | },
150 | fail: (err) => {
151 | wx.showToast({
152 | title: "GPS定位失败",
153 | icon: "fail",
154 | });
155 | console.log("err", err);
156 | },
157 | });
158 | },
159 | onMarkerTap: function (event) {
160 | wx.navigateTo({
161 | url: '../info/info?id=' + event.markerId,
162 | })
163 | },
164 |
165 | getOpenID: function (event) {
166 | wx.cloud.callFunction({
167 | name: "getUserOpenId"
168 | }).then(res => {
169 | wx.setClipboardData({
170 | data: res.result.openid,
171 | success: res => {
172 | wx.showToast({
173 | title: 'openID已复制',
174 | })
175 | }
176 | })
177 | })
178 | },
179 | hideMe: function (res) {
180 | this.setData({
181 | hideMe: true
182 | })
183 | },
184 | showAdmin: function (res) {
185 | wx.setStorage({
186 | key: 'showAdmin',
187 | data: !this.data.showAdmin,
188 | })
189 | this.setData({
190 | showAdmin: !this.data.showAdmin
191 | })
192 | },
193 | search: function () {
194 | wx.navigateTo({
195 | url: '../search/search',
196 | })
197 | },
198 | /**
199 | * 用户点击右上角分享
200 | */
201 | onShareAppMessage: function () {
202 | return {
203 | title: '菜狗识途,为你带路!',
204 | path: '/pages/type1/map',
205 | imageUrl: "/images/poster_l.png"
206 | }
207 | },
208 | /**
209 | * 用户分享到朋友圈
210 | */
211 | onShareTimeline: function () {
212 | return {
213 | title: '菜狗识途,为你带路!',
214 | path: '/pages/type1/map',
215 | imageUrl: "/images/poster_r.png"
216 | }
217 | },
218 | /*去type1*/
219 | toType1: function () {
220 | wx.reLaunch({
221 | url: '/pages/type1/map'
222 | })
223 | },
224 | /*去type2*/
225 | toType2: function () {
226 | wx.reLaunch({
227 | url: '/pages/type2/map'
228 | })
229 | },
230 | })
--------------------------------------------------------------------------------
/miniprogram/pages/type13/map.json:
--------------------------------------------------------------------------------
1 | {
2 | "usingComponents": {
3 |
4 | }
5 | }
--------------------------------------------------------------------------------
/miniprogram/pages/type13/map.wxml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/miniprogram/pages/type13/map.wxss:
--------------------------------------------------------------------------------
1 | map {
2 | width: 750rpx;
3 | }
4 |
5 | .show_all {
6 | position: absolute;
7 | right: 100rpx;
8 | bottom: 100rpx;
9 | color: rgb(62, 207, 142);
10 | background-color: rgb(255, 255, 255);
11 | box-shadow: 0 4px 6px rgba(50, 50, 93, .11), 0 1px 3px rgba(0, 0, 0, .08);
12 | }
13 |
14 | .cover {
15 | color: #fff;
16 | height: 100rpx;
17 | width: 220rpx;
18 | line-height: 100rpx;
19 | font-size: 35rpx;
20 | text-align: center;
21 | position: absolute;
22 | left: 100rpx;
23 | bottom: 100rpx;
24 | border-radius: 50rpx;
25 | text-shadow: 0 1px 3px rgba(36, 180, 126, .4);
26 | }
27 |
28 | .add_me {
29 | font-size: 30rpx;
30 | color: #fff;
31 | background-color: rgb(62, 207, 142);
32 | width: 450rpx;
33 | padding: 20rpx;
34 | position: absolute;
35 | right: 10rpx;
36 | top: 20rpx;
37 | text-align: center;
38 | }
39 |
40 | .up {
41 | position: absolute;
42 | right: 150rpx;
43 | top: 5rpx;
44 | border-right: 20rpx solid transparent;
45 | border-left: 20rpx solid transparent;
46 | border-bottom: 20rpx solid rgb(62, 207, 142);
47 | }
48 |
49 | .getLocation {
50 | position: absolute;
51 | left: 20rpx;
52 | bottom: 250rpx;
53 | text-align: center;
54 | width: 20px;
55 | background-color:rgb(255, 255, 255,0.9);
56 | padding: 13px;
57 | box-shadow: 1px 2px 3px #999999;
58 | border-radius: 100px;
59 | }
60 |
61 | .list {
62 | position: absolute;
63 | left: 20rpx;
64 | bottom: 360rpx;
65 | text-align: center;
66 | width: 20px;
67 | background-color: rgb(62, 207, 142,0.9);
68 | padding: 13px;
69 | box-shadow: 1px 2px 3px #999999;
70 | border-radius: 100px;
71 | }
72 |
73 | .tab-h{
74 | height: 400rpx;
75 | width: 140rpx;
76 | bottom:250rpx;
77 | right: 12px;
78 | box-sizing: border-box;
79 | overflow: hidden;
80 | line-height: 80rpx;
81 | background: rgba(255, 255, 255, 0.9);
82 | font-size: 16px;
83 | white-space: nowrap;
84 | position: fixed;
85 | z-index: 99;
86 | border-radius: 10px;
87 | }
88 | .chouse_type {
89 | font-size: 32rpx;
90 | color: rgb(62, 207, 142);
91 | text-align: center;
92 | }
93 | .type {
94 | font-size: 32rpx;
95 |
96 | color: rgb(192, 192, 192);
97 | text-align: center;
98 | }
99 | scroll-view ::-webkit-scrollbar {
100 | width: 0;
101 | height: 0;
102 | color: transparent;
103 | display: none;
104 | }
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/miniprogram/pages/type14/map.js:
--------------------------------------------------------------------------------
1 | const app = getApp();
2 | const config = require('../../config.js');
3 | const db = wx.cloud.database()
4 | const store = db.collection('store').where({
5 | type:'停车场',
6 | });
7 | const userInfo = db.collection('userInfo');
8 |
9 | Page({
10 |
11 | /**
12 | * 页面的初始数据
13 | */
14 | data: {
15 | longitude: config.center_longitude,
16 | latitude: config.center_latitude,
17 | windowHeight: 600,
18 | mapSubKey: config.mapSubKey,
19 | hideMe: true,
20 | showAdmin: false,
21 | },
22 |
23 | /**
24 | * 生命周期函数--监听页面加载
25 | */
26 | onLoad: function (options) {
27 |
28 | let showAdmin = config.show_admin ? true : false;
29 |
30 | if (app.globalData.showAdmin) {
31 | showAdmin = true;
32 | }
33 |
34 | wx.showLoading({
35 | title: '数据载入中...',
36 | })
37 | store.get().then(res => {
38 | let data = res.data;
39 | // 将 _id 给 id ,确保 marker 事件的正确触发
40 | data.map(item => {
41 | item.id = item._id
42 | });
43 | this.setData({
44 | longitude:120.74038982, //默认定位经度
45 | latitude: 31.27141370, //默认定位纬度
46 | markers: res.data,
47 | windowHeight: app.globalData.windowHeight,
48 | hideMe: false,
49 | showAdmin: showAdmin,
50 | defaultScale: config.default_scale
51 | },
52 | () => {
53 | wx.hideLoading();
54 | // wx.showToast({
55 | // title: '菜狗识途,为你带路!',
56 | // icon: 'none'
57 | // })
58 | })
59 | })
60 |
61 | // 获取用户经纬度
62 | this.getCenterLocation();
63 | },
64 |
65 | onShow: function () {
66 | // #10 添加完成后更新一下 map
67 | store.get().then(res => {
68 | let data = res.data;
69 | data.map(item => {
70 | item.id = item._id
71 | });
72 | this.setData({
73 | markers: res.data
74 | })
75 | })
76 | },
77 |
78 | viewAll: function () {
79 | wx.navigateTo({
80 | url: '../list/list',
81 | })
82 | },
83 | getUserInfo: function (e) {
84 | if (e.detail.userInfo) {
85 | userInfo.get().then(res => {
86 | if (!res.data.length) {
87 | userInfo.add({
88 | data: e.detail.userInfo
89 | })
90 | }
91 | wx.cloud.callFunction({
92 | name: 'checkUserAuth'
93 | }).then(res => {
94 | if (res.result.data.is_administrator) {
95 | app.globalData.is_administrator = true;
96 | wx.showModal({
97 | title: '管理员登陆成功',
98 | content: '是否要进入新增界面?',
99 | success: res => {
100 | if (res.cancel == false && res.confirm == true) {
101 | wx.navigateTo({
102 | url: '../add/add',
103 | })
104 | } else {
105 | wx.showToast({
106 | title: '您可以点击下方查看全部按钮管理已有数据',
107 | icon: 'none'
108 | });
109 | }
110 | }
111 | })
112 | } else {
113 | wx.showToast({
114 | title: '您不是管理员,无法进入管理入口!',
115 | icon: 'none'
116 | });
117 | }
118 | })
119 | })
120 | } else {
121 | // 处理未授权的场景
122 | wx.showModal({
123 | title: '授权失败',
124 | content: '您尚未授权获取您的用户信息,是否开启授权界面?',
125 | success: res => {
126 | if (res.confirm) {
127 | wx.openSetting({})
128 | }
129 | }
130 | })
131 | }
132 | },
133 | /**
134 | * 获取用户经纬度
135 | */
136 | getCenterLocation: function () {
137 | wx.getLocation({
138 | type: "gcj02",
139 | success: (res) => {
140 | this.setData({
141 | longitude: res.longitude,
142 | latitude: res.latitude,
143 | });
144 | console.log(
145 | "当前中心点的位置:",
146 | this.data.longitude,
147 | this.data.latitude
148 | );
149 | },
150 | fail: (err) => {
151 | wx.showToast({
152 | title: "GPS定位失败",
153 | icon: "fail",
154 | });
155 | console.log("err", err);
156 | },
157 | });
158 | },
159 | onMarkerTap: function (event) {
160 | wx.navigateTo({
161 | url: '../info/info?id=' + event.markerId,
162 | })
163 | },
164 |
165 | getOpenID: function (event) {
166 | wx.cloud.callFunction({
167 | name: "getUserOpenId"
168 | }).then(res => {
169 | wx.setClipboardData({
170 | data: res.result.openid,
171 | success: res => {
172 | wx.showToast({
173 | title: 'openID已复制',
174 | })
175 | }
176 | })
177 | })
178 | },
179 | hideMe: function (res) {
180 | this.setData({
181 | hideMe: true
182 | })
183 | },
184 | showAdmin: function (res) {
185 | wx.setStorage({
186 | key: 'showAdmin',
187 | data: !this.data.showAdmin,
188 | })
189 | this.setData({
190 | showAdmin: !this.data.showAdmin
191 | })
192 | },
193 | search: function () {
194 | wx.navigateTo({
195 | url: '../search/search',
196 | })
197 | },
198 | /**
199 | * 用户点击右上角分享
200 | */
201 | onShareAppMessage: function () {
202 | return {
203 | title: '菜狗识途,为你带路!',
204 | path: '/pages/type1/map',
205 | imageUrl: "/images/poster_l.png"
206 | }
207 | },
208 | /**
209 | * 用户分享到朋友圈
210 | */
211 | onShareTimeline: function () {
212 | return {
213 | title: '菜狗识途,为你带路!',
214 | path: '/pages/type1/map',
215 | imageUrl: "/images/poster_r.png"
216 | }
217 | },
218 | /*去type1*/
219 | toType1: function () {
220 | wx.reLaunch({
221 | url: '/pages/type1/map'
222 | })
223 | },
224 | /*去type2*/
225 | toType2: function () {
226 | wx.reLaunch({
227 | url: '/pages/type2/map'
228 | })
229 | },
230 | })
--------------------------------------------------------------------------------
/miniprogram/pages/type14/map.json:
--------------------------------------------------------------------------------
1 | {
2 | "usingComponents": {
3 |
4 | }
5 | }
--------------------------------------------------------------------------------
/miniprogram/pages/type14/map.wxml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/miniprogram/pages/type14/map.wxss:
--------------------------------------------------------------------------------
1 | map {
2 | width: 750rpx;
3 | }
4 |
5 | .show_all {
6 | position: absolute;
7 | right: 100rpx;
8 | bottom: 100rpx;
9 | color: rgb(62, 207, 142);
10 | background-color: rgb(255, 255, 255);
11 | box-shadow: 0 4px 6px rgba(50, 50, 93, .11), 0 1px 3px rgba(0, 0, 0, .08);
12 | }
13 |
14 | .cover {
15 | color: #fff;
16 | height: 100rpx;
17 | width: 220rpx;
18 | line-height: 100rpx;
19 | font-size: 35rpx;
20 | text-align: center;
21 | position: absolute;
22 | left: 100rpx;
23 | bottom: 100rpx;
24 | border-radius: 50rpx;
25 | text-shadow: 0 1px 3px rgba(36, 180, 126, .4);
26 | }
27 |
28 | .add_me {
29 | font-size: 30rpx;
30 | color: #fff;
31 | background-color: rgb(62, 207, 142);
32 | width: 450rpx;
33 | padding: 20rpx;
34 | position: absolute;
35 | right: 10rpx;
36 | top: 20rpx;
37 | text-align: center;
38 | }
39 |
40 | .up {
41 | position: absolute;
42 | right: 150rpx;
43 | top: 5rpx;
44 | border-right: 20rpx solid transparent;
45 | border-left: 20rpx solid transparent;
46 | border-bottom: 20rpx solid rgb(62, 207, 142);
47 | }
48 |
49 | .getLocation {
50 | position: absolute;
51 | left: 20rpx;
52 | bottom: 250rpx;
53 | text-align: center;
54 | width: 20px;
55 | background-color:rgb(255, 255, 255,0.9);
56 | padding: 13px;
57 | box-shadow: 1px 2px 3px #999999;
58 | border-radius: 100px;
59 | }
60 |
61 | .list {
62 | position: absolute;
63 | left: 20rpx;
64 | bottom: 360rpx;
65 | text-align: center;
66 | width: 20px;
67 | background-color: rgb(62, 207, 142,0.9);
68 | padding: 13px;
69 | box-shadow: 1px 2px 3px #999999;
70 | border-radius: 100px;
71 | }
72 |
73 | .tab-h{
74 | height: 400rpx;
75 | width: 140rpx;
76 | bottom:250rpx;
77 | right: 12px;
78 | box-sizing: border-box;
79 | overflow: hidden;
80 | line-height: 80rpx;
81 | background: rgba(255, 255, 255, 0.9);
82 | font-size: 16px;
83 | white-space: nowrap;
84 | position: fixed;
85 | z-index: 99;
86 | border-radius: 10px;
87 | }
88 | .chouse_type {
89 | font-size: 32rpx;
90 | color: rgb(62, 207, 142);
91 | text-align: center;
92 | }
93 | .type {
94 | font-size: 32rpx;
95 |
96 | color: rgb(192, 192, 192);
97 | text-align: center;
98 | }
99 | scroll-view ::-webkit-scrollbar {
100 | width: 0;
101 | height: 0;
102 | color: transparent;
103 | display: none;
104 | }
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/miniprogram/pages/type2/map.js:
--------------------------------------------------------------------------------
1 | const app = getApp();
2 | const config = require('../../config.js');
3 | const db = wx.cloud.database()
4 | const store = db.collection('store').where({
5 | type:'打印机',
6 | });
7 | const userInfo = db.collection('userInfo');
8 |
9 | Page({
10 |
11 | /**
12 | * 页面的初始数据
13 | */
14 | data: {
15 | longitude: config.center_longitude,
16 | latitude: config.center_latitude,
17 | windowHeight: 600,
18 | mapSubKey: config.mapSubKey,
19 | hideMe: true,
20 | showAdmin: false,
21 | },
22 |
23 | /**
24 | * 生命周期函数--监听页面加载
25 | */
26 | onLoad: function (options) {
27 |
28 | let showAdmin = config.show_admin ? true : false;
29 |
30 | if (app.globalData.showAdmin) {
31 | showAdmin = true;
32 | }
33 |
34 | wx.showLoading({
35 | title: '数据载入中...',
36 | })
37 | store.get().then(res => {
38 | let data = res.data;
39 | // 将 _id 给 id ,确保 marker 事件的正确触发
40 | data.map(item => {
41 | item.id = item._id
42 | });
43 | this.setData({
44 | longitude:120.74038982, //默认定位经度
45 | latitude: 31.27141370, //默认定位纬度
46 | markers: res.data,
47 | windowHeight: app.globalData.windowHeight,
48 | hideMe: false,
49 | showAdmin: showAdmin,
50 | defaultScale: config.default_scale
51 | },
52 | () => {
53 | wx.hideLoading();
54 | // wx.showToast({
55 | // title: '菜狗识途,为你带路!',
56 | // icon: 'none'
57 | // })
58 | })
59 | })
60 |
61 | // 获取用户经纬度
62 | this.getCenterLocation();
63 | },
64 |
65 | onShow: function () {
66 | // #10 添加完成后更新一下 map
67 | store.get().then(res => {
68 | let data = res.data;
69 | data.map(item => {
70 | item.id = item._id
71 | });
72 | this.setData({
73 | markers: res.data
74 | })
75 | })
76 | },
77 |
78 | viewAll: function () {
79 | wx.navigateTo({
80 | url: '../list/list',
81 | })
82 | },
83 | getUserInfo: function (e) {
84 | if (e.detail.userInfo) {
85 | userInfo.get().then(res => {
86 | if (!res.data.length) {
87 | userInfo.add({
88 | data: e.detail.userInfo
89 | })
90 | }
91 | wx.cloud.callFunction({
92 | name: 'checkUserAuth'
93 | }).then(res => {
94 | if (res.result.data.is_administrator) {
95 | app.globalData.is_administrator = true;
96 | wx.showModal({
97 | title: '管理员登陆成功',
98 | content: '是否要进入新增界面?',
99 | success: res => {
100 | if (res.cancel == false && res.confirm == true) {
101 | wx.navigateTo({
102 | url: '../add/add',
103 | })
104 | } else {
105 | wx.showToast({
106 | title: '您可以点击下方查看全部按钮管理已有数据',
107 | icon: 'none'
108 | });
109 | }
110 | }
111 | })
112 | } else {
113 | wx.showToast({
114 | title: '您不是管理员,无法进入管理入口!',
115 | icon: 'none'
116 | });
117 | }
118 | })
119 | })
120 | } else {
121 | // 处理未授权的场景
122 | wx.showModal({
123 | title: '授权失败',
124 | content: '您尚未授权获取您的用户信息,是否开启授权界面?',
125 | success: res => {
126 | if (res.confirm) {
127 | wx.openSetting({})
128 | }
129 | }
130 | })
131 | }
132 | },
133 | /**
134 | * 获取用户经纬度
135 | */
136 | getCenterLocation: function () {
137 | wx.getLocation({
138 | type: "gcj02",
139 | success: (res) => {
140 | this.setData({
141 | longitude: res.longitude,
142 | latitude: res.latitude,
143 | });
144 | console.log(
145 | "当前中心点的位置:",
146 | this.data.longitude,
147 | this.data.latitude
148 | );
149 | },
150 | fail: (err) => {
151 | wx.showToast({
152 | title: "GPS定位失败",
153 | icon: "fail",
154 | });
155 | console.log("err", err);
156 | },
157 | });
158 | },
159 | onMarkerTap: function (event) {
160 | wx.navigateTo({
161 | url: '../info/info?id=' + event.markerId,
162 | })
163 | },
164 |
165 | getOpenID: function (event) {
166 | wx.cloud.callFunction({
167 | name: "getUserOpenId"
168 | }).then(res => {
169 | wx.setClipboardData({
170 | data: res.result.openid,
171 | success: res => {
172 | wx.showToast({
173 | title: 'openID已复制',
174 | })
175 | }
176 | })
177 | })
178 | },
179 | hideMe: function (res) {
180 | this.setData({
181 | hideMe: true
182 | })
183 | },
184 | showAdmin: function (res) {
185 | wx.setStorage({
186 | key: 'showAdmin',
187 | data: !this.data.showAdmin,
188 | })
189 | this.setData({
190 | showAdmin: !this.data.showAdmin
191 | })
192 | },
193 | search: function () {
194 | wx.navigateTo({
195 | url: '../search/search',
196 | })
197 | },
198 | /**
199 | * 用户点击右上角分享
200 | */
201 | onShareAppMessage: function () {
202 | return {
203 | title: '菜狗识途,为你带路!',
204 | path: '/pages/type1/map',
205 | imageUrl: "/images/poster_l.png"
206 | }
207 | },
208 | /**
209 | * 用户分享到朋友圈
210 | */
211 | onShareTimeline: function () {
212 | return {
213 | title: '菜狗识途,为你带路!',
214 | path: '/pages/type1/map',
215 | imageUrl: "/images/poster_r.png"
216 | }
217 | },
218 | /*去type1*/
219 | toType1: function () {
220 | wx.reLaunch({
221 | url: '/pages/type1/map'
222 | })
223 | },
224 | /*去type2*/
225 | toType2: function () {
226 | wx.reLaunch({
227 | url: '/pages/type2/map'
228 | })
229 | },
230 | })
--------------------------------------------------------------------------------
/miniprogram/pages/type2/map.json:
--------------------------------------------------------------------------------
1 | {
2 | "usingComponents": {
3 |
4 | }
5 | }
--------------------------------------------------------------------------------
/miniprogram/pages/type2/map.wxml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/miniprogram/pages/type2/map.wxss:
--------------------------------------------------------------------------------
1 | map {
2 | width: 750rpx;
3 | }
4 |
5 | .show_all {
6 | position: absolute;
7 | right: 100rpx;
8 | bottom: 100rpx;
9 | color: rgb(62, 207, 142);
10 | background-color: rgb(255, 255, 255);
11 | box-shadow: 0 4px 6px rgba(50, 50, 93, .11), 0 1px 3px rgba(0, 0, 0, .08);
12 | }
13 |
14 | .cover {
15 | color: #fff;
16 | height: 100rpx;
17 | width: 220rpx;
18 | line-height: 100rpx;
19 | font-size: 35rpx;
20 | text-align: center;
21 | position: absolute;
22 | left: 100rpx;
23 | bottom: 100rpx;
24 | border-radius: 50rpx;
25 | text-shadow: 0 1px 3px rgba(36, 180, 126, .4);
26 | }
27 |
28 | .add_me {
29 | font-size: 30rpx;
30 | color: #fff;
31 | background-color: rgb(62, 207, 142);
32 | width: 450rpx;
33 | padding: 20rpx;
34 | position: absolute;
35 | right: 10rpx;
36 | top: 20rpx;
37 | text-align: center;
38 | }
39 |
40 | .up {
41 | position: absolute;
42 | right: 150rpx;
43 | top: 5rpx;
44 | border-right: 20rpx solid transparent;
45 | border-left: 20rpx solid transparent;
46 | border-bottom: 20rpx solid rgb(62, 207, 142);
47 | }
48 |
49 | .getLocation {
50 | position: absolute;
51 | left: 20rpx;
52 | bottom: 250rpx;
53 | text-align: center;
54 | width: 20px;
55 | background-color:rgb(255, 255, 255,0.9);
56 | padding: 13px;
57 | box-shadow: 1px 2px 3px #999999;
58 | border-radius: 100px;
59 | }
60 |
61 | .list {
62 | position: absolute;
63 | left: 20rpx;
64 | bottom: 360rpx;
65 | text-align: center;
66 | width: 20px;
67 | background-color: rgb(62, 207, 142,0.9);
68 | padding: 13px;
69 | box-shadow: 1px 2px 3px #999999;
70 | border-radius: 100px;
71 | }
72 |
73 | .tab-h{
74 | height: 400rpx;
75 | width: 140rpx;
76 | bottom:250rpx;
77 | right: 12px;
78 | box-sizing: border-box;
79 | overflow: hidden;
80 | line-height: 80rpx;
81 | background: rgba(255, 255, 255, 0.9);
82 | font-size: 16px;
83 | white-space: nowrap;
84 | position: fixed;
85 | z-index: 99;
86 | border-radius: 10px;
87 | }
88 | .chouse_type {
89 | font-size: 32rpx;
90 | color: rgb(62, 207, 142);
91 | text-align: center;
92 | }
93 | .type {
94 | font-size: 32rpx;
95 |
96 | color: rgb(192, 192, 192);
97 | text-align: center;
98 | }
99 | scroll-view ::-webkit-scrollbar {
100 | width: 0;
101 | height: 0;
102 | color: transparent;
103 | display: none;
104 | }
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/miniprogram/pages/type3/map.js:
--------------------------------------------------------------------------------
1 | const app = getApp();
2 | const config = require('../../config.js');
3 | const db = wx.cloud.database()
4 | const store = db.collection('store').where({
5 | type:'餐饮',
6 | });
7 | const userInfo = db.collection('userInfo');
8 |
9 | Page({
10 |
11 | /**
12 | * 页面的初始数据
13 | */
14 | data: {
15 | longitude: config.center_longitude,
16 | latitude: config.center_latitude,
17 | windowHeight: 600,
18 | mapSubKey: config.mapSubKey,
19 | hideMe: true,
20 | showAdmin: false,
21 | },
22 |
23 | /**
24 | * 生命周期函数--监听页面加载
25 | */
26 | onLoad: function (options) {
27 |
28 | let showAdmin = config.show_admin ? true : false;
29 |
30 | if (app.globalData.showAdmin) {
31 | showAdmin = true;
32 | }
33 |
34 | wx.showLoading({
35 | title: '数据载入中...',
36 | })
37 | store.get().then(res => {
38 | let data = res.data;
39 | // 将 _id 给 id ,确保 marker 事件的正确触发
40 | data.map(item => {
41 | item.id = item._id
42 | });
43 | this.setData({
44 | longitude:120.74038982, //默认定位经度
45 | latitude: 31.27141370, //默认定位纬度
46 | markers: res.data,
47 | windowHeight: app.globalData.windowHeight,
48 | hideMe: false,
49 | showAdmin: showAdmin,
50 | defaultScale: config.default_scale
51 | },
52 | () => {
53 | wx.hideLoading();
54 | // wx.showToast({
55 | // title: '菜狗识途,为你带路!',
56 | // icon: 'none'
57 | // })
58 | })
59 | })
60 |
61 | // 获取用户经纬度
62 | this.getCenterLocation();
63 | },
64 |
65 | onShow: function () {
66 | // #10 添加完成后更新一下 map
67 | store.get().then(res => {
68 | let data = res.data;
69 | data.map(item => {
70 | item.id = item._id
71 | });
72 | this.setData({
73 | markers: res.data
74 | })
75 | })
76 | },
77 |
78 | viewAll: function () {
79 | wx.navigateTo({
80 | url: '../list/list',
81 | })
82 | },
83 | getUserInfo: function (e) {
84 | if (e.detail.userInfo) {
85 | userInfo.get().then(res => {
86 | if (!res.data.length) {
87 | userInfo.add({
88 | data: e.detail.userInfo
89 | })
90 | }
91 | wx.cloud.callFunction({
92 | name: 'checkUserAuth'
93 | }).then(res => {
94 | if (res.result.data.is_administrator) {
95 | app.globalData.is_administrator = true;
96 | wx.showModal({
97 | title: '管理员登陆成功',
98 | content: '是否要进入新增界面?',
99 | success: res => {
100 | if (res.cancel == false && res.confirm == true) {
101 | wx.navigateTo({
102 | url: '../add/add',
103 | })
104 | } else {
105 | wx.showToast({
106 | title: '您可以点击下方查看全部按钮管理已有数据',
107 | icon: 'none'
108 | });
109 | }
110 | }
111 | })
112 | } else {
113 | wx.showToast({
114 | title: '您不是管理员,无法进入管理入口!',
115 | icon: 'none'
116 | });
117 | }
118 | })
119 | })
120 | } else {
121 | // 处理未授权的场景
122 | wx.showModal({
123 | title: '授权失败',
124 | content: '您尚未授权获取您的用户信息,是否开启授权界面?',
125 | success: res => {
126 | if (res.confirm) {
127 | wx.openSetting({})
128 | }
129 | }
130 | })
131 | }
132 | },
133 | /**
134 | * 获取用户经纬度
135 | */
136 | getCenterLocation: function () {
137 | wx.getLocation({
138 | type: "gcj02",
139 | success: (res) => {
140 | this.setData({
141 | longitude: res.longitude,
142 | latitude: res.latitude,
143 | });
144 | console.log(
145 | "当前中心点的位置:",
146 | this.data.longitude,
147 | this.data.latitude
148 | );
149 | },
150 | fail: (err) => {
151 | wx.showToast({
152 | title: "GPS定位失败",
153 | icon: "fail",
154 | });
155 | console.log("err", err);
156 | },
157 | });
158 | },
159 | onMarkerTap: function (event) {
160 | wx.navigateTo({
161 | url: '../info/info?id=' + event.markerId,
162 | })
163 | },
164 |
165 | getOpenID: function (event) {
166 | wx.cloud.callFunction({
167 | name: "getUserOpenId"
168 | }).then(res => {
169 | wx.setClipboardData({
170 | data: res.result.openid,
171 | success: res => {
172 | wx.showToast({
173 | title: 'openID已复制',
174 | })
175 | }
176 | })
177 | })
178 | },
179 | hideMe: function (res) {
180 | this.setData({
181 | hideMe: true
182 | })
183 | },
184 | showAdmin: function (res) {
185 | wx.setStorage({
186 | key: 'showAdmin',
187 | data: !this.data.showAdmin,
188 | })
189 | this.setData({
190 | showAdmin: !this.data.showAdmin
191 | })
192 | },
193 | search: function () {
194 | wx.navigateTo({
195 | url: '../search/search',
196 | })
197 | },
198 | /**
199 | * 用户点击右上角分享
200 | */
201 | onShareAppMessage: function () {
202 | return {
203 | title: '菜狗识途,为你带路!',
204 | path: '/pages/type1/map',
205 | imageUrl: "/images/poster_l.png"
206 | }
207 | },
208 | /**
209 | * 用户分享到朋友圈
210 | */
211 | onShareTimeline: function () {
212 | return {
213 | title: '菜狗识途,为你带路!',
214 | path: '/pages/type1/map',
215 | imageUrl: "/images/poster_r.png"
216 | }
217 | },
218 | /*去type1*/
219 | toType1: function () {
220 | wx.reLaunch({
221 | url: '/pages/type1/map'
222 | })
223 | },
224 | /*去type2*/
225 | toType2: function () {
226 | wx.reLaunch({
227 | url: '/pages/type2/map'
228 | })
229 | },
230 | })
--------------------------------------------------------------------------------
/miniprogram/pages/type3/map.json:
--------------------------------------------------------------------------------
1 | {
2 | "usingComponents": {
3 |
4 | }
5 | }
--------------------------------------------------------------------------------
/miniprogram/pages/type3/map.wxml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/miniprogram/pages/type3/map.wxss:
--------------------------------------------------------------------------------
1 | map {
2 | width: 750rpx;
3 | }
4 |
5 | .show_all {
6 | position: absolute;
7 | right: 100rpx;
8 | bottom: 100rpx;
9 | color: rgb(62, 207, 142);
10 | background-color: rgb(255, 255, 255);
11 | box-shadow: 0 4px 6px rgba(50, 50, 93, .11), 0 1px 3px rgba(0, 0, 0, .08);
12 | }
13 |
14 | .cover {
15 | color: #fff;
16 | height: 100rpx;
17 | width: 220rpx;
18 | line-height: 100rpx;
19 | font-size: 35rpx;
20 | text-align: center;
21 | position: absolute;
22 | left: 100rpx;
23 | bottom: 100rpx;
24 | border-radius: 50rpx;
25 | text-shadow: 0 1px 3px rgba(36, 180, 126, .4);
26 | }
27 |
28 | .add_me {
29 | font-size: 30rpx;
30 | color: #fff;
31 | background-color: rgb(62, 207, 142);
32 | width: 450rpx;
33 | padding: 20rpx;
34 | position: absolute;
35 | right: 10rpx;
36 | top: 20rpx;
37 | text-align: center;
38 | }
39 |
40 | .up {
41 | position: absolute;
42 | right: 150rpx;
43 | top: 5rpx;
44 | border-right: 20rpx solid transparent;
45 | border-left: 20rpx solid transparent;
46 | border-bottom: 20rpx solid rgb(62, 207, 142);
47 | }
48 |
49 | .getLocation {
50 | position: absolute;
51 | left: 20rpx;
52 | bottom: 250rpx;
53 | text-align: center;
54 | width: 20px;
55 | background-color:rgb(255, 255, 255,0.9);
56 | padding: 13px;
57 | box-shadow: 1px 2px 3px #999999;
58 | border-radius: 100px;
59 | }
60 |
61 | .list {
62 | position: absolute;
63 | left: 20rpx;
64 | bottom: 360rpx;
65 | text-align: center;
66 | width: 20px;
67 | background-color: rgb(62, 207, 142,0.9);
68 | padding: 13px;
69 | box-shadow: 1px 2px 3px #999999;
70 | border-radius: 100px;
71 | }
72 |
73 | .tab-h{
74 | height: 400rpx;
75 | width: 140rpx;
76 | bottom:250rpx;
77 | right: 12px;
78 | box-sizing: border-box;
79 | overflow: hidden;
80 | line-height: 80rpx;
81 | background: rgba(255, 255, 255, 0.9);
82 | font-size: 16px;
83 | white-space: nowrap;
84 | position: fixed;
85 | z-index: 99;
86 | border-radius: 10px;
87 | }
88 | .chouse_type {
89 | font-size: 32rpx;
90 | color: rgb(62, 207, 142);
91 | text-align: center;
92 | }
93 | .type {
94 | font-size: 32rpx;
95 |
96 | color: rgb(192, 192, 192);
97 | text-align: center;
98 | }
99 | scroll-view ::-webkit-scrollbar {
100 | width: 0;
101 | height: 0;
102 | color: transparent;
103 | display: none;
104 | }
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/miniprogram/pages/type4/map.js:
--------------------------------------------------------------------------------
1 | const app = getApp();
2 | const config = require('../../config.js');
3 | const db = wx.cloud.database()
4 | const store = db.collection('store').where({
5 | type:'便利店',
6 | });
7 | const userInfo = db.collection('userInfo');
8 |
9 | Page({
10 |
11 | /**
12 | * 页面的初始数据
13 | */
14 | data: {
15 | longitude: config.center_longitude,
16 | latitude: config.center_latitude,
17 | windowHeight: 600,
18 | mapSubKey: config.mapSubKey,
19 | hideMe: true,
20 | showAdmin: false,
21 | },
22 |
23 | /**
24 | * 生命周期函数--监听页面加载
25 | */
26 | onLoad: function (options) {
27 |
28 | let showAdmin = config.show_admin ? true : false;
29 |
30 | if (app.globalData.showAdmin) {
31 | showAdmin = true;
32 | }
33 |
34 | wx.showLoading({
35 | title: '数据载入中...',
36 | })
37 | store.get().then(res => {
38 | let data = res.data;
39 | // 将 _id 给 id ,确保 marker 事件的正确触发
40 | data.map(item => {
41 | item.id = item._id
42 | });
43 | this.setData({
44 | longitude:120.74038982, //默认定位经度
45 | latitude: 31.27141370, //默认定位纬度
46 | markers: res.data,
47 | windowHeight: app.globalData.windowHeight,
48 | hideMe: false,
49 | showAdmin: showAdmin,
50 | defaultScale: config.default_scale
51 | },
52 | () => {
53 | wx.hideLoading();
54 | // wx.showToast({
55 | // title: '菜狗识途,为你带路!',
56 | // icon: 'none'
57 | // })
58 | })
59 | })
60 |
61 | // 获取用户经纬度
62 | this.getCenterLocation();
63 | },
64 |
65 | onShow: function () {
66 | // #10 添加完成后更新一下 map
67 | store.get().then(res => {
68 | let data = res.data;
69 | data.map(item => {
70 | item.id = item._id
71 | });
72 | this.setData({
73 | markers: res.data
74 | })
75 | })
76 | },
77 |
78 | viewAll: function () {
79 | wx.navigateTo({
80 | url: '../list/list',
81 | })
82 | },
83 | getUserInfo: function (e) {
84 | if (e.detail.userInfo) {
85 | userInfo.get().then(res => {
86 | if (!res.data.length) {
87 | userInfo.add({
88 | data: e.detail.userInfo
89 | })
90 | }
91 | wx.cloud.callFunction({
92 | name: 'checkUserAuth'
93 | }).then(res => {
94 | if (res.result.data.is_administrator) {
95 | app.globalData.is_administrator = true;
96 | wx.showModal({
97 | title: '管理员登陆成功',
98 | content: '是否要进入新增界面?',
99 | success: res => {
100 | if (res.cancel == false && res.confirm == true) {
101 | wx.navigateTo({
102 | url: '../add/add',
103 | })
104 | } else {
105 | wx.showToast({
106 | title: '您可以点击下方查看全部按钮管理已有数据',
107 | icon: 'none'
108 | });
109 | }
110 | }
111 | })
112 | } else {
113 | wx.showToast({
114 | title: '您不是管理员,无法进入管理入口!',
115 | icon: 'none'
116 | });
117 | }
118 | })
119 | })
120 | } else {
121 | // 处理未授权的场景
122 | wx.showModal({
123 | title: '授权失败',
124 | content: '您尚未授权获取您的用户信息,是否开启授权界面?',
125 | success: res => {
126 | if (res.confirm) {
127 | wx.openSetting({})
128 | }
129 | }
130 | })
131 | }
132 | },
133 | /**
134 | * 获取用户经纬度
135 | */
136 | getCenterLocation: function () {
137 | wx.getLocation({
138 | type: "gcj02",
139 | success: (res) => {
140 | this.setData({
141 | longitude: res.longitude,
142 | latitude: res.latitude,
143 | });
144 | console.log(
145 | "当前中心点的位置:",
146 | this.data.longitude,
147 | this.data.latitude
148 | );
149 | },
150 | fail: (err) => {
151 | wx.showToast({
152 | title: "GPS定位失败",
153 | icon: "fail",
154 | });
155 | console.log("err", err);
156 | },
157 | });
158 | },
159 | onMarkerTap: function (event) {
160 | wx.navigateTo({
161 | url: '../info/info?id=' + event.markerId,
162 | })
163 | },
164 |
165 | getOpenID: function (event) {
166 | wx.cloud.callFunction({
167 | name: "getUserOpenId"
168 | }).then(res => {
169 | wx.setClipboardData({
170 | data: res.result.openid,
171 | success: res => {
172 | wx.showToast({
173 | title: 'openID已复制',
174 | })
175 | }
176 | })
177 | })
178 | },
179 | hideMe: function (res) {
180 | this.setData({
181 | hideMe: true
182 | })
183 | },
184 | showAdmin: function (res) {
185 | wx.setStorage({
186 | key: 'showAdmin',
187 | data: !this.data.showAdmin,
188 | })
189 | this.setData({
190 | showAdmin: !this.data.showAdmin
191 | })
192 | },
193 | search: function () {
194 | wx.navigateTo({
195 | url: '../search/search',
196 | })
197 | },
198 | /**
199 | * 用户点击右上角分享
200 | */
201 | onShareAppMessage: function () {
202 | return {
203 | title: '菜狗识途,为你带路!',
204 | path: '/pages/type1/map',
205 | imageUrl: "/images/poster_l.png"
206 | }
207 | },
208 | /**
209 | * 用户分享到朋友圈
210 | */
211 | onShareTimeline: function () {
212 | return {
213 | title: '菜狗识途,为你带路!',
214 | path: '/pages/type1/map',
215 | imageUrl: "/images/poster_r.png"
216 | }
217 | },
218 | /*去type1*/
219 | toType1: function () {
220 | wx.reLaunch({
221 | url: '/pages/type1/map'
222 | })
223 | },
224 | /*去type2*/
225 | toType2: function () {
226 | wx.reLaunch({
227 | url: '/pages/type2/map'
228 | })
229 | },
230 | })
--------------------------------------------------------------------------------
/miniprogram/pages/type4/map.json:
--------------------------------------------------------------------------------
1 | {
2 | "usingComponents": {
3 |
4 | }
5 | }
--------------------------------------------------------------------------------
/miniprogram/pages/type4/map.wxml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/miniprogram/pages/type4/map.wxss:
--------------------------------------------------------------------------------
1 | map {
2 | width: 750rpx;
3 | }
4 |
5 | .show_all {
6 | position: absolute;
7 | right: 100rpx;
8 | bottom: 100rpx;
9 | color: rgb(62, 207, 142);
10 | background-color: rgb(255, 255, 255);
11 | box-shadow: 0 4px 6px rgba(50, 50, 93, .11), 0 1px 3px rgba(0, 0, 0, .08);
12 | }
13 |
14 | .cover {
15 | color: #fff;
16 | height: 100rpx;
17 | width: 220rpx;
18 | line-height: 100rpx;
19 | font-size: 35rpx;
20 | text-align: center;
21 | position: absolute;
22 | left: 100rpx;
23 | bottom: 100rpx;
24 | border-radius: 50rpx;
25 | text-shadow: 0 1px 3px rgba(36, 180, 126, .4);
26 | }
27 |
28 | .add_me {
29 | font-size: 30rpx;
30 | color: #fff;
31 | background-color: rgb(62, 207, 142);
32 | width: 450rpx;
33 | padding: 20rpx;
34 | position: absolute;
35 | right: 10rpx;
36 | top: 20rpx;
37 | text-align: center;
38 | }
39 |
40 | .up {
41 | position: absolute;
42 | right: 150rpx;
43 | top: 5rpx;
44 | border-right: 20rpx solid transparent;
45 | border-left: 20rpx solid transparent;
46 | border-bottom: 20rpx solid rgb(62, 207, 142);
47 | }
48 |
49 | .getLocation {
50 | position: absolute;
51 | left: 20rpx;
52 | bottom: 250rpx;
53 | text-align: center;
54 | width: 20px;
55 | background-color:rgb(255, 255, 255,0.9);
56 | padding: 13px;
57 | box-shadow: 1px 2px 3px #999999;
58 | border-radius: 100px;
59 | }
60 |
61 | .list {
62 | position: absolute;
63 | left: 20rpx;
64 | bottom: 360rpx;
65 | text-align: center;
66 | width: 20px;
67 | background-color: rgb(62, 207, 142,0.9);
68 | padding: 13px;
69 | box-shadow: 1px 2px 3px #999999;
70 | border-radius: 100px;
71 | }
72 |
73 | .tab-h{
74 | height: 400rpx;
75 | width: 140rpx;
76 | bottom:250rpx;
77 | right: 12px;
78 | box-sizing: border-box;
79 | overflow: hidden;
80 | line-height: 80rpx;
81 | background: rgba(255, 255, 255, 0.9);
82 | font-size: 16px;
83 | white-space: nowrap;
84 | position: fixed;
85 | z-index: 99;
86 | border-radius: 10px;
87 | }
88 | .chouse_type {
89 | font-size: 32rpx;
90 | color: rgb(62, 207, 142);
91 | text-align: center;
92 | }
93 | .type {
94 | font-size: 32rpx;
95 |
96 | color: rgb(192, 192, 192);
97 | text-align: center;
98 | }
99 | scroll-view ::-webkit-scrollbar {
100 | width: 0;
101 | height: 0;
102 | color: transparent;
103 | display: none;
104 | }
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/miniprogram/pages/type5/map.js:
--------------------------------------------------------------------------------
1 | const app = getApp();
2 | const config = require('../../config.js');
3 | const db = wx.cloud.database()
4 | const store = db.collection('store').where({
5 | type:'咖啡机',
6 | });
7 | const userInfo = db.collection('userInfo');
8 |
9 | Page({
10 |
11 | /**
12 | * 页面的初始数据
13 | */
14 | data: {
15 | longitude: config.center_longitude,
16 | latitude: config.center_latitude,
17 | windowHeight: 600,
18 | mapSubKey: config.mapSubKey,
19 | hideMe: true,
20 | showAdmin: false,
21 | },
22 |
23 | /**
24 | * 生命周期函数--监听页面加载
25 | */
26 | onLoad: function (options) {
27 |
28 | let showAdmin = config.show_admin ? true : false;
29 |
30 | if (app.globalData.showAdmin) {
31 | showAdmin = true;
32 | }
33 |
34 | wx.showLoading({
35 | title: '数据载入中...',
36 | })
37 | store.get().then(res => {
38 | let data = res.data;
39 | // 将 _id 给 id ,确保 marker 事件的正确触发
40 | data.map(item => {
41 | item.id = item._id
42 | });
43 | this.setData({
44 | longitude:120.74038982, //默认定位经度
45 | latitude: 31.27141370, //默认定位纬度
46 | markers: res.data,
47 | windowHeight: app.globalData.windowHeight,
48 | hideMe: false,
49 | showAdmin: showAdmin,
50 | defaultScale: config.default_scale
51 | },
52 | () => {
53 | wx.hideLoading();
54 | // wx.showToast({
55 | // title: '菜狗识途,为你带路!',
56 | // icon: 'none'
57 | // })
58 | })
59 | })
60 |
61 | // 获取用户经纬度
62 | this.getCenterLocation();
63 | },
64 |
65 | onShow: function () {
66 | // #10 添加完成后更新一下 map
67 | store.get().then(res => {
68 | let data = res.data;
69 | data.map(item => {
70 | item.id = item._id
71 | });
72 | this.setData({
73 | markers: res.data
74 | })
75 | })
76 | },
77 |
78 | viewAll: function () {
79 | wx.navigateTo({
80 | url: '../list/list',
81 | })
82 | },
83 | getUserInfo: function (e) {
84 | if (e.detail.userInfo) {
85 | userInfo.get().then(res => {
86 | if (!res.data.length) {
87 | userInfo.add({
88 | data: e.detail.userInfo
89 | })
90 | }
91 | wx.cloud.callFunction({
92 | name: 'checkUserAuth'
93 | }).then(res => {
94 | if (res.result.data.is_administrator) {
95 | app.globalData.is_administrator = true;
96 | wx.showModal({
97 | title: '管理员登陆成功',
98 | content: '是否要进入新增界面?',
99 | success: res => {
100 | if (res.cancel == false && res.confirm == true) {
101 | wx.navigateTo({
102 | url: '../add/add',
103 | })
104 | } else {
105 | wx.showToast({
106 | title: '您可以点击下方查看全部按钮管理已有数据',
107 | icon: 'none'
108 | });
109 | }
110 | }
111 | })
112 | } else {
113 | wx.showToast({
114 | title: '您不是管理员,无法进入管理入口!',
115 | icon: 'none'
116 | });
117 | }
118 | })
119 | })
120 | } else {
121 | // 处理未授权的场景
122 | wx.showModal({
123 | title: '授权失败',
124 | content: '您尚未授权获取您的用户信息,是否开启授权界面?',
125 | success: res => {
126 | if (res.confirm) {
127 | wx.openSetting({})
128 | }
129 | }
130 | })
131 | }
132 | },
133 | /**
134 | * 获取用户经纬度
135 | */
136 | getCenterLocation: function () {
137 | wx.getLocation({
138 | type: "gcj02",
139 | success: (res) => {
140 | this.setData({
141 | longitude: res.longitude,
142 | latitude: res.latitude,
143 | });
144 | console.log(
145 | "当前中心点的位置:",
146 | this.data.longitude,
147 | this.data.latitude
148 | );
149 | },
150 | fail: (err) => {
151 | wx.showToast({
152 | title: "GPS定位失败",
153 | icon: "fail",
154 | });
155 | console.log("err", err);
156 | },
157 | });
158 | },
159 | onMarkerTap: function (event) {
160 | wx.navigateTo({
161 | url: '../info/info?id=' + event.markerId,
162 | })
163 | },
164 |
165 | getOpenID: function (event) {
166 | wx.cloud.callFunction({
167 | name: "getUserOpenId"
168 | }).then(res => {
169 | wx.setClipboardData({
170 | data: res.result.openid,
171 | success: res => {
172 | wx.showToast({
173 | title: 'openID已复制',
174 | })
175 | }
176 | })
177 | })
178 | },
179 | hideMe: function (res) {
180 | this.setData({
181 | hideMe: true
182 | })
183 | },
184 | showAdmin: function (res) {
185 | wx.setStorage({
186 | key: 'showAdmin',
187 | data: !this.data.showAdmin,
188 | })
189 | this.setData({
190 | showAdmin: !this.data.showAdmin
191 | })
192 | },
193 | search: function () {
194 | wx.navigateTo({
195 | url: '../search/search',
196 | })
197 | },
198 | /**
199 | * 用户点击右上角分享
200 | */
201 | onShareAppMessage: function () {
202 | return {
203 | title: '菜狗识途,为你带路!',
204 | path: '/pages/type1/map',
205 | imageUrl: "/images/poster_l.png"
206 | }
207 | },
208 | /**
209 | * 用户分享到朋友圈
210 | */
211 | onShareTimeline: function () {
212 | return {
213 | title: '菜狗识途,为你带路!',
214 | path: '/pages/type1/map',
215 | imageUrl: "/images/poster_r.png"
216 | }
217 | },
218 | /*去type1*/
219 | toType1: function () {
220 | wx.reLaunch({
221 | url: '/pages/type1/map'
222 | })
223 | },
224 | /*去type2*/
225 | toType2: function () {
226 | wx.reLaunch({
227 | url: '/pages/type2/map'
228 | })
229 | },
230 | })
--------------------------------------------------------------------------------
/miniprogram/pages/type5/map.json:
--------------------------------------------------------------------------------
1 | {
2 | "usingComponents": {
3 |
4 | }
5 | }
--------------------------------------------------------------------------------
/miniprogram/pages/type5/map.wxml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/miniprogram/pages/type5/map.wxss:
--------------------------------------------------------------------------------
1 | map {
2 | width: 750rpx;
3 | }
4 |
5 | .show_all {
6 | position: absolute;
7 | right: 100rpx;
8 | bottom: 100rpx;
9 | color: rgb(62, 207, 142);
10 | background-color: rgb(255, 255, 255);
11 | box-shadow: 0 4px 6px rgba(50, 50, 93, .11), 0 1px 3px rgba(0, 0, 0, .08);
12 | }
13 |
14 | .cover {
15 | color: #fff;
16 | height: 100rpx;
17 | width: 220rpx;
18 | line-height: 100rpx;
19 | font-size: 35rpx;
20 | text-align: center;
21 | position: absolute;
22 | left: 100rpx;
23 | bottom: 100rpx;
24 | border-radius: 50rpx;
25 | text-shadow: 0 1px 3px rgba(36, 180, 126, .4);
26 | }
27 |
28 | .add_me {
29 | font-size: 30rpx;
30 | color: #fff;
31 | background-color: rgb(62, 207, 142);
32 | width: 450rpx;
33 | padding: 20rpx;
34 | position: absolute;
35 | right: 10rpx;
36 | top: 20rpx;
37 | text-align: center;
38 | }
39 |
40 | .up {
41 | position: absolute;
42 | right: 150rpx;
43 | top: 5rpx;
44 | border-right: 20rpx solid transparent;
45 | border-left: 20rpx solid transparent;
46 | border-bottom: 20rpx solid rgb(62, 207, 142);
47 | }
48 |
49 | .getLocation {
50 | position: absolute;
51 | left: 20rpx;
52 | bottom: 250rpx;
53 | text-align: center;
54 | width: 20px;
55 | background-color:rgb(255, 255, 255,0.9);
56 | padding: 13px;
57 | box-shadow: 1px 2px 3px #999999;
58 | border-radius: 100px;
59 | }
60 |
61 | .list {
62 | position: absolute;
63 | left: 20rpx;
64 | bottom: 360rpx;
65 | text-align: center;
66 | width: 20px;
67 | background-color: rgb(62, 207, 142,0.9);
68 | padding: 13px;
69 | box-shadow: 1px 2px 3px #999999;
70 | border-radius: 100px;
71 | }
72 |
73 | .tab-h{
74 | height: 400rpx;
75 | width: 140rpx;
76 | bottom:250rpx;
77 | right: 12px;
78 | box-sizing: border-box;
79 | overflow: hidden;
80 | line-height: 80rpx;
81 | background: rgba(255, 255, 255, 0.9);
82 | font-size: 16px;
83 | white-space: nowrap;
84 | position: fixed;
85 | z-index: 99;
86 | border-radius: 10px;
87 | }
88 | .chouse_type {
89 | font-size: 32rpx;
90 | color: rgb(62, 207, 142);
91 | text-align: center;
92 | }
93 | .type {
94 | font-size: 32rpx;
95 |
96 | color: rgb(192, 192, 192);
97 | text-align: center;
98 | }
99 | scroll-view ::-webkit-scrollbar {
100 | width: 0;
101 | height: 0;
102 | color: transparent;
103 | display: none;
104 | }
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/miniprogram/pages/type6/map.js:
--------------------------------------------------------------------------------
1 | const app = getApp();
2 | const config = require('../../config.js');
3 | const db = wx.cloud.database()
4 | const store = db.collection('store').where({
5 | type:'售货机',
6 | });
7 | const userInfo = db.collection('userInfo');
8 |
9 | Page({
10 |
11 | /**
12 | * 页面的初始数据
13 | */
14 | data: {
15 | longitude: config.center_longitude,
16 | latitude: config.center_latitude,
17 | windowHeight: 600,
18 | mapSubKey: config.mapSubKey,
19 | hideMe: true,
20 | showAdmin: false,
21 | },
22 |
23 | /**
24 | * 生命周期函数--监听页面加载
25 | */
26 | onLoad: function (options) {
27 |
28 | let showAdmin = config.show_admin ? true : false;
29 |
30 | if (app.globalData.showAdmin) {
31 | showAdmin = true;
32 | }
33 |
34 | wx.showLoading({
35 | title: '数据载入中...',
36 | })
37 | store.get().then(res => {
38 | let data = res.data;
39 | // 将 _id 给 id ,确保 marker 事件的正确触发
40 | data.map(item => {
41 | item.id = item._id
42 | });
43 | this.setData({
44 | longitude:120.74038982, //默认定位经度
45 | latitude: 31.27141370, //默认定位纬度
46 | markers: res.data,
47 | windowHeight: app.globalData.windowHeight,
48 | hideMe: false,
49 | showAdmin: showAdmin,
50 | defaultScale: config.default_scale
51 | },
52 | () => {
53 | wx.hideLoading();
54 | // wx.showToast({
55 | // title: '菜狗识途,为你带路!',
56 | // icon: 'none'
57 | // })
58 | })
59 | })
60 |
61 | // 获取用户经纬度
62 | this.getCenterLocation();
63 | },
64 |
65 | onShow: function () {
66 | // #10 添加完成后更新一下 map
67 | store.get().then(res => {
68 | let data = res.data;
69 | data.map(item => {
70 | item.id = item._id
71 | });
72 | this.setData({
73 | markers: res.data
74 | })
75 | })
76 | },
77 |
78 | viewAll: function () {
79 | wx.navigateTo({
80 | url: '../list/list',
81 | })
82 | },
83 | getUserInfo: function (e) {
84 | if (e.detail.userInfo) {
85 | userInfo.get().then(res => {
86 | if (!res.data.length) {
87 | userInfo.add({
88 | data: e.detail.userInfo
89 | })
90 | }
91 | wx.cloud.callFunction({
92 | name: 'checkUserAuth'
93 | }).then(res => {
94 | if (res.result.data.is_administrator) {
95 | app.globalData.is_administrator = true;
96 | wx.showModal({
97 | title: '管理员登陆成功',
98 | content: '是否要进入新增界面?',
99 | success: res => {
100 | if (res.cancel == false && res.confirm == true) {
101 | wx.navigateTo({
102 | url: '../add/add',
103 | })
104 | } else {
105 | wx.showToast({
106 | title: '您可以点击下方查看全部按钮管理已有数据',
107 | icon: 'none'
108 | });
109 | }
110 | }
111 | })
112 | } else {
113 | wx.showToast({
114 | title: '您不是管理员,无法进入管理入口!',
115 | icon: 'none'
116 | });
117 | }
118 | })
119 | })
120 | } else {
121 | // 处理未授权的场景
122 | wx.showModal({
123 | title: '授权失败',
124 | content: '您尚未授权获取您的用户信息,是否开启授权界面?',
125 | success: res => {
126 | if (res.confirm) {
127 | wx.openSetting({})
128 | }
129 | }
130 | })
131 | }
132 | },
133 | /**
134 | * 获取用户经纬度
135 | */
136 | getCenterLocation: function () {
137 | wx.getLocation({
138 | type: "gcj02",
139 | success: (res) => {
140 | this.setData({
141 | longitude: res.longitude,
142 | latitude: res.latitude,
143 | });
144 | console.log(
145 | "当前中心点的位置:",
146 | this.data.longitude,
147 | this.data.latitude
148 | );
149 | },
150 | fail: (err) => {
151 | wx.showToast({
152 | title: "GPS定位失败",
153 | icon: "fail",
154 | });
155 | console.log("err", err);
156 | },
157 | });
158 | },
159 | onMarkerTap: function (event) {
160 | wx.navigateTo({
161 | url: '../info/info?id=' + event.markerId,
162 | })
163 | },
164 |
165 | getOpenID: function (event) {
166 | wx.cloud.callFunction({
167 | name: "getUserOpenId"
168 | }).then(res => {
169 | wx.setClipboardData({
170 | data: res.result.openid,
171 | success: res => {
172 | wx.showToast({
173 | title: 'openID已复制',
174 | })
175 | }
176 | })
177 | })
178 | },
179 | hideMe: function (res) {
180 | this.setData({
181 | hideMe: true
182 | })
183 | },
184 | showAdmin: function (res) {
185 | wx.setStorage({
186 | key: 'showAdmin',
187 | data: !this.data.showAdmin,
188 | })
189 | this.setData({
190 | showAdmin: !this.data.showAdmin
191 | })
192 | },
193 | search: function () {
194 | wx.navigateTo({
195 | url: '../search/search',
196 | })
197 | },
198 | /**
199 | * 用户点击右上角分享
200 | */
201 | onShareAppMessage: function () {
202 | return {
203 | title: '菜狗识途,为你带路!',
204 | path: '/pages/type1/map',
205 | imageUrl: "/images/poster_l.png"
206 | }
207 | },
208 | /**
209 | * 用户分享到朋友圈
210 | */
211 | onShareTimeline: function () {
212 | return {
213 | title: '菜狗识途,为你带路!',
214 | path: '/pages/type1/map',
215 | imageUrl: "/images/poster_r.png"
216 | }
217 | },
218 | /*去type1*/
219 | toType1: function () {
220 | wx.reLaunch({
221 | url: '/pages/type1/map'
222 | })
223 | },
224 | /*去type2*/
225 | toType2: function () {
226 | wx.reLaunch({
227 | url: '/pages/type2/map'
228 | })
229 | },
230 | })
--------------------------------------------------------------------------------
/miniprogram/pages/type6/map.json:
--------------------------------------------------------------------------------
1 | {
2 | "usingComponents": {
3 |
4 | }
5 | }
--------------------------------------------------------------------------------
/miniprogram/pages/type6/map.wxml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/miniprogram/pages/type6/map.wxss:
--------------------------------------------------------------------------------
1 | map {
2 | width: 750rpx;
3 | }
4 |
5 | .show_all {
6 | position: absolute;
7 | right: 100rpx;
8 | bottom: 100rpx;
9 | color: rgb(62, 207, 142);
10 | background-color: rgb(255, 255, 255);
11 | box-shadow: 0 4px 6px rgba(50, 50, 93, .11), 0 1px 3px rgba(0, 0, 0, .08);
12 | }
13 |
14 | .cover {
15 | color: #fff;
16 | height: 100rpx;
17 | width: 220rpx;
18 | line-height: 100rpx;
19 | font-size: 35rpx;
20 | text-align: center;
21 | position: absolute;
22 | left: 100rpx;
23 | bottom: 100rpx;
24 | border-radius: 50rpx;
25 | text-shadow: 0 1px 3px rgba(36, 180, 126, .4);
26 | }
27 |
28 | .add_me {
29 | font-size: 30rpx;
30 | color: #fff;
31 | background-color: rgb(62, 207, 142);
32 | width: 450rpx;
33 | padding: 20rpx;
34 | position: absolute;
35 | right: 10rpx;
36 | top: 20rpx;
37 | text-align: center;
38 | }
39 |
40 | .up {
41 | position: absolute;
42 | right: 150rpx;
43 | top: 5rpx;
44 | border-right: 20rpx solid transparent;
45 | border-left: 20rpx solid transparent;
46 | border-bottom: 20rpx solid rgb(62, 207, 142);
47 | }
48 |
49 | .getLocation {
50 | position: absolute;
51 | left: 20rpx;
52 | bottom: 250rpx;
53 | text-align: center;
54 | width: 20px;
55 | background-color:rgb(255, 255, 255,0.9);
56 | padding: 13px;
57 | box-shadow: 1px 2px 3px #999999;
58 | border-radius: 100px;
59 | }
60 |
61 | .list {
62 | position: absolute;
63 | left: 20rpx;
64 | bottom: 360rpx;
65 | text-align: center;
66 | width: 20px;
67 | background-color: rgb(62, 207, 142,0.9);
68 | padding: 13px;
69 | box-shadow: 1px 2px 3px #999999;
70 | border-radius: 100px;
71 | }
72 |
73 | .tab-h{
74 | height: 400rpx;
75 | width: 140rpx;
76 | bottom:250rpx;
77 | right: 12px;
78 | box-sizing: border-box;
79 | overflow: hidden;
80 | line-height: 80rpx;
81 | background: rgba(255, 255, 255, 0.9);
82 | font-size: 16px;
83 | white-space: nowrap;
84 | position: fixed;
85 | z-index: 99;
86 | border-radius: 10px;
87 | }
88 | .chouse_type {
89 | font-size: 32rpx;
90 | color: rgb(62, 207, 142);
91 | text-align: center;
92 | }
93 | .type {
94 | font-size: 32rpx;
95 |
96 | color: rgb(192, 192, 192);
97 | text-align: center;
98 | }
99 | scroll-view ::-webkit-scrollbar {
100 | width: 0;
101 | height: 0;
102 | color: transparent;
103 | display: none;
104 | }
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/miniprogram/pages/type7/map.js:
--------------------------------------------------------------------------------
1 | const app = getApp();
2 | const config = require('../../config.js');
3 | const db = wx.cloud.database()
4 | const store = db.collection('store').where({
5 | type:'充电桩',
6 | });
7 | const userInfo = db.collection('userInfo');
8 |
9 | Page({
10 |
11 | /**
12 | * 页面的初始数据
13 | */
14 | data: {
15 | longitude: config.center_longitude,
16 | latitude: config.center_latitude,
17 | windowHeight: 600,
18 | mapSubKey: config.mapSubKey,
19 | hideMe: true,
20 | showAdmin: false,
21 | },
22 |
23 | /**
24 | * 生命周期函数--监听页面加载
25 | */
26 | onLoad: function (options) {
27 |
28 | let showAdmin = config.show_admin ? true : false;
29 |
30 | if (app.globalData.showAdmin) {
31 | showAdmin = true;
32 | }
33 |
34 | wx.showLoading({
35 | title: '数据载入中...',
36 | })
37 | store.get().then(res => {
38 | let data = res.data;
39 | // 将 _id 给 id ,确保 marker 事件的正确触发
40 | data.map(item => {
41 | item.id = item._id
42 | });
43 | this.setData({
44 | longitude:120.74038982, //默认定位经度
45 | latitude: 31.27141370, //默认定位纬度
46 | markers: res.data,
47 | windowHeight: app.globalData.windowHeight,
48 | hideMe: false,
49 | showAdmin: showAdmin,
50 | defaultScale: config.default_scale
51 | },
52 | () => {
53 | wx.hideLoading();
54 | // wx.showToast({
55 | // title: '菜狗识途,为你带路!',
56 | // icon: 'none'
57 | // })
58 | })
59 | })
60 |
61 | // 获取用户经纬度
62 | this.getCenterLocation();
63 | },
64 |
65 | onShow: function () {
66 | // #10 添加完成后更新一下 map
67 | store.get().then(res => {
68 | let data = res.data;
69 | data.map(item => {
70 | item.id = item._id
71 | });
72 | this.setData({
73 | markers: res.data
74 | })
75 | })
76 | },
77 |
78 | viewAll: function () {
79 | wx.navigateTo({
80 | url: '../list/list',
81 | })
82 | },
83 | getUserInfo: function (e) {
84 | if (e.detail.userInfo) {
85 | userInfo.get().then(res => {
86 | if (!res.data.length) {
87 | userInfo.add({
88 | data: e.detail.userInfo
89 | })
90 | }
91 | wx.cloud.callFunction({
92 | name: 'checkUserAuth'
93 | }).then(res => {
94 | if (res.result.data.is_administrator) {
95 | app.globalData.is_administrator = true;
96 | wx.showModal({
97 | title: '管理员登陆成功',
98 | content: '是否要进入新增界面?',
99 | success: res => {
100 | if (res.cancel == false && res.confirm == true) {
101 | wx.navigateTo({
102 | url: '../add/add',
103 | })
104 | } else {
105 | wx.showToast({
106 | title: '您可以点击下方查看全部按钮管理已有数据',
107 | icon: 'none'
108 | });
109 | }
110 | }
111 | })
112 | } else {
113 | wx.showToast({
114 | title: '您不是管理员,无法进入管理入口!',
115 | icon: 'none'
116 | });
117 | }
118 | })
119 | })
120 | } else {
121 | // 处理未授权的场景
122 | wx.showModal({
123 | title: '授权失败',
124 | content: '您尚未授权获取您的用户信息,是否开启授权界面?',
125 | success: res => {
126 | if (res.confirm) {
127 | wx.openSetting({})
128 | }
129 | }
130 | })
131 | }
132 | },
133 | /**
134 | * 获取用户经纬度
135 | */
136 | getCenterLocation: function () {
137 | wx.getLocation({
138 | type: "gcj02",
139 | success: (res) => {
140 | this.setData({
141 | longitude: res.longitude,
142 | latitude: res.latitude,
143 | });
144 | console.log(
145 | "当前中心点的位置:",
146 | this.data.longitude,
147 | this.data.latitude
148 | );
149 | },
150 | fail: (err) => {
151 | wx.showToast({
152 | title: "GPS定位失败",
153 | icon: "fail",
154 | });
155 | console.log("err", err);
156 | },
157 | });
158 | },
159 | onMarkerTap: function (event) {
160 | wx.navigateTo({
161 | url: '../info/info?id=' + event.markerId,
162 | })
163 | },
164 |
165 | getOpenID: function (event) {
166 | wx.cloud.callFunction({
167 | name: "getUserOpenId"
168 | }).then(res => {
169 | wx.setClipboardData({
170 | data: res.result.openid,
171 | success: res => {
172 | wx.showToast({
173 | title: 'openID已复制',
174 | })
175 | }
176 | })
177 | })
178 | },
179 | hideMe: function (res) {
180 | this.setData({
181 | hideMe: true
182 | })
183 | },
184 | showAdmin: function (res) {
185 | wx.setStorage({
186 | key: 'showAdmin',
187 | data: !this.data.showAdmin,
188 | })
189 | this.setData({
190 | showAdmin: !this.data.showAdmin
191 | })
192 | },
193 | search: function () {
194 | wx.navigateTo({
195 | url: '../search/search',
196 | })
197 | },
198 | /**
199 | * 用户点击右上角分享
200 | */
201 | onShareAppMessage: function () {
202 | return {
203 | title: '菜狗识途,为你带路!',
204 | path: '/pages/type1/map',
205 | imageUrl: "/images/poster_l.png"
206 | }
207 | },
208 | /**
209 | * 用户分享到朋友圈
210 | */
211 | onShareTimeline: function () {
212 | return {
213 | title: '菜狗识途,为你带路!',
214 | path: '/pages/type1/map',
215 | imageUrl: "/images/poster_r.png"
216 | }
217 | },
218 | /*去type1*/
219 | toType1: function () {
220 | wx.reLaunch({
221 | url: '/pages/type1/map'
222 | })
223 | },
224 | /*去type2*/
225 | toType2: function () {
226 | wx.reLaunch({
227 | url: '/pages/type2/map'
228 | })
229 | },
230 | })
--------------------------------------------------------------------------------
/miniprogram/pages/type7/map.json:
--------------------------------------------------------------------------------
1 | {
2 | "usingComponents": {
3 |
4 | }
5 | }
--------------------------------------------------------------------------------
/miniprogram/pages/type7/map.wxml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/miniprogram/pages/type7/map.wxss:
--------------------------------------------------------------------------------
1 | map {
2 | width: 750rpx;
3 | }
4 |
5 | .show_all {
6 | position: absolute;
7 | right: 100rpx;
8 | bottom: 100rpx;
9 | color: rgb(62, 207, 142);
10 | background-color: rgb(255, 255, 255);
11 | box-shadow: 0 4px 6px rgba(50, 50, 93, .11), 0 1px 3px rgba(0, 0, 0, .08);
12 | }
13 |
14 | .cover {
15 | color: #fff;
16 | height: 100rpx;
17 | width: 220rpx;
18 | line-height: 100rpx;
19 | font-size: 35rpx;
20 | text-align: center;
21 | position: absolute;
22 | left: 100rpx;
23 | bottom: 100rpx;
24 | border-radius: 50rpx;
25 | text-shadow: 0 1px 3px rgba(36, 180, 126, .4);
26 | }
27 |
28 | .add_me {
29 | font-size: 30rpx;
30 | color: #fff;
31 | background-color: rgb(62, 207, 142);
32 | width: 450rpx;
33 | padding: 20rpx;
34 | position: absolute;
35 | right: 10rpx;
36 | top: 20rpx;
37 | text-align: center;
38 | }
39 |
40 | .up {
41 | position: absolute;
42 | right: 150rpx;
43 | top: 5rpx;
44 | border-right: 20rpx solid transparent;
45 | border-left: 20rpx solid transparent;
46 | border-bottom: 20rpx solid rgb(62, 207, 142);
47 | }
48 |
49 | .getLocation {
50 | position: absolute;
51 | left: 20rpx;
52 | bottom: 250rpx;
53 | text-align: center;
54 | width: 20px;
55 | background-color:rgb(255, 255, 255,0.9);
56 | padding: 13px;
57 | box-shadow: 1px 2px 3px #999999;
58 | border-radius: 100px;
59 | }
60 |
61 | .list {
62 | position: absolute;
63 | left: 20rpx;
64 | bottom: 360rpx;
65 | text-align: center;
66 | width: 20px;
67 | background-color: rgb(62, 207, 142,0.9);
68 | padding: 13px;
69 | box-shadow: 1px 2px 3px #999999;
70 | border-radius: 100px;
71 | }
72 |
73 | .tab-h{
74 | height: 400rpx;
75 | width: 140rpx;
76 | bottom:250rpx;
77 | right: 12px;
78 | box-sizing: border-box;
79 | overflow: hidden;
80 | line-height: 80rpx;
81 | background: rgba(255, 255, 255, 0.9);
82 | font-size: 16px;
83 | white-space: nowrap;
84 | position: fixed;
85 | z-index: 99;
86 | border-radius: 10px;
87 | }
88 | .chouse_type {
89 | font-size: 32rpx;
90 | color: rgb(62, 207, 142);
91 | text-align: center;
92 | }
93 | .type {
94 | font-size: 32rpx;
95 |
96 | color: rgb(192, 192, 192);
97 | text-align: center;
98 | }
99 | scroll-view ::-webkit-scrollbar {
100 | width: 0;
101 | height: 0;
102 | color: transparent;
103 | display: none;
104 | }
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/miniprogram/pages/type8/map.js:
--------------------------------------------------------------------------------
1 | const app = getApp();
2 | const config = require('../../config.js');
3 | const db = wx.cloud.database()
4 | const store = db.collection('store').where({
5 | type:'通宵教室',
6 | });
7 | const userInfo = db.collection('userInfo');
8 |
9 | Page({
10 |
11 | /**
12 | * 页面的初始数据
13 | */
14 | data: {
15 | longitude: config.center_longitude,
16 | latitude: config.center_latitude,
17 | windowHeight: 600,
18 | mapSubKey: config.mapSubKey,
19 | hideMe: true,
20 | showAdmin: false,
21 | },
22 |
23 | /**
24 | * 生命周期函数--监听页面加载
25 | */
26 | onLoad: function (options) {
27 |
28 | let showAdmin = config.show_admin ? true : false;
29 |
30 | if (app.globalData.showAdmin) {
31 | showAdmin = true;
32 | }
33 |
34 | wx.showLoading({
35 | title: '数据载入中...',
36 | })
37 | store.get().then(res => {
38 | let data = res.data;
39 | // 将 _id 给 id ,确保 marker 事件的正确触发
40 | data.map(item => {
41 | item.id = item._id
42 | });
43 | this.setData({
44 | longitude:120.74038982, //默认定位经度
45 | latitude: 31.27141370, //默认定位纬度
46 | markers: res.data,
47 | windowHeight: app.globalData.windowHeight,
48 | hideMe: false,
49 | showAdmin: showAdmin,
50 | defaultScale: config.default_scale
51 | },
52 | () => {
53 | wx.hideLoading();
54 | // wx.showToast({
55 | // title: '菜狗识途,为你带路!',
56 | // icon: 'none'
57 | // })
58 | })
59 | })
60 |
61 | // 获取用户经纬度
62 | this.getCenterLocation();
63 | },
64 |
65 | onShow: function () {
66 | // #10 添加完成后更新一下 map
67 | store.get().then(res => {
68 | let data = res.data;
69 | data.map(item => {
70 | item.id = item._id
71 | });
72 | this.setData({
73 | markers: res.data
74 | })
75 | })
76 | },
77 |
78 | viewAll: function () {
79 | wx.navigateTo({
80 | url: '../list/list',
81 | })
82 | },
83 | getUserInfo: function (e) {
84 | if (e.detail.userInfo) {
85 | userInfo.get().then(res => {
86 | if (!res.data.length) {
87 | userInfo.add({
88 | data: e.detail.userInfo
89 | })
90 | }
91 | wx.cloud.callFunction({
92 | name: 'checkUserAuth'
93 | }).then(res => {
94 | if (res.result.data.is_administrator) {
95 | app.globalData.is_administrator = true;
96 | wx.showModal({
97 | title: '管理员登陆成功',
98 | content: '是否要进入新增界面?',
99 | success: res => {
100 | if (res.cancel == false && res.confirm == true) {
101 | wx.navigateTo({
102 | url: '../add/add',
103 | })
104 | } else {
105 | wx.showToast({
106 | title: '您可以点击下方查看全部按钮管理已有数据',
107 | icon: 'none'
108 | });
109 | }
110 | }
111 | })
112 | } else {
113 | wx.showToast({
114 | title: '您不是管理员,无法进入管理入口!',
115 | icon: 'none'
116 | });
117 | }
118 | })
119 | })
120 | } else {
121 | // 处理未授权的场景
122 | wx.showModal({
123 | title: '授权失败',
124 | content: '您尚未授权获取您的用户信息,是否开启授权界面?',
125 | success: res => {
126 | if (res.confirm) {
127 | wx.openSetting({})
128 | }
129 | }
130 | })
131 | }
132 | },
133 | /**
134 | * 获取用户经纬度
135 | */
136 | getCenterLocation: function () {
137 | wx.getLocation({
138 | type: "gcj02",
139 | success: (res) => {
140 | this.setData({
141 | longitude: res.longitude,
142 | latitude: res.latitude,
143 | });
144 | console.log(
145 | "当前中心点的位置:",
146 | this.data.longitude,
147 | this.data.latitude
148 | );
149 | },
150 | fail: (err) => {
151 | wx.showToast({
152 | title: "GPS定位失败",
153 | icon: "fail",
154 | });
155 | console.log("err", err);
156 | },
157 | });
158 | },
159 | onMarkerTap: function (event) {
160 | wx.navigateTo({
161 | url: '../info/info?id=' + event.markerId,
162 | })
163 | },
164 |
165 | getOpenID: function (event) {
166 | wx.cloud.callFunction({
167 | name: "getUserOpenId"
168 | }).then(res => {
169 | wx.setClipboardData({
170 | data: res.result.openid,
171 | success: res => {
172 | wx.showToast({
173 | title: 'openID已复制',
174 | })
175 | }
176 | })
177 | })
178 | },
179 | hideMe: function (res) {
180 | this.setData({
181 | hideMe: true
182 | })
183 | },
184 | showAdmin: function (res) {
185 | wx.setStorage({
186 | key: 'showAdmin',
187 | data: !this.data.showAdmin,
188 | })
189 | this.setData({
190 | showAdmin: !this.data.showAdmin
191 | })
192 | },
193 | search: function () {
194 | wx.navigateTo({
195 | url: '../search/search',
196 | })
197 | },
198 | /**
199 | * 用户点击右上角分享
200 | */
201 | onShareAppMessage: function () {
202 | return {
203 | title: '菜狗识途,为你带路!',
204 | path: '/pages/type1/map',
205 | imageUrl: "/images/poster_l.png"
206 | }
207 | },
208 | /**
209 | * 用户分享到朋友圈
210 | */
211 | onShareTimeline: function () {
212 | return {
213 | title: '菜狗识途,为你带路!',
214 | path: '/pages/type1/map',
215 | imageUrl: "/images/poster_r.png"
216 | }
217 | },
218 | /*去type1*/
219 | toType1: function () {
220 | wx.reLaunch({
221 | url: '/pages/type1/map'
222 | })
223 | },
224 | /*去type2*/
225 | toType2: function () {
226 | wx.reLaunch({
227 | url: '/pages/type2/map'
228 | })
229 | },
230 | })
--------------------------------------------------------------------------------
/miniprogram/pages/type8/map.json:
--------------------------------------------------------------------------------
1 | {
2 | "usingComponents": {
3 |
4 | }
5 | }
--------------------------------------------------------------------------------
/miniprogram/pages/type8/map.wxml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/miniprogram/pages/type8/map.wxss:
--------------------------------------------------------------------------------
1 | map {
2 | width: 750rpx;
3 | }
4 |
5 | .show_all {
6 | position: absolute;
7 | right: 100rpx;
8 | bottom: 100rpx;
9 | color: rgb(62, 207, 142);
10 | background-color: rgb(255, 255, 255);
11 | box-shadow: 0 4px 6px rgba(50, 50, 93, .11), 0 1px 3px rgba(0, 0, 0, .08);
12 | }
13 |
14 | .cover {
15 | color: #fff;
16 | height: 100rpx;
17 | width: 220rpx;
18 | line-height: 100rpx;
19 | font-size: 35rpx;
20 | text-align: center;
21 | position: absolute;
22 | left: 100rpx;
23 | bottom: 100rpx;
24 | border-radius: 50rpx;
25 | text-shadow: 0 1px 3px rgba(36, 180, 126, .4);
26 | }
27 |
28 | .add_me {
29 | font-size: 30rpx;
30 | color: #fff;
31 | background-color: rgb(62, 207, 142);
32 | width: 450rpx;
33 | padding: 20rpx;
34 | position: absolute;
35 | right: 10rpx;
36 | top: 20rpx;
37 | text-align: center;
38 | }
39 |
40 | .up {
41 | position: absolute;
42 | right: 150rpx;
43 | top: 5rpx;
44 | border-right: 20rpx solid transparent;
45 | border-left: 20rpx solid transparent;
46 | border-bottom: 20rpx solid rgb(62, 207, 142);
47 | }
48 |
49 | .getLocation {
50 | position: absolute;
51 | left: 20rpx;
52 | bottom: 250rpx;
53 | text-align: center;
54 | width: 20px;
55 | background-color:rgb(255, 255, 255,0.9);
56 | padding: 13px;
57 | box-shadow: 1px 2px 3px #999999;
58 | border-radius: 100px;
59 | }
60 |
61 | .list {
62 | position: absolute;
63 | left: 20rpx;
64 | bottom: 360rpx;
65 | text-align: center;
66 | width: 20px;
67 | background-color: rgb(62, 207, 142,0.9);
68 | padding: 13px;
69 | box-shadow: 1px 2px 3px #999999;
70 | border-radius: 100px;
71 | }
72 |
73 | .tab-h{
74 | height: 400rpx;
75 | width: 140rpx;
76 | bottom:250rpx;
77 | right: 12px;
78 | box-sizing: border-box;
79 | overflow: hidden;
80 | line-height: 80rpx;
81 | background: rgba(255, 255, 255, 0.9);
82 | font-size: 16px;
83 | white-space: nowrap;
84 | position: fixed;
85 | z-index: 99;
86 | border-radius: 10px;
87 | }
88 | .chouse_type {
89 | font-size: 32rpx;
90 | color: rgb(62, 207, 142);
91 | text-align: center;
92 | }
93 | .type {
94 | font-size: 32rpx;
95 |
96 | color: rgb(192, 192, 192);
97 | text-align: center;
98 | }
99 | scroll-view ::-webkit-scrollbar {
100 | width: 0;
101 | height: 0;
102 | color: transparent;
103 | display: none;
104 | }
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/miniprogram/pages/type9/map.js:
--------------------------------------------------------------------------------
1 | const app = getApp();
2 | const config = require('../../config.js');
3 | const db = wx.cloud.database()
4 | const store = db.collection('store').where({
5 | type:'西浦秀',
6 | });
7 | const userInfo = db.collection('userInfo');
8 |
9 | Page({
10 |
11 | /**
12 | * 页面的初始数据
13 | */
14 | data: {
15 | longitude: config.center_longitude,
16 | latitude: config.center_latitude,
17 | windowHeight: 600,
18 | mapSubKey: config.mapSubKey,
19 | hideMe: true,
20 | showAdmin: false,
21 | },
22 |
23 | /**
24 | * 生命周期函数--监听页面加载
25 | */
26 | onLoad: function (options) {
27 |
28 | let showAdmin = config.show_admin ? true : false;
29 |
30 | if (app.globalData.showAdmin) {
31 | showAdmin = true;
32 | }
33 |
34 | wx.showLoading({
35 | title: '数据载入中...',
36 | })
37 | store.get().then(res => {
38 | let data = res.data;
39 | // 将 _id 给 id ,确保 marker 事件的正确触发
40 | data.map(item => {
41 | item.id = item._id
42 | });
43 | this.setData({
44 | longitude:120.74038982, //默认定位经度
45 | latitude: 31.27141370, //默认定位纬度
46 | markers: res.data,
47 | windowHeight: app.globalData.windowHeight,
48 | hideMe: false,
49 | showAdmin: showAdmin,
50 | defaultScale: config.default_scale
51 | },
52 | () => {
53 | wx.hideLoading();
54 | // wx.showToast({
55 | // title: '菜狗识途,为你带路!',
56 | // icon: 'none'
57 | // })
58 | })
59 | })
60 |
61 | // 获取用户经纬度
62 | this.getCenterLocation();
63 | },
64 |
65 | onShow: function () {
66 | // #10 添加完成后更新一下 map
67 | store.get().then(res => {
68 | let data = res.data;
69 | data.map(item => {
70 | item.id = item._id
71 | });
72 | this.setData({
73 | markers: res.data
74 | })
75 | })
76 | },
77 |
78 | viewAll: function () {
79 | wx.navigateTo({
80 | url: '../list/list',
81 | })
82 | },
83 | getUserInfo: function (e) {
84 | if (e.detail.userInfo) {
85 | userInfo.get().then(res => {
86 | if (!res.data.length) {
87 | userInfo.add({
88 | data: e.detail.userInfo
89 | })
90 | }
91 | wx.cloud.callFunction({
92 | name: 'checkUserAuth'
93 | }).then(res => {
94 | if (res.result.data.is_administrator) {
95 | app.globalData.is_administrator = true;
96 | wx.showModal({
97 | title: '管理员登陆成功',
98 | content: '是否要进入新增界面?',
99 | success: res => {
100 | if (res.cancel == false && res.confirm == true) {
101 | wx.navigateTo({
102 | url: '../add/add',
103 | })
104 | } else {
105 | wx.showToast({
106 | title: '您可以点击下方查看全部按钮管理已有数据',
107 | icon: 'none'
108 | });
109 | }
110 | }
111 | })
112 | } else {
113 | wx.showToast({
114 | title: '您不是管理员,无法进入管理入口!',
115 | icon: 'none'
116 | });
117 | }
118 | })
119 | })
120 | } else {
121 | // 处理未授权的场景
122 | wx.showModal({
123 | title: '授权失败',
124 | content: '您尚未授权获取您的用户信息,是否开启授权界面?',
125 | success: res => {
126 | if (res.confirm) {
127 | wx.openSetting({})
128 | }
129 | }
130 | })
131 | }
132 | },
133 | /**
134 | * 获取用户经纬度
135 | */
136 | getCenterLocation: function () {
137 | wx.getLocation({
138 | type: "gcj02",
139 | success: (res) => {
140 | this.setData({
141 | longitude: res.longitude,
142 | latitude: res.latitude,
143 | });
144 | console.log(
145 | "当前中心点的位置:",
146 | this.data.longitude,
147 | this.data.latitude
148 | );
149 | },
150 | fail: (err) => {
151 | wx.showToast({
152 | title: "GPS定位失败",
153 | icon: "fail",
154 | });
155 | console.log("err", err);
156 | },
157 | });
158 | },
159 | onMarkerTap: function (event) {
160 | wx.navigateTo({
161 | url: '../info/info?id=' + event.markerId,
162 | })
163 | },
164 |
165 | getOpenID: function (event) {
166 | wx.cloud.callFunction({
167 | name: "getUserOpenId"
168 | }).then(res => {
169 | wx.setClipboardData({
170 | data: res.result.openid,
171 | success: res => {
172 | wx.showToast({
173 | title: 'openID已复制',
174 | })
175 | }
176 | })
177 | })
178 | },
179 | hideMe: function (res) {
180 | this.setData({
181 | hideMe: true
182 | })
183 | },
184 | showAdmin: function (res) {
185 | wx.setStorage({
186 | key: 'showAdmin',
187 | data: !this.data.showAdmin,
188 | })
189 | this.setData({
190 | showAdmin: !this.data.showAdmin
191 | })
192 | },
193 | search: function () {
194 | wx.navigateTo({
195 | url: '../search/search',
196 | })
197 | },
198 | /**
199 | * 用户点击右上角分享
200 | */
201 | onShareAppMessage: function () {
202 | return {
203 | title: '菜狗识途,为你带路!',
204 | path: '/pages/type1/map',
205 | imageUrl: "/images/poster_l.png"
206 | }
207 | },
208 | /**
209 | * 用户分享到朋友圈
210 | */
211 | onShareTimeline: function () {
212 | return {
213 | title: '菜狗识途,为你带路!',
214 | path: '/pages/type1/map',
215 | imageUrl: "/images/poster_r.png"
216 | }
217 | },
218 | /*去type1*/
219 | toType1: function () {
220 | wx.reLaunch({
221 | url: '/pages/type1/map'
222 | })
223 | },
224 | /*去type2*/
225 | toType2: function () {
226 | wx.reLaunch({
227 | url: '/pages/type2/map'
228 | })
229 | },
230 | })
--------------------------------------------------------------------------------
/miniprogram/pages/type9/map.json:
--------------------------------------------------------------------------------
1 | {
2 | "usingComponents": {
3 |
4 | }
5 | }
--------------------------------------------------------------------------------
/miniprogram/pages/type9/map.wxml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/miniprogram/pages/type9/map.wxss:
--------------------------------------------------------------------------------
1 | map {
2 | width: 750rpx;
3 | }
4 |
5 | .show_all {
6 | position: absolute;
7 | right: 100rpx;
8 | bottom: 100rpx;
9 | color: rgb(62, 207, 142);
10 | background-color: rgb(255, 255, 255);
11 | box-shadow: 0 4px 6px rgba(50, 50, 93, .11), 0 1px 3px rgba(0, 0, 0, .08);
12 | }
13 |
14 | .cover {
15 | color: #fff;
16 | height: 100rpx;
17 | width: 220rpx;
18 | line-height: 100rpx;
19 | font-size: 35rpx;
20 | text-align: center;
21 | position: absolute;
22 | left: 100rpx;
23 | bottom: 100rpx;
24 | border-radius: 50rpx;
25 | text-shadow: 0 1px 3px rgba(36, 180, 126, .4);
26 | }
27 |
28 | .add_me {
29 | font-size: 30rpx;
30 | color: #fff;
31 | background-color: rgb(62, 207, 142);
32 | width: 450rpx;
33 | padding: 20rpx;
34 | position: absolute;
35 | right: 10rpx;
36 | top: 20rpx;
37 | text-align: center;
38 | }
39 |
40 | .up {
41 | position: absolute;
42 | right: 150rpx;
43 | top: 5rpx;
44 | border-right: 20rpx solid transparent;
45 | border-left: 20rpx solid transparent;
46 | border-bottom: 20rpx solid rgb(62, 207, 142);
47 | }
48 |
49 | .getLocation {
50 | position: absolute;
51 | left: 20rpx;
52 | bottom: 250rpx;
53 | text-align: center;
54 | width: 20px;
55 | background-color:rgb(255, 255, 255,0.9);
56 | padding: 13px;
57 | box-shadow: 1px 2px 3px #999999;
58 | border-radius: 100px;
59 | }
60 |
61 | .list {
62 | position: absolute;
63 | left: 20rpx;
64 | bottom: 360rpx;
65 | text-align: center;
66 | width: 20px;
67 | background-color: rgb(62, 207, 142,0.9);
68 | padding: 13px;
69 | box-shadow: 1px 2px 3px #999999;
70 | border-radius: 100px;
71 | }
72 |
73 | .tab-h{
74 | height: 400rpx;
75 | width: 140rpx;
76 | bottom:250rpx;
77 | right: 12px;
78 | box-sizing: border-box;
79 | overflow: hidden;
80 | line-height: 80rpx;
81 | background: rgba(255, 255, 255, 0.9);
82 | font-size: 16px;
83 | white-space: nowrap;
84 | position: fixed;
85 | z-index: 99;
86 | border-radius: 10px;
87 | }
88 | .chouse_type {
89 | font-size: 32rpx;
90 | color: rgb(62, 207, 142);
91 | text-align: center;
92 | }
93 | .type {
94 | font-size: 32rpx;
95 |
96 | color: rgb(192, 192, 192);
97 | text-align: center;
98 | }
99 | scroll-view ::-webkit-scrollbar {
100 | width: 0;
101 | height: 0;
102 | color: transparent;
103 | display: none;
104 | }
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/miniprogram/sitemap.json:
--------------------------------------------------------------------------------
1 | {
2 | "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
3 | "rules": [{
4 | "action": "allow",
5 | "page": "*"
6 | }]
7 | }
--------------------------------------------------------------------------------
/miniprogram/tools/tools.wxs:
--------------------------------------------------------------------------------
1 | //换行
2 | var replaceBr = function (val) {
3 | return val ? val.replace(getRegExp("
", "g"), "\n") : val
4 | }
5 |
6 | var replaceLine = function (val) {
7 | return val ? val.replace(getRegExp("\\\\n", "g"), "\n") : val
8 | }
9 |
10 | var replaceLineNull = function (val) {
11 | return val ? val.replace(getRegExp("\\\\n", "g"), "") : val
12 | }
13 |
14 | module.exports.replaceBr = replaceBr
15 | module.exports.replaceLine = replaceLine
16 | module.exports.replaceLineNull = replaceLineNull
--------------------------------------------------------------------------------
/miniprogram/vendor/fontawesome.wxss:
--------------------------------------------------------------------------------
1 | .icon {
2 | display: inline-block;
3 | font: normal normal normal 14px/1 FontAwesome;
4 | font-size: inherit;
5 | text-rendering: auto;
6 | margin-right: 10rpx;
7 | }
8 |
9 | .fa-phone:before {
10 | content: "\f095";
11 | }
12 |
13 | .fa-map:before {
14 | content: "\f041";
15 | }
16 |
17 | .fa-star:before {
18 | content: "\f005";
19 | }
20 |
21 | .fa-money:before {
22 | content: "\f0d6";
23 | }
24 |
25 | .fa-comment:before {
26 | content: "\f075";
27 | }
28 |
29 | .fa-thumbs-up:before {
30 | content: "\f164";
31 | }
32 |
33 | .fa-tag:before {
34 | content: "\f02b";
35 | }
36 |
37 | .fa-cutlery:before {
38 | content: "\f0f5";
39 | }
40 |
--------------------------------------------------------------------------------
/project.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "miniprogramRoot": "miniprogram/",
3 | "cloudfunctionRoot": "cloudfunctions/",
4 | "setting": {
5 | "urlCheck": true,
6 | "es6": true,
7 | "enhance": true,
8 | "postcss": true,
9 | "preloadBackgroundData": false,
10 | "minified": true,
11 | "newFeature": true,
12 | "coverView": true,
13 | "nodeModules": true,
14 | "autoAudits": false,
15 | "showShadowRootInWxmlPanel": true,
16 | "scopeDataCheck": false,
17 | "uglifyFileName": false,
18 | "checkInvalidKey": true,
19 | "checkSiteMap": true,
20 | "uploadWithSourceMap": true,
21 | "compileHotReLoad": false,
22 | "lazyloadPlaceholderEnable": false,
23 | "useMultiFrameRuntime": true,
24 | "useApiHook": true,
25 | "useApiHostProcess": true,
26 | "babelSetting": {
27 | "ignore": [],
28 | "disablePlugins": [],
29 | "outputPath": ""
30 | },
31 | "enableEngineNative": false,
32 | "useIsolateContext": false,
33 | "userConfirmedBundleSwitch": false,
34 | "packNpmManually": false,
35 | "packNpmRelationList": [],
36 | "minifyWXSS": true,
37 | "showES6CompileOption": false,
38 | "useSummerCompiler": false
39 | },
40 | "appid": "wx878ef08382a91eb5",
41 | "projectname": "caigoushitu",
42 | "libVersion": "2.4.4",
43 | "cloudfunctionTemplateRoot": "cloudfunctionTemplate",
44 | "condition": {
45 | "search": {
46 | "list": []
47 | },
48 | "conversation": {
49 | "list": []
50 | },
51 | "plugin": {
52 | "list": []
53 | },
54 | "game": {
55 | "list": []
56 | },
57 | "miniprogram": {
58 | "list": [
59 | {
60 | "id": -1,
61 | "name": "全部内容",
62 | "pathName": "pages/list/list",
63 | "query": ""
64 | },
65 | {
66 | "id": 1,
67 | "name": "商铺详情",
68 | "pathName": "pages/info/info",
69 | "query": "id=XE0cj8DR1TiNzjpY",
70 | "scene": null
71 | },
72 | {
73 | "id": -1,
74 | "name": "新增数据",
75 | "pathName": "pages/add/add",
76 | "query": ""
77 | },
78 | {
79 | "id": -1,
80 | "name": "搜索页面",
81 | "pathName": "pages/search/search",
82 | "query": "",
83 | "scene": null
84 | }
85 | ]
86 | }
87 | }
88 | }
--------------------------------------------------------------------------------