更新优化定位, 推荐商品
This commit is contained in:
parent
c6a95fd7e2
commit
4b1d003905
@ -5,13 +5,14 @@
|
||||
<view class="site-box flex_a_c_j_sb" :style="{ opacity: backColor }">
|
||||
<view
|
||||
:class="['place_wrapper', 'flex_a_c', isFshow ? 'sitebox' : '']"
|
||||
@click="selectLocation"
|
||||
@click="changeMap"
|
||||
>
|
||||
<view
|
||||
:class="['iconfont', 'icon-weizhi', isFshow ? 'sitebox' : '']"
|
||||
style="margin-left: 20rpx"
|
||||
>
|
||||
</view>
|
||||
<view class="town_name">{{ street||'定位中' }}</view>
|
||||
</view>
|
||||
<navigator
|
||||
url="/pages/chat/customer_list/index?type=0"
|
||||
@ -706,57 +707,61 @@ export default {
|
||||
}).catch(err => {
|
||||
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('定位失败,请检查定位权限是否开启')
|
||||
|
||||
}
|
||||
});
|
||||
},
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 设置手机通知权限
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -4,10 +4,10 @@
|
||||
<view v-if="isFshow">
|
||||
<view class="site-box flex_a_c_j_sb" :style="{'opacity':backColor}">
|
||||
|
||||
<view :class="['place_wrapper','flex_a_c',isFshow?'sitebox':'']" @click="selectLocation">
|
||||
<view :class="['place_wrapper','flex_a_c',isFshow?'sitebox':'']" @click="changeMap">
|
||||
<view :class="['iconfont','icon-weizhi',isFshow?'sitebox':'']" style="margin-left: 20rpx;">
|
||||
</view>
|
||||
<view class="town_name">{{street}}</view>
|
||||
<view class="town_name">{{ street||'定位中' }}</view>
|
||||
</view>
|
||||
<navigator url="/pages/chat/customer_list/index?type=0" hover-class="none">
|
||||
<view :class="['iconfont','icon-xiaoxi',isFshow?'sitebox':'']" style="color:#fff;"></view>
|
||||
@ -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);
|
||||
})
|
||||
}
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user