瀏覽代碼

地图、投票、产品调试

yfso 2 年之前
父節點
當前提交
cc213fd099

+ 7 - 2
pages/goods/goods-detail/index.scss

xqd xqd
@@ -259,6 +259,11 @@ $pageColor:#F9F9F9;
 			font-size: 30rpx;
 			color: #333333;
 			line-height: 48rpx;
+			overflow: hidden;
+			
+			img,image{
+				max-width: 100%;
+			}
 		}
 	}
 
@@ -310,10 +315,10 @@ $pageColor:#F9F9F9;
 
 
 	.home-swiper {
-		height: 576rpx;
+		height: 100vw;
 
 		.swiper-box {
-			height: 576rpx;
+			height: 100vw;
 		}
 	}
 

+ 74 - 27
pages/goods/goods-detail/index.vue

xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd
@@ -16,7 +16,7 @@
 				<swiper class="swiper-box" @change="change1" circular>
 					<swiper-item v-for="(item ,index) in info" :key="index"  v-if="resource_type == 1 ">
 						<view class="swiper-item">
-							<image style="width: 100%;height:576rpx;" :src="item.img" mode="aspectFill"></image>
+							<image style="width: 100vw;height:100vw;" :src="item.img" mode="aspectFill"></image>
 						</view>
 					</swiper-item>
 					<swiper-item  v-if="resource_type == 2 ">
@@ -38,7 +38,7 @@
 					<text>{{productDetail.price}}</text>
 				</view>
 				<view class="price-top" v-if="produceType == 2">
-					<text>{{productDetail.integral}}</text>
+					<text>{{productDetail.price}}</text>
 					<text>积分</text>
 				</view>	
 				<text class="price-text">{{productDetail.name}}</text>
@@ -52,7 +52,7 @@
 						<text>选择</text>
 					</view>
 					<view class="price-specs-main" @click="Recipientopen()">
-						<text>{{specsText||'请选择规格'}}</text>
+						<text>{{showAttr||'请选择规格'}}</text>
 					</view>
 					<view @click="Recipientopen()">
 						<image style="width: 12rpx;height: 20rpx;" src="/static/icon/right03.png" mode=""></image>
@@ -94,7 +94,7 @@
 				<image style="width: 40rpx;height: 42rpx;" src="/static/icon/home01.png" mode=""></image>
 				<text>首页</text>
 			</view>
-			<view class="buy-btn-right" @click="$refs.codePurchase.open()" v-if="produceType==1">
+			<view class="buy-btn-right" @click="goIntegralOrder" v-if="produceType==1">
 				<text>立即购买</text>
 			</view>
 			<view v-if="produceType==2" class="buy-btn-right" @click="goProductChange(product_id,flavorIsActive)">
@@ -115,7 +115,7 @@
 							<text>{{productDetail.price}}</text>
 						</view>
 						<view class="pop-price-left-money" v-if="produceType == 2">
-							<text>{{productDetail.integral}}</text>
+							<text>{{productDetail.price}}</text>
 							<text>积分</text>
 						</view>
 					</view>
@@ -136,7 +136,7 @@
 					</view>
 				</view>
 			</view>
-			<view class="purchase" v-if="produceType == 1" @click="goIntegralOrder(product_id)">
+			<view class="purchase" v-if="produceType == 1" @click="goIntegralOrder">
 				<view class="purchase-btn">立即购买</view>
 			</view>
 			<view class="purchase" v-if="produceType == 2"  @click="selectSpecs">
@@ -216,7 +216,7 @@
 				}
 			}
 		},
-		onReady: function(res) {
+		onReady: function() {
 			this.videoContext = uni.createVideoContext('myVideo')
 		},
 		onLoad(op) {
@@ -224,9 +224,24 @@
 			this.admin = this.$store.getters.userInfo
 			this.product_id=id
 			this.produceType = type
-			this.getProductDetail(this.product_id)
+			this.getProductDetail(this.product_id,true)
+		},
+		computed:{
+			showAttr:function(){
+				if(this.flavorIsActive.length <=0) return false;
+				let text = '';
+				for(const k in this.flavorIsActive){
+					text += `${k}-${this.flavorIsActive[k]},`
+				}
+				return text.substr(0, text.length-1);
+			},
+			selectedHotelId:function(){
+				return this.$store.state.tab.selectedHotelId;
+			}
 		},
-		methods: {
+		methods: {
+			//显示所选规格
+			
 			//获取当前页面路径
 			getPageUrl() {
 				const pages = getCurrentPages();
@@ -281,11 +296,11 @@
 				this.videoContext.play()
 			},
 			// 获取商品详情
-			getProductDetail(product_id){
+			getProductDetail(product_id, init=false){
 				this.$api.product.getProductDetail({
 					product_id:product_id
 				}).then(res=>{
-					if(res.code==0){
+					if(res.code==0 && res.data){
 						this.productDetail=res.data
 						this.info = JSON.parse(res.data.img_urls).map(item => {
 							return {
@@ -303,12 +318,21 @@
 						//规格对接
 						this.attr_groups = JSON.parse(res.data.attr_group)
 						//获取默认酒店
-						const hotel_ids = JSON.parse(res.data.hotel_ids);
-						(hotel_ids.constructor == Array) && (hotel_ids.length > 0) &&  this.getHotelDetail(hotel_ids[0]);
+						const hotel_ids = JSON.parse(res.data.hotel_ids);
+						if((hotel_ids.constructor == Array) && (hotel_ids.length > 0)){
+							this.$store.commit("tab/SET_SELECTEDHOTELId", hotel_ids[0])
+						}
 						//
 						const sku = JSON.parse(res.data.sku);
 						this.sku.keys = Object.keys(sku.attrs);
 						this.sku.sku = sku.sku;
+						
+						//首次默认选中第一个规格
+						if(init){
+							this.attr_groups.forEach(item => {
+								this.flavorchecked(item.attr_list[0]?.attr_name,item.attr_group_name)
+							})
+						}
 					}
 				})
 			},
@@ -379,11 +403,11 @@
 			},
 			// 选择规格
 			selectSpecs(){
-				this.specs.flavor='五仁'
-				this.specs.weight='50g'
-				this.specs.pack='礼盒'
-				console.log(this.specs)
-				this.specsText=this.specs.flavor+'--'+this.specs.weight+'--'+this.specs.pack
+				// this.specs.flavor='五仁'
+				// this.specs.weight='50g'
+				// this.specs.pack='礼盒'
+				// console.log(this.specs)
+				// this.specsText=this.specs.flavor+'--'+this.specs.weight+'--'+this.specs.pack
 				this.Recipientclose()
 			},
 			Recipientopen() {
@@ -401,25 +425,48 @@
 			},
 			//积分兑换
 			goProductChange(id,flavorIsActive){
-				console.log(flavorIsActive,'------flavorIsActive');
-				let arr = []
-				Object.keys(flavorIsActive).forEach(key =>{
-					arr.push(flavorIsActive[key])
-				})
-				console.log(arr);
+				// console.log(flavorIsActive,'------flavorIsActive');
+				// let arr = []
+				// Object.keys(flavorIsActive).forEach(key =>{
+				// 	arr.push(flavorIsActive[key])
+				// })
+				// console.log(arr);
 				// uni.navigateTo({
 				// 	url:'/pages/my/integral/integralOrder?product_id='+id
-				// })
+				// })
+				const resArr = [];
+				outer: for(const k in this.flavorIsActive){	
+					inner: for(const i in this.attr_groups){
+						if(this.attr_groups[i].attr_group_name == k){
+							laster: for(const l in this.attr_groups[i].attr_list){
+								if(this.attr_groups[i].attr_list[l].attr_name == this.flavorIsActive[k]){
+									resArr.push(this.attr_groups[i].attr_list[l].attr_id);
+									break inner;
+								}
+							}
+						}
+					}
+				}
+				const selectedIds = resArr.join(':');
+				uni.navigateTo({
+					url:`/pages/my/integral/integralOrder?product_id=${this.productDetail.id}&attr=${selectedIds}`
+				})
 			},
 			// 跳转积分兑换
-			goIntegralOrder(id){
+			goIntegralOrder(){
 				this.$utils.jump({
 					jump_type: this.hotelDetail.buy_jump_type,
 					jump_config: this.hotelDetail.buy_jump_config,
 					attr: JSON.stringify(this.flavorIsActive)
 				})
 			},
-		}
+		},
+		watch:{
+			selectedHotelId(newValue) {
+				console.log(newValue)
+				this.getHotelDetail(newValue);
+			}
+		}
 	}
 </script>
 

+ 95 - 20
pages/goods/goods-hotel/index.vue

xqd xqd
@@ -10,20 +10,20 @@
 		</view>
 
 		<view class="content">
-			<view class="content-item" v-for="item in 2">
-				<image style="flex: none;width: 112rpx;height: 112rpx;border-radius: 50%;" src="/static/icon/youyue.png"
+			<view class="content-item" v-for="item in hotelList" :key="item.id" @click="selected(item.id)">
+				<image style="flex: none;width: 112rpx;height: 112rpx;border-radius: 50%;" :src="item.logo"
 					mode=""></image>
 				<view class="content-item-main">
-					<text class="content-item-main-text">成都环球中心天堂洲际大饭店</text>
+					<text class="content-item-main-text">{{item.name}}</text>
 					<view class="content-item-main-call" style="margin: 20rpx 0 12rpx;">
 						<image style="width: 26rpx;height: 26rpx; margin-right: 8rpx;" src="/static/icon/phone02.png"
 							mode=""></image>
-						<text>028-129320</text>
+						<text>{{item.phone?item.phone:""}}</text>
 					</view>
 					<view class="content-item-main-call">
 						<image style="width: 24rpx;height: 28rpx; margin-right: 8rpx; " src="/static/icon/address01.png"
 							mode=""></image>
-						<text>1.2km</text>
+						<text>{{item.distanceToMe?item.distanceToMe+"km":""}}</text>
 					</view>
 				</view>
 				<view class="content-item-right">
@@ -56,47 +56,122 @@
 				},
 				// 酒店列表
 				hotelList:[],
-				// 产品id
-				product_id:'',
+				
+				//______________
+				product_id:-1,			// 产品id
+				
+				//______________
+				geo: {},
 			}
 		},
 		onLoad(op) {
 			this.product_id=op.product_id
-			if(op.product_id!=''){
-				this.getHotelList(op.product_id)
-			}
+			this.init();
 		},
 		methods: {
+			//初始化
+			async init(){
+				await this.getGeo();
+				await this.getHotelList();
+			},
+			//获取地理位置
+			getGeo(callback){
+				return new Promise((resolve,reject)=>{
+					uni.getLocation({
+						type: "gcj02", //返回可以用于wx.openLocation的经纬度
+						success: (res) => {
+							const {latitude, longitude} = res;
+							this.geo.latitude = latitude
+							this.geo.longitude = longitude
+							resolve(true);
+						},
+						fail: function(res) {
+							console.error(res);
+							reject(res)
+						}
+					})
+				}) 
+			},
+			//选择
+			selected(id){
+				this.$store.commit("tab/SET_SELECTEDHOTELId", id)
+				uni.navigateBack({
+					fail: ()=>{
+						uni.switchTab({
+							url: "/pages/index/index"
+						})
+					}
+				})
+			},
 			// 获取酒店列表
-			getHotelList(id){
+			getHotelList(page=1){
+				if(page==1){
+					this.hotelList = [];
+				}
+				const tempobj = {};
+				if(this.geo.latitude&&this.geo.longitude){
+					tempobj['latitude'] = this.geo.latitude;
+					tempobj['longitude'] = this.geo.longitude;
+				}
 				this.$api.hotel.getHotelList({
-					page:1,
-					product_id:id
+					page:page,
+					product_id:this.product_id,
+					...tempobj
 				}).then(res=>{
 					console.log(res,"酒店列表")
 					if(res.code==0){
-						this.hotelList=res.data.data
+						let hotelList = res.data.data
+						hotelList = this.calcDistance(hotelList);
+						this.hotelList.push(...hotelList);
+						if(hotelList.length >= 15){
+							this.getHotelList(page + 1);
+						}
 					}
 				})
 			},
+			//计算距离
+			calcDistance(hotel){
+				let target = hotel
+				if(this.geo.latitude && this.geo.longitude){
+					target.map(item=>{
+						item.distanceToMe=this.$utils.calcDistance(this.geo.latitude,this.geo.longitude,item.latitude,item.longitude).toFixed(1);
+						return item;
+					})
+				}
+				
+				return target;
+			},
 			// 搜索防抖
 			searchText:util.debounce(function(){
 				this.goSearch()
 			},1000),
 			// 搜索
-			goSearch(){
+			goSearch(page=1){
+				if(page==1){
+					this.hotelList = [];
+				}
+				const tempobj = {};
+				if(this.search){
+					tempobj['name'] = this.search;
+				}
 				this.$api.hotel.getHotelList({
-					page:1,
-					name:this.search,
-					product_id:this.product_id
+					page:page,
+					product_id:this.product_id,
+					...tempobj
 				}).then(res=>{
 					console.log(res,'搜索酒店列表')
 					if(res.code==0){
-						this.hotelList=res.data.data
+						let hotelList=res.data.data
+						hotelList = this.calcDistance(hotelList);
+						this.hotelList.push(...hotelList);
+						if(hotelList.length >= 15){
+							this.getHotelList(page + 1);
+						}
 					}
 				})
 			},
-		}
+		},
+		
 	}
 </script>
 

+ 12 - 12
pages/goods/goods.vue

xqd
@@ -31,18 +31,18 @@
 			<view class="content">
 
 				<view class="home-hotel-img-content">
-
-					<view @click="goGoodsDetail(item.id)" class="home-hotel-img-content-item" v-for="(item,index) in goodsList" :key="index"
-						:style="{marginTop:item.marginTop || 0 }">
-						<image class="home-hotel-img-content-item-img"
-							:class="item.short?'home-hotel-img-content-item-img': 'home-hotel-img-content-item-img-long' "
-							:src="item.cover_img" mode=""></image>
-						<view class="text">
-							<text class="text-top">{{item.name}}</text>
-							<text class="text-main">{{item.hotel.name}}</text>
-						</view>
-					</view>
-
+					<template v-for="(item,index) in goodsList">
+						<view v-if="item.status==1" @click="goGoodsDetail(item.id)" class="home-hotel-img-content-item" :key="index"
+							:style="{marginTop:item.marginTop || 0 }">
+							<image class="home-hotel-img-content-item-img"
+								:class="item.short?'home-hotel-img-content-item-img': 'home-hotel-img-content-item-img-long' "
+								:src="item.cover_img" mode=""></image>
+							<view class="text">
+								<text class="text-top">{{item.name}}</text>
+								<text class="text-main">{{item.hotel.name}}</text>
+							</view>
+						</view>
+					</template>
 				</view>
 				<!-- 触底 -->
 				<view class="home-bottom">

+ 17 - 14
pages/index/index.vue

xqd xqd xqd
@@ -124,20 +124,22 @@
 		</view>
 
 		<!-- 酒店推荐图片 -->
-		<view class="home-hotel-img">
-			<view class="home-hotel-img-content">
-				<view  class="home-hotel-img-content-item" v-for="(item,index) in goodsList" :key="index"
-					:style="{marginTop:item.marginTop || 0 }" 
-					@click="goToProduct(item.id)">
-					<image class="home-hotel-img-content-item-img"
-						:class="item.short?'home-hotel-img-content-item-img': 'home-hotel-img-content-item-img-long' "
-						:src="item.cover_img" mode=""></image>
-					<view class="text">
-						<text class="text-top">{{item.name}}</text>
+		<view class="home-hotel-img" >
+			<view class="home-hotel-img-content" v-if="isDevelopment">
+				<template v-for="(item,index) in goodsList" >
+					<view v-if="item.status==1" class="home-hotel-img-content-item" :key="index"
+						:style="{marginTop:item.marginTop || 0 }" 
+						@click="goToProduct(item.id)">
+						<image class="home-hotel-img-content-item-img"
+							:class="item.short?'home-hotel-img-content-item-img': 'home-hotel-img-content-item-img-long' "
+							:src="item.cover_img" mode=""></image>
+						<view class="text">
+							<text class="text-top">{{item.name}}</text>
+						</view>
 					</view>
-				</view>
+				</template>	
 			</view>
-			<view class="home-hotel-img-more" @click="$utils.jump({
+			<view v-if="isDevelopment" class="home-hotel-img-more" @click="$utils.jump({
 				jump_type: 4,
 				jump_config: '/pages/goods/goods'
 			})">
@@ -289,7 +291,8 @@
 				// 金刚图
 				navList: [],
 				//活动专区
-				specialList: []
+				specialList: [],
+				isDevelopment:false,
 			}
 		},
 		onTabItemTap(e){
@@ -315,7 +318,7 @@
 		onLoad() {
 			this.getGoodsList()
 			this.getAllSet()
-			
+			this.isDevelopment = process.env.NODE_ENV === 'development';
 			//用户访问
 			this.getUserVisits()
 		},

+ 3 - 14
pages/map/map.vue

xqd xqd xqd xqd
@@ -171,7 +171,7 @@
 		</view>
 
 		<!-- 酒店列表 -->
-		<view class="hotel-list" style="position: absolute;z-index:11;height:100%" v-if="!isShow">
+		<view class="hotel-list" style="position: absolute;z-index:11;min-height:100%;padding-bottom: 80px;" v-if="!isShow">
 			<view class="hotel-list-item" v-for="(item,index) in hotelList" :key="index" @click="goBook(item.id)">
 				<view class="wrap">
 					<view class="mark">
@@ -387,17 +387,6 @@
 					}
 				})
 			},			
-			space(lat1, lng1, lat2, lng2) {
-			  var radLat1 = lat1 * Math.PI / 180.0;
-			  var radLat2 = lat2 * Math.PI / 180.0;
-			  var a = radLat1 - radLat2;
-			  var b = lng1 * Math.PI / 180.0 - lng2 * Math.PI / 180.0;
-			  var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
-					 Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
-			  s = s * 6378.137;
-			  s = Math.round(s * 10000) / 10000;
-			  return s;
-			},
 			//-------------------------------------
 			requestHotelPage(tempobj){
 				tempobj.page = tempobj.page + 1;
@@ -434,7 +423,7 @@
 							}
 						}
 						this.hotelList.map(item=>{
-							item.distanceToMe=this.space(this.latitude,this.longitude,item.latitude,item.longitude).toFixed(1);
+							item.distanceToMe=this.$utils.calcDistance(this.latitude,this.longitude,item.latitude,item.longitude).toFixed(1);
 							return item;
 						})
 						
@@ -494,7 +483,7 @@
 					})
 					if(res.data.data.length <= 0) return;
 					this.hotelList.map(item=>{
-						item.distanceToMe=this.space(this.latitude,this.longitude,item.latitude,item.longitude).toFixed(1);
+						item.distanceToMe=this.$utils.calcDistance(this.latitude,this.longitude,item.latitude,item.longitude).toFixed(1);
 						return item;
 					})	
 					// this.hotelList.sort((prev,next)=>{

+ 2 - 2
setting.js

xqd
@@ -2,8 +2,8 @@
  * Created by JianJia.Zhou<jianjia.zhou> on 2022/3/18.
  */
 const IS_DEV = process.env.NODE_ENV === 'development1'
-const URL = 'https://t9.9026.com'
-// const URL = 'https://ihg.9026.com'
+// const URL = 'https://t9.9026.com'
+const URL = 'https://ihg.9026.com'
 
 module.exports = {
   // 版本

+ 5 - 1
store/modules/tab.js

xqd xqd
@@ -3,7 +3,8 @@ import Constant from '@/utils/constant'
 const val = Cache.get(Constant.CACHE_TAB_SELECTED)
 const getDefaultState = () => {
   return {
-    index: val === undefined ? 1 : val
+    index: val === undefined ? 1 : val,
+	selectedHotelId: 0
   }
 }
 
@@ -13,6 +14,9 @@ const mutations = {
   SET_INDEX: (state, index) => {
     Cache.set(Constant.CACHE_TAB_SELECTED, index)
     state.index = index
+  },
+  SET_SELECTEDHOTELId: (state, hotelId) => {
+    state.selectedHotelId = hotelId
   }
 }
 

+ 18 - 2
utils/tools.js

xqd xqd
@@ -1,5 +1,5 @@
 /**
- * http杞琱ttps
+ * http转换为https
  */
 const toHttps = (url)=>{
 	if(url.indexOf('http')>-1 && url.indexOf('https') == -1){
@@ -170,10 +170,26 @@ const arrayDiff = function(arr1, arr2) {
  
     return subset;
 }
+
+/**
+ * 测试两个地理位置间得距离
+ */
+const calcDistance = (lat1, lng1, lat2, lng2) => {
+	let radLat1 = lat1 * Math.PI / 180.0;
+	let radLat2 = lat2 * Math.PI / 180.0;
+	let a = radLat1 - radLat2;
+	let b = lng1 * Math.PI / 180.0 - lng2 * Math.PI / 180.0;
+	let s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + 
+	Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
+	s = s * 6378.137;
+	s = Math.round(s * 10000) / 10000;
+	return s;
+}
 
 export default {
 	toHttps,
 	jump,
 	jumpJoinVip,
-	arrayDiff
+	arrayDiff,
+	calcDistance
 }