Răsfoiți Sursa

feat(home): 首页定位

18285564342 1 an în urmă
părinte
comite
d3d4b8b8b0

+ 5 - 5
src/manifest.json

@@ -55,12 +55,12 @@
       "subPackages": true
     },
     "usingComponents": true,
-    "permission" : {
-      "scope.userLocation" : {
-        "desc" : "使用定位功能"
+    "permission": {
+      "scope.userLocation": {
+        "desc": "使用定位功能"
       }
-     },
-     "requiredPrivateInfos": ["getLocation"]
+    },
+    "requiredPrivateInfos": ["getLocation", "chooseLocation"]
   },
   "mp-alipay": {
     "usingComponents": true

+ 1 - 1
src/pages/client/allComments/index.vue

@@ -115,7 +115,7 @@
         // this.isSearch = false;
         // this.searching = true;
         uni.navigateTo({
-          url: "/client/CommunitySearch/index",
+          url: "/pages/client/CommunitySearch/index",
         })
       },
       allReply() {

+ 0 - 0
src/pages/client/chooseCity/index copy 2.vue


+ 45 - 4
src/pages/client/chooseCity/index.vue

@@ -1,7 +1,11 @@
 <template>
   <view class="chooseCity">
-    <!-- 地图 -->
-    <view class="map">地图</view>
+    <view class="map">
+			<view class="page-section page-section-gap">
+				<map style="width: 100%; height: 300px;" :latitude="latitude" :longitude="longitude" :markers="covers">
+				</map>
+			</view>
+		</view>
     <view class="nearsMap">附近地址</view>
     <view class="city">
       <view class="citeItem1">某某省某某市某某区某某</view>
@@ -23,8 +27,46 @@
 </template>
 
 <script>
+import { getHomePage } from '@/api/home';
 export default {
-
+  data() {
+		return {
+			id:0, // 使用 marker点击事件 需要填写id
+			title: 'map',
+			latitude: 0,
+			longitude: 0,
+			covers: [{
+				latitude: 0,
+				longitude: 0,
+				iconPath: '../../../static/location.png'
+			}, {
+				latitude: 0,
+				longitude: 0,
+				iconPath: '../../../static/location.png'
+			}]
+		}
+	},
+	methods: {
+    onShow() {
+      uni.getLocation({
+        type: 'gcj02',
+        success: res => {
+          console.log('当前位置的经度:' + res.longitude);
+          console.log('当前位置的纬度:' + res.latitude);
+          this.location.longitude = res.longitude;
+          this.location.latitude = res.latitude;
+          this.$store.commit('SET_LOCATION', { longitude: res.longitude, latitude: res.latitude });
+          getHomePage(this.location)
+            .then(res => {
+              console.log(res);
+            })
+            .catch(err => {
+              console.log(err);
+            });
+        },
+      });
+    },
+	}
 }
 </script>
 
@@ -37,7 +79,6 @@ export default {
     height: 600rpx;
     text-align: center;
     line-height: 600rpx;
-    background-color: pink;
   }
 
   .nearsMap {

+ 1 - 1
src/pages/tabbar/community/index copy.vue

@@ -102,7 +102,7 @@ export default {
       // this.isSearch = false;
       // this.searching = true;
       uni.navigateTo({
-        url: '/client/CommunitySearch/index',
+        url: '/pages/client/CommunitySearch/index',
       });
     },
     allReply() {

+ 2 - 2
src/pages/tabbar/community/index.vue

@@ -113,12 +113,12 @@ export default {
       // this.isSearch = false;
       // this.searching = true;
       uni.navigateTo({
-        url: '/client/CommunitySearch/index',
+        url: '/pages/client/CommunitySearch/index',
       });
     },
     allReply() {
       uni.navigateTo({
-        url: '/client/allComments/index',
+        url: '/pages/client/allComments/index',
       });
     },
     changeCom(index) {

+ 12 - 2
src/pages/tabbar/home/index.vue

@@ -2,11 +2,11 @@
   <view class="home">
     <!-- 顶部导航 -->
     <view class="home-header">
-      <view class="goto-address" @click="$Router.push('/client/chooseCity/index')">
+      <view class="goto-address" @click="manualGetLocation">
         <text>地址</text>
         <text class="iconfont icon-sanjiaoxing1"></text>
       </view>
-      <view class="search-item" @click="Router.push('/client/search/index')">
+      <view class="search-item" @click="Router.push('/pages/client/search/index')">
         <u-search placeholder="请输入搜索内容" :showAction="false" v-model="keyword" />
       </view>
     </view>
@@ -153,6 +153,16 @@ export default {
         },
       });
     },
+    manualGetLocation() {
+      uni.chooseLocation({
+        success:  (res)=> {
+          console.log('位置名称:' + res.name);
+          console.log('详细地址:' + res.address);
+          console.log('纬度:' + res.latitude);
+          console.log('经度:' + res.longitude);
+        },
+      });
+    },
   },
 };
 </script>