获取地址,获取不同地区的里海云仓

This commit is contained in:
cc_zbp 2023-05-19 11:12:35 +08:00
parent 17dcf15a47
commit 1539e07755
2 changed files with 407 additions and 465 deletions

View File

@ -7,7 +7,7 @@
<view class="site-box flex_a_c_j_sb">
<view class="place_wrapper flex_a_c" @click="selectLocation">
<view class="iconfont icon-weizhi"></view>
<view class="town_name">{{location_Arr.location_name}}</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" style="color:#fff;"></view>
@ -51,13 +51,14 @@
type: Boolean,
default: false
},
location_Arr:{
type:Object,
default:()=>({})
location_Arr: {
type: Object,
default: () => ({})
}
},
data() {
return {
street: '',
showPicker: false,
styleConfig: [],
columnData: [],
@ -76,20 +77,19 @@
},
}
},
// computed: mapGetters(['location']),
computed: mapGetters(['location']),
watch: {},
created() {
this.getBanner()
this.Area()
// this.selfLocation()
// const loca = JSON.parse(this.location)
// this.street = loca.address_component.street
this.street = JSON.parse(this.location).address_component.street
},
methods: {
selectLocation() {
this.isSelectPlace ? this.showPicker = true : ''
},
confirm(e) {
this.street = e.value[1].name
this.showPicker = false
this.$emit('selectPlce', e)
},
@ -110,17 +110,13 @@
}
},
Area() {
getArea({
city_code: 510500
}).then(res => {
getArea({ city_code: 510500 }).then(res => {
this.$refs.uPicker.setColumnValues(0, res.data);
this.Street(res.data[0]['code']);
});
},
Street(code) {
getStreet({
area_code: code
}).then(res => {
getStreet({ area_code: code }).then(res => {
this.$refs.uPicker.setColumnValues(1, res.data);
});
},
@ -139,12 +135,7 @@
},
async getBanner(id) {
let that = this;
const {
data
} = await getDiy({
id: 0
})
const { data } = await getDiy({ id: 0 })
that.styleConfig = that.objToArr(data.value);
/* 循环数组得到数据*/
that.styleConfig.forEach((item, index, arr) => {

View File

@ -3,16 +3,16 @@
<view class="circle_friends_wrapper">
<zbpSwiper :isSelectPlace="true" @selectPlce="selectPlce" :location_Arr="locationArr"></zbpSwiper>
<view class="shop_wrapper">
<!-- locationArr.address_reference.town.id -->
<navigator class="l_yun" hover-class="none"
:url="`/pages/nongKe/supply_chain/supplier?type_id=10&street_id=${locationArr.address_reference.town.id}`"
:url="`/pages/nongKe/supply_chain/supplier?type_id=10&street_id=${street_id}`"
:style=" {'background-image': `url(${bgData[0].pic})`}">
<view class=" text-name">
<text>{{locationArr.location_name}}</text>
<text>{{town}}</text>
<view class="name_town">-供销综合云市场-</view>
</view>
</navigator>
<view class="r_lihai" hover-class="none" @click="go_shop()"
:style=" {'background-image': `url(${bgData[1].pic})`}">
<view class="r_lihai" @click="go_shop" :style=" {'background-image': `url(${bgData[1].pic})`}">
<view class="title">里海云仓</view>
</view>
</view>
@ -25,8 +25,7 @@
</view>
<view class="article_box">
<block v-for="(item, index) in recoList.slice(0,2)" :key="index">
<navigator :url='"/pages/news_details/index?id="+item.article_id' hover-class='none'
class='article-item'>
<navigator :url='"/pages/news_details/index?id="+item.article_id' hover-class='none' class='article-item'>
<view class='text'>
<view class='name'>{{item.title}}</view>
<view class="time">{{item.create_time}}</view>
@ -50,13 +49,12 @@
<view class="title">{{item.title}}</view>
<view class="goods_info flex_a_c">
<view class="l_info flex_a_c">
<image :src="(item.author && item.author.avatar) || '/static/images/f.png'"
mode="aspectFill" class="g_img"></image>
<image :src="(item.author && item.author.avatar) || '/static/images/f.png'" mode="aspectFill"
class="g_img"></image>
<view class="g_name">{{item.author}}</view>
</view>
<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>
</view>
</view>
@ -83,28 +81,13 @@
<script>
import zbpSwiper from '@/components/zbpSwiper'
import {
mapGetters
} from 'vuex'
import { mapGetters } from 'vuex'
import mTabbar from '@/components/m-tabbar/m-tabbar.vue'
import {
graphicStartApi
} from '@/api/community.js'
import {
getArticleList,
getArticleCategoryList,
get_cloud_shop
} from '@/api/api.js'
import {
getHotBanner
} from '@/api/store.js'
import {
Toast
} from '@/libs/uniApi'
import {
getGeocoder
} from '@/api/store.js';
import { graphicStartApi } from '@/api/community.js'
import { getArticleList, getArticleCategoryList, get_cloud_shop } from '@/api/api.js'
import { getHotBanner } from '@/api/store.js'
import { Toast } from '@/libs/uniApi'
import { getGeocoder } from '@/api/store.js';
export default {
components: {
mTabbar,
@ -121,73 +104,47 @@
articleList: [],
recoList: [],
street_id: '',
bgData: [{
pic: ''
}, {
pic: ''
}],
bgData: [{ pic: '' }, { pic: '' }],
store_id: '',
locationArr: ({}),
setrecommend_address: "",
mer_id: 0
}
},
onLoad() {
getHotBanner('good').then(res => {
this.bgData = res.data
})
uni.$on('resetLocation', function() {
console.log('resetLocation');
})
this.getArticle()
this.selfLocation()
getArticleList(19).then(res => {
this.recoList = res.data.list
})
console.log("位置", JSON.parse(this.location));
const LOCA = JSON.parse(this.location)
this.street_id = LOCA.address_reference.town.id
this.getCloudShopMerId(this.street_id)
this.town = LOCA.address_component.street ?? ''
},
onShow() {},
methods: {
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 => {
this.locationArr = res.data
this.locationArr.location_name = res.data.address_component.street
get_cloud_shop(res.data.address_reference.town.id).then(re => {
if(re.data.mer_id){
this.mer_id = re.data.mer_id
computed: mapGetters(['location']),
watch: {
location(newVal, oldVal) {
console.log('newVal', newVal);
return newVal
}
})
}).catch(err => Toast(err))
},
fail: (err) => {
Toast(err)
},
});
},
methods: {
selectPlce(e) {
console.log("e", e);
this.street_id = e.value[1].code
this.store_id = e.value[1].id
this.town = e.value[1].name
get_cloud_shop(e.value[1].code).then(re => {
this.mer_id = re.data.mer_id
this.getCloudShopMerId(e.value[1].code)
},
getCloudShopMerId(id) {
get_cloud_shop(id).then(res => {
this.mer_id = res.data.mer_id ?? 0
})
},
navigat() {
uni.navigateTo({
@ -199,22 +156,18 @@
url: '/pages/news_details/index?id=' + item.article_id
})
},
go_shop(id) {
go_shop() {
if (this.mer_id == 0) {
Toast('当前区域没有云仓库')
return false
return Toast('当前区域没有云仓库')
}
console.log(this.mer_id)
uni.navigateTo({
url: '/pages/store/home/index?id=' + this.mer_id + '&LihaiYun=Lihai'
})
},
async getArticle() {
let list = []
const {
data
} = await getArticleCategoryList()
const { data } = await getArticleCategoryList()
data.map((item, index) => {
if (item.title !== '推荐') {
list.push(item)
@ -224,9 +177,7 @@
this.getArticleList(list[0].article_category_id)
},
async getArticleList(id) {
const {
data
} = await getArticleList(id)
const { data } = await getArticleList(id)
this.articleList = data.list
},
//