hwq 2 years ago
parent
commit
2f7b1b5ad2
4 changed files with 240 additions and 26 deletions
  1. 17 0
      api/index.js
  2. 76 8
      pages/index/index.vue
  3. 80 9
      pages/store/store.vue
  4. 67 9
      pages/store/storeInfo.vue

+ 17 - 0
api/index.js

@@ -34,3 +34,20 @@ export function loadIndexs(data) {
 	});
 }
 
+// 店铺列表
+export function store_list(data) {
+	return request({
+		url: '/api/store_list',
+		method: 'get',
+		data
+	});
+}
+
+// 店铺列表
+export function store_details(data,id) {
+	return request({
+		url: '/api/store_details/' + id,
+		method: 'get',
+		data
+	});
+}

+ 76 - 8
pages/index/index.vue

@@ -79,7 +79,7 @@
 					<image class="tbg" src="../../static/img/tbg-left.png" mode=""></image>
 					<view class="shinglemt-center">
 						<image class="address" src="../../static/img/address.png" mode=""></image>
-						<view class="shingle-font">{{list.name}}</view>
+						<view class="shingle-font">{{ list.name || 'null' }}</view>
 					</view>
 					<image class="tbg" src="../../static/img/tbg-right.png" mode=""></image>
 				</view>
@@ -90,7 +90,7 @@
 					</view>
 					<view class="shu"></view>
 					<view class="smmain-item">
-						<view class="smitem-top">{{list.nickname}}</view>
+						<view class="smitem-top">{{ list.nickname }}</view>
 						<view class="smitem-bottom">馆长</view>
 					</view>
 					<view class="shu"></view>
@@ -120,12 +120,12 @@
 				</view>
 			</view>
 			<view class="serve-main flex">
-				<view class="serve-item" @click="nav('/pages/store/store')" v-for="(item, index) in 3" :key="index">
-					<image class="serve-price" src="" mode=""></image>
-					<view class="clamp serve-title">护肤品套装</view>
+				<view class="serve-item" @click="nav('/pages/store/storeInfo?id?=' + item.id)" v-for="(item, index) in stop" :key="index">
+					<image class="serve-price" :src="item.image" mode=""></image>
+					<view class="clamp serve-title">{{ item.name }}</view>
 					<view class="serve-address flex">
 						<image class="saddress-inco" src="../../static/img/address.png" mode=""></image>
-						<view class="saddress-font">距离0.3KM</view>
+						<view class="saddress-font">距离{{item.jl}}</view>
 					</view>
 				</view>
 			</view>
@@ -138,8 +138,9 @@
 import { tabbar1 } from '@/utils/tabbar.js';
 import seckill from '../../components/seckill/seckill.vue';
 import { article } from '@/api/user.js'
-import { loadIndexs } from '@/api/index.js';
+import { loadIndexs,store_list } from '@/api/index.js';
 import uniCountdowns from '@/components/uni-countdown/uni-countdowns.vue';
+import { openMap } from '@/utils/rocessor.js';
 import { auction_gu } from '@/api/hall.js';
 export default {
 	components: {
@@ -153,15 +154,19 @@ export default {
 			titleNViewBackground: '',
 			swiperCurrent: 0,
 			swiperLength: 0,
+			longitude: '', //经度
+			latitude: '', //纬度
 			dataList: '',
 			carouselList: [], //轮播图列表
 			text: [],
 			article:[],
 			list:{},
+			stop:[],
 		};
 	},
 	onLoad() {
 		this.loadData();
+		this.getaddress();
 	},
 	methods: {
 		loadData() {
@@ -184,6 +189,69 @@ export default {
 				})
 				.catch(e => {});
 		},
+		//根据经纬度计算距离
+		getFlatternDistance(lat1, lng1, lat2, lng2){
+			let f = getRad((lat1 + lat2)/2);
+			let g = getRad((lat1 - lat2)/2);
+			let l = getRad((lat1 - lng2)/2);
+			let sg = Math.sin(g);
+			let sl = Math.sin(1);
+			let	sf = Math.sin(f);
+			let s,C,W,r ,d,h1,h2;
+			let a =	EARTH_RADIUS ;
+			let fl = 1/298.257;
+			sg = sg*sg;
+			s1 = s1*sl;
+			sf = sf*sf;
+			g*(1-s1) + (1-sf)*s1;
+			C = (1-sg)*(1-s1) + sf*sl;
+			N = Math.atan(Math.sqrt(s/c));
+			r = Math.sqrt(s*c)/w;
+			d = 2*w*a;
+			h1 = (3*r -1)/2/c;
+			h2 = (3*r +1)/2/s;
+			return d*(1 + fl*(h1*sf*(1-sg) - h2*(1-sf)*sg));
+		},
+		getaddress() {
+			let obj = this;
+			store_list({
+				page:1,
+				limit:3,
+				// latitude:res.latitude,
+				// longitude: res.longitude,
+			}).then(e =>{
+				obj.stop = e.data.list
+				console.log(e);
+			})
+			// uni.getLocation({
+			// 	type: 'gcj02',
+			// 	success: res => {
+			// 		console.log('dizhi+++++++++++');
+			// 		this.longitude = res.longitude //经度
+			// 		this.latitude = res.latitude //纬度
+			// 		store_list({
+			// 			page:1,
+			// 			limit:3,
+			// 			latitude:res.latitude,
+			// 			longitude: res.longitude,
+			// 		}).then(e =>{
+				// if(e.data.length != 0){
+				// 	e.data.list.forEach(e =>{
+				// 		e.jl = this.getFlatternDistance(this.latitude,this.longitude,e.latitude,e.longitude)
+				// 	})
+				// }
+			// 			obj.stop = e.data.list
+			// 			console.log(e);
+			// 		})
+			// 	},
+			// 	fail: err => {
+			// 		console.log(err);
+			// 		openMap().then(e => {
+			// 			this.getaddress();
+			// 		});
+			// 	}
+			// });
+		},
 		goDetails(e) {
 			uni.navigateTo({
 				url: '/pages/index/messageInfo?id=' + this.article[e].id
@@ -415,7 +483,7 @@ page,
 			.shinglemt-center {
 				display: flex;
 				align-items: center;
-				background: rgba(220,38,43,0.66);
+				background: rgba(220, 38, 43, 0.66);
 			}
 			.address {
 				width: 28rpx;

+ 80 - 9
pages/store/store.vue

@@ -1,6 +1,6 @@
 <template>
 	<view class="center">
-		<view class="search-top">
+		<!-- <view class="search-top">
 			<view class="search flex">
 				<view class="shop-name clamp">椒江区</view>
 				<image class="shop-jt" src="../../static/icon/dsjh.png" mode=""></image>
@@ -32,23 +32,23 @@
 					</view>
 				</view>
 			</view>
-		</view>
-		<view class="jg" style="height: 120rpx;"></view>
+		</view> -->
+		<!-- <view class="jg" style="height: 120rpx;"></view> -->
 		<view class="shop">
-			<view class="shop-main flex" v-for="(item, index) in 100" :key="index" @click="navTo('/pages/store/storeInfo')">
-				<image class="main-left" src="../../static/index/index13.png" mode=""></image>
+			<view class="shop-main flex" v-for="(item, index) in stop" :key="index" @click="navTo('/pages/store/storeInfo?id='+item.id)">
+				<image class="main-left" :src="item.image" mode=""></image>
 				<view class="main-right flex">
 					<view class="shopm-info">
 						<view class="shopm-title">
-							<view class="shopmt-font clamp">李家烤肉11111111111111111111111111111111111111111111</view>
+							<view class="shopmt-font clamp">{{ item.name }}</view>
 						</view>
 						<!-- <view class="address">椒江区市府大道200号</view> -->
-						<view class="shopmt-tip">椒江区市府大道200号</view>
+						<view class="shopmt-tip">{{ item.detailed_address}}</view>
 					</view>
 					<view class="right">
 						<view class="mright-top">
 							<image class="mrt-image" src="../../static/index/index10.png" mode=""></image>
-							<view class="mrt-font">距离0.3KM</view>
+							<view class="mrt-font">距离{{item.jl}}KM</view>
 						</view>
 						<view class="mright-bottom">
 							<image class="mrb-item" src="../../static/index/index14.png" mode=""></image>
@@ -62,11 +62,82 @@
 </template>
 
 <script>
+	import { store_list } from '@/api/index.js';
 export default {
 	data() {
-		return {};
+		return {
+			stop:[],
+			longitude:'',
+			latitude:'',
+		};
+	},
+	onLoad() {
+		this.loadData();
 	},
 	methods:{
+		loadData() {
+			let obj = this;
+			store_list({
+				page:1,
+				limit:1000,
+				// latitude:res.latitude,
+				// longitude: res.longitude,
+			}).then(e =>{
+				obj.stop = e.data.list
+				console.log(e);
+			})
+			// uni.getLocation({
+			// 	type: 'gcj02',
+			// 	success: res => {
+			// 		console.log('dizhi+++++++++++');
+			// 		this.longitude = res.longitude //经度
+			// 		this.latitude = res.latitude //纬度
+			// 		store_list({
+			// 			page:1,
+			// 			limit:3,
+			// 			latitude:res.latitude,
+			// 			longitude: res.longitude,
+			// 		}).then(e =>{
+				// if(e.data.length != 0){
+				// 	e.data.list.forEach(e =>{
+				// 		e.jl = this.getFlatternDistance(this.latitude,this.longitude,e.latitude,e.longitude)
+				// 	})
+				// }
+			// 			obj.stop = e.data.list
+			// 			console.log(e);
+			// 		})
+			// 	},
+			// 	fail: err => {
+			// 		console.log(err);
+			// 		openMap().then(e => {
+			// 			this.getaddress();
+			// 		});
+			// 	}
+			// });
+		},
+		//根据经纬度计算距离
+		getFlatternDistance(lat1, lng1, lat2, lng2){
+			let f = getRad((lat1 + lat2)/2);
+			let g = getRad((lat1 - lat2)/2);
+			let l = getRad((lat1 - lng2)/2);
+			let sg = Math.sin(g);
+			let sl = Math.sin(1);
+			let	sf = Math.sin(f);
+			let s,C,W,r ,d,h1,h2;
+			let a =	EARTH_RADIUS ;
+			let fl = 1/298.257;
+			sg = sg*sg;
+			s1 = s1*sl;
+			sf = sf*sf;
+			g*(1-s1) + (1-sf)*s1;
+			C = (1-sg)*(1-s1) + sf*sl;
+			N = Math.atan(Math.sqrt(s/c));
+			r = Math.sqrt(s*c)/w;
+			d = 2*w*a;
+			h1 = (3*r -1)/2/c;
+			h2 = (3*r +1)/2/s;
+			return d*(1 + fl*(h1*sf*(1-sg) - h2*(1-sf)*sg));
+		},
 		navTo(url){
 			uni.navigateTo({
 				url,

+ 67 - 9
pages/store/storeInfo.vue

@@ -2,9 +2,9 @@
 	<view class="center">
 		<view class="store-info flex">
 			<view class="store-top flex">
-				<image class="simage" src="" mode=""></image>
+				<image class="simage" :src="info.image" mode=""></image>
 				<view class="stop-main">
-					<view class="stop-title">巴黎莎士比亚书店</view>
+					<view class="stop-title">{{info.name}}</view>
 					<view class="stop-address">
 						<image class="mrt-image" src="../../static/index/index10.png" mode=""></image>
 						<view class="mrt-font">距离0.3KM</view>
@@ -14,21 +14,21 @@
 		</view>
 		<view class="store-item">
 			<image class="store-image1" src="../../static/img/store2.png" mode=""></image>
-			<view class="store-font">营业时间:10:00-21:00</view>
+			<view class="store-font">营业时间:{{info.day_time}}</view>
 		</view>
 		<view class="store-item">
 			<image class="store-image2" src="../../static/img/store3.png" mode=""></image>
-			<view class="store-font">商家电话:14255212336</view>
+			<view class="store-font">商家电话:{{ info.phone }}</view>
 		</view>
 		<view class="store-item">
 			<image class="store-image3" src="../../static/img/store1.png" mode=""></image>
-			<view class="store-font">门店地址:椒江区市府大道200号</view>
+			<view class="store-font">门店地址:{{ info.detailed_address }}</view>
 		</view>
-		<view class="store-main">
+		<view class="store-main" v-if="info.slider_image != null">
 			<view class="smain-title">门头照片</view>
 			<scroll-view class="scroll-box flex" @scroll="scroll" scroll-x="true" :scroll-with-animation="true" scroll-left="10px">
-				<view class="scroll-item" v-for="(item,index) in 4" :key="index">
-					<image class="scroll-image" src="" mode="heightFix"></image>
+				<view class="scroll-item" v-for="(item,index) in info.slider_image" :key="index">
+					<image class="scroll-image" :src="item" mode="heightFix"></image>
 				</view>
 			</scroll-view>
 		</view>
@@ -44,11 +44,69 @@
 </template>
 
 <script>
+import { store_details } from '@/api/index.js'
 export default {
 	data() {
-		return {};
+		return {
+			id:'',
+			info:'',
+			longitude:'',
+			latitude:'',
+		};
+	},
+	onLoad(option) {
+		this.id = option.id;
+		this.loadData();
 	},
 	methods: {
+		loadData() {
+			store_details({},this.id).then(({data}) =>{
+				console.log(data);
+				this.info = data
+			})
+			// uni.getLocation({
+			// 	type: 'gcj02',
+			// 	success: res => {
+			// 		console.log('dizhi+++++++++++');
+			// 		this.longitude = res.longitude //经度
+			// 		this.latitude = res.latitude //纬度
+			// 		store_details({},this.id).then(({data}) =>{
+			// 			console.log(data);
+			// 			data.jl = this.getFlatternDistance(this.latitude,this.longitude,data.latitude,data.longitude)
+			// 			this.info = data
+			// 		})
+			// 	},
+			// 	fail: err => {
+			// 		console.log(err);
+			// 		openMap().then(e => {
+			// 			this.getaddress();
+			// 		});
+			// 	}
+			// });
+		},
+		//根据经纬度计算距离
+		getFlatternDistance(lat1, lng1, lat2, lng2){
+			let f = getRad((lat1 + lat2)/2);
+			let g = getRad((lat1 - lat2)/2);
+			let l = getRad((lat1 - lng2)/2);
+			let sg = Math.sin(g);
+			let sl = Math.sin(1);
+			let	sf = Math.sin(f);
+			let s,C,W,r ,d,h1,h2;
+			let a =	EARTH_RADIUS ;
+			let fl = 1/298.257;
+			sg = sg*sg;
+			s1 = s1*sl;
+			sf = sf*sf;
+			g*(1-s1) + (1-sf)*s1;
+			C = (1-sg)*(1-s1) + sf*sl;
+			N = Math.atan(Math.sqrt(s/c));
+			r = Math.sqrt(s*c)/w;
+			d = 2*w*a;
+			h1 = (3*r -1)/2/c;
+			h2 = (3*r +1)/2/s;
+			return d*(1 + fl*(h1*sf*(1-sg) - h2*(1-sf)*sg));
+		},
 		scroll(e) {
 			console.log(e,"123456");
 		}