浏览代码

Signed-off-by: 李妹妹 <1639016684@qq.com>

李妹妹 2 周之前
父节点
当前提交
f0532dfca3

+ 14 - 13
pages/shopping/paymentOrder.vue

@@ -390,10 +390,10 @@
 				// 2. 检查 maOpenId,但不要直接修改字符串
 				// 3. 检查用户信息是否有效
 				if (!this.userinfo || Object.keys(this.userinfo).length === 0) {
-					uni.showToast({
-						title: '用户信息异常,请重新登录',
-						icon: 'none'
-					});
+					// uni.showToast({
+					// 	title: '用户信息异常,请重新登录',
+					// 	icon: 'none'
+					// });
 
 					// 直接跳转到登录页
 					this.redirectToLogin();
@@ -402,15 +402,16 @@
 
 				// 4. 检查 maOpenId,如果不存在则提示重新登录
 				if (!this.userinfo.maOpenId) {
-					uni.showModal({
-						title: '提示',
-						content: '用户信息不完整,需要重新登录',
-						success: (res) => {
-							if (res.confirm) {
-								this.redirectToLogin();
-							}
-						}
-					});
+					// uni.showModal({
+					// 	title: '提示',
+					// 	content: '用户信息不完整,需要重新登录',
+					// 	success: (res) => {
+					// 		if (res.confirm) {
+					// 			this.redirectToLogin();
+					// 		}
+					// 	}
+					// });
+					this.redirectToLogin();
 					return;
 				}
 

文件差异内容过多而无法显示
+ 298 - 243
pages/shopping/productDetails.vue


+ 2 - 2
pages/user/index.vue

@@ -181,12 +181,12 @@
 
 
 							<!-- 测试用下面的 -->
-							<view class="item no-marin-bottom align-top" @click="navgetTo('/pages_course/livingList')">
+							<!-- <view class="item no-marin-bottom align-top" @click="navgetTo('/pages_course/livingList')">
 								<image
 									src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/shop/images/integral.png"
 									mode=""></image>
 								<text class="text">直播</text>
-							</view>
+							</view> -->
 
 							<view class="item no-marin-bottom" @click="toManager()">
 								<image

+ 204 - 126
pages_course/living.vue

@@ -87,7 +87,7 @@
 							</view>
 							<view class="viewer-count ">{{formattedWatchCount || 0 }}</view>
 						</view>
-					
+
 					</view>
 				</view>
 
@@ -103,6 +103,7 @@
 
 				<view class="videolist" v-if="liveItem.status == 2" :class="isFullscreen ? 'screen' : ''">
 					<view class="video-container"
+						:style="{ paddingBottom: liveItem.showType==2||isFullscreen?'':videoRatio + '%',height:liveItem.showType==2?'100vh':'auto',width:isFullscreen?'0':'100%'}"
 						:class="{'horizontal-layout': liveItem.showType == 1,'fullscreen-mode': isFullscreen}">
 						<!-- <video v-if="liveItem.videoUrl && liveItem.liveType == 2 && !generating"
 							:id="`myVideo_${liveId}`" :autoplay="true" class="video-player" :src="liveItem.videoUrl"
@@ -120,19 +121,21 @@
 						</video> -->
 						<video v-if="liveItem.videoUrl && liveItem.liveType == 2 && !generating"
 							:id="`myVideo_${liveId}`" :autoplay="true" class="video-player" :src="liveItem.videoUrl"
-							:object-fit="isFullscreen?'contain':'cover'" :custom-cache="false" :enable-progress-gesture="false"
-							vslide-gesture-in-fullscreen="false" :show-center-play-btn="false" :http-cache="false" loop
-							@error="videoError" @timeupdate="onVideoTimeUpdate" @loadedmetadata="onVideoMetaLoaded"
-							@pause="onVideoPause" @play="onVideoPlay" @waiting="onVideoWaiting"
-							:enable-play-gesture="false" :play-strategy="1" @dblclick="preventDoubleClick"
-							preload="auto" :enable-stash-buffer="false" :stash-initial-size="0" :stash-max-size="0"
-							:stash-time="0" type="application/x-mpegURL" :controls="false" :show-fullscreen-btn="false"
-							show-play-btn show-mute-btn enable-play-gesture="true"
-							@fullscreenchange="onFullscreenChange" x5-video-player-fullscreen="false"
-							x5-video-player-type="h5" x5-video-orientation="landscape" :webkit-playsinline="true"
-							playsinline="true" :x5-playsinline="true">
+							:style="{transform: `scale(${scale})`, transformOrigin: 'center center', bottom:isFullscreen?'0':''}"
+							:object-fit="liveItem.showType==2?'contain':'fill'" :custom-cache="false"
+							:enable-progress-gesture="false" vslide-gesture-in-fullscreen="false"
+							:show-center-play-btn="false" :http-cache="false" loop @error="videoError"
+							@timeupdate="onVideoTimeUpdate" @loadedmetadata="onVideoMetaLoaded" @pause="onVideoPause"
+							@play="onVideoPlay" @waiting="onVideoWaiting" :enable-play-gesture="false"
+							:play-strategy="1" @dblclick="preventDoubleClick" preload="auto"
+							:enable-stash-buffer="false" :stash-initial-size="0" :stash-max-size="0" :stash-time="0"
+							type="application/x-mpegURL" :controls="false" :show-fullscreen-btn="false" show-play-btn
+							show-mute-btn enable-play-gesture="true" @fullscreenchange="onFullscreenChange"
+							x5-video-player-fullscreen="false" x5-video-player-type="h5"
+							x5-video-orientation="landscape" :webkit-playsinline="true" playsinline="true"
+							:x5-playsinline="true">
 						</video>
-                        <view v-else class="txt">回放生成中...</view>
+						<view v-else class="txt">回放生成中...</view>
 						<view v-if="showCustomControls && liveItem.showType==1 && !isFullscreen" class="custom-controls"
 							@click.stop="toggleFullscreen">
 							<image src="/static/images/full_screen.png" class="control-icon" />
@@ -147,22 +150,22 @@
 						<!-- 投诉按钮 -->
 						<view v-if="liveItem.showType==2||isFullscreen" class="complaint-box"
 							:class="isFullscreen ? 'complaint-full' : ''"
+							:style="{top:isFullscreen?'':'15%',bottom:isFullscreen?'86vw':''}"
 							@click="navgetTo('/pages_shopping/live/complaintList') ">
 							<image class="image w32 h32 mr10" src="/static/images/complaint.png" mode="widthFix" />
 							<view class="fs26">投诉</view>
 						</view>
 
 						<!-- 回放标签 -->
-						<view v-if="isPlayback" class="replay-label" 
-						:style="{top:liveItem.showType === 2 ?'16%':'10%'}"
-						:class="isFullscreen? 'replay-full' : ''">回放
+						<view v-if="isPlayback" class="replay-label" :style="{top:liveItem.showType === 2?'22%':isFullscreen?'':'10%',bottom:isFullscreen?'75vw':''}"
+							:class="isFullscreen? 'replay-full' : ''">回放
 						</view>
 					</view>
 				</view>
 				<!-- 直播结束状态 -->
 				<!-- v-if="liveItem.status == 3" -->
 				<view class="videolist" v-if="liveItem.status == 3">
-					<view class="video-container"
+					<view class="video-container" style="height: 500rpx;"
 						:class="{'horizontal-layout': liveItem.showType == 1, 'fullscreen-mode': isFullscreen}">
 						<view class="live-end-message">直播已结束</view>
 					</view>
@@ -173,7 +176,7 @@
 					<view class="video-container" :class="liveItem.showType == 1 ? 'horizontal-layout' : ''">
 						<video v-if="liveItem.videoUrl && liveItem.liveType == 3" :id="`myVideo_${liveId}`"
 							class="video-player" :src="liveItem.videoUrl" :autoplay="true" :controls="true"
-							:object-fit="isFullscreen?'contain':'cover'" :custom-cache="false"
+							:object-fit="isFullscreen?'contain':'contain'" :custom-cache="false"
 							:enable-progress-gesture="liveItem.isSpeedAllowed" vslide-gesture-in-fullscreen="true"
 							:show-center-play-btn="true" :http-cache="false" loop @error="videoError"
 							@timeupdate="onVideoTimeUpdate" @loadedmetadata="onVideoMetaLoaded" @pause="onVideoPause"
@@ -207,7 +210,7 @@
 				    'chat-area-container2': liveItem.showType == 1,
 					'chat-area-container3': liveItem.status == 1,
 				    'chat-area-focused': isFocus
-				  }" :style="{ '--keyboard-height': keyboardHeight + 'rpx' }">
+				  }" :style="{ '--keyboard-height': keyboardHeight + 'rpx' ,'display':isFullscreen?'none':''}">
 					<view class="tabs_bg" v-if="liveItem.showType == 1">
 						<u-tabs :list="listTabs" @click="clickTabs" lineColor="#02B176"
 							:activeStyle="{color: '#02B176',fontWeight: 'bold',transform: 'scale(1.05)'}">
@@ -226,6 +229,7 @@
 							公告消息: {{notice.msg}}
 						</view>
 						<scroll-view id="msgScroll" v-if="Array.isArray(talklist)" enable-flex scroll-y="true"
+						:style="{ height: `calc(100% - ${commonViewHeight}px)`,marginTop:commonViewHeight+'px' }"
 							:enhanced="true" :bounces="false" :show-scrollbar="false" :fast-deceleration="false"
 							:enable-back-to-top="false" class="message-scroll-view"
 							:class="liveItem.status == 1 ? 'message-scroll2' : ''" :scroll-top="scrollTop"
@@ -463,16 +467,16 @@
 			</u-popup>
 
 			<!-- 消息弹窗 -->
-			<u-popup  :show="isShowPopMsg" round="20rpx" mode="center" zIndex="10076">
-							<view class="message-popup">
-								<image class="message-close-icon"
-									src="/static/images/message_icon.png"/>
-								<view class="message-title">消息通知</view>
-								<view class="message-content">{{popMsg}}</view>
-								<view class="message-confirm-button" @click="isShowPopMsg = false">确认</view>
-								<image src="/static/images/close_white_icon.png" class="close" @click="isShowPopMsg = false"></image>
-							</view>
-						</u-popup>
+			<u-popup :show="isShowPopMsg" round="20rpx" mode="center" zIndex="10076">
+				<view class="message-popup">
+					<image class="message-close-icon" src="/static/images/message_icon.png" />
+					<view class="message-title">消息通知</view>
+					<view class="message-content">{{popMsg}}</view>
+					<view class="message-confirm-button" @click="isShowPopMsg = false">确认</view>
+					<image src="/static/images/close_white_icon.png" class="close" @click="isShowPopMsg = false">
+					</image>
+				</view>
+			</u-popup>
 
 
 			<!-- 中奖和未中奖 -->
@@ -735,11 +739,13 @@
 		},
 		data() {
 			return {
-				menuButtonInfo:{},// 胶囊按钮布局信息
+				menuButtonInfo: {}, // 胶囊按钮布局信息
+
 				isFullscreen: false,
 				isVideoRotated: false,
 				showNonVideoElementsFlag: true,
-
+				videoRatio: 56.25, // 默认16:9比例
+				scale: 1,
 				isMuted: false,
 				showCustomControls: true,
 				videoContext: null,
@@ -875,7 +881,7 @@
 				isFocus: false,
 				shopping: false,
 				systemInfo: null, // 缓存系统信息,避免重复调用同步API
-
+				generatingTimer: null, //回访生成中
 				inputInfo: '',
 				showWelcomeMessage: false,
 				isShowGoods: false,
@@ -908,11 +914,12 @@
 				userData: {},
 				diffTotalTime: '',
 				address: '',
+				commonViewHeight: '',
 				user: {}
 			};
 		},
 		async onLoad(options) {
-            this.getMenuButtonInfo(); // 初始化获取胶囊信息
+			this.getMenuButtonInfo(); // 初始化获取胶囊信息
 			this.initTime()
 			this.getLocationByIP();
 			if (options.liveId) {
@@ -1023,7 +1030,6 @@
 			// 监听视频全屏事件
 			setTimeout(() => {
 				this.videoContext = uni.createVideoContext(`myVideo_${this.liveId}`, this);
-
 				// 添加全屏状态变化监听(更可靠的方式)
 				if (this.videoContext) {
 					// 使用 uni.onUserCaptureScreen 作为备选方案
@@ -1048,7 +1054,6 @@
 				console.error('初始化失败:', error);
 			}
 
-
 			this.getLocationByIP();
 
 			this.uuId = generateRandomString(16);
@@ -1110,7 +1115,7 @@
 			this.startTimer();
 
 			this.$nextTick(() => {
-				console.log(444,this.userInfo);
+				console.log(444, this.userInfo);
 				if (!this.userInfo || !this.userInfo.nickname) {
 					console.log('用户信息不完整,显示授权弹窗');
 					this.userlogo = true;
@@ -1368,23 +1373,42 @@
 					}
 				},
 				immediate: true
-			}
+			},
+			'isShowNotice': {
+							handler(newVal, oldVal) {
+								setTimeout(() => {
+									this.noticeHeightFun()
+								}, 800)
+							},
+							immediate: true
+						}
 		},
-		methods: { 
+		methods: {
+			noticeHeightFun() {
+				const query = uni.createSelectorQuery().in(this);
+				query.select('.notice-message').boundingClientRect(rect => {
+					if (rect) {
+						this.commonViewHeight = rect.height;
+						this.forceScrollToBottomOnSend();
+					} else {
+						this.commonViewHeight = ''
+					}
+				}).exec();
+			},
 			// 获取胶囊按钮布局参数
-			    getMenuButtonInfo() {
-			      // 微信小程序API(Uniapp可直接用uni.getMenuButtonBoundingClientRect)
-			      const menuBtn = uni.getMenuButtonBoundingClientRect();
-			      if (menuBtn) {
-					  
-			        this.menuButtonInfo = {
-			          top: menuBtn.top + 'px', // 胶囊顶部距离
-			          height: menuBtn.height + 'px', // 胶囊高度
-			          centerY: (menuBtn.top + menuBtn.height / 2) + 'px', // 胶囊垂直居中Y坐标
-			          right: menuBtn.right + 'px' // 胶囊右侧距离
-			        };
-			      }
-			    },
+			getMenuButtonInfo() {
+				// 微信小程序API(Uniapp可直接用uni.getMenuButtonBoundingClientRect)
+				const menuBtn = uni.getMenuButtonBoundingClientRect();
+				if (menuBtn) {
+
+					this.menuButtonInfo = {
+						top: menuBtn.top + 'px', // 胶囊顶部距离
+						height: menuBtn.height + 'px', // 胶囊高度
+						centerY: (menuBtn.top + menuBtn.height / 2) + 'px', // 胶囊垂直居中Y坐标
+						right: menuBtn.right + 'px' // 胶囊右侧距离
+					};
+				}
+			},
 			// 退出全屏
 			exitFullscreen() {
 				console.log('执行退出全屏');
@@ -1502,7 +1526,6 @@
 			enterFullscreen() {
 				console.log('执行进入全屏');
 				this.isFullscreen = true;
-
 				// 设置横屏样式
 				this.rotateVideoList();
 
@@ -2275,7 +2298,7 @@
 					'trafficTimer', 'pingTimeoutTimer', 'heartBeatTimer', 'liveViewDataTimer',
 					'reconnectTimer', 'scrollTimer', 'searchTimer', 'purchasePromptTimer',
 					'welcomeTimer', 'redTimer', 'liveStartTimer', 'lotteryTimer',
-					'memoryMonitorTimer', 'networkStatusTimer', 'networkRetryTimer'
+					'memoryMonitorTimer', 'networkStatusTimer', 'networkRetryTimer', 'generatingTimer'
 				];
 
 				return timers.filter(timer => this[timer] !== null).length;
@@ -2288,7 +2311,7 @@
 					'trafficTimer', 'pingTimeoutTimer', 'heartBeatTimer', 'liveViewDataTimer',
 					'reconnectTimer', 'scrollTimer', 'searchTimer', 'purchasePromptTimer',
 					'welcomeTimer', 'redTimer', 'liveStartTimer', 'lotteryTimer', 'noticeTimer',
-					'networkStatusTimer', 'networkRetryTimer'
+					'networkStatusTimer', 'networkRetryTimer', 'generatingTimer'
 				];
 
 				timers.forEach(timerName => {
@@ -2374,7 +2397,8 @@
 					'searchTimer',
 					'purchasePromptTimer',
 					'heartBeatTimer',
-					'pingTimeoutTimer'
+					'pingTimeoutTimer',
+					'generatingTimer'
 				];
 
 				timers.forEach((timer) => {
@@ -3038,6 +3062,22 @@
 			// 录播时间点
 			onVideoMetaLoaded(e) {
 				console.log("录播时间点", e)
+				const width = e.detail.width;
+				const height = e.detail.height;
+				const res = uni.getSystemInfoSync();
+				const winH = res.windowHeight;
+				const winW = res.windowWidth;
+				//横屏
+				const wW = (winW / winH) * 100;
+				//竖屏
+				const wH = (winH / winW) * 100;
+				if (this.liveItem.showType == 2) {
+					const videoRatio = (height / width) * 100;
+					this.scale = wH / videoRatio;
+					console.log("比例", this.videoRatio, width, height)
+				} else if (this.isFullscreen) {
+					this.scale = wW / this.videoRatio;
+				}
 				this.videoProgressKey = `videoProgress_${this.liveId}`;
 				this.setVideoProgress();
 			},
@@ -3782,7 +3822,39 @@
 					this.$set(this.liveItem, 'showType', res.data.showType);
 					this.storeId = res.storeId;
 					this.startLiveViewDataTimer();
-					this.playVideo();
+					const diff = this.getTimeDifferenceInSeconds(this.liveItem.startTime)
+					if (diff >= this.liveItem.duration) {
+						const diffTime = diff - this.liveItem.duration
+						if (diffTime < 180) {
+							this.generating = true;
+
+							// 计算剩余等待时间
+							const remainingTime = Math.max(0, 180 - diffTime) * 1000;
+
+							if (this.generatingTimer) {
+								clearTimeout(this.generatingTimer);
+							}
+
+							this.generatingTimer = setTimeout(() => {
+								this.generating = false;
+								this.hasPlayback = true;
+								this.playVideo();
+								this.closeWebSocket(true);
+								this.isEnd = true;
+							}, remainingTime);
+
+						} else {
+							// 已经超过18秒,应该直接播放
+							this.generating = false;
+							this.hasPlayback = true;
+							this.playVideo();
+							this.closeWebSocket(true);
+							this.isEnd = true;
+						}
+					} else {
+						// 直播还未结束,正常播放
+						this.playVideo();
+					}
 				} catch (err) {
 					console.error('获取直播信息失败:', err);
 					uni.showToast({
@@ -4655,13 +4727,15 @@
 	.video-container.fullscreen-mode .fullscreen-exit-btn {
 		z-index: 999999 !important;
 	}
-     .fullscreen-mode {
-     		background-color: #000 !important;
-     	}
+
+	.fullscreen-mode {
+		background-color: #000 !important;
+	}
+
 	/* 全屏模式样式 */
 	.video-container.fullscreen-mode {
-		width: auto !important;
-		height: auto !important;
+		// width: auto !important;
+		// height: auto !important;
 		z-index: 99999 !important;
 		background-color: #000 !important;
 		transform: rotate(90deg) !important;
@@ -4680,6 +4754,8 @@
 	}
 
 	.video-container {
+		position: relative;
+		bottom: -1px;
 		transition: all 0.3s ease;
 	}
 
@@ -4942,7 +5018,8 @@
 					// margin-top:calc(var(--status-bar-height) + 10rpx);
 					display: flex;
 					justify-content: space-between;
-                    flex-direction: column;
+					flex-direction: column;
+
 					&.horizontal-top {
 						position: static;
 						margin-bottom: 30rpx;
@@ -4974,7 +5051,7 @@
 
 					.viewers-section {
 						display: flex;
-						justify-content:flex-end;
+						justify-content: flex-end;
 						align-items: center;
 						margin-top: 30rpx;
 
@@ -5036,16 +5113,17 @@
 				// 视频区域
 				.videolist {
 					position: relative;
-					height: var(--video-height);
+					// height: var(--video-height);
 					width: 100%;
 
 					&.screen {
-						width: 100vw;
-						height: 100vh;
+						width: 100%;
+						height: 100%;
+						//height: 100vh;
 					}
 
 					.video-container {
-						height: var(--video-height);
+						//height: var(--video-height);
 						width: 100%;
 						transform: translateZ(0);
 						backface-visibility: hidden;
@@ -5060,7 +5138,7 @@
 
 						.complaint-box {
 							position: absolute;
-							top: 20%;
+							// top: 20%;
 							right: 20rpx;
 							width: 140rpx;
 							margin-top: 20rpx;
@@ -5071,10 +5149,9 @@
 							padding: 16rpx 0;
 							color: #fff;
 							border-radius: 28rpx;
-							z-index: 999;
-
+							z-index: 999999 !important;
 							&.complaint-full {
-								top: 10rpx;
+								// top: 10rpx;
 								left: 82vh;
 							}
 
@@ -5094,7 +5171,7 @@
 						.video-player {
 							width: 100%;
 							height: 100%;
-							position: relative;
+							position: absolute;
 							z-index: 1;
 						}
 
@@ -5109,7 +5186,7 @@
 
 						.replay-label {
 							position: absolute;
-							top: 10%;
+							// top: 10%;
 							right: 24rpx;
 							background-color: rgba(57, 57, 57, 0.6);
 							width: 100rpx;
@@ -5118,11 +5195,11 @@
 							text-align: center;
 							color: #fff;
 							border-radius: 15rpx;
-							z-index: 1;
+							z-index: 999999 !important;
 
 							&.replay-full {
 								left: 82vh;
-								top: 16%!important;
+								// top: 16% !important;
 							}
 						}
 					}
@@ -5973,57 +6050,58 @@
 
 			// 消息弹窗
 			.message-popup {
-							display: flex;
-							flex-direction: column;
-							position: relative;
-							align-items: center;
-							padding: 126rpx 48rpx 0;
-							width: 554rpx;
-							box-sizing: border-box;
-							background: linear-gradient( 180deg, #E2FCEF 0%, rgba(226,252,239,0) 100%);
-							border-radius: 62rpx 62rpx 0rpx 0rpx;
-			
-							.message-close-icon {
-								position: absolute;
-								z-index: 9;
-								top: -74rpx;
-								width: 176rpx;
-								height: 176rpx;
-							}
-			
-							.message-title {
-								font-weight: 600;
-								font-size: 36rpx;
-								color: #333333;
-								margin: 24rpx 0 28rpx;
-							}
-			
-							.message-content {
-								margin-bottom: 52rpx;
-								font-weight: 400;
-								font-size: 28rpx;
-								color: #333333;
-							}
-			
-							.message-confirm-button {
-								width: 358rpx;
-								height: 88rpx;
-								line-height: 88rpx;
-								background: linear-gradient( 136deg, #38D97D 0%, #02B176 100%);
-								border-radius: 44rpx 44rpx 44rpx 44rpx;
-								font-weight: 600;
-								font-size: 32rpx;
-								text-align: center;
-								color: #FFFFFF;
-							}
-							.close{
-								position: absolute;
-								z-index: 9;
-								bottom: -168rpx;
-								width: 64rpx;
-								height: 64rpx;
-							}
-						}
+				display: flex;
+				flex-direction: column;
+				position: relative;
+				align-items: center;
+				padding: 126rpx 48rpx 0;
+				width: 554rpx;
+				box-sizing: border-box;
+				background: linear-gradient(180deg, #E2FCEF 0%, rgba(226, 252, 239, 0) 100%);
+				border-radius: 62rpx 62rpx 0rpx 0rpx;
+
+				.message-close-icon {
+					position: absolute;
+					z-index: 9;
+					top: -74rpx;
+					width: 176rpx;
+					height: 176rpx;
+				}
+
+				.message-title {
+					font-weight: 600;
+					font-size: 36rpx;
+					color: #333333;
+					margin: 24rpx 0 28rpx;
+				}
+
+				.message-content {
+					margin-bottom: 52rpx;
+					font-weight: 400;
+					font-size: 28rpx;
+					color: #333333;
+				}
+
+				.message-confirm-button {
+					width: 358rpx;
+					height: 88rpx;
+					line-height: 88rpx;
+					background: linear-gradient(136deg, #38D97D 0%, #02B176 100%);
+					border-radius: 44rpx 44rpx 44rpx 44rpx;
+					font-weight: 600;
+					font-size: 32rpx;
+					text-align: center;
+					color: #FFFFFF;
+				}
+
+				.close {
+					position: absolute;
+					z-index: 9;
+					bottom: -168rpx;
+					width: 64rpx;
+					height: 64rpx;
+				}
+			}
 
 			// 中奖弹窗
 			.prize-popup {

+ 70 - 53
pages_shopping/live/goods.vue

@@ -36,7 +36,9 @@
 			<view class="safe-box">
 				<text class="text">服务</text>
 				<view class="box">
-					<image class="mr20" src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/userapp/images/safe.png" mode=""></image>
+					<image class="mr20"
+						src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/userapp/images/safe.png" mode="">
+					</image>
 					<view class="mr30" v-for="(item,index) in serviceList" :key="index">
 						<text>{{item}}</text>
 					</view>
@@ -64,7 +66,9 @@
 			<view class="product-spec">
 				<view class="pro-info">
 					<view class="img-box">
-						<image :src="goosDetail.image ||'https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/userapp/images/img.png'" mode="aspectFill"></image>
+						<image
+							:src="goosDetail.image ||'https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/userapp/images/img.png'"
+							mode="aspectFill"></image>
 					</view>
 					<view class="info-text">
 						<view class="info-title">{{goosDetail.productName}}</view>
@@ -78,25 +82,22 @@
 						</view>
 					</view>
 				</view>
-				
-				
+
+
 				<!-- 规格 -->
-				<view class="spec-box" >
+				<view class="spec-box">
 					<view v-for="(item,index) in attrs" :key="index">
 						<view class="title">{{item.attrName}}</view>
 						<view class="spec-list">
-							<view 
-								v-for="(subItem,subindex) in item.values" 
-								:key="subindex" 
-								:class="subindex==item.index?'item active':'item'" 
-								@click="choseSpec(index,subindex)">
+							<view v-for="(subItem,subindex) in item.values" :key="subindex"
+								:class="subindex==item.index?'item active':'item'" @click="choseSpec(index,subindex)">
 								{{ subItem }}
 							</view>
 						</view>
 					</view>
 				</view>
-				
-				
+
+
 
 				<view class="price-num">
 					<view class="label">数量</view>
@@ -109,7 +110,9 @@
 </template>
 
 <script>
-	import {liveGoodsDetail} from '@/api/living'
+	import {
+		liveGoodsDetail
+	} from '@/api/living'
 	import {
 		liveOrderKey, // 生成订单key
 	} from "@/api/order.js"
@@ -121,7 +124,7 @@
 		},
 		data() {
 			return {
-				attrs:[],
+				attrs: [],
 				banner: [],
 				goodsId: null,
 				totalNum: 1,
@@ -192,7 +195,8 @@
 							uni.navigateTo({
 								url: '/pages_shopping/live/confirmCreateOrder?&orderKey=' + this.orderKey +
 									'&liveId=' + this.liveId + '&goodsId=' + this.goodsId +
-									'&productId=' + this.productId + '&totalNum=' + this.totalNum+"&productValueSelect="+this.productValueSelect.id
+									'&productId=' + this.productId + '&totalNum=' + this.totalNum +
+									"&productValueSelect=" + this.productValueSelect.id
 							})
 						} else {
 							uni.showToast({
@@ -208,11 +212,11 @@
 			goodsNumChange(e) {
 				console.log('当前选择商品数量为: ' + e.value)
 				this.totalNum = e.value
-				if(this.totalNum < 1) {
+				if (this.totalNum < 1) {
 					this.totalNum = 1
 				}
-				if(this.totalNum>=this.productValueSelect.stock){
-					this.totalNum=this.productValueSelect.stock
+				if (this.totalNum >= this.productValueSelect.stock) {
+					this.totalNum = this.productValueSelect.stock
 				}
 			},
 			// 提交
@@ -222,6 +226,15 @@
 			},
 			// 加入购物车
 			addCart(type) {
+				if (type == 'buy') {
+					const userInfoStr = uni.getStorageSync('userInfo');
+					if (!userInfoStr || !userInfoStr.maOpenId) {
+						uni.navigateTo({
+							url: '/pages/auth/login'
+						});
+						return;
+					}
+				}
 				this.type = type;
 				this.specVisible = true
 			},
@@ -236,14 +249,14 @@
 						if (res.code == 200) {
 							this.goosDetail = res.product
 							this.banner = res.product.sliderImage.split(',');
-							
-							this.attrs=res.productAttr;
-							this.attrs.forEach((item,index,arr)=>{
-							     item.values=item.attrValues.split(',');
-								 item.index=0
+
+							this.attrs = res.productAttr;
+							this.attrs.forEach((item, index, arr) => {
+								item.values = item.attrValues.split(',');
+								item.index = 0
 							});
-							this.values=res.productValues;
-							this.choseSpec(0,0)
+							this.values = res.productValues;
+							this.choseSpec(0, 0)
 						} else {
 							uni.showToast({
 								title: res.msg,
@@ -254,46 +267,45 @@
 					rej => {}
 				);
 			},
-			getValueSelect(){
-				var valueSelect=this.values.filter((item)=>{
-				     return item.sku==this.selectVal;
+			getValueSelect() {
+				var valueSelect = this.values.filter((item) => {
+					return item.sku == this.selectVal;
 				});
 				return valueSelect;
 			},
 			// 规格选择
-			choseSpec(index,subIndex) {
+			choseSpec(index, subIndex) {
 				this.attrs[index].index = subIndex;
 				this.$forceUpdate();
 				let productAttr = this.attrs;
 				let values = [];
 				for (let i = 0; i < productAttr.length; i++) {
-				   for (let j = 0; j < productAttr[i].values.length; j++) {
-					  if (productAttr[i].index === j) {  //筛选出默认规格
-					     values.push(productAttr[i].values[j]);
-					  }
-				   }
+					for (let j = 0; j < productAttr[i].values.length; j++) {
+						if (productAttr[i].index === j) { //筛选出默认规格
+							values.push(productAttr[i].values[j]);
+						}
+					}
 				}
-				let selectVal=values.sort().join(","); //返回值:默认
-				this.selectVal=selectVal;
+				let selectVal = values.sort().join(","); //返回值:默认
+				this.selectVal = selectVal;
 				// var valueSelect=this.values.filter((item)=>{
 				//      return item.sku==selectVal;
 				// });
-				var valueSelect=this.getValueSelect();
-				console.log("qxj valueSelect:"+valueSelect);
-				if(valueSelect!=null&&valueSelect.length>0){
-					this.productValueSelect=valueSelect[0];
+				var valueSelect = this.getValueSelect();
+				console.log("qxj valueSelect:" + valueSelect);
+				if (valueSelect != null && valueSelect.length > 0) {
+					this.productValueSelect = valueSelect[0];
 				}
-				console.log("qxj productValueSelect:"+JSON.stringify(this.productValueSelect));
+				console.log("qxj productValueSelect:" + JSON.stringify(this.productValueSelect));
 				this.updateSpecNum();
-				
+
 			},
 			//更新数量
-			updateSpecNum(){
-				if(this.productValueSelect.stock==0){
-					this.totalNum=0;
-				}
-				else{
-					this.totalNum=1;
+			updateSpecNum() {
+				if (this.productValueSelect.stock == 0) {
+					this.totalNum = 0;
+				} else {
+					this.totalNum = 1;
 				}
 			}
 		}
@@ -626,20 +638,24 @@
 				}
 			}
 		}
-.spec-box{
+
+		.spec-box {
 			padding-top: 50upx;
-			.title{
+
+			.title {
 				font-size: 34upx;
 				font-family: PingFang SC;
 				font-weight: bold;
 				color: #111111;
 				line-height: 1;
 			}
-			.spec-list{
+
+			.spec-list {
 				display: flex;
 				flex-wrap: wrap;
 				margin-top: 30upx;
-				.item{
+
+				.item {
 					box-sizing: border-box;
 					height: 64upx;
 					padding: 0 30upx;
@@ -653,7 +669,8 @@
 					border-radius: 32upx;
 					margin-right: 20upx;
 					margin-bottom: 30upx;
-					&.active{
+
+					&.active {
 						background: #F1FFFE;
 						border: 1px solid #8AD5CE;
 						color: #2BC7B9;

+ 14 - 13
pages_shopping/live/paymentOrder.vue

@@ -242,10 +242,10 @@
 
 				// 3. 检查用户信息是否有效
 				if (!this.userinfo || Object.keys(this.userinfo).length === 0) {
-					uni.showToast({
-						title: '用户信息异常,请重新登录',
-						icon: 'none'
-					});
+					// uni.showToast({
+					// 	title: '用户信息异常,请重新登录',
+					// 	icon: 'none'
+					// });
 					
 					// 直接跳转到登录页
 					this.redirectToLogin();
@@ -253,15 +253,16 @@
 				}
 				// 4. 检查 maOpenId,如果不存在则提示重新登录
 				if (!this.userinfo.maOpenId) {
-					uni.showModal({
-						title: '提示',
-						content: '用户信息不完整,需要重新登录',
-						success: (res) => {
-							if (res.confirm) {
-								this.redirectToLogin();
-							}
-						}
-					});
+					// uni.showModal({
+					// 	title: '提示',
+					// 	content: '用户信息不完整,需要重新登录',
+					// 	success: (res) => {
+					// 		if (res.confirm) {
+					// 			this.redirectToLogin();
+					// 		}
+					// 	}
+					// });
+					this.redirectToLogin();
 					return;
 				}
 

+ 1 - 1
pages_user/user/storeOrderDetail.vue

@@ -158,7 +158,7 @@
 						<!-- 已优惠、小计 -->
 						<view class="sub-total">
 							<view class="discount">
-								商品金额:¥{{order.payPrice}}
+								商品金额:¥{{order.totalPrice}}
 							</view>
 							<!-- <text class="label">实付金额:</text>
 							<view class="price">

部分文件因为文件数量过多而无法显示