htc 2 дней назад
Родитель
Сommit
860336d4a1
5 измененных файлов с 78 добавлено и 9 удалено
  1. 8 1
      common/stores/user.js
  2. 1 1
      pages/home.vue
  3. 1 1
      pages/my.vue
  4. 66 4
      pagesHome/activityDetail.vue
  5. 2 2
      pagesMy/exclusiveScroll.vue

+ 8 - 1
common/stores/user.js

@@ -7,7 +7,8 @@ export const useUserStore = defineStore('user', {
 		isLogin: false,        // 用户是否已登录
 		showLoginModal: false, // 是否显示登录弹框
 		token:'',
-		userInfo: null,        // 用户信息
+		userInfo: null,        // 用户信息
+		inpage:false,			//是否当前页面
 	}),
 	getters: {
 		// 方便在模板中直接使用
@@ -60,6 +61,12 @@ export const useUserStore = defineStore('user', {
 					this.token = res.data?.token;
 					this.userInfo = res.data;
 					uni.setStorageSync('token',this.userInfo?.token)
+					
+					const currentDate = new Date();
+					const futureDate = new Date(currentDate);
+					futureDate.setDate(currentDate.getDate() + 7);
+					uni.setStorageSync('expaireTime',Date.parse(futureDate))
+					
 					uni.setStorageSync('userInfo',JSON.stringify(this.userInfo))
 					uni.showToast({
 						title: '登录成功',

+ 1 - 1
pages/home.vue

@@ -3,7 +3,7 @@
 		<up-navbar title=" " bgColor="transparent">
             <template #left>
 				<view class="u-nav-slot" slot="left" style="display: flex;background-color: transparent;">
-					<image src="https://oss.familydaf.cn/sxsnfile/20251218/4717d4567e404bd0bdf4f5c642acbffd.png" style="width: 370rpx;height: 40rpx;"></image>
+					<image src="https://oss.familydaf.cn/sxsnfile/20260105/087c26c68a18424c83763a768a2fd81d.png" style="width: 370rpx;height: 40rpx;"></image>
 				</view>
 			</template>
 		</up-navbar>

+ 1 - 1
pages/my.vue

@@ -87,7 +87,7 @@
 				</view>
 				<view class="box-other-pre adffcac" @click="handleTurnPage('/pagesMy/exclusiveScroll')">
 					<image src="https://oss.familydaf.cn/sxsnfile/20251218/7ee3c42e8408489fb0768406d72b73b4.png"></image>
-					<text>我的专享</text>
+					<text>我的专享</text>
 				</view>
 			</view>
 		</view>

+ 66 - 4
pagesHome/activityDetail.vue

@@ -219,15 +219,18 @@
 				</div>
 			</template>
 		</view>
+		<login-register></login-register>
 	</view>
 </template>
 
 <script setup name="">
 	import CusHeader from '@/components/CusHeader/index.vue'
 	import { onLoad } from '@dcloudio/uni-app';
-	import { ref, reactive, onMounted, getCurrentInstance ,nextTick } from 'vue'
+	import { ref, reactive, onMounted, getCurrentInstance ,nextTick, watch } from 'vue'
 	import { onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app' 
 	const { proxy } = getCurrentInstance()
+	import { useUserStore } from '@/common/stores/user';
+	const userStore = useUserStore();
 	
 	const id = ref('')
 	const activityInfo = ref(null)
@@ -346,16 +349,16 @@
 	}
 	
 	onShareAppMessage((res) => {
+		const sharerId = JSON.parse(uni.getStorageSync('userInfo'))?.id;
 		// 如果是点击海报菜单的“发送给朋友”按钮
 		if (res.from === 'button' && res.target.id === 'posterShareBtn') {
 			return {
 				title: posterData.title,
-				path: `/pagesHome/activityDetail?shareADId=${id.value}`,
+				path: `/pagesHome/activityDetail?shareADId=${activityInfo.value?.id}&shareUserId=${sharerId}`,
 				imageUrl: posterUrl.value // 使用生成的海报作为分享图
 			};
 		}
 		// 默认页面右上角分享
-		const sharerId = JSON.parse(uni.getStorageSync('userInfo'))?.id;
 		return {
 		  title: activityInfo.value?.activityName || '发现一个好物,分享给你!',
 		  path: `/pagesHome/activityDetail?shareADId=${activityInfo.value?.id}&shareUserId=${sharerId}`,
@@ -632,7 +635,25 @@
 	  
 	const getActivityDetail = (id) => {
 		proxy.$api.get(`/core/activity/${id}`).then(({data:res})=>{
-			if(res.code!==0) return proxy.$showToast(res.msg)
+			if(res.code!==0){
+				if(options?.shareADId){
+					uni.showModal({
+						title:'温馨提示',
+						content:res.msg,
+						showCancel:false,
+						confirmText:'返回首页',
+						success: (res) => {
+							if(res.confirm){
+								uni.reLaunch({
+									url:'/pages/home'
+								})
+							}
+						}
+					})
+					return
+				}
+				return proxy.$showToast(res.msg)
+			} 
 			activityInfo.value = res.data;
 			// 更新海报数据
 			posterData.title = activityInfo.value?.activityName || posterData.title;
@@ -653,8 +674,49 @@
 		})
 	}
 	
+	watch(()=>userStore.token,(newVal,oldVal)=>{
+		if(oldVal!=newVal&&newVal){
+			setTimeout(()=>{
+				uni.showToast({
+					title: '登录成功',
+					icon: 'success'
+				});
+			},200)
+			nextTick(()=>{
+				getActivityDetail(id.value)
+			})
+		}
+	})
+	
 	onLoad(options=>{
 		id.value = options?.id||options?.shareADId||'';
+		if(!uni.getStorageSync('token')||!uni.getStorageSync('expaireTime')||(Date.parse(new Date())>(uni.getStorageSync('expaireTime')||0))){
+			uni.showModal({
+				title:'温馨提示',
+				content:'您当前登录已失效或未登录过,是否立即登录?',
+				success: (res) => {
+					if(res.confirm){
+						userStore.openLoginModal()
+					}else if(res.cancel){
+						uni.showModal({
+							title:'温馨提示',
+							content:'您已取消登录,当前活动详情页面不可查看',
+							showCancel:false,
+							confirmText:'返回首页',
+							success: (res) => {
+								if(res.confirm){
+									uni.reLaunch({
+										url:'/pages/home'
+									})
+								}
+							}
+						})
+					}
+				}
+			})
+			return
+		}
+		
 		if(id.value) {
 			getActivityDetail(id.value)
 		}

+ 2 - 2
pagesMy/exclusiveScroll.vue

@@ -1,6 +1,6 @@
 <template>
 	<view class="common_page adffc" :style="{'height':h+'px', 'padding-top':mt+'px'}">
-		<cus-header title="我的专享" bgColor="#FFFFFF"></cus-header>
+		<cus-header title="我的专享" bgColor="#FFFFFF"></cus-header>
 		<view class="tab adf">
 			<view class="tab-pre adfacjc" :class="{'active':tidx===0}" @click="changeTab(0,0)">未使用</view>
 			<view class="tab-pre adfacjc" :class="{'active':tidx===1}" @click="changeTab(1,1)">已使用</view>
@@ -18,7 +18,7 @@
 									<image class="box-check" v-if="item.check" src="https://oss.familydaf.cn/sxsnfile/20251218/c11b9a1b56f34e1189621f4270f0349a.png"></image>
 									<image class="box-check" v-else src="https://oss.familydaf.cn/sxsnfile/20251218/2a2f7bdefb474a3e93faa00aef6d0e1f.png"></image>
 								</template>
-								<view class="box-top-title">活动专享</view>
+								<view class="box-top-title">活动专享</view>
 								<view class="box-top-tip">{{item?.activityName||''}}</view>
 								<view class="box-top-date adfacjb">
 									<view class="box-top-date-left">有效期至{{item?.expiredTime||''}}</view>