228 lines
6.3 KiB
Vue
228 lines
6.3 KiB
Vue
|
|
<template>
|
|
<view class="content" :style="viewColor">
|
|
<view class="top-tab" :style="`padding-top:`+navtop">
|
|
<view class="tab-location">
|
|
深圳
|
|
<view class="iconfont icon-dingwei"></view>
|
|
</view>
|
|
商家联盟
|
|
<view class="tab-sao iconfont icon-saoma" @tap='handleBorcode'></view>
|
|
</view>
|
|
<view class="content-map" >
|
|
<map class="map" :latitude="22.547" :longitude="114.085947"></map>
|
|
|
|
</view>
|
|
<view class="content-type">
|
|
<!-- <cover-image src="../annex/static/vipBg.png" style="position: absolute;
|
|
top: -20px;"></cover-image> -->
|
|
<view class="type-item" v-for="(item,index) in tabList" :key="index" @click="goShopSearch(item)">
|
|
<image class="type-item-img" src="@/static/images/shop/tab1.png" mode=""></image>
|
|
<text class="type-item-text">{{item.category_name}}</text>
|
|
</view>
|
|
</view>
|
|
<view class="content-list">
|
|
<view class="list-tab">
|
|
<view :class="current==0?'action':''" @click="selectCurrent(0)">全部商家</view>
|
|
<view :class="current==1?'action':''" @click="selectCurrent(1,true)">附近商家</view>
|
|
</view>
|
|
<view class="list-container" v-if="shopList.length">
|
|
<view class="list-item" v-for="(item,index) in shopList" :key='index'>
|
|
<view class="list-item-left">
|
|
<image :src="item.mer_avatar" mode=""></image>
|
|
</view>
|
|
<view class="list-item-right" @click="navtoDetail(item)">
|
|
<view class="item-title">
|
|
{{item.mer_name}}
|
|
</view>
|
|
<view class="item-content">
|
|
<view class="right-center-left">
|
|
<view class="center-left-score">
|
|
<text class="iconfont icon-kongxinxing"></text>
|
|
<!-- <text class="iconfont icon-kongxinxing">★</text> -->
|
|
<text>{{item.service_score}}分</text>
|
|
</view>
|
|
<view class="center-left-time" v-if="item.config&&item.config.mer_take_time">营业时间:{{item.config.mer_take_time.join('-')}}</view>
|
|
</view>
|
|
<view class="right-center-right">
|
|
去选购
|
|
</view>
|
|
</view>
|
|
<view class="item-address">
|
|
<view class="address" v-if="item.mer_address">{{item.mer_address}}</view>
|
|
<view class="distance" v-if="item.distance">{{item.distance}}</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="list-container" v-else>
|
|
<view class="list-fail">
|
|
<image :src="`${domain}/static/images/noCart.png`"></image>
|
|
<view>暂无商家,去看看其他的吧</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<!--自定义底部tab栏-->
|
|
<customTab :newData="newData" :activeRouter="activeRouter"></customTab>
|
|
</view>
|
|
</template>
|
|
<script>
|
|
import { HTTP_REQUEST_URL } from '@/config/app';
|
|
import { getGeocoder } from '@/api/store.js';
|
|
import { getNavigation } from '@/api/public.js';
|
|
import customTab from '@/components/customTab';
|
|
import { mapGetters } from "vuex";
|
|
import {shopInit,shopNearby} from '@/api/shop.js'
|
|
export default {
|
|
components:{
|
|
customTab,
|
|
},
|
|
data(){
|
|
return{
|
|
domain: HTTP_REQUEST_URL,
|
|
newData: {},
|
|
activeRouter: '',
|
|
tabList:[],
|
|
shopList:[],
|
|
current:0,
|
|
navtop:0,
|
|
addressInfo:[],
|
|
latitude: '',
|
|
longitude: '',
|
|
}
|
|
},
|
|
onLoad(){
|
|
this.init();
|
|
this.selfLocation();
|
|
},
|
|
onShow(){
|
|
this.getNav();
|
|
},
|
|
computed:{
|
|
...mapGetters(['viewColor'])
|
|
},
|
|
created(options) {
|
|
let statusBarHeight= uni.getSystemInfoSync().statusBarHeight+"px";
|
|
this.navtop=statusBarHeight;
|
|
let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
|
|
let curRoute = routes[routes.length - 1].route //获取当前页面路由
|
|
this.activeRouter = '/' + curRoute
|
|
},
|
|
methods:{
|
|
init(){
|
|
shopInit().then((res)=>{
|
|
if(res.data.lst){
|
|
this.tabList=res.data.lst;
|
|
}
|
|
if(res.data.list){
|
|
this.shopList=res.data.list;
|
|
}
|
|
console.log('res: ',res);
|
|
})
|
|
},
|
|
selfLocation() {
|
|
let self = this
|
|
// uni.showLoading({
|
|
// title: '定位中',
|
|
// mask: true,
|
|
// });
|
|
uni.getLocation({
|
|
type: 'gcj02',
|
|
success: (res) => {
|
|
let latitude, longitude;
|
|
latitude = res.latitude.toString();
|
|
longitude = res.longitude.toString();
|
|
self.latitude = res.latitude
|
|
self.longitude = res.longitude
|
|
getGeocoder({
|
|
lat: latitude,
|
|
long: longitude
|
|
}).then(res => {
|
|
uni.hideLoading();
|
|
const data = res.data;
|
|
console.log('data: ',data);
|
|
let data1={
|
|
mini:1,
|
|
type_id:4,
|
|
location:data.location.lat+','+data.location.lng
|
|
}
|
|
shopNearby(data1).then((r)=>{
|
|
if(r.data.list){
|
|
this.shopList=r.data.list;
|
|
}
|
|
})
|
|
// getCityList(data.address_component.province+'/'+data.address_component.city+'/'+data.address_component.district+'/'+(!data.address_reference.town ? '' : data.address_reference.town.title)).then(res=>{
|
|
// self.addressInfo = res.data;
|
|
// // self.$set(self.userAddress, 'detail', data.formatted_addresses.recommend);
|
|
// uni.hideLoading();
|
|
// }).catch(e=>{
|
|
// uni.showToast({
|
|
// title: '定位失败,请手动输入地址',
|
|
// icon: 'none',
|
|
// duration: 1000
|
|
// });
|
|
// })
|
|
}).catch(e=>{
|
|
uni.hideLoading();
|
|
uni.showToast({
|
|
title: '定位失败,请手动输入地址',
|
|
icon: 'none',
|
|
duration: 1000
|
|
});
|
|
})
|
|
},
|
|
fail: (res) => {
|
|
uni.hideLoading();
|
|
uni.showToast({
|
|
title: res.errMsg,
|
|
icon: 'none',
|
|
duration: 1000
|
|
});
|
|
}
|
|
});
|
|
},
|
|
goShopSearch(item){
|
|
uni.navigateTo({
|
|
url:'./search/index'
|
|
})
|
|
},
|
|
getNav(){
|
|
getNavigation().then(res => {
|
|
this.newData = res.data
|
|
if (this.newData.status && this.newData.status.status) {
|
|
uni.hideTabBar()
|
|
} else {
|
|
uni.showTabBar()
|
|
}
|
|
})
|
|
},
|
|
handleBorcode() {
|
|
// 从相机和相册扫码
|
|
// #ifdef APP-PLUS
|
|
uni.scanCode({
|
|
scanType:['qrCode'],
|
|
success: function (res) {
|
|
console.log('二维码信息:' + res);
|
|
}
|
|
});
|
|
// #endif
|
|
},
|
|
selectCurrent(val,b){
|
|
if(b){
|
|
this.selfLocation();
|
|
}else{
|
|
this.init();
|
|
}
|
|
this.current=val;
|
|
},
|
|
navtoDetail(item){
|
|
uni.navigateTo({
|
|
url:'/pages/shop_details/index?id='+item.mer_id
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
<style lang="less" scoped>
|
|
@import url("css/shop.css");
|
|
</style> |