diff --git a/App.vue b/App.vue index 6a0ba6f..2102825 100644 --- a/App.vue +++ b/App.vue @@ -4,6 +4,7 @@ // #ifdef MP-WEIXIN uni.cache.set('menuInfo', uni.getMenuButtonBoundingClientRect()); // #endif + uni.cache.set('NAME', '零点八零'); }, onShow: function() { this.$store.dispatch("HeightActions"); //获取随时获取页面的高度 diff --git a/common/js/api.js b/common/js/api.js index 0d65af0..04086f0 100644 --- a/common/js/api.js +++ b/common/js/api.js @@ -126,4 +126,7 @@ export default { productqueryShopIdByTableCode(data) { //通过桌码获取shopId return uni.api.get("/product/queryShopIdByTableCode", data); }, + geocodelocation(data) { //根据经纬度获取信息 + return uni.api.get("/location/geocode", data); + }, } \ No newline at end of file diff --git a/pages.json b/pages.json index 00d3abb..25a9929 100644 --- a/pages.json +++ b/pages.json @@ -222,7 +222,7 @@ ], "globalStyle": { "navigationBarTextStyle": "black", - "navigationBarTitleText": "美味抢先点", + "navigationBarTitleText": "零点八零", "navigationBarBackgroundColor": "#ffffff", "backgroundColor": "#F2F2F2" }, diff --git a/pages/index/components/todaylist.vue b/pages/index/components/todaylist.vue index acadce1..58b5f89 100644 --- a/pages/index/components/todaylist.vue +++ b/pages/index/components/todaylist.vue @@ -37,7 +37,8 @@ + style="background: url(https://czg-qr-order.oss-cn-beijing.aliyuncs.com/index/towcontent_box2.png) no-repeat; background-size: cover;" + @click="jrtoday(1)"> {{salesList.name}} @@ -83,7 +84,7 @@ type: Object, default () { return { - salesList:[] + salesList: [] } } }, @@ -91,7 +92,7 @@ type: Object, default () { return { - todayList:[] + todayList: [] } } }, @@ -100,16 +101,16 @@ default: '每日特价' } }, - methods:{ - clickproduct(item){ - uni.pro.navigateTo('product/index',{ - id:item.id + methods: { + clickproduct(item) { + uni.pro.navigateTo('product/index', { + id: item.id }) }, - jrtoday(e){ - if(e == 0){ + jrtoday(e) { + if (e == 0) { uni.pro.navigateTo('index/jtoday') - }else{ + } else { uni.pro.navigateTo('index/hotlist') } } @@ -125,7 +126,7 @@ width: 336rpx; border-radius: 18rpx; background: #FFFFFF; - + height:396rpx; .therecontent_box_itembox { padding: 10rpx 18rpx 24rpx 24rpx; @@ -148,6 +149,7 @@ font-weight: 400; font-size: 24rpx; color: #333333; + text { margin-left: 4rpx; overflow: hidden; diff --git a/pages/index/index.vue b/pages/index/index.vue index 32bccdb..020a0d0 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -17,8 +17,8 @@ - 美味抢先点 - 西安 + {{NAME}} + {{form.address}} @@ -60,8 +60,8 @@ - - + + - 八点八零 - 西安 + {{NAME}} + {{form.address}} @@ -188,26 +188,26 @@ - + + + + + + + + - {{item.label}} + {{item.name}} - - - - - - @@ -233,6 +233,7 @@ }, data() { return { + NAME: uni.cache.get('NAME'), timersetInterval: '0', //定时器 isFixedTop: false, //吸顶是否显示 Topdistance: 3000, //吸顶初始距离 @@ -249,7 +250,10 @@ itemStyle: [ //样式 ], homelist: [], //下面数据 - clickhometoplistmenulist: {}, //下拉点击的数据 + clickhometoplistmenulist: { + detail: [], + quilt: '' + }, //下拉点击的数据 form: { address: '西安市', //地址 type: '', //品类 @@ -291,10 +295,14 @@ return this.$store.getters.is_BarHeight }, }, - async onLoad() { + mounted() { setTimeout(() => { - this.GetTop() + this.$nextTick(() => { + this.GetTop() + }); }, 1000) + // 当组件挂载完成后获取距离 + }, onReachBottom() { this.onLoadhome() @@ -302,28 +310,50 @@ onShow() { uni.getLocation({ type: 'wgs84', - success: (res) => { - let datastorage = { - address: '西安市', //地址 + success: async (res) => { + let successres = await this.api.geocodelocation({ lng: res.longitude, lat: res.latitude, + }) + if (successres.code == 0) { + let datastorage = { + country: successres.data.addressComponent.country, // "中国" + province: successres.data.addressComponent.province, //province: "陕西省" + address: successres.data.addressComponent.city, //district: "西安市" + district: successres.data.addressComponent.district, //district: "未央区" + lng: res.longitude, + lat: res.latitude, + } + uni.cache.set('getLocationstorage', datastorage); + this.hometop() + this.init_fn() + this.timersetInterval = '0' } - uni.cache.set('getLocationstorage', datastorage); - this.hometop() - this.init_fn() - this.timersetInterval = '0' }, - fail: (err) => { - let datastorage = { - address: '西安市', //地址 - lng: res.longitude, - lat: res.latitude, - } - uni.cache.set('getLocationstorage', datastorage); - this.hometop() - this.init_fn() - this.timersetInterval = '0' + fail: async (err) => { console.log(err, '获取错误') + let successres = await this.api.geocodelocation({ + lng: '', + lat: '', + }) + if (successres.code == 0) { + console.log(successres.data.addressComponent.streetNumber.location.split(',')) + let res = successres.data.addressComponent.streetNumber.location.split(',') + // this.form.lng = res[0] + // this.form.lat = res[1] + let datastorage = { + country: successres.data.addressComponent.country, // "中国" + province: successres.data.addressComponent.province, //province: "陕西省" + address: successres.data.addressComponent.city, //district: "西安市" + district: successres.data.addressComponent.district, //district: "未央区" + lng: res[0], + lat: res[1], + } + uni.cache.set('getLocationstorage', datastorage); + this.hometop() + this.init_fn() + this.timersetInterval = '0' + } } }); @@ -354,11 +384,8 @@ success: (data) => { this.seighT = data.windowHeight; this.$u.getRect('.fourcontent').then(res => { - this.Topdistance = res.top - this.HeighT.heightBar //滚动距离 - this.seighT = this.seighT - res.height //高度 - }) - this.$u.getRect('.navbar').then(res => { - this.seighT = this.seighT - res.height //高度 + console.log(res.top) + this.Topdistance = res.top - res.height -20 //滚动距离 }) } }) @@ -461,9 +488,10 @@ this.viewHistoryindex = index if (item.dictName == 'allCity') { let res = await this.api.locationdistrict({ - keywords: '西安市' + keywords: uni.cache.get('getLocationstorage').address }) - this.clickhometoplistmenulist = res.data[0] + this.clickhometoplistmenulist.detail = res.data + this.clickhometoplistmenulist.quilt = '1' } else { this.clickhometoplistmenulist = item } @@ -488,7 +516,7 @@ console.log(category); this.clickdetailindex = index this.showproductlist = false - this.hometoplist.menu[this.viewHistoryindex].name = item.label + this.hometoplist.menu[this.viewHistoryindex].name = item.name switch (item.dictName) { case 'category': // 品类 @@ -507,13 +535,28 @@ }, //城市二级菜单 categoryMainClick(category) { - console.log(category); - this.subCategoryList = category.category.districts; + console.log(category.category.name); + if (category.category.name == '全城') { + this.showproductlist = false + this.form.lng = uni.cache.get('getLocationstorage').lng, + this.form.lat = uni.cache.get('getLocationstorage').lat, + this.form.address = uni.cache.get('getLocationstorage').address, //地址 + this.form.page = 1 + this.form.size = 10 + this.form.status = 'loadmore' + this.homelist = [] + this.onLoadhome() + this.hometoplist.menu[this.viewHistoryindex].name = uni.cache.get('getLocationstorage').address + this.subCategoryList = [] + } else { + this.subCategoryList = category.category.districts; + } }, //确定街道菜单赋值 categorySubClick(category) { console.log(category); this.hometoplist.menu[this.viewHistoryindex].name = category.name + this.form.address = category.name //地址 this.showproductlist = false console.log(category.center.split(',')) let res = category.center.split(',') @@ -718,8 +761,7 @@ .fivecontent { padding: 0 28rpx; - overflow: auto; - + height: 100vh; .fivecontent_item:nth-child(1) { margin-top: 0; }