Huanyuyuehui/pages/shop/index.vue

241 lines
6.7 KiB
Vue
Raw Normal View History

2024-03-24 15:23:25 +08:00
<template>
2024-03-25 16:25:29 +08:00
<view class="content" :style="viewColor">
2024-03-24 18:34:07 +08:00
<view class="top-tab" :style="`padding-top:`+navtop">
2024-03-24 15:23:25 +08:00
<view class="tab-location">
2024-03-24 15:49:14 +08:00
深圳
2024-03-24 15:23:25 +08:00
<view class="iconfont icon-dingwei"></view>
</view>
商家联盟
2024-03-24 17:43:25 +08:00
<view class="tab-sao iconfont icon-saoma" @tap='handleBorcode'></view>
2024-03-24 15:23:25 +08:00
</view>
<view class="content-map" >
2024-03-24 15:33:16 +08:00
<map class="map" :latitude="22.547" :longitude="114.085947"></map>
2024-03-24 18:34:07 +08:00
2024-03-24 15:23:25 +08:00
</view>
<view class="content-type">
2024-03-24 18:34:07 +08:00
<!-- <cover-image src="../annex/static/vipBg.png" style="position: absolute;
top: -20px;"></cover-image> -->
2024-03-26 14:48:11 +08:00
<view class="type-item" v-for="(item,index) in tabList" :key="index" @click="goShopSearch(item)">
2024-03-24 15:23:25 +08:00
<image class="type-item-img" src="@/static/images/shop/tab1.png" mode=""></image>
2024-03-26 14:48:11 +08:00
<text class="type-item-text">{{item.category_name}}</text>
2024-03-24 15:23:25 +08:00
</view>
</view>
<view class="content-list">
<view class="list-tab">
2024-03-24 15:41:18 +08:00
<view :class="current==0?'action':''" @click="selectCurrent(0)">全部商家</view>
2024-03-26 14:48:11 +08:00
<view :class="current==1?'action':''" @click="selectCurrent(1,true)">附近商家</view>
2024-03-24 15:23:25 +08:00
</view>
2024-03-26 14:48:11 +08:00
<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>
2024-03-24 17:43:00 +08:00
</view>
2024-03-26 14:48:11 +08:00
<view class="list-item-right" @click="navtoDetail(item)">
2024-03-24 15:23:25 +08:00
<view class="item-title">
2024-03-26 14:48:11 +08:00
{{item.mer_name}}
2024-03-24 15:23:25 +08:00
</view>
<view class="item-content">
<view class="right-center-left">
<view class="center-left-score">
2024-03-26 17:17:16 +08:00
<text class="iconfont icon-shitixing"></text>
2024-03-24 15:23:25 +08:00
<!-- <text class="iconfont icon-kongxinxing"></text> -->
2024-03-26 14:48:11 +08:00
<text>{{item.service_score}}</text>
2024-03-24 15:23:25 +08:00
</view>
2024-03-26 14:48:11 +08:00
<view class="center-left-time" v-if="item.config&&item.config.mer_take_time">营业时间:{{item.config.mer_take_time.join('-')}}</view>
2024-03-24 15:23:25 +08:00
</view>
<view class="right-center-right">
去选购
</view>
</view>
<view class="item-address">
2024-03-26 14:48:11 +08:00
<view class="address" v-if="item.mer_address">{{item.mer_address}}</view>
<view class="distance" v-if="item.distance">{{item.distance}}</view>
2024-03-24 15:23:25 +08:00
</view>
</view>
</view>
</view>
2024-03-25 10:42:01 +08:00
<view class="list-container" v-else>
<view class="list-fail">
<image :src="`${domain}/static/images/noCart.png`"></image>
<view>暂无商家去看看其他的吧</view>
</view>
</view>
2024-03-24 15:23:25 +08:00
</view>
2024-03-24 17:43:00 +08:00
<!--自定义底部tab栏-->
<customTab :newData="newData" :activeRouter="activeRouter"></customTab>
2024-03-24 15:23:25 +08:00
</view>
</template>
<script>
2024-03-25 10:42:01 +08:00
import { HTTP_REQUEST_URL } from '@/config/app';
2024-03-26 14:48:11 +08:00
import { getGeocoder } from '@/api/store.js';
2024-03-24 17:43:00 +08:00
import { getNavigation } from '@/api/public.js';
import customTab from '@/components/customTab';
2024-03-25 16:25:29 +08:00
import { mapGetters } from "vuex";
2024-03-26 14:48:11 +08:00
import {shopInit,shopNearby} from '@/api/shop.js'
2024-03-26 15:06:27 +08:00
import {getOrderOfflinePay} from '@/api/admin.js'
2024-03-24 15:23:25 +08:00
export default {
components:{
2024-03-24 17:43:00 +08:00
customTab,
2024-03-24 15:23:25 +08:00
},
data(){
return{
2024-03-25 10:42:01 +08:00
domain: HTTP_REQUEST_URL,
newData: {},
activeRouter: '',
2024-03-24 15:41:18 +08:00
tabList:[],
2024-03-26 14:48:11 +08:00
shopList:[],
2024-03-24 15:41:18 +08:00
current:0,
2024-03-24 18:34:07 +08:00
navtop:0,
2024-03-26 14:48:11 +08:00
addressInfo:[],
latitude: '',
longitude: '',
2024-03-24 15:23:25 +08:00
}
},
onLoad(){
2024-03-26 14:48:11 +08:00
this.init();
this.selfLocation();
2024-03-24 15:23:25 +08:00
},
2024-03-24 17:43:00 +08:00
onShow(){
this.getNav();
},
2024-03-25 16:25:29 +08:00
computed:{
...mapGetters(['viewColor'])
},
2024-03-24 17:43:00 +08:00
created(options) {
2024-03-24 18:34:07 +08:00
let statusBarHeight= uni.getSystemInfoSync().statusBarHeight+"px";
this.navtop=statusBarHeight;
2024-03-24 17:43:00 +08:00
let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
let curRoute = routes[routes.length - 1].route //获取当前页面路由
this.activeRouter = '/' + curRoute
},
2024-03-24 15:23:25 +08:00
methods:{
2024-03-26 14:48:11 +08:00
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({
2024-03-26 17:17:16 +08:00
url:'./search/index?id='+item.merchant_category_id
2024-03-26 14:48:11 +08:00
})
},
2024-03-24 17:43:00 +08:00
getNav(){
getNavigation().then(res => {
this.newData = res.data
if (this.newData.status && this.newData.status.status) {
uni.hideTabBar()
} else {
uni.showTabBar()
}
})
},
2024-03-24 17:43:25 +08:00
handleBorcode() {
// 从相机和相册扫码
// #ifdef APP-PLUS
uni.scanCode({
scanType:['qrCode'],
2024-03-26 15:06:27 +08:00
success: async (res)=> {
let result = JSON.parse(res.result)
let val = await getOrderOfflinePay(result.sn)
if(val.status == 200){
this.$util.Tips({
title: '支付成功',
icon: 'success'
});
setTimeout(()=>{
uni.navigateTo({
url:'/pages/users/order_list/index?status=-1'
})
},1000)
}
2024-03-24 17:43:25 +08:00
}
});
// #endif
2024-03-24 17:43:00 +08:00
},
2024-03-26 14:48:11 +08:00
selectCurrent(val,b){
if(b){
this.selfLocation();
}else{
this.init();
}
2024-03-24 15:41:18 +08:00
this.current=val;
},
2024-03-26 14:48:11 +08:00
navtoDetail(item){
2024-03-24 15:41:18 +08:00
uni.navigateTo({
2024-03-26 14:48:11 +08:00
url:'/pages/shop_details/index?id='+item.mer_id
2024-03-24 15:41:18 +08:00
})
}
2024-03-24 15:23:25 +08:00
}
}
</script>
<style lang="less" scoped>
@import url("css/shop.css");
</style>