瀏覽代碼

Merge branch 'master' of ssh://git.9026.com:2212/gubai/IHG

gubai 2 年之前
父節點
當前提交
4ca2db43cd
共有 8 個文件被更改,包括 283 次插入179 次删除
  1. 2 1
      manifest.json
  2. 30 73
      pages/goods/goods-detail/index.vue
  3. 47 10
      pages/index/index.vue
  4. 29 86
      pages/index/vote-detail/index.vue
  5. 12 6
      pages/map/hotel-book/index.vue
  6. 3 2
      pages/map/map.vue
  7. 15 0
      setting - 副本.js
  8. 145 1
      utils/tools.js

+ 2 - 1
manifest.json

xqd
@@ -68,7 +68,8 @@
                 "desc" : "获取位置,推荐精彩信息"
             }
         },
-        "requiredPrivateInfos" : [ "getLocation", "chooseLocation" ]
+        "requiredPrivateInfos" : [ "getLocation", "chooseLocation" ],
+		"lazyCodeLoading": "requiredComponents"
     },
     "mp-alipay" : {
         "usingComponents" : true

+ 30 - 73
pages/goods/goods-detail/index.vue

xqd xqd xqd xqd xqd xqd xqd xqd xqd
@@ -120,40 +120,22 @@
 					</view>
 					<image style="width: 52rpx;height: 52rpx;" src="/static/icon/close01.png" mode=""  @click="Recipientclose"></image>
 				</view>
-
-				<view class="pop-flavor">
-					<text>口味</text>
-					<view class="tab_flavor">
-						<view class="flavorTitle-item" :class="{'flavorTitle-item-active':flavorIsActive === index}"  v-for="(item,index) in flavorList" :key="index"
-							@click="flavorchecked(index,item.attr_name)">
-							<view :class="{'active-flavor':flavorIsActive === index}">
-								{{item.attr_name}}
-							</view>
-						</view>
-					</view>
-				</view>
-				<view class="pop-flavor" style="margin-top: 44rpx;">
-					<text>重量</text>
+				
+				
+				<view class="pop-flavor" v-for="i in attr_groups" :key="i.attr_group_id" style="margin-top: 44rpx;">
+					<text>{{i.attr_group_name}}</text>
 					<view class="tab_flavor">
-						<view class="flavorTitle-item" :class="{'flavorTitle-item-active':weightIsActive === index}" v-for="(item,index) in weightList" :key="index"
-							@click="weightchecked(index,item.attr_name)">
-							<view :class="{'active-flavor':weightIsActive === index}">
+						<view class="flavorTitle-item" 
+							:class="{'flavorTitle-item-active':flavorIsActive[i.attr_group_id] === item.attr_id}"  
+							v-for="(item,index) in i.attr_list" :key="item.attr_id"
+							@click="flavorchecked(item.attr_id,i.attr_group_id)"
+						>
+							<view :class="{'active-flavor':flavorIsActive[i.attr_group_id] === item.attr_id}">
 								{{item.attr_name}}
 							</view>
 						</view>
 					</view>
 				</view>
-				<view class="pop-flavor" style="margin-top: 44rpx;">
-					<text>包装</text>
-					<view class="tab_flavor">
-						<view class="flavorTitle-item" :class="{'flavorTitle-item-active':packIsActive === index}" v-for="(item,index) in packList" :key="index"
-							@click="packchecked(index,item.title)">
-							<view :class="{'active-flavor':packIsActive === index}">
-								{{item.title}}
-							</view>
-						</view>
-					</view>
-				</view>
 			</view>
 			<view class="purchase" v-if="produceType == 1" @click="goIntegralOrder(product_id)">
 				<view class="purchase-btn">立即购买</view>
@@ -162,7 +144,6 @@
 				<!-- <view class="purchase-btn">立即兑换</view> -->
 				<view class="purchase-btn">确认</view>
 			</view>
-
 		</uni-popup>
 
 		<!-- 二维码购买 -->
@@ -205,30 +186,9 @@
 				hotelDetail:'',
 				// 产品id
 				product_id:'',
-				packList: [{
-						title: '礼盒'
-					},
-					{
-						title: '普通'
-					}
-				],
-				weightList: [{
-					attr_name: '50g'
-				}, {
-					attr_name: '100g'
-				}, {
-					attr_name: '150g'
-				}],
-				flavorList: [{
-					attr_name: '五仁'
-				}, {
-					attr_name: '豆沙'
-				}, {
-					attr_name: '水果'
-				}],
 				//激活指定table菜单
 				isActive: 0,
-				flavorIsActive:0,
+				flavorIsActive:{},
 				weightIsActive:0,
 				packIsActive:0,
 				
@@ -250,19 +210,18 @@
 				current1: 0,
 				//指示点模式
 				mode: 'dot',
+				attr_groups:[],
 			}
 		},
 		onReady: function(res) {
 			this.videoContext = uni.createVideoContext('myVideo')
 		},
 		onLoad(op) {
+			const {id, type} = op;
 			this.admin = this.$store.getters.userInfo
-			console.log(this.admin);
-			this.product_id=op.id
-			this.produceType = op.type
-			console.log(this.product_id,this.produceType,"产品id")
-			this.getProductDetail(op.id)
-			
+			this.product_id=id
+			this.produceType = type
+			this.getProductDetail(this.product_id)
 		},
 		methods: {
 			//获取当前页面路径
@@ -313,19 +272,16 @@
 						console.log(e, '失败')
 					}
 				})
-			},
-			
+			},	
 			//视频自动播放
 			openVideoPlay() {
 				this.videoContext.play()
 			},
 			// 获取商品详情
-			getProductDetail(id){
+			getProductDetail(product_id){
 				this.$api.product.getProductDetail({
-					product_id:id
+					product_id:product_id
 				}).then(res=>{
-					console.log(res,"产品详情")
-					// console.log(res.data.attr_group,"产品规格")
 					if(res.code==0){
 						this.productDetail=res.data
 						this.info = JSON.parse(res.data.img_urls).map(item => {
@@ -339,14 +295,13 @@
 						//banner展示视频或者图片
 						this.resource_type = res.data.resource_type
 						this.video_url = res.data.video_url
-						console.log(this.video_url, '--->this.video_url');
 						//视频自动播放
 						this.openVideoPlay()
-						// 口味
-						// this.flavorList=JSON.parse(res.data.attr_group)[0].attr_list
-						// 重量
-						// this.weightList=JSON.parse(res.data.attr_group)[1].attr_list
-						this.getHotelDetail(res.data.hotel_id)
+						//规格对接
+						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]);
 					}
 				})
 			},
@@ -355,7 +310,6 @@
 				this.$api.hotel.getHotelDetail({
 					hotel_id:id
 				}).then(res=>{
-					console.log(res,"酒店详情")
 					this.hotelDetail=res.data
 				})
 			},
@@ -387,7 +341,8 @@
 			},
 			// 口味切换
 			flavorchecked(index,name) {
-				this.flavorIsActive = index
+				this.$set(this.flavorIsActive, name, index)
+				console.log(this.flavorIsActive)
 				this.specs.flavor=name
 			},
 			// 重量切换
@@ -424,8 +379,10 @@
 			},
 			// 跳转积分兑换
 			goIntegralOrder(id){
-				uni.navigateTo({
-					url:'/pages/my/integral/integralOrder?product_id='+id
+				this.$utils.jump({
+					jump_type: this.hotelDetail.buy_jump_type,
+					jump_config: this.hotelDetail.buy_jump_config,
+					attr: JSON.stringify(this.flavorIsActive)
 				})
 			},
 		}

+ 47 - 10
pages/index/index.vue

xqd xqd xqd xqd xqd xqd xqd xqd xqd
@@ -7,7 +7,10 @@
 				<swiper class="swiper-box" @change="change1" circular>
 					<swiper-item v-for="(item ,index) in infoList" :key="index">
 						<view class="swiper-item" v-if="item.resource_type == 1"
-							@click="jumpHAppID(item.jump_type,item.jump_config)">
+							@click="$utils.jump({
+								jump_type: item.jump_type,
+								jump_config: item.jump_config
+							})">
 							<image style="width: 100%;height:592rpx;" :src="item.img" mode="aspectFill"></image>
 						</view>
 						<view class="swiper-item" v-if="item.resource_type == 2">
@@ -23,7 +26,10 @@
 		<!-- 金刚图 -->
 		<view class="home-nav">
 			<view class="home-nav-item" v-for="(item,index) in navList" :key="index"
-				@click="jumpHAppID(item.jump_type,item.jump_config)">
+				@click="$utils.jump({
+					jump_type: item.jump_type,
+					jump_config: item.jump_config
+				})">
 				<image style="width: 101.96rpx;height: 103.96rpx;" :src="item.img" mode=""></image>
 				<text style="color: #333;font-size: 24rpx;margin-top: 18rpx; ">{{item.title}}</text>
 			</view>
@@ -47,7 +53,11 @@
 		<!-- 活动图片 -->
 		<view class="home-special-img">
 			<template v-for="(item,index) in specialList" >
-				<view class="ListItem" v-if="item.show_status" :key="index" @click="activeDetail(item.id)">
+				<view class="ListItem" v-if="item.show_status" :key="index" @click="$utils.jump({
+					jump_type: 3,
+					jump_config: '/pages/index/active-detail/index',
+					id: item.id,
+				})">
 					<image style="width: 312rpx;height: 200rpx; border-radius: 12rpx; "
 						:src="item.banners?item.cover_img:'http://t9.9026.com/imgs/Kudosbg.png'" mode=""></image>
 					<view class="kudosicon" @click.stop="kudosActive(item.id,index)">
@@ -64,7 +74,11 @@
 		<!-- 广告图 -->
 		<view class="home-banner" v-if="!isShowAdver">
 			<view class="home-banner-img" v-if="in_page==1 && type == 1 ">
-				<image style="width: 100%; height: 576rpx; border-radius: 12rpx;" :src="advData.img" mode="" @click="jumpHAppID(advData.jump_type, advData.jump_config)"></image>
+				<image style="width: 100%; height: 576rpx; border-radius: 12rpx;" :src="advData.img" mode="" 
+				@click="$utils.jump({
+					jump_type: item.jump_type,
+					jump_config: item.jump_config
+				})"></image>
 				<image @click="cleanCoverImg" class="img-clean" style="width: 20rpx; height: 20rpx; "
 					src="/static/icon/clean.png" mode="">
 				</image>
@@ -84,14 +98,19 @@
 
 		<movable-area class="movableArea">
 			<movable-view class="movableView" direction="all" x="630rpx" y="700rpx">
-				<view class="img-IHg" @click="goJoin">
+				<view class="img-IHg" @click="$utils.jumpJoinVip()">
 					<image style="width: 64rpx; height: 58rpx; " src="/static/icon/vip.png" mode=""></image>
 				</view>
 			</movable-view>
 		</movable-area>
 
 		<!-- 广告的附图 -->
-		<view class="home-attach" @click="jumpHAppID(advInsetImg.jump_type, advInsetImg.jump_config)">
+		<view class="home-attach" 
+			@click="$utils.jump({
+				jump_type: advInsetImg.jump_type,
+				jump_config: advInsetImg.jump_config
+			})"
+		>
 			<image style="width: 690rpx;height: 156rpx;border-radius: 79rpx;" :src="advInsetImg.img" mode=""></image>
 		</view>
 		<!-- 酒店推荐 -->
@@ -107,7 +126,15 @@
 		<!-- 酒店推荐图片 -->
 		<view class="home-hotel-img">
 			<view class="home-hotel-img-content">
-				<view @click="produceDetail(item.id)" class="home-hotel-img-content-item" v-for="(item,index) in goodsList" :key="index"
+				<!-- <view @click="produceDetail(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': 'homel-hotel-img-content-item-img-long' "
+						:src="item.cover_img" mode=""></image>
+					<view class="text">
+						<text class="text-top">{{item.name}}</text>
+				</view> -->
+				<view  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' "
@@ -117,7 +144,10 @@
 					</view>
 				</view>
 			</view>
-			<view class="home-hotel-img-more" @click="goProduceList">
+			<view class="home-hotel-img-more" @click="$utils.jump({
+				jump_type: 4,
+				jump_config: '/pages/goods/goods'
+			})">
 				<text>查看更多商品</text>
 			</view>
 		</view>
@@ -136,7 +166,11 @@
 				<swiper class="swiper-box" circular @change="change2">
 					<swiper-item v-for="(items ,index) in info" :key="index">
 						<view v-for="(item ,j) in items" :key="j" class="swiper-item"
-							@click="jumpHAppID(item.jump_type,item.jump_config)">
+							@click="$utils.jump({
+								jump_type: item.jump_type,
+								jump_config: item.jump_config
+							})"
+						>
 							<image style="width:144rpx;height:142rpx;" :src="item.img" mode="aspectFill"></image>
 						</view>
 					</swiper-item>
@@ -151,7 +185,10 @@
 		<!-- 弹窗广告 -->
 		<uni-popup ref="popup" type="center">
 			<view class="popup-banner">
-				<image @click="jumpHAppID(popupData.jump_type, popupData.jump_config)" style="width: 656rpx;height: 916rpx;border-radius: 12rpx;" :src="popupData.img">
+				<image @click="$utils.jump({
+						jump_type: popupData.jump_type,
+						jump_config: popupData.jump_config
+				})" style="width: 656rpx;height: 916rpx;border-radius: 12rpx;" :src="popupData.img">
 				</image>
 				<view class="popup-banner-clean" @click='closePopupBanner'>
 					<image style="width: 20rpx; height: 20rpx; " src="/static/icon/clean.png" mode="">

+ 29 - 86
pages/index/vote-detail/index.vue

xqd xqd xqd
@@ -267,11 +267,9 @@
 
 			//去兑换页面
 			goConvert() {
-				uni.navigateTo({
-					url: '/pages/my/prize/prize',
-					fail:(err)=>{
-						console.log(err)
-					}
+				this.$utils.jump({
+					jump_type: 4,
+					jump_config: '/pages/my/prize/prize'
 				})
 			},
 
@@ -336,48 +334,10 @@
 
 			//轮播图跳转h5或者小程序和内部页面
 			goSwiperSmall() {
-				//跳转h5
-				if (this.jump_type == 1) {
-					const url = this.jump_config; // 跳转的外链
-					const navtitle = 'H5'; // 这个标题是你自己可以设置的
-					uni.navigateTo({
-						// 跳转到webview页面
-						url: `/pages/webview/webview?url=${url}&nav=${navtitle}`,
-						success: () => {
-							console.log('成功')
-						},
-						fail: (e) => {
-							console.log(e, "失败")
-						}
-					});
-				} else if (this.jump_type == 2) {
-					let obj = JSON.parse(this.jump_config);
-					wx.navigateToMiniProgram({
-						appId: `${obj.appid}`, //appid
-						path: `${obj.path}`, //path
-						extraData: { //参数
-							foo: 'bar'
-						},
-						// envVersion: 'develop', //开发版develop 开发版 trial   体验版 release 正式版 
-						success(res) {
-							console.log('成功')
-							// 打开成功
-						},
-						fail(e) {
-							console.log(e, '失败')
-						}
-					})
-				} else if (this.jump_type == 4) {
-					let obj = this.jump_config
-					uni.reLaunch({
-						url: obj,
-						fail:(err)=>{
-							uni.navigateTo({
-								url: obj
-							})
-						}
-					})
-				}
+				this.$utils.jump({
+					jump_type: this.jump_type,
+					jump_config: this.jump_config
+				})
 			},
 			cancelTime(i, j) {
 				let nowtime = new Date() //获取当前时间
@@ -432,46 +392,29 @@
 
 			// 跳转其他小程序
 			goJoin() {
-				let _this = this
-				wx.navigateToMiniProgram({
-					appId: 'wx255b58f0992b3c53', //appid
-					path: 'newUIMain/enrollment/enrollment', //path
-					extraData: { //参数
-						foo: 'bar'
-					},
-					// envVersion: 'develop', //开发版develop 开发版 trial   体验版 release 正式版 
-					success(res) {
-						let page = _this.getPageUrl()
-						let user_id = ''
-						if (_this.admin != null) {
-							user_id = _this.admin.id
-						} else {
-							user_id = 0
-						}
-						console.log('成功', page)
-						_this.$api.my.userMemberAdd({
-							user_id,
-							page,
-						}).then(res => {
-							console.log(res.data);
-						})
-						
-						//增加票数
-						_this.$api.my.userJoinVip({
-							source_type: 1,
-							source_id: _this.sourceId
-						}).then(res => {
-							uni.setStorage({
-								key: 'is_vip',
-								data: 1,
-							});
-							_this.is_vip = true
-						})
-						// 打开成功
-					},
-					fail(e) {
-						console.log(e, '失败')
+				this.$utils.jumpJoinVip().then( _=>{
+					const page = this.getPageUrl()
+					let user_id = ''
+					if (this.admin != null) {
+						user_id = this.admin.id
+					} else {
+						user_id = 0
 					}
+					this.$api.my.userMemberAdd({
+						user_id,
+						page,
+					})
+					//增加票数
+					this.$api.my.userJoinVip({
+						source_type: 1,
+						source_id: this.sourceId
+					}).then(res => {
+						uni.setStorage({
+							key: 'is_vip',
+							data: 1,
+						});
+						this.is_vip = true
+					})
 				})
 			},
 			// 投票

+ 12 - 6
pages/map/hotel-book/index.vue

xqd
@@ -108,14 +108,20 @@
 			this.videoContext = uni.createVideoContext('myVideo')
 		},
 
-		onLoad(o) {
-			if (o.hotel_id) {
-				this.hotel = o;
-				this.hotel_id = o.hotel_id
-				this.getDetail()
+		onLoad(params) {
+			if(!this.$store.getters.userInfo){
+				uni.navigateTo({
+					url: '/pages/login/login'
+				})
 			}
+			if (params?.hotel_id) {
+				params.address = params.address == 'null' ? "" : params.address;
+				this.hotel = params;
+				this.hotel_id = params.hotel_id;
+				this.getDetail()
+			}			
 		},
-
+		
 		methods: {
 			// 切换轮播图指示点
 			change1(e) {

+ 3 - 2
pages/map/map.vue

xqd xqd xqd
@@ -167,7 +167,7 @@
 							<view class="address-detail-main">
 								<view class="address-detail-main-left">
 									<text class="title">{{item.name}}</text>
-									<view class="content">
+									<view class="content" :style="{opacity: item.label?1:0}">
 										<text>{{item.label}}</text>
 									</view>
 									<view class="bottom" v-if="item.min_price">
@@ -209,7 +209,7 @@
 						<view class="address-detail-main">
 							<view class="address-detail-main-left">
 								<text class="title">{{item.name}}</text>
-								<view class="content">
+								<view class="content" :style="{opacity: item.label?1:0}">
 									<text>{{item.label}}</text>
 								</view>
 								<view class="bottom" v-if="item.min_price">
@@ -470,6 +470,7 @@
 					uni.navigateTo({
 						url: '/pages/login/login'
 					})
+					return;
 				}
 				const hotel = this.hotelList[index];
 

+ 15 - 0
setting - 副本.js

xqd
@@ -0,0 +1,15 @@
+/**
+ * Created by JianJia.Zhou<jianjia.zhou> on 2022/3/18.
+ */
+const IS_DEV = process.env.NODE_ENV === 'development'
+// const URL = 'https://t9.9026.com'
+const URL = 'https://ihg.9026.com'
+
+module.exports = {
+  // 版本
+  VERSION: '0.0.1',
+  // API 接口URL
+  BASE_URL: IS_DEV ? 'https://t9.9026.com/api' : URL + '/api',
+  // API 接口URL
+  IMAGE_URL: IS_DEV ? 'https://t9.9026.com/static/image' : URL + '/static/image'
+}

+ 145 - 1
utils/tools.js

xqd
@@ -8,6 +8,150 @@ const toHttps = (url)=>{
 	return url;
 }
 
+/**
+ *	@param {
+		jump_type   		1.跳转H5 2.跳转新小程序 3.图片 4.跳转内部页面
+		jump_config   		string | stringify(object)
+		@param 其他参数		如:id,nav
+	}
+ * 注:jump_type,接口3和4有冲突所以写了兼容
+ * 注:图片跳转逻辑空缺
+ */
+const jump = ({jump_type, jump_config, ...params} = {})=>{
+	console.log(params);
+	return new Promise((resolve, reject)=>{
+		if(!jump_type) reject(false);
+		jump_config = jump_config == undefined ? "" : jump_config;
+		if(jump_type == 1){
+			const nav =	Reflect.has(params, "nav") ?  `&nav=${params.nav}` : ``;
+			const url = `/pages/webview/webview?url=${jump_config+nav}`;
+			uni.navigateTo({
+				url: url,
+				success: () => {
+					resolve(true)
+				},
+				fail: _ => {
+					uni.reLaunch({
+						url: url,
+						fail:(err)=>{
+							reject(err)
+						}
+					})
+				}
+			});
+		}else if(jump_type == 2){
+			const {appid, path} = JSON.parse(jump_config);
+			wx.navigateToMiniProgram({
+				appId: `${appid}`,
+				path: `${path}`,
+				extraData: {
+					foo: 'bar'
+				},
+				// envVersion: 'develop', //开发版develop 开发版 trial   体验版 release 正式版 
+				success:() => {
+					resolve(true)
+				},
+				fail:(err) => {
+					reject(err)
+				}
+			})
+		}else if(jump_type == 3){
+			if(jump_config.substr(0, 7) == '/pages/'){
+				jumpInner(jump_config, params)
+				.then(_=>{
+					resolve(true)
+				})
+				.catch(err=>{
+					reject(err)
+				})
+			}else{
+				//图片跳转
+				console.log("图片跳转逻辑空缺")
+			}
+		}else if(jump_type == 4){
+			jumpInner(jump_config, params)
+			.then(_=>{
+				resolve(true)
+			})
+			.catch(err=>{
+				reject(err)
+			})
+		}else{
+			reject('unkown error')
+		}
+	})
+}
+/**
+ * jumpy依赖函数
+ */
+const jumpInner = (url, params)=>{
+	const tabbarPageList = [
+		'pages/index/index',
+		'pages/map/map',
+		'pages/msg/msg',
+		'pages/my/my'
+	]
+	let paramsText = ``;
+	for(let [k, v] of Object.entries(params)){
+		paramsText +=`${k}=${v}&`
+	}
+	if(paramsText.length>0){
+		paramsText = paramsText.slice(0,paramsText.length-1);
+		url = url.indexOf("?") > -1 ? `${url}&${paramsText}` : `${url}?${paramsText}`;
+	}
+	let func = uni.switchTab;
+	const pages = getCurrentPages();
+	if(pages.length>0){
+		const {route} = pages[pages.length - 1];
+		tabbarPageList.includes(route)
+		func = tabbarPageList.includes(route) ? uni.reLaunch : uni.switchTab;
+	}
+	func = uni.reLaunch;
+	console.log(url, '跳转完整地址');
+	return new Promise((resolve,reject)=>{
+		uni.navigateTo({
+			url: url,
+			success:()=>{
+				resolve(true)
+			},
+			fail: _=>{
+				func({
+					url: url,
+					success:()=>{
+						resolve(true)
+					},
+					fail:(err)=>{
+						reject(err)
+					}
+				})
+			}
+		})
+	})
+}
+/**
+ * 跳转加入会员小程序
+ */
+const jumpJoinVip = () => {
+	return new Promise((resolve, reject)=>{
+		wx.navigateToMiniProgram({
+			appId: 'wx255b58f0992b3c53', //appid
+			path: 'newUIMain/enrollment/enrollment', //path
+			extraData: { //参数
+				foo: 'bar'
+			},
+			// envVersion: 'develop', //开发版develop 开发版 trial   体验版 release 正式版 
+			success(res) {
+				resolve(res)
+				// 打开成功
+			},
+			fail(e) {
+				reject(e)
+			}
+		})
+	})
+}
 export default {
-	toHttps
+	toHttps,
+	jump,
+	jumpJoinVip
 }