Browse Source

opt:优化引导样式

LiChengjin 2 weeks ago
parent
commit
4f25213477
2 changed files with 90 additions and 66 deletions
  1. 77 55
      components/guide/guide.vue
  2. 13 11
      pages/home/home.vue

+ 77 - 55
components/guide/guide.vue

@@ -9,10 +9,18 @@
 			</view>
 			</view>
 		</template>
 		</template>
 		<template v-if="noticeArray[currentIndex].type == 'top' ">
 		<template v-if="noticeArray[currentIndex].type == 'top' ">
+			<view class="arrow"
+				:style="{'height':'96rpx','width':'96rpx','top': (top-height-topMsgHeight+50) +'px', 'left': left<(winWidth/2)?left+'px':'' , 'right': left>(winWidth/2)?(winWidth-right) +'px':'' }">
+				<image mode="aspectFill" src="../../static/arrow-down.png" style="width: 96rpx;height: 96rpx;"></image>
+			</view>
 			<view :class="left<(winWidth/2)?'show-message_top_left':'show-message_top_right'"
 			<view :class="left<(winWidth/2)?'show-message_top_left':'show-message_top_right'"
-				:style="{'top': (top-height-topMsgHeght+30) +'px', 'left': left<(winWidth/2)?left+'px':'' , 'right': left>(winWidth/2)?(winWidth-right)+'px':''  }">
+				:style="{'top': (top-height-topMsgHeight-10) +'px', 'left': left<(winWidth/2)?left+'px':'' , 'right': left>(winWidth/2)?(winWidth-right)+'px':''  }">
 				<view style="padding: 12rpx 18rpx;">{{showMessage}}</view>
 				<view style="padding: 12rpx 18rpx;">{{showMessage}}</view>
 			</view>
 			</view>
+			<view @click="click" class="guide-next"
+				:style="{'top': (top-height-topMsgHeight+170) +'px', 'left': left<(winWidth/2)?left+'px':'' , 'right': left>(winWidth/2)?(winWidth-right) +'px':'' }">
+				<image mode="aspectFit" src="../../static/i_know.png" style="width: 200rpx; height: 100rpx;"></image>
+			</view>
 		</template>
 		</template>
 		<template v-if="noticeArray[currentIndex].type == 'right' ">
 		<template v-if="noticeArray[currentIndex].type == 'right' ">
 			<view class="show-message_right" :style="{'top': top +'px', 'left': (left+width+20) +'px' }">
 			<view class="show-message_right" :style="{'top': top +'px', 'left': (left+width+20) +'px' }">
@@ -20,15 +28,22 @@
 			</view>
 			</view>
 		</template>
 		</template>
 		<template v-if="noticeArray[currentIndex].type == 'bottom' ">
 		<template v-if="noticeArray[currentIndex].type == 'bottom' ">
+			<view class="arrow"
+				:style="{'height':'96rpx','width':'96rpx','top': (top+height) +'px', 'left': left<(winWidth/2)?left+'px':'' , 'right': left>(winWidth/2)?(winWidth-right) +'px':'' }">
+				<image mode="aspectFill" src="../../static/arrow-top.png" style="width: 96rpx;height: 96rpx;"></image>
+			</view>
 			<view :class="left<(winWidth/2)?'show-message_bottom_left':'show-message_bottom_right'"
 			<view :class="left<(winWidth/2)?'show-message_bottom_left':'show-message_bottom_right'"
-				:style="{'top': (top+height+15) +'px', 'left': left<(winWidth/2)?left+'px':'' , 'right': left>(winWidth/2)?(winWidth-right) +'px':'' }">
+				:style="{'top': (top+height+50) +'px', 'left': left<(winWidth/2)?left+'px':'' , 'right': left>(winWidth/2)?(winWidth-right) +'px':'' }">
 				<view style="padding: 12rpx 18rpx;">{{showMessage}}</view>
 				<view style="padding: 12rpx 18rpx;">{{showMessage}}</view>
 			</view>
 			</view>
+			<view @click="click" class="guide-next"
+				:style="{'top': (top+height+110) +'px', 'left': left<(winWidth/2)?left+'px':'' , 'right': left>(winWidth/2)?(winWidth-right) +'px':'' }">
+				<image mode="aspectFit" src="../../static/i_know.png" style="width: 200rpx; height: 100rpx;"></image>
+			</view>
 		</template>
 		</template>
-		<view class="cover-wrap">
-			<view class="guide-next" @tap="click"
-				:style="{color: '#000000'}">{{nextText}}</view>
-		</view>
+		<!-- <view class="cover-wrap">
+			<view class="guide-next" @tap="click" :style="{color: '#000000'}">{{nextText}}</view>
+		</view> -->
 	</view>
 	</view>
 </template>
 </template>
 
 
@@ -75,7 +90,7 @@
 		},
 		},
 		data() {
 		data() {
 			return {
 			return {
-				topMsgHeght: 0,
+				topMsgHeight: 0,
 				winWidth: 0,
 				winWidth: 0,
 				nextText: '下一步' // 知道了,关闭说明
 				nextText: '下一步' // 知道了,关闭说明
 			}
 			}
@@ -83,18 +98,16 @@
 		watch: {
 		watch: {
 			show(n) {},
 			show(n) {},
 			currentIndex(value) {
 			currentIndex(value) {
+				console.log('currentIndex', value)
 				if (value != this.noticeArray.length && this.noticeArray[value].type == 'top') {
 				if (value != this.noticeArray.length && this.noticeArray[value].type == 'top') {
 					const className = this.left < (this.winWidth / 2) ? '.show-message_top_left' :
 					const className = this.left < (this.winWidth / 2) ? '.show-message_top_left' :
 						'.show-message_top_right'
 						'.show-message_top_right'
 					const query = uni.createSelectorQuery().in(this);
 					const query = uni.createSelectorQuery().in(this);
 					query.select(className).boundingClientRect(data => {
 					query.select(className).boundingClientRect(data => {
 						// 29px 为一行语句的高度
 						// 29px 为一行语句的高度
-						this.topMsgHeght = data.height - 29
+						this.topMsgHeight = data.height - 29
 					}).exec();
 					}).exec();
 				}
 				}
-				if (value == this.noticeArray.length - 1) {
-					this.nextText = '我知道啦'
-				}
 			}
 			}
 		},
 		},
 		methods: {
 		methods: {
@@ -135,6 +148,10 @@
 		pointer-events: none;
 		pointer-events: none;
 	}
 	}
 
 
+	.arrow {
+		position: absolute;
+	}
+
 	.show-message_left,
 	.show-message_left,
 	.show-message_top_left,
 	.show-message_top_left,
 	.show-message_top_right,
 	.show-message_top_right,
@@ -148,7 +165,7 @@
 		pointer-events: none;
 		pointer-events: none;
 		color: #fff;
 		color: #fff;
 		font-size: 24rpx;
 		font-size: 24rpx;
-		max-width: 50%;
+		max-width: 30%;
 		text-align: left;
 		text-align: left;
 	}
 	}
 
 
@@ -165,18 +182,18 @@
 		right: -22rpx;
 		right: -22rpx;
 	}
 	}
 
 
-	.show-message_top_left::after,
-	.show-message_top_right::after {
-		content: '';
-		border-left: 12rpx solid transparent;
-		border-top: 12rpx solid rgba(0, 0, 0, .5);
-		border-right: 12rpx solid transparent;
-		border-bottom: 12rpx solid transparent;
-		width: 0;
-		height: 0;
-		position: absolute;
-		top: 100%;
-	}
+	// .show-message_top_left::after,
+	// .show-message_top_right::after {
+	// 	content: '';
+	// 	border-left: 12rpx solid transparent;
+	// 	border-top: 12rpx solid rgba(0, 0, 0, .5);
+	// 	border-right: 12rpx solid transparent;
+	// 	border-bottom: 12rpx solid transparent;
+	// 	width: 0;
+	// 	height: 0;
+	// 	position: absolute;
+	// 	top: 100%;
+	// }
 
 
 	.show-message_top_left::after {
 	.show-message_top_left::after {
 		left: 20%;
 		left: 20%;
@@ -199,18 +216,18 @@
 		left: -24rpx;
 		left: -24rpx;
 	}
 	}
 
 
-	.show-message_bottom_left::after,
-	.show-message_bottom_right::after {
-		content: '';
-		border-left: 12rpx solid transparent;
-		border-top: 12rpx solid transparent;
-		border-right: 12rpx solid transparent;
-		border-bottom: 12rpx solid rgba(0, 0, 0, .5);
-		width: 0;
-		height: 0;
-		position: absolute;
-		top: -22rpx;
-	}
+	// .show-message_bottom_left::after,
+	// .show-message_bottom_right::after {
+	// 	content: '';
+	// 	border-left: 12rpx solid transparent;
+	// 	border-top: 12rpx solid transparent;
+	// 	border-right: 12rpx solid transparent;
+	// 	border-bottom: 12rpx solid rgba(0, 0, 0, .5);
+	// 	width: 0;
+	// 	height: 0;
+	// 	position: absolute;
+	// 	top: -22rpx;
+	// }
 
 
 	.show-message_bottom_left::after {
 	.show-message_bottom_left::after {
 		left: 20%;
 		left: 20%;
@@ -220,25 +237,30 @@
 		right: 20%;
 		right: 20%;
 	}
 	}
 
 
-	.cover-wrap {
-		width: 100vw;
-		height: 100vh;
-		top: 0;
-		left: 0;
+	.guide-next {
 		position: absolute;
 		position: absolute;
-
-		.guide-next {
-			// padding: 0 40rpx;
-			padding: 16rpx 32rpx;
-			height: 40rpx;
-			background-color: #FFFFFF;
-			text-align: center;
-			font-size: 28rpx;
-			border-radius: 38rpx;
-			position: absolute;
-			bottom: 60rpx;
-			left: 50%;
-			transform: translate(-50%, 0);
-		}
 	}
 	}
+
+	// .cover-wrap {
+	// 	width: 100vw;
+	// 	height: 100vh;
+	// 	top: 0;
+	// 	left: 0;
+	// 	position: absolute;
+
+	// 	.guide-next {
+	// 		position: absolute;
+	// 		padding: 0 40rpx;
+	// 		padding: 16rpx 32rpx;
+	// 		height: 40rpx;
+	// 		background-color: #FFFFFF;
+	// 		text-align: center;
+	// 		font-size: 28rpx;
+	// 		border-radius: 38rpx;
+	// 		position: absolute;
+	// 		bottom: 60rpx;
+	// 		left: 50%;
+	// 		transform: translate(-50%, 0);
+	// 	}
+	// }
 </style>
 </style>

+ 13 - 11
pages/home/home.vue

@@ -66,7 +66,7 @@
 			</view>
 			</view>
 		</view>
 		</view>
 		<guide :show="showGuide" :width="cWidth" :height="cHeight" :left="cLeft" :right="cRight" :top="cTop"
 		<guide :show="showGuide" :width="cWidth" :height="cHeight" :left="cLeft" :right="cRight" :top="cTop"
-			:showMessage='cShowMsg' :currentIndex="currentIndex" :noticeArray="noticeArray" @click="clicktoNext">
+			:showMessage='cShowMsg' :currentIndex="currentIndex" :noticeArray="noticeArray" @click="clickNext">
 		</guide>
 		</guide>
 	</view>
 	</view>
 </template>
 </template>
@@ -137,11 +137,11 @@
 						"showMessage": "如面部无法识别, 点击进入手机开门界面",
 						"showMessage": "如面部无法识别, 点击进入手机开门界面",
 						"type": "top"
 						"type": "top"
 					},
 					},
-					{
-						"showID": "shop",
-						"showMessage": "点击进入酒店小超市, 挑选心仪商品",
-						"type": "top"
-					}
+					// {
+					// 	"showID": "shop",
+					// 	"showMessage": "点击进入酒店小超市, 挑选心仪商品",
+					// 	"type": "top"
+					// }
 				],
 				],
 				appId: ''
 				appId: ''
 			};
 			};
@@ -191,7 +191,7 @@
 					url: '/subpkg/chooseHotel/chooseHotel?source=home'
 					url: '/subpkg/chooseHotel/chooseHotel?source=home'
 				})
 				})
 			},
 			},
-			clicktoNext() {
+			clickNext() {
 				console.log('点击了下一个')
 				console.log('点击了下一个')
 				if (this.currentIndex >= this.noticeArray.length) {
 				if (this.currentIndex >= this.noticeArray.length) {
 					this.showGuide = false;
 					this.showGuide = false;
@@ -229,7 +229,11 @@
 			}
 			}
 		},
 		},
 		async onLoad() {
 		async onLoad() {
-			const {miniProgram: {appId}} = uni.getAccountInfoSync();
+			const {
+				miniProgram: {
+					appId
+				}
+			} = uni.getAccountInfoSync();
 			this.appId = appId
 			this.appId = appId
 			// console.log(__wxConfig)
 			// console.log(__wxConfig)
 			//获取openid
 			//获取openid
@@ -279,10 +283,8 @@
 			//显示引导
 			//显示引导
 			// uni.setStorageSync('showGuide', true)
 			// uni.setStorageSync('showGuide', true)
 			let showGuide = uni.getStorageSync('showGuide')
 			let showGuide = uni.getStorageSync('showGuide')
-			console.log(typeof showGuide)
-			console.log(showGuide)
-			console.log(showGuide === '')
 			if (showGuide === '') {
 			if (showGuide === '') {
+				// if (true) {
 				this.showGuide = true
 				this.showGuide = true
 				uni.setStorageSync('showGuide', 'false')
 				uni.setStorageSync('showGuide', 'false')
 				let _this = this;
 				let _this = this;