瀏覽代碼

添加路由 首页跳转更多 热门推荐 附近商家

zxl 1 年之前
父節點
當前提交
bbe8d51adb

+ 12 - 0
src/pages.json

@@ -98,6 +98,18 @@
           "style": {
             "navigationBarTitleText": "服务列表"
           }
+        },
+        {
+          "path": "nearby/index",
+          "style": {
+            "navigationBarTitleText": "附近商家"
+          }
+        },
+        {
+          "path": "hot/index",
+          "style": {
+            "navigationBarTitleText": "热门推荐"
+          }
         }
       ]
     },

+ 66 - 0
src/pages/business/hot/index.vue

@@ -0,0 +1,66 @@
+<template>
+  <view class="container">
+    <serviceItem v-for="item of 5"></serviceItem>
+  </view>
+</template>
+
+<script>
+  import { getHomePageApi,getCurrentLocation } from '@/api/home';
+  import serviceItem from '@/components/service/index.vue';
+  export default{
+    data(){
+      return{
+        queryParams:{
+          region:null,//地区编码
+          longitude:null,//经度
+          latitude:null,//纬度
+        },
+        init_list:[]
+      }
+    },
+    components:{
+      serviceItem
+    },
+    mounted() {
+      this.handlerInitLocation()
+    },
+    methods:{
+      // 获取当前经纬度
+      handlerInitLocation(){
+        uni.getLocation({
+        	type: 'gcj02',
+        	success: res => {
+        		this.queryParams.longitude = res.longitude;
+        		this.queryParams.latitude = res.longitude;
+            let point = {
+              latitude: res.longitude,
+              longitude: res.longitude
+            }
+            getCurrentLocation(point).then(rc=>{
+              this.queryParams.region = rc.data.id
+              this.handlerInitList()
+            })
+        	},
+        	fail: (rs) => {
+            uni.showToast({
+              title:rs,
+              icon:'none'
+            })
+        	}
+        });
+      },
+      // 初始化列表信息
+      handlerInitList(){
+        getHomePageApi(this.queryParams).then(res=>{
+          console.log('getHomePageApi',res);
+        })
+      }
+    }
+  }
+</script>
+
+<style lang="scss" scoped>
+  .container{
+
+  }
+</style>

+ 17 - 9
src/pages/business/list.vue

@@ -79,7 +79,9 @@
 						<view class="bottom-right">{{(item.distance/1000).toFixed(2)}}KM</view>
 					</view>
 				</view>
-			</view>
+			</view>
+      <u-empty v-show="sellerList.length == 0" mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png"></u-empty>
+
 		</view>
 	</view>
 </template>
@@ -101,7 +103,7 @@
 			}catch(e){
 				console.log(e,'error')
 			}
-			
+
 		},
 		computed:{
 			...mapState({
@@ -111,7 +113,6 @@
 		},
 		data() {
 			return {
-				keyword: null,
 				filterShow: false,
 				filterType: 0,
 				sortCondition:'综合排序',
@@ -135,10 +136,15 @@
 					latitude:'',
 					sort:'SYNTHESE',
 					size:10,
-					region:'',
+					region:'',//地区编码
+          keyword: null,//关键字
+          categoryId:null,//分类ID
 				}
 			}
-		},
+		},
+    onLoad(option) {
+    	this.sellerListParams.categoryId = option.id
+    },
 		methods: {
 			// 点击综合排序
 			handlerSelectAllFilter(e) {
@@ -164,16 +170,18 @@
 						break;
 				}
 				this.getData()
-			},
+			},
+      // 获取初始化列表
 			getData(){
 				this.sellerListParams.latitude = this.latitude
 				this.sellerListParams.longitude = this.longitude
-				getSellerList(this.sellerListParams).then(res => {
+				getSellerList(this.sellerListParams).then(res => {
 					this.sellerList = res.data
 				}).catch(err => {
 					console.log(err)
 				});
-			},
+			},
+      // 点击进入详情
 			goSellerDetail(id){
 				uni.navigateTo({
 					url: `pages/business/detail?id=${id}`
@@ -424,4 +432,4 @@
 			}
 		}
 	}
-</style>
+</style>

+ 25 - 0
src/pages/business/nearby/index.vue

@@ -0,0 +1,25 @@
+<template>
+  <view class="container">
+    <serviceItem v-for="item of 5"></serviceItem>
+  </view>
+</template>
+
+<script>
+  import serviceItem from '@/components/service/index.vue';
+  export default{
+    data(){
+      return{
+
+      }
+    },
+    components:{
+      serviceItem
+    }
+  }
+</script>
+
+<style lang="scss" scoped>
+  .container{
+
+  }
+</style>

+ 6 - 3
src/pages/tabbar/home/index.vue

@@ -162,7 +162,8 @@
 
 		watch: {
 			location: {
-				handler: async function(newVal, oldVal) {
+				handler: async function(newVal, oldVal) {
+          console.log('newVal',newVal);
 					const result = await getCurrentLocation(newVal);
 					const param = Object.assign({}, {
 						region: result.data.id
@@ -237,7 +238,9 @@
 				if (item.id === 'all') {
 					this.$Router.push('/pages/business/category');
 				} else {
-					this.$Router.push('/pages/business/list');
+          uni.navigateTo({
+          	url: `/pages/business/list?id=${item.id}`
+          })
 				}
 			},
 		},
@@ -323,4 +326,4 @@
 			}
 		}
 	}
-</style>
+</style>

+ 1 - 0
src/store/modules/user.js

@@ -19,6 +19,7 @@ export default {
       return new Promise((resolve, reject) => {
         getUserInfo()
           .then(res => {
+            console.log('res',res);
             commit('SET_USER_INFO', res.data);
             resolve(res);
           })