修复地址错误

修复供应链列表错误
This commit is contained in:
mkm 2023-05-15 22:46:19 +08:00 committed by shengchanzhe
parent 3e1f97f269
commit a46be7373a
3 changed files with 876 additions and 744 deletions

View File

@ -7,7 +7,7 @@
<view class="site-box flex_a_c_j_sb"> <view class="site-box flex_a_c_j_sb">
<view class="place_wrapper flex_a_c" @click="selectLocation"> <view class="place_wrapper flex_a_c" @click="selectLocation">
<view class="iconfont icon-weizhi"></view> <view class="iconfont icon-weizhi"></view>
<view class="town_name">{{street}}</view> <view class="town_name">{{recommend_address}}</view>
</view> </view>
<navigator url="/pages/chat/customer_list/index?type=0" hover-class="none"> <navigator url="/pages/chat/customer_list/index?type=0" hover-class="none">
<view class="iconfont icon-xiaoxi" style="color:#fff;"></view> <view class="iconfont icon-xiaoxi" style="color:#fff;"></view>
@ -41,9 +41,19 @@
</template> </template>
<script> <script>
import { getArea, getStreet } from '@/api/article.js'; import {
import { getIndexData, getDiy } from '@/api/api.js' getArea,
import { mapGetters } from 'vuex' getStreet
} from '@/api/article.js';
import {
getIndexData,
getDiy
} from '@/api/api.js'
import {getGeocoder } from '@/api/store.js';
import {
mapGetters
} from 'vuex'
export default { export default {
props: { props: {
isSelectPlace: { isSelectPlace: {
@ -54,9 +64,11 @@
data() { data() {
return { return {
showPicker: false, showPicker: false,
styleConfig: [],
columnData: [], columnData: [],
homeCombData:[],
keyword: '', keyword: '',
street: '', recommend_address: '',
bgColor: '', bgColor: '',
swiper: { swiper: {
url: [{ url: [{
@ -70,11 +82,14 @@
}, },
} }
}, },
computed: mapGetters(['location']), // computed: mapGetters(['location']),
watch: {}, watch: {},
created() { created() {
const loca = JSON.parse(this.location) //#ifdef APP
this.street = loca.address_component.street this.selfLocation()
//#endif
// const loca = JSON.parse(this.location)
// this.street = loca.address_component.street
this.getBanner() this.getBanner()
this.Area() this.Area()
}, },
@ -87,39 +102,100 @@
this.$emit('selectPlce', e) this.$emit('selectPlce', e)
}, },
changeHandler(e) { changeHandler(e) {
const { columnIndex, value, values, index, picker = this.$refs.uPicker } = e; const {
columnIndex,
value,
values,
index,
picker = this.$refs.uPicker
} = e;
if (columnIndex === 0) { if (columnIndex === 0) {
getStreet({ area_code: value[0]['code'] }).then(res => { getStreet({
area_code: value[0]['code']
}).then(res => {
picker.setColumnValues(1, res.data); picker.setColumnValues(1, res.data);
}); });
} }
}, },
Area() { Area() {
getArea({ city_code: 510500 }).then(res => { getArea({
city_code: 510500
}).then(res => {
this.$refs.uPicker.setColumnValues(0, res.data); this.$refs.uPicker.setColumnValues(0, res.data);
this.Street(res.data[0]['code']); this.Street(res.data[0]['code']);
}); });
}, },
Street(code) { Street(code) {
getStreet({ area_code: code }).then(res => { getStreet({
area_code: code
}).then(res => {
this.$refs.uPicker.setColumnValues(1, res.data); this.$refs.uPicker.setColumnValues(1, res.data);
}); });
}, },
selfLocation() {
let self = this
uni.getLocation({
type: 'gcj02',
success: (res) => {
let latitude, longitude;
latitude = res.latitude.toString();
longitude = res.longitude.toString();
this.latitude = res.latitude
this.longitude = res.longitude
getGeocoder({
lat: latitude,
long: longitude
}).then(res => {
console.log(res)
this.detaile_address = res.data.address;
this.location_address = res.data.address;
this.recommend_address = res.data.formatted_addresses.recommend.length > 4 ? res.data.formatted_addresses.recommend.slice(0,7) + '...' : res.data.formatted_addresses.recommend
}).catch(err => {
uni.showToast({
title: err,
icon: 'none'
})
})
},
fail: (res) => {
uni.showToast({
title: res,
icon: 'none',
duration: 1000
});
},
});
},
swiperChange(e) { swiperChange(e) {
let { current, source } = e.detail; let {
current,
source
} = e.detail;
if (source === 'autoplay' || source === 'touch') { if (source === 'autoplay' || source === 'touch') {
this.bgColor = this.swiper.url[e.detail.current]['img'] this.bgColor = this.swiper.url[e.detail.current]['img']
} }
}, },
async getBanner() { //
const { data } = await getDiy({ id: 0 }) objToArr(data) {
/* 对象转数组*/ let obj = Object.keys(data).sort();
let obj = Object.keys(data.value).sort(); let m = obj.map(key => data[key]);
let styleConfig = obj.map(key => data.value[key]); return m;
},
async getBanner(id) {
let that = this;
const {
data
} = await getDiy({
id: 0
})
that.styleConfig = that.objToArr(data.value);
/* 循环数组得到数据*/ /* 循环数组得到数据*/
styleConfig.forEach((item, index, arr) => { that.styleConfig.forEach((item, index, arr) => {
if (item.name == 'headerSerch' || item.name == 'homeComb') { if (item.name == 'headerSerch' || item.name == 'homeComb') {
item.name == 'homeComb' ? this.swiper.url = item.swiperConfig.list : ''; if (item.name == 'homeComb') {
that.swiper.url = item.swiperConfig.list
}
} }
}) })
this.bgColor = this.swiper.url[0].img this.bgColor = this.swiper.url[0].img

View File

@ -17,12 +17,13 @@
<view class="title">{{item.title}}</view> <view class="title">{{item.title}}</view>
<view class="goods_info flex_a_c"> <view class="goods_info flex_a_c">
<view class="l_info flex_a_c"> <view class="l_info flex_a_c">
<image :src="(item.author && item.author.avatar) || '/static/images/f.png'" mode="aspectFill" <image :src="(item.author && item.author.avatar) || '/static/images/f.png'"
class="g_img"></image> mode="aspectFill" class="g_img"></image>
<view class="g_name">{{item.author && item.author.nickname}}</view> <view class="g_name">{{item.author && item.author.nickname}}</view>
</view> </view>
<view class="nice_box" @click.stop="giveStart(item)"> <view class="nice_box" @click.stop="giveStart(item)">
<text class="iconfont" :class="item.relevance_id ? 'icon-shoucang1' : 'icon-dianzan'"></text> <text class="iconfont"
:class="item.relevance_id ? 'icon-shoucang1' : 'icon-dianzan'"></text>
<text class="collect">{{item.count_start}}</text> <text class="collect">{{item.count_start}}</text>
</view> </view>
</view> </view>
@ -53,12 +54,29 @@
<script> <script>
import mTabbar from '@/components/m-tabbar/m-tabbar.vue' import mTabbar from '@/components/m-tabbar/m-tabbar.vue'
import zbpSwiper from '@/components/zbpSwiper' import zbpSwiper from '@/components/zbpSwiper'
import { getSlideAPI } from '@/api/lihai.js' import {
import { graphicLstApi, getTopicList, graphicStartApi } from '@/api/community.js' getSlideAPI
import { getIndexData, getDiy } from '@/api/api.js' } from '@/api/lihai.js'
import { getGeocoder, merClassifly } from '@/api/store.js'; import {
import { getArea, getStreet } from '@/api/article.js'; graphicLstApi,
import { Toast } from '@/libs/uniApi' getTopicList,
graphicStartApi
} from '@/api/community.js'
import {
getIndexData,
getDiy
} from '@/api/api.js'
import {
getGeocoder,
merClassifly
} from '@/api/store.js';
import {
getArea,
getStreet
} from '@/api/article.js';
import {
Toast
} from '@/libs/uniApi'
export default { export default {
components: { components: {
mTabbar, mTabbar,
@ -119,7 +137,10 @@
methods: { methods: {
// //
swiperChange(e) { swiperChange(e) {
let { current, source } = e.detail; let {
current,
source
} = e.detail;
if (source === 'autoplay' || source === 'touch') { if (source === 'autoplay' || source === 'touch') {
this.bgColor = this.swiper.url[e.detail.current]['img'] this.bgColor = this.swiper.url[e.detail.current]['img']
} }
@ -129,28 +150,45 @@
this.showPicker = false this.showPicker = false
}, },
changeHandler(e) { changeHandler(e) {
const { columnIndex, value, values, index, picker = this.$refs.uPicker } = e; const {
columnIndex,
value,
values,
index,
picker = this.$refs.uPicker
} = e;
if (columnIndex === 0) { if (columnIndex === 0) {
getStreet({ area_code: value[0]['code'] }).then(res => { getStreet({
area_code: value[0]['code']
}).then(res => {
this.$refs.uPicker.setColumnValues(1, res.data); this.$refs.uPicker.setColumnValues(1, res.data);
}); });
} }
}, },
Area() { Area() {
getArea({ city_code: 510500 }).then(res => { getArea({
city_code: 510500
}).then(res => {
this.$refs.uPicker.setColumnValues(0, res.data); this.$refs.uPicker.setColumnValues(0, res.data);
this.Street(res.data[0]['code']); this.Street(res.data[0]['code']);
}); });
}, },
Street(code) { Street(code) {
getStreet({ area_code: code }).then(res => { getStreet({
area_code: code
}).then(res => {
this.$refs.uPicker.setColumnValues(1, res.data); this.$refs.uPicker.setColumnValues(1, res.data);
}); });
}, },
gogogo(item) { gogogo(item) {
if (this.tabsData.tabsActive == 1) { if (this.tabsData.tabsActive == 1) {
uni.navigateTo({ uni.navigateTo({
//#ifdef APP
url: '/pages/short_video/appSwiper/index?id=' + item.community_id
//#endif
//#ifndef APP
url: '/pages/short_video/nvueSwiper/index?id=' + item.community_id url: '/pages/short_video/nvueSwiper/index?id=' + item.community_id
//#endif
}) })
} else { } else {
uni.navigateTo({ uni.navigateTo({
@ -160,7 +198,9 @@
}, },
giveStart(item) { giveStart(item) {
let status = item.relevance_id ? 0 : 1 let status = item.relevance_id ? 0 : 1
graphicStartApi(item.community_id, { status: status }).then(res => { graphicStartApi(item.community_id, {
status: status
}).then(res => {
Toast(res.message) Toast(res.message)
this.getGoods() this.getGoods()
}) })
@ -178,11 +218,17 @@
}, },
/*获取分类列表*/ /*获取分类列表*/
async getCateList() { async getCateList() {
const { data } = await getTopicList() const {
data
} = await getTopicList()
this.tabsData.list = [{ this.tabsData.list = [{
cate_name: "推荐", cate_name: "推荐",
category_id: 0 category_id: 0
}, { cate_name: "视频", category_id: -1, children: [] }, ...data] }, {
cate_name: "视频",
category_id: -1,
children: []
}, ...data]
}, },
tabsChange(item) { tabsChange(item) {
this.where.category_id = item.category_id this.where.category_id = item.category_id
@ -196,7 +242,11 @@
} }
}, },
async getBanner() { async getBanner() {
const { data } = await getDiy({ id: 0 }) const {
data
} = await getDiy({
id: 0
})
if (data.value['1683638943100000']) { if (data.value['1683638943100000']) {
this.swiper.url = data.value['1683638943100000'].swiperConfig.list this.swiper.url = data.value['1683638943100000'].swiperConfig.list
} else { } else {
@ -211,11 +261,17 @@
let latitude, longitude; let latitude, longitude;
latitude = res.latitude.toString(); latitude = res.latitude.toString();
longitude = res.longitude.toString(); longitude = res.longitude.toString();
getGeocoder({ lat: latitude, long: longitude }).then(res => { getGeocoder({
lat: latitude,
long: longitude
}).then(res => {
this.$store.commit('setLocation', res.data) this.$store.commit('setLocation', res.data)
this.street = res.data.address_component.street this.street = res.data.address_component.street
}).catch(err => { }).catch(err => {
uni.showToast({ title: err, icon: 'none' }) uni.showToast({
title: err,
icon: 'none'
})
}) })
}, },
fail: (err) => { fail: (err) => {

View File

@ -1,7 +1,7 @@
<template> <template>
<view class="Circle_friends"> <view class="Circle_friends">
<view class="circle_friends_wrapper"> <view class="circle_friends_wrapper">
<zbpSwiper :isSelectPlace="true" @selectPlce="selectPlce"></zbpSwiper> <zbpSwiper></zbpSwiper>
<view class="shop_wrapper"> <view class="shop_wrapper">
<navigator class="l_yun" hover-class="none" <navigator class="l_yun" hover-class="none"
:url="`/pages/nongKe/supply_chain/supplier?type_id=10&street_id=${street_id}`"> :url="`/pages/nongKe/supply_chain/supplier?type_id=10&street_id=${street_id}`">
@ -162,7 +162,7 @@
} }
</script> </script>
<style lang="scss"> <style lang="scss" scoped>
page { page {
background-color: #F5F5F5; background-color: #F5F5F5;
} }
@ -188,7 +188,7 @@
.l_yun { .l_yun {
width: 456.14rpx; width: 456.14rpx;
border-radius: 8px; border-radius: 16rpx;
background-image: url("@/static/images/zonghe.png"); background-image: url("@/static/images/zonghe.png");
background-repeat: no-repeat; background-repeat: no-repeat;
background-size: cover; background-size: cover;
@ -223,7 +223,7 @@
.iconlihai { .iconlihai {
font-size: 24.56rpx; font-size: 24.56rpx;
margin-left: 8px; margin-left: 16rpx;
} }
} }
@ -250,7 +250,7 @@
background: url("@/static/images/lihaiyun.png") no-repeat; background: url("@/static/images/lihaiyun.png") no-repeat;
background-size: cover; background-size: cover;
box-sizing: border-box; box-sizing: border-box;
border-radius: 8px; border-radius: 16rpx;
color: #fff; color: #fff;
font-weight: bold; font-weight: bold;
@ -271,7 +271,7 @@
width: 694.74rpx; width: 694.74rpx;
margin: 0 auto; margin: 0 auto;
background-color: #fff; background-color: #fff;
border-radius: 8px; border-radius: 16rpx;
padding: 0 24.56rpx; padding: 0 24.56rpx;
box-sizing: border-box; box-sizing: border-box;