From 4b1d0039053cfc675718b6de8d217f13c230ef4d Mon Sep 17 00:00:00 2001 From: weipengfei <2187978347@qq.com> Date: Tue, 5 Dec 2023 10:29:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BC=98=E5=8C=96=E5=AE=9A?= =?UTF-8?q?=E4=BD=8D,=20=E6=8E=A8=E8=8D=90=E5=95=86=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/index.vue | 85 +++++++++++++------------ pages/nongKe/supply_chain/supplierB.vue | 6 +- pages/supply_chains/supply_chains.vue | 54 ++++++++++------ 3 files changed, 81 insertions(+), 64 deletions(-) diff --git a/pages/index/index.vue b/pages/index/index.vue index 0a6fd5b..003677f 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -5,13 +5,14 @@ + {{ street||'定位中' }} { console.log(err); this.isshow = false - uni.showToast({ - title: err, - icon: 'none' - }) + // uni.showToast({ + // title: err, + // icon: 'none' + // }) + this.uniLocation(); }) } - else uni.getLocation({ - type: 'wgs84', - timeout: '1000', - success: (res) => { + else this.uniLocation(); + }, + uniLocation(){ + uni.getLocation({ + type: 'wgs84', + timeout: '1000', + success: (res) => { console.log('定位成功', res); - this.isshow = false - let latitude, longitude; - latitude = res.latitude.toString(); - longitude = res.longitude.toString(); + this.isshow = false + let latitude, longitude; + latitude = res.latitude.toString(); + longitude = res.longitude.toString(); this.$store.commit('setLocation', { lat: res.latitude.toFixed(6), long: res.longitude.toFixed(6), }); - getGeocoder({ - lat: latitude, - long: longitude - }).then(res => { - - let town = res.data.address_reference.town.title - let street_id = res.data.address_reference.town.id - this.street = res.data.address_reference.town.title - this.$nextTick(() => { - this.$bus.$emit('value-updated', this.street + ',' + - street_id); - - }) - }).catch(err => { - this.isshow = false - uni.showToast({ - title: err, - icon: 'none' - }) + getGeocoder({ + lat: latitude, + long: longitude + }).then(res => { + + let town = res.data.address_reference.town.title + let street_id = res.data.address_reference.town.id + this.street = res.data.address_reference.town.title + this.$nextTick(() => { + this.$bus.$emit('value-updated', this.street + ',' + + street_id); + + }) + }).catch(err => { + this.isshow = false + uni.showToast({ + title: err, + icon: 'none' + }) this.street = '定位失败' - }) - }, - fail: (err) => { + }) + }, + fail: (err) => { console.log(err); - uni.setStorageSync("RejectTarget", true) - this.isshow = false + uni.setStorageSync("RejectTarget", true) + this.isshow = false this.street = '定位失败' Toast('定位失败,请检查定位权限是否开启') - } - }); - }, + } + }); + }, /** * 设置手机通知权限 diff --git a/pages/nongKe/supply_chain/supplierB.vue b/pages/nongKe/supply_chain/supplierB.vue index b88128d..9d5f8bc 100644 --- a/pages/nongKe/supply_chain/supplierB.vue +++ b/pages/nongKe/supply_chain/supplierB.vue @@ -308,7 +308,7 @@ page: 1, limit: 10, order: 'location', - merchant_category_id: '', //商品类型id + merchant_category_id: '', //商户/商品类型id category_id: '', //商户类型id type_id: '', street_id: '', @@ -738,7 +738,7 @@ this.status = "loading" this.loading = true let rqData = { - keyword: this.storeParam.keyword, + // keyword: this.storeParam.keyword, page: this.storeParam.page, limit: 10, order: this.storeParam.order, @@ -746,7 +746,7 @@ type_id: this.storeParam.type_id, credit_buy: this.credit_buy, } - rqData.street_id = this.storeParam.street_id + // rqData.street_id = this.storeParam.street_id if (this.latitude) { rqData.location = this.latitude + ',' + this.longitude } diff --git a/pages/supply_chains/supply_chains.vue b/pages/supply_chains/supply_chains.vue index b9cc7cc..b53051e 100644 --- a/pages/supply_chains/supply_chains.vue +++ b/pages/supply_chains/supply_chains.vue @@ -4,10 +4,10 @@ - + - {{street}} + {{ street||'定位中' }} @@ -207,6 +207,7 @@ import { Toast } from '@/libs/uniApi' +import { data } from '../../uni_modules/uview-ui/libs/mixin/mixin'; export default { components: { mTabbar, @@ -241,12 +242,12 @@ where: { category_id: 0, page: 1, - limit: 6 + limit: 10 }, where2: { category_id: 0, page: 1, - limit: 6 + limit: 10 }, currentItemId: 69, // 默认获取 社区的数据 0 表示推荐 || 69 社区 @@ -272,9 +273,13 @@ } }, onPullDownRefresh() { + this.loadend = false; + this.loading = false; this.list(true, this.street_id); this.Area() - uni.stopPullDownRefresh() + this.$u.sleep(1000).then(()=>{ + uni.stopPullDownRefresh() + }) }, onShow() {}, onLoad() { @@ -362,18 +367,18 @@ }, //获取商品列表 - list(isPage, id) { + list(isPage=false, id) { // if(!id) return that.list2(true, ''); // 定位没有获取到时,直接推荐 let that = this; - if (that.loadend) return; - if (that.loading) return; + if (that.loadend&&!isPage) return; + if (that.loading&&!isPage) return; if (isPage === true) { that.$set(that, 'productList', []); that.$set(that, 'where', { category_id: 0, page: 1, - limit: 6 + limit: 10 }) } that.$set(that, 'productList2', []); @@ -389,7 +394,7 @@ }).then(res => { // console.log(222) let list = res.data.list; - if (list.length == 0 && that.productList.length == 0 && that.where.page == 1) { + if (res.data.count == 0 && isPage) { that.list2(true, ''); } let productList = that.$util.SplitArray(list, that.productList); @@ -407,29 +412,30 @@ }); }, - list2(isPage, id) { + list2(isPage=false, id) { let that = this; - if (that.loadend2) return; - if (that.loading2) return; + + if (that.loadend2&&!isPage) return; + if (that.loading2&&!isPage) return; if (isPage === true) { that.$set(that, 'productList2', []); that.$set(that, 'where2', { category_id: 0, page: 1, - limit: 6 + limit: 10 }) } that.$set(that, 'productList', []); that.loading2 = true; that.loadTitle2 = ''; - spuRecommend({ + let query = { page: that.where2.page, limit: that.where2.limit, - location: this.latitude + ',' + this.longitude - }).then(res => { - // console.log(222) + }; + if(this.latitude&&this.longitude) query.location = this.latitude + ',' + this.longitude + spuRecommend(query).then(res => { let list = res.data.list; let productList = that.$util.SplitArray(list, that.productList2); let loadend = list.length < that.where2.limit; @@ -604,7 +610,7 @@ if (uni.getStorageSync('RejectTarget')) return; if (uni.getStorageSync('loction') == true) { this.isshow = false - this.list2(true, '') + this.list(true, '') } else { this.isshow = true uni.setStorageSync('loction', true); @@ -711,8 +717,14 @@ this.$set(this.where, 'page', 1) this.$set(this.where2, 'page', 1) this.$set(this, 'productList', []); - this.list(true, this.street_id) - this.$bus.$emit('value-updated', e.value[1].name + ',' + e.value[1].code); + uni.pageScrollTo({ + scrollTop: 0, // 滚动到页面的目标位置(单位px) + duration: 200 // 滚动动画的时长,默认300ms,单位 ms + }); + this.$nextTick(()=>{ + this.list(true, this.street_id); + }); + this.$bus.$emit('value-updated', e.street.name + ',' + e.street.code); }) } })