htc 7 小時之前
父節點
當前提交
189c2658fc
共有 7 個文件被更改,包括 70 次插入43 次删除
  1. 1 1
      common/api/index.js
  2. 0 14
      common/stores/user.js
  3. 0 4
      components/pages/loginRegister/index.vue
  4. 14 4
      pages/home.vue
  5. 14 3
      pages/my.vue
  6. 17 16
      pagesHome/activityDetail.vue
  7. 24 1
      pagesHome/allActivity.vue

+ 1 - 1
common/api/index.js

@@ -22,7 +22,7 @@ export const $http = (url, method, data, json, isloading=true) => {
 			uni.hideLoading()
 		}
 		
-		if (response?.data?.code === 401 || response?.data?.msg.indexOf('未授权') > -1 || response?.data?.msg.indexOf('重新登录') > -1) {
+		if (response?.data?.code === 401 || response?.data?.msg?.indexOf('未授权') > -1 || response?.data?.msg?.indexOf('重新登录') > -1) {
 			return uni.showModal({
 				title: '温馨提示',
 				content:'当前登录已失效,是否返回首页?',

+ 0 - 14
common/stores/user.js

@@ -45,20 +45,6 @@ export const useUserStore = defineStore('user', {
 
 		async login(loginDto) {
 			await new Promise(resolve => {
-				//临时
-				this.showLoginModal = false;
-				this.isLogin = true;
-				this.token = 'f74c5cde0acc4daabbd2cbf118f4ad98';
-				this.userInfo = {realName:'黄小鱼',id:1,token:'f74c5cde0acc4daabbd2cbf118f4ad98'};
-				uni.setStorageSync('token',this.userInfo?.token)
-				uni.setStorageSync('userInfo',JSON.stringify(this.userInfo))
-				uni.showToast({
-					title: '登录成功',
-					icon: 'success'
-				});
-				return
-				
-				
 				api.get('/wx/login',loginDto).then(({data:res})=>{
 					if(res.code !== 0){
 						uni.showModal({

+ 0 - 4
components/pages/loginRegister/index.vue

@@ -150,10 +150,6 @@
 	}
 	
 	const decryptPhoneNumberLogin = e => {
-		userStore.login();
-		return
-				
-				
 		if(e.detail.code) toPhoneLogin(e.detail.code);
 	}
 	

+ 14 - 4
pages/home.vue

@@ -52,7 +52,7 @@
 				<page-empty></page-empty>
 			</view>
 		</view>
-		<login-register @loginSucc="loginSucc"></login-register>
+		<login-register></login-register>
 		<CusTabbar :tabbarIndex="0"></CusTabbar>
 	</view>
 </template>
@@ -61,7 +61,7 @@
 	import CusTabbar from '@/components/CusTabbar/index.vue'
 	import NonprofitActivety from '@/components/pages/nonprofitActivety/index.vue'
 	import PageEmpty from '@/components/pageEmpty/index.vue'
-	import { ref, getCurrentInstance, onMounted, watch } from 'vue'
+	import { ref, getCurrentInstance, onMounted, nextTick, watch } from 'vue'
 	const { proxy } = getCurrentInstance()
 	import { useUserStore } from '@/common/stores/user';
 	const userStore = useUserStore();
@@ -152,8 +152,18 @@
 		  };
 	}
 	
-	watch(()=>userStore.token,newVal=>{
-		getActivityList('')
+	watch(()=>userStore.token,(newVal,oldVal)=>{
+		if(oldVal!=newVal&&newVal){
+			setTimeout(()=>{
+				uni.showToast({
+					title: '登录成功',
+					icon: 'success'
+				});
+			},200)
+			nextTick(()=>{
+				getActivityList('')
+			})
+		}
 	})
 	
 	onMounted(()=>{

+ 14 - 3
pages/my.vue

@@ -98,7 +98,7 @@
 
 <script setup name="">
 	import CusTabbar from '@/components/CusTabbar/index.vue'
-	import { ref, onMounted, watch, getCurrentInstance } from 'vue'
+	import { ref, onMounted, watch, nextTick, getCurrentInstance } from 'vue'
 	const { proxy } = getCurrentInstance();
 	import { useUserStore } from '@/common/stores/user';
 	const userStore = useUserStore();
@@ -139,8 +139,19 @@
 		})
 	}
 	
-	watch(()=>userStore.token,newVal=>{
-		getUserInfo()
+	watch(()=>userStore.token,(newVal,oldVal)=>{
+		if(oldVal!=newVal&&newVal){
+			setTimeout(()=>{
+				uni.showToast({
+					title: '登录成功',
+					icon: 'success'
+				});
+			},200)
+			nextTick(()=>{
+				getUserInfo()
+				getUserNums()
+			})
+		}
 	})
 	
 	onMounted(()=>{

+ 17 - 16
pagesHome/activityDetail.vue

@@ -124,6 +124,7 @@
 				<view class="right" @click="handleFill" v-else-if="activityInfo?.activeState==3&&activityInfo?.signupState==1">填写公益档案</view>
 				
 				<view class="right end" v-else-if="activityInfo?.activeState==0">活动未开始</view>
+				<view class="right end" v-else-if="activityInfo?.activeState==1&&activityInfo?.signupState==2">活动已签到</view>
 				<view class="right end" v-else-if="activityInfo?.activeState==2&&activityInfo?.signupState==0">活动进行中不可报名</view>
 				<view class="right end" v-else-if="activityInfo?.activeState==3">活动已结束</view>
 				<view class="right end" v-else-if="activityInfo?.activeState==4">已报满暂无活动名额</view>
@@ -190,8 +191,16 @@
 				
 				<div class="posterbox-menu adfacjb">
 					<div class="posterbox-menu-pre adffcac" v-for="(item,index) in menuList" :key="index" @click="handleMenuClick(item.type)">
-						<image :src="item.img"></image>
-						<text>{{item.title}}</text>
+						<template v-if="index===0">
+							<button class="share-btn" open-type="share">
+								<image :src="item.img"></image>
+								<text>{{item.title}}</text>
+							</button>
+						</template>
+						<template v-else>
+							<image :src="item.img"></image>
+							<text>{{item.title}}</text>
+						</template>
 					</div>
 				</div>
 				<div class="posterbox-close adfacjc">
@@ -336,7 +345,7 @@
 	}
 	
 	// 分享到朋友圈(旧逻辑)
-	const shareToTimeline_old = () => {
+	const shareToTimeline = () => {
 		uni.showModal({
 			title:'温馨提示',
 			content:'分享到朋友圈请点击页面右上方的“···”标志后选择“分享到朋友圈”进行分享'
@@ -518,25 +527,17 @@
 	const handleMenuClick = (type) => {
 		switch(type) {
 			case 'shareApp':
-				// 小程序不支持直接唤起分享API,需要使用 open-type="share" 的 button
-				// 这里我们可以提示用户点击右上角分享
-				uni.showToast({ title: '请点击右上角“···”进行分享', icon: 'none' });
 				break;
 			case 'shareTimeline':
 				// 同上,提示用户
 				uni.showToast({ title: '请点击右上角“···”分享到朋友圈', icon: 'none' });
 				break;
 			case 'favorite':
-				// 实现收藏功能
-				uni.addFavorite({
-					title: activityInfo.value?.activityName || '公益活动详情',
-					imageUrl: posterUrl.value,
-					success: () => {
-						proxy.$showToast('收藏成功');
-					},
-					fail: (err) => {
-						proxy.$showToast('收藏失败');
-					}
+				 uni.showModal({
+					title: '收藏提示',
+					content: "请点击右上角 '...' 按钮,然后选择 '添加到我的小程序' 或 '收藏',即可方便下次访问哦!",
+					showCancel: false, // 通常只保留一个“我知道了”按钮
+					confirmText: '我知道了'
 				});
 				break;
 			case 'save':

+ 24 - 1
pagesHome/allActivity.vue

@@ -69,6 +69,7 @@
 				<view class="pre" v-for="(t,i) in typeList2" :key="i" @click="changeType2(t,t.name,i)">{{t.name}}</view>
 			</view>
 		</view>
+		<login-register></login-register>
 	</view>
 </template>
 
@@ -79,8 +80,10 @@
 	import ActivityCalendar from '@/components/pages/activityCalendar/index.vue'
 	import ActivityArea from '@/components/pages/activityArea/index.vue'
 	import PageEmpty from '@/components/pageEmpty/index.vue'
-	import { ref, onMounted, nextTick, getCurrentInstance } from 'vue'
+	import { ref, onMounted, nextTick, getCurrentInstance, watch } from 'vue'
 	const { proxy } = getCurrentInstance()
+	import { useUserStore } from '@/common/stores/user';
+	const userStore = useUserStore();
 	
 	const typeIndex = ref('')
 	const typeList = ref([])
@@ -110,6 +113,26 @@
 	const wtIndex = ref(0)
 	const acRef = ref(null)
 	
+	watch(()=>userStore.token,(newVal,oldVal)=>{
+		if(oldVal!=newVal&&newVal){
+			setTimeout(()=>{
+				uni.showToast({
+					title: '登录成功',
+					icon: 'success'
+				});
+			},200)
+			nextTick(()=>{
+				queryParams.value.userId = JSON.parse(uni.getStorageSync('userInfo'))?.id;
+				getTypeList()
+				initList();
+				getActivityList()
+				nextTick(()=>{
+					getTop();
+				})
+			})
+		}
+	})
+	
 	const toSearch = () => {
 		uni.navigateTo({
 			url:'/pagesHome/searchActivity',