xlh 1 年之前
父节点
当前提交
9b330dc111
共有 8 个文件被更改,包括 377 次插入129 次删除
  1. 1 0
      main.js
  2. 23 2
      pages/activityDetail/activityDetail.vue
  3. 50 8
      pages/hd/hd.vue
  4. 48 6
      pages/jys/jys.vue
  5. 80 58
      pages/mineActive/mineActive.vue
  6. 121 36
      pages/publish/publish.vue
  7. 33 7
      pages/teachingDetail/teachingDetail.vue
  8. 21 12
      store/index.js

+ 1 - 0
main.js

@@ -18,6 +18,7 @@ Vue.use(uView);
 
 App.mpType = 'app'
 const app = new Vue({
+	store,
   ...App
 })
 app.$mount()

+ 23 - 2
pages/activityDetail/activityDetail.vue

@@ -12,7 +12,7 @@
 						{{ item.acName }}
 					</view>
 					<view class="col fz-font">
-						活动日期:<text>{{ item.begin_at}}</text>
+						活动日期:<text>{{ item.create_at.split('T')[0] }}</text>
 					</view>
 					<view class="col fz-font">
 						招募人数:<text>0/{{ item.pers }}</text>
@@ -78,7 +78,8 @@
 
 		<!-- 申请加入 -->
 		<view class="btnBlock" v-show="btnShow">
-			<button class="btn" @click="gotoAdd">立即报名</button>
+			<button class="btn zw-font" :disabled="isButtonDisabled" @click="gotoAdd"
+				:style="isButtonDisabled ? 'background-color:#87CEFA;' : 'background-colo:#0056a8;'">{{ btnText }}</button>
 		</view>
 	</view>
 </template>
@@ -92,6 +93,8 @@
 					btn: 1
 				},
 				btnShow: true,  //控制按钮显示隐藏
+				isButtonDisabled: false,
+				btnText: '立即报名',
 				judge: {
 					isShow: 1,
 					info: ''
@@ -143,6 +146,22 @@
 					url: '/pages/hd/hd?acId=' + clickedAcId + '&ty=' + ty
 				})
 			},
+			//判断是否报名
+			btnEnroll(clickedAcId) {
+				this.$request('/selectActivityEnrollid', "POST", {
+					acId: clickedAcId,
+					openid: uni.getStorageSync('oId')
+				}).then(res => {
+					if (!res[0][0] || !res[0][0].hasOwnProperty('acId')) {
+						console.log('acId 未定义或不存在');
+						return
+					}
+					if (clickedAcId === res[0][0].acId) {
+						this.isButtonDisabled = true
+						this.btnText = '已加入'
+					}
+				})
+			},
 			getActivity() {
 				// 获取当前页面的URL
 				const routes = getCurrentPages();
@@ -170,6 +189,8 @@
 					console.log(res[0]);
 					// this.activeList=[...this.activeList,...res[0]]
 					this.actItemList = res[0]
+					const clickedAcId = this.actItemList[0].acId;
+					this.btnEnroll(clickedAcId)
 				})
 			},
 		},

+ 50 - 8
pages/hd/hd.vue

@@ -12,7 +12,7 @@
 							<view class="t1 bmTit-font">{{ item.acName }}</view>
 						</view>
 						<view class="col sZw-font">
-							活动日期:{{ item.begin_at }}~{{ item.endTime }}
+							活动日期:{{ item.create_at.split('T')[0] }}
 						</view>
 						<view class="col sZw-font">
 							招募人数:0/{{ item.pers }}
@@ -34,12 +34,12 @@
 							</view>
 							<view class="name  sZw-font">
 								联系方式:
-								<input type="text" style=" text-align: right;" maxlength="10" placeholder="请输入联系方式"
+								<input type="text" style=" text-align: right;" maxlength="11" placeholder="请输入联系方式"
 									placeholder-style="font-size: 28rpx; color: rgb(153, 153, 153);" v-model="telephone" />
 							</view>
 							<view class="name  sZw-font">
 								单位:
-								<input type="text" style=" text-align: right;" maxlength="10" placeholder="请输入单位"
+								<input type="text" style=" text-align: right;" maxlength="15" placeholder="请输入单位"
 									placeholder-style="font-size: 28rpx; color: rgb(153, 153, 153);" v-model="units" />
 							</view>
 						</view>
@@ -52,7 +52,7 @@
 				<button @click="button1Action" class="btn1 sZw-font">清空填写信息</button>
 				<!-- <text class="button-spacing"></text> -->
 				<!-- 添加间距 -->
-				<button @click="gotoSign" class="btn2 sZw-font">申请加入</button>
+				<button :disabled="isButtonDisabled" :style="isButtonDisabled ? 'background-color:#87CEFA;' : 'background-colo:#0056a8;'" @click="gotoSign" class="btn2 sZw-font">申请加入</button>
 			</view>
 		</view>
 	</view>
@@ -69,7 +69,8 @@ export default {
 			nickname: '',
 			telephone: '',
 			units: '',
-			actItemList:[]
+			actItemList:[],
+			isButtonDisabled: false,
 		};
 	},
 	methods: {
@@ -80,15 +81,54 @@ export default {
 		},
 		gotoSign() {
 			// 这里添加按钮2点击后触发的动作
-			if(this.nickname.trim() === '' || this.telephone.trim() === '') {
+			if (this.nickname.trim() === '' || this.telephone.trim() === '') {
 				uni.showToast({
 					title: '请填写完整的表单内容',
 					icon: 'none'
 				});
 				return;
 			}
-			uni.navigateTo({
-				url: '/pages/Sign/Sign'
+			let data = {
+				acId: this.actItemList[0].acId,
+				openid: uni.getStorageSync('oId'),
+				acName: this.actItemList[0].acName,
+				brief: this.actItemList[0].brief,
+				pic: this.actItemList[0].pic,
+				pers: this.actItemList[0].pers,
+				acshape: this.actItemList[0].acshape,
+				// create_at:this.actItemList[0].create_at,
+				address: this.actItemList[0].address,
+				type: this.actItemList[0].type,
+				begin_at: this.actItemList[0].begin_at,
+				endTime: this.actItemList[0].endTime,
+				cost: this.actItemList[0].cost
+			}
+			console.log(data);
+			console.log('1111');
+			console.log(this.actItemList[0].acId);
+			this.$request('/insertActivityEnroll', "POST", data).then(res => {
+				console.log(res);
+				uni.navigateTo({
+					url: '/pages/Sign/Sign'
+				})
+			})
+			
+		},
+		enrollPublisher(clickedAcId) {
+			this.$request('/selectPublisher', "POST", {
+				openid: uni.getStorageSync('oId'),
+				acId: clickedAcId,
+			}).then(res => {
+				const openid = uni.getStorageSync('oId')
+				console.log(res[0][0].openid);
+				if (openid === res[0][0].openid) {
+					uni.showToast({
+						title: '您是该活动的发布者,不能报名',
+						icon: 'none'
+					});
+					this.isButtonDisabled = true
+					return;
+				}
 			})
 		},
 		getActivity() {
@@ -105,6 +145,8 @@ export default {
 				console.log(res[0]);
 				// this.activeList=[...this.activeList,...res[0]]
 				this.actItemList = res[0]
+				const clickedAcId = this.actItemList[0].acId;
+				this.enrollPublisher(clickedAcId)
 			})
 		},
 	},

+ 48 - 6
pages/jys/jys.vue

@@ -34,12 +34,12 @@
 						</view>
 						<view class="name  sZw-font">
 							联系方式:
-							<input type="text" style=" text-align: right;" maxlength="10" placeholder="请输入联系方式"
+							<input type="text" style=" text-align: right;" maxlength="11" placeholder="请输入联系方式"
 								placeholder-style="font-size: 28rpx; color: rgb(153, 153, 153);" v-model="telephone" />
 						</view>
 						<view class="name  sZw-font">
 							单位:
-							<input type="text" style=" text-align: right;" maxlength="10" placeholder="请输入单位"
+							<input type="text" style=" text-align: right;" maxlength="15" placeholder="请输入单位"
 								placeholder-style="font-size: 28rpx; color: rgb(153, 153, 153);" v-model="units" />
 						</view>
 					</view>
@@ -52,7 +52,7 @@
 				<button @click="button1Action" class="btn1 sZw-font">清空填写信息</button>
 				<!-- <text class="button-spacing"></text> -->
 				<!-- 添加间距 -->
-				<button @click="gotoSign" class="btn2 sZw-font">申请加入</button>
+				<button :disabled="isButtonDisabled" :style="isButtonDisabled ? 'background-color:#87CEFA;' : 'background-colo:#0056a8;'" @click="gotoSign" class="btn2 sZw-font">申请加入</button>
 			</view>
 		</view>
 	</view>
@@ -70,7 +70,8 @@
 				telephone: '',
 				units: '',
 				actItemList: [],
-				typetext: ''
+				typetext: '',
+				isButtonDisabled: false,
 			};
 		},
 		methods: {
@@ -88,9 +89,31 @@
 					});
 					return;
 				}
-				uni.navigateTo({
-					url: '/pages/Sign/Sign'
+				let data = {
+					acId: this.actItemList[0].acId,
+					openid: uni.getStorageSync('oId'),
+					acName: this.actItemList[0].acName,
+					brief: this.actItemList[0].brief,
+					pic: this.actItemList[0].pic,
+					pers: this.actItemList[0].pers,
+					acshape: this.actItemList[0].acshape,
+					// create_at:this.actItemList[0].create_at,
+					address: this.actItemList[0].address,
+					type: this.actItemList[0].type,
+					begin_at: this.actItemList[0].begin_at,
+					endTime: this.actItemList[0].endTime,
+					cost: this.actItemList[0].cost
+				}
+				console.log(data);
+				console.log('1111');
+				console.log(this.actItemList[0].acId);
+				this.$request('/insertActivityEnroll', "POST", data).then(res => {
+					console.log(res);
+					uni.navigateTo({
+						url: '/pages/Sign/Sign'
+					})
 				})
+				
 			},
 			mapTypeToText(type) {
 				if (type === 0) {
@@ -101,6 +124,23 @@
 					return "专题教研活动";
 				}
 			},
+			enrollPublisher(clickedAcId) {
+				this.$request('/selectPublisher', "POST", {
+					openid: uni.getStorageSync('oId'),
+					acId: clickedAcId,
+				}).then(res => {
+					const openid = uni.getStorageSync('oId')
+					console.log(res[0][0].openid);
+					if (openid === res[0][0].openid) {
+						uni.showToast({
+							title: '您是该活动的发布者,不能报名',
+							icon: 'none'
+						});
+						this.isButtonDisabled = true
+						return;
+					}
+				})
+			},
 			getActivity() {
 				// 获取当前页面的URL
 				const routes = getCurrentPages();
@@ -115,6 +155,8 @@
 					// this.activeList=[...this.activeList,...res[0]]
 					this.actItemList = res[0]
 					this.typetext = this.mapTypeToText(this.actItemList.type);
+					const clickedAcId = this.actItemList[0].acId;
+					this.enrollPublisher(clickedAcId)
 				})
 			},
 		},

+ 80 - 58
pages/mineActive/mineActive.vue

@@ -6,31 +6,32 @@
 		<view class="activeBox" v-for="(item,index) in activeList" :key="index">
 			<view class="teaching_case">
 				<view class="img">
-					<!-- <image src="https://teacherapi.cocorobo.cn/teaching-file/static//activity/bg2.png" mode="aspectFill"></image> -->
-					<image :src="activeList[index].img" mode="aspectFill"></image>
+					<!-- <image src="http://43.139.158.220:5007/img/static/activity/bg2.png" mode="aspectFill"></image> -->
+					<image :src="activeList[index].pic" mode="aspectFill"></image>
 
 				</view>
 
-				<view class="right" @click="gotoActivityDetail(index)">
+				<view class="right" @click="gotoActivityDetail" :data-index="index">
 					<view class="title">
 						<view class="tag bqZ-font">类型</view>
-						<text class="three-font" style="font-weight: 600;">{{ item.className }}</text>
+						<text class="three-font" style="font-weight: 600;">{{ item.acName }}</text>
 					</view>
 
 					<view class="introduce">
-						{{ item.intro }}
+						{{ item.brief }}
 					</view>
 
 					<view class="operate">
 						<view class="left">
-							<view class="money fNum-font"><text class="three-font">¥</text> {{ item.price }}</view>
-							<view class="person">已报名{{ item.count }}人</view>
+							<view class="money fNum-font"><text class="three-font">¥</text> {{ item.cost }}</view>
+							<view class="person">已报名{{ item.pers }}人</view>
 						</view>
 
 						<view class="Oright">
 							<view class="text">查看详情</view>
 							<view class="arrow">
-								<image src="https://teacherapi.cocorobo.cn/teaching-file/static//mine/arrow-right-blue.png" mode="aspectFill"></image>
+								<image src="http://43.139.158.220:5007/img/static/mine/arrow-right-blue.png"
+									mode="aspectFill"></image>
 							</view>
 						</view>
 
@@ -39,7 +40,7 @@
 			</view>
 		</view>
 		<view class="" style="width: 100%;height: 50rpx;">
-			
+
 		</view>
 	</view>
 </template>
@@ -52,59 +53,80 @@
 					title: '我的活动',
 					btn: 1
 				},
-				activeList: [{
-						img: "https://teacherapi.cocorobo.cn/teaching-file/static//img/1695656271245-image.png",
-						count: "3842",
-						price: "299",
-						className: "丽湖职教双创教育国际虚拟教研室启动大会暨双创教育国际论坛圆满举行",
-						intro: "丽湖职教双创教育国际虚拟教研室为立足全国,辐射海外的国际化教研室,围绕创新创业教育的人才培养与课程建设开展深度研究。教研室以贯彻落实立德树人根本任务,通过加强跨专业、跨校、跨地域的教研交流,推动高校协同打造国际化的精品教学资",
-					},
-					{
-						img: "https://teacherapi.cocorobo.cn/teaching-file/static//img/img1.png",
-						count: "17",
-						price: "188",
-						className: "丽湖职教双创教育国际虚拟教研室2023年常规教研活动安排",
-						intro: "丽湖职教双创教育国际虚拟教研室为立足全国,辐射海外的国际化教研室,围绕创新创业教育的人才培养与课程建设开展深度研究。教研室以贯彻落实立德树人根本任务,通过加强跨专业、跨校、跨地域的教研交流,推动高校协同打造国际化的精品教学资",
-					},
-					{
-						img: "https://teacherapi.cocorobo.cn/teaching-file/static//img/img3.png",
-						count: "1",
-						price: "188",
-						className: "产教融合情境下的双创通识课程建设 | 丽湖职教双创教育国际虚拟教研室常规教研活动第2期顺利举行",
-						intro: "【图片】为提升职业院校双创课程建设水平,促进双创课程的改革与发展,丽湖职教双创教育国际虚拟教研室于3月29日组织举办了以“产教融合情境下的双创通识课程建设”为主题的第2期线上教研活动,来自全国各职业院校的60多位教师参会。",
-					},
-					{
-						img: "https://teacherapi.cocorobo.cn/teaching-file/static//yym/83b48be81d4ed9c93908737496f2a54.png",
-						count: "3842",
-						price: "299",
-						className: "丽湖职教双创教育国际虚拟教研室 • 常规教研活动 第9期",
-						intro:"丽湖职教双创教育国际虚拟教研室 • 常规教研活动 第9期"
-					},
+				activeList: [
+					// {
+					// 	img: "https://teacherapi.cocorobo.cn/teaching-file/static//img/1695656271245-image.png",
+					// 	count: "3842",
+					// 	price: "299",
+					// 	className: "丽湖职教双创教育国际虚拟教研室启动大会暨双创教育国际论坛圆满举行",
+					// 	intro: "丽湖职教双创教育国际虚拟教研室为立足全国,辐射海外的国际化教研室,围绕创新创业教育的人才培养与课程建设开展深度研究。教研室以贯彻落实立德树人根本任务,通过加强跨专业、跨校、跨地域的教研交流,推动高校协同打造国际化的精品教学资",
+					// },
+					// {
+					// 	img: "https://teacherapi.cocorobo.cn/teaching-file/static//img/img1.png",
+					// 	count: "17",
+					// 	price: "188",
+					// 	className: "丽湖职教双创教育国际虚拟教研室2023年常规教研活动安排",
+					// 	intro: "丽湖职教双创教育国际虚拟教研室为立足全国,辐射海外的国际化教研室,围绕创新创业教育的人才培养与课程建设开展深度研究。教研室以贯彻落实立德树人根本任务,通过加强跨专业、跨校、跨地域的教研交流,推动高校协同打造国际化的精品教学资",
+					// },
+					// {
+					// 	img: "https://teacherapi.cocorobo.cn/teaching-file/static//img/img3.png",
+					// 	count: "1",
+					// 	price: "188",
+					// 	className: "产教融合情境下的双创通识课程建设 | 丽湖职教双创教育国际虚拟教研室常规教研活动第2期顺利举行",
+					// 	intro: "【图片】为提升职业院校双创课程建设水平,促进双创课程的改革与发展,丽湖职教双创教育国际虚拟教研室于3月29日组织举办了以“产教融合情境下的双创通识课程建设”为主题的第2期线上教研活动,来自全国各职业院校的60多位教师参会。",
+					// },
+					// {
+					// 	img: "https://teacherapi.cocorobo.cn/teaching-file/static//yym/83b48be81d4ed9c93908737496f2a54.png",
+					// 	count: "3842",
+					// 	price: "299",
+					// 	className: "丽湖职教双创教育国际虚拟教研室 • 常规教研活动 第9期",
+					// 	intro: "丽湖职教双创教育国际虚拟教研室 • 常规教研活动 第9期"
+					// },
 				],
 			};
 		},
-		methods:{
-			gotoActivityDetail(index) {
-				const value = uni.getStorageSync("login");
-				if (value == 0) {
-					uni.navigateTo({
-						url: "/pages/login/login",
-					});
-				} else {
-					const urls = [
-						"https://szptxnjys.yuketang.cn/pro/portal/announcementdetail/1181",
-						"https://szptxnjys.yuketang.cn/pro/portal/announcementdetail/1183",
-						"https://szptxnjys.yuketang.cn/pro/portal/announcementdetail/1210",
-						"https://szptxnjys.yuketang.cn/pro/portal/announcementdetail/1234",
-					];
-					if (index >= 0 && index < urls.length) {
-						const url = urls[index];
-						uni.navigateTo({
-							url: "/pages/skipone/skipone?url=" + encodeURIComponent(url),
-						});
-					}
-				}
+		methods: {
+			gotoActivityDetail(e) {
+				// const value = uni.getStorageSync("login");
+				// if (value == 0) {
+				// 	// uni.navigateTo({
+				// 	// 	url: "/pages/login/login",
+				// 	// });
+				// } else {
+				// 	const urls = [
+				// 		"https://szptxnjys.yuketang.cn/pro/portal/announcementdetail/1181",
+				// 		"https://szptxnjys.yuketang.cn/pro/portal/announcementdetail/1183",
+				// 		"https://szptxnjys.yuketang.cn/pro/portal/announcementdetail/1210",
+				// 		"https://szptxnjys.yuketang.cn/pro/portal/announcementdetail/1234",
+				// 	];
+				// 	if (index >= 0 && index < urls.length) {
+				// 		const url = urls[index];
+				// 		uni.navigateTo({
+				// 			url: "/pages/skipone/skipone?url=" + encodeURIComponent(url),
+				// 		});
+				// 	}
+				// }
+				let edata = e.currentTarget.dataset['index'];
+				const clickedAcId = this.activeList[edata].acId;
+				const type = this.activeList[edata].type;
+				const isShow = false
+				uni.navigateTo({
+					url: "/pages/activityDetail/activityDetail?acId=" + clickedAcId + "&ty=" + type + "&isShow=" +
+						isShow,
+				});
 			},
+			myactivity() {
+				let data = {
+					openid: uni.getStorageSync('oId'),
+				}
+				this.$request('/selectActivityEnroll', "POST", data).then(res => {
+					console.log(res[0]);
+					this.activeList = res[0]
+				})
+			}
+		},
+		onShow() {
+			this.myactivity()
 		}
 	}
 </script>

+ 121 - 36
pages/publish/publish.vue

@@ -63,7 +63,8 @@
 										<view class="uni-input text">{{classify}}</view>
 									</view>
 									<view class="arrow">
-										<image src="https://teacherapi.cocorobo.cn/teaching-file/static//mine/arrow-right.png"
+										<image
+											src="https://teacherapi.cocorobo.cn/teaching-file/static//mine/arrow-right.png"
 											mode="aspectFill"></image>
 									</view>
 								</view>
@@ -91,7 +92,8 @@
 										<view class="uni-input text">{{recruitment}}</view>
 									</view>
 									<view class="arrow">
-										<image src="https://teacherapi.cocorobo.cn/teaching-file/static//mine/arrow-right.png"
+										<image
+											src="https://teacherapi.cocorobo.cn/teaching-file/static//mine/arrow-right.png"
 											mode="aspectFill"></image>
 									</view>
 								</view>
@@ -117,7 +119,8 @@
 										<view class="uni-input text">{{activityform}}</view>
 									</view>
 									<view class="arrow">
-										<image src="https://teacherapi.cocorobo.cn/teaching-file/static//mine/arrow-right.png"
+										<image
+											src="https://teacherapi.cocorobo.cn/teaching-file/static//mine/arrow-right.png"
 											mode="aspectFill"></image>
 									</view>
 								</view>
@@ -142,7 +145,8 @@
 										<view class="uni-input text">{{address}}</view>
 									</view>
 									<view class="arrow">
-										<image src="https://teacherapi.cocorobo.cn/teaching-file/static//mine/arrow-right.png"
+										<image
+											src="https://teacherapi.cocorobo.cn/teaching-file/static//mine/arrow-right.png"
 											mode="aspectFill"></image>
 									</view>
 								</view>
@@ -181,23 +185,26 @@
 								活动时间
 							</text>
 						</view>
-					
+
 						<view class="option_right">
 							<view class="input_details">
 								<view class="details">
 									<!-- <view class="uni-input text">{{ activityDate }}</view> -->
-									<u-calendar :show="show" :mode="mode" @confirm="confirm" :closeOnClickOverlay="true" @close="show=false"></u-calendar>
+									<u-calendar :show="show" :mode="mode" @confirm="confirm" :closeOnClickOverlay="true"
+										@close="show=false"></u-calendar>
 									<view class="text">
 										{{ activityDate }}
 									</view>
 								</view>
 								<view class="arrow">
-									<image src="https://teacherapi.cocorobo.cn/teaching-file/static//mine/arrow-right.png" mode="aspectFill"></image>
+									<image
+										src="https://teacherapi.cocorobo.cn/teaching-file/static//mine/arrow-right.png"
+										mode="aspectFill"></image>
 								</view>
 							</view>
 						</view>
 					</view>
-					
+
 				</view>
 			</view>
 			<view class="userOptionsBox">
@@ -216,7 +223,8 @@
 										<view class="uni-input text">{{funds}}</view>
 									</view>
 									<view class="arrow">
-										<image src="https://teacherapi.cocorobo.cn/teaching-file/static//mine/arrow-right.png"
+										<image
+											src="https://teacherapi.cocorobo.cn/teaching-file/static//mine/arrow-right.png"
 											mode="aspectFill"></image>
 									</view>
 								</view>
@@ -243,7 +251,8 @@
 										<view class="uni-input text">{{ deadlineDate }}</view>
 									</view>
 									<view class="arrow">
-										<image src="https://teacherapi.cocorobo.cn/teaching-file/static//mine/arrow-right.png"
+										<image
+											src="https://teacherapi.cocorobo.cn/teaching-file/static//mine/arrow-right.png"
 											mode="aspectFill"></image>
 									</view>
 								</view>
@@ -283,7 +292,8 @@
 			<view class="popup-container" style="height: 175px;" v-show="showPopupConfirm">
 				<view class="popup">
 					<view class="header" style="margin-top: 15px;">
-						<image src="https://teacherapi.cocorobo.cn/teaching-file/static//gou1.png" mode="aspectFill"></image>
+						<image src="https://teacherapi.cocorobo.cn/teaching-file/static//gou1.png" mode="aspectFill">
+						</image>
 						<text style="margin-bottom: 24px;">{{ poptext }}成功</text>
 					</view>
 					<view class="footer" style="padding-top: 0px;">
@@ -355,7 +365,8 @@
 				// activityDate: currentDate,
 				activityDate: '请选择',
 				deadlineDate: currentDate,
-				activeList: []
+				activeList: [],
+				formData: {}
 			};
 		},
 		computed: {
@@ -367,10 +378,13 @@
 			}
 		},
 		methods: {
+			clearData() {
+				this.$store.commit('removeData');
+			},
 			confirm(e) {
 				console.log(e);
-				console.log(e[0],e[e.length-1]);
-				this.activityDate = e[0] + '~' + e[e.length-1]
+				console.log(e[0], e[e.length - 1]);
+				this.activityDate = e[0] + '~' + e[e.length - 1]
 				this.show = false
 			},
 			editPublish() {
@@ -419,28 +433,46 @@
 			submitForm() {
 				//判断表单内容是否完整
 				const conditions = [
-				// 添加提示信息
-				  { value: this.activitytitle.trim(), message: '请填写活动标题' },
-				  { value: this.activityintro.trim(), message: '请填写活动内容' },
-				  { value: this.classify, message: '请填写活动分类' },
-				  { value: this.recruitment, message: '请填写招募人数' },
-				  { value: this.address, message: '请填写活动地址' },
-				  { value: this.activityDate, message: '请填写活动时间' },
+					// 添加提示信息
+					{
+						value: this.activitytitle.trim(),
+						message: '请填写活动标题'
+					},
+					{
+						value: this.activityintro.trim(),
+						message: '请填写活动内容'
+					},
+					{
+						value: this.classify,
+						message: '请填写活动分类'
+					},
+					{
+						value: this.recruitment,
+						message: '请填写招募人数'
+					},
+					{
+						value: this.address,
+						message: '请填写活动地址'
+					},
+					{
+						value: this.activityDate,
+						message: '请填写活动时间'
+					},
 				];
 				for (const condition of conditions) {
-				  if (!condition.value || condition.value === '请选择') {
-				    uni.showToast({
-				      title: condition.message,
-				      icon: 'none'
-				    });
-				    return;
-				  }
+					if (!condition.value || condition.value === '请选择') {
+						uni.showToast({
+							title: condition.message,
+							icon: 'none'
+						});
+						return;
+					}
 				}
 
 				//判断没有填写的表单内容是否填写,如果没有替换
 				if (
 					this.imageValue == '' ||
-					this.activityform.trim() === '请选择' ||
+					this.activityform === '请选择' ||
 					this.funds === '请选择'
 				) {
 					this.imageValue = 'https://teacherapi.cocorobo.cn/teaching-file/static//zanwu_img.png'
@@ -465,7 +497,7 @@
 					this.classify = 2
 				}
 				// 将文本框内容和图片链接存储在一个对象中
-				const formData = {
+				this.formData = {
 					// id: this.$store.state.user.openid,
 					id: this.btntext === '修改发布' ? this.acId : this.$store.state.user.openid,
 					activitytitle: this.activitytitle,
@@ -489,20 +521,29 @@
 				if (this.btntext === '修改发布') {
 					// formData.acId = this.acId
 					// console.log(formData);
-					this.$request('/updateMyPublish', 'POST', formData).then(res => {
+					this.$request('/updateMyPublish', 'POST', this.formData).then(res => {
 						console.log(res);
 						setTimeout(() => {
 							uni.navigateBack();
 						}, 500)
 					})
 				} else {
-					this.$request('/insertActive', 'POST', formData).then(res => {
+					this.$request('/insertActive', 'POST', this.formData).then(res => {
 						console.log(res.data);
 						if (res.code == 200) {
+							this.activitytitle = ''
+							this.activityintro = ''
+							this.imageValue = ''
+							this.classify = '请选择'
+							this.recruitment = '请选择'
+							this.activityform = '请选择'
+							this.address = '请选择'
+							this.funds = '请选择'
+							this.activityDate = '请选择'
+							this.deadlineDate = '请选择'
 							setTimeout(() => {
-								uni.switchTab({
-									url: "/pages/activityPage/activityPage"
-								})
+								this.clearData()
+								uni.navigateBack();
 							}, 500)
 						}
 					})
@@ -591,7 +632,51 @@
 				this.editPublish()
 				this.isFirstShow = false
 			}
-		}
+
+			this.formData = this.$store.state.formData
+			console.log(this.formData);
+			this.activitytitle = this.formData.activitytitle
+			this.activityintro = this.formData.activityintro
+			this.imageValue = this.formData.imageValue
+			this.classify = this.formData.classify
+			this.recruitment = this.formData.recruitment
+			this.activityform = this.formData.activityform
+			this.address = this.formData.address
+			this.funds = this.formData.funds
+			this.activityDate = this.formData.activityDate
+			this.deadlineDate = this.formData.deadlineDate
+			switch (this.classify) {
+				case 0:
+					this.classify = "直播活动";
+					break;
+				case 1:
+					this.classify = "常规教研活动";
+					break;
+				case 2:
+					this.classify = "专题教研活动";
+					break;
+				default:
+					this.classify = "请选择";
+			}
+		},
+		beforeDestroy() {
+			// 在组件销毁之前保存表单数据到 Vuex 中
+			this.formData = {
+				activitytitle: this.activitytitle,
+				activityintro: this.activityintro,
+				imageValue: this.imageValue,
+				classify: this.classify,
+				recruitment: this.recruitment,
+				activityform: this.activityform,
+				address: this.address,
+				funds: this.funds,
+				activityDate: this.activityDate,
+				deadlineDate: this.deadlineDate
+			}
+			this.$store.commit('saveformData', this.formData);
+			console.log('Submitted formData:', this.formData);
+			console.log('Current state.formData:', this.$store.state.formData);
+		},
 	}
 </script>
 

+ 33 - 7
pages/teachingDetail/teachingDetail.vue

@@ -5,23 +5,26 @@
 
 		<!-- 顶部 -->
 		<view class="backPic" v-for="(item,index) in actItemList" :key="index + 'a' ">
-			<image src="https://teacherapi.cocorobo.cn/teaching-file/static//yym/Rectangle 40.png" mode="aspectFill"></image>
+			<image src="https://teacherapi.cocorobo.cn/teaching-file/static//yym/Rectangle 40.png" mode="aspectFill">
+			</image>
 			<view class="card">
 				<view class="cardTop">
 					<view class="title three-font">{{ item.acName }}</view>
 					<view class="icons">
 						<view class="icon">
-							<image src="https://teacherapi.cocorobo.cn/teaching-file/static//yym/Star 1 (Stroke) (2).png"
+							<image
+								src="https://teacherapi.cocorobo.cn/teaching-file/static//yym/Star 1 (Stroke) (2).png"
 								style="width: 42rpx;height: 40rpx;" mode="aspectFill"></image>
 						</view>
 						<view class="icon">
-							<image src="https://teacherapi.cocorobo.cn/teaching-file/static//yym/Vector (Stroke) (1).png"
+							<image
+								src="https://teacherapi.cocorobo.cn/teaching-file/static//yym/Vector (Stroke) (1).png"
 								style="width: 38rpx;height: 42rpx;" mode="aspectFill"></image>
 						</view>
 					</view>
 				</view>
 				<view class="col fz-font">
-					成立日期:{{ item.begin_at.split('~')[0] }}
+					成立日期:{{ item.create_at.split('T')[0] }}
 				</view>
 				<view class="col fz-font">
 					人数:{{ item.pers }}人
@@ -100,7 +103,8 @@
 
 		<!-- 申请加入 -->
 		<view class="btnBlock">
-			<button class="btn zw-font" @click="applyAdd">申请加入</button>
+			<button class="btn zw-font" :disabled="isButtonDisabled" @click="applyAdd"
+				:style="isButtonDisabled ? 'background-color:#87CEFA;' : 'background-colo:#0056a8;'">{{ btnText }}</button>
 		</view>
 	</view>
 </template>
@@ -113,6 +117,8 @@
 					title: '教研室详情',
 					btn: 1
 				},
+				isButtonDisabled: false,
+				btnText: '申请加入',
 				actItemList: [],
 				perNum: [{
 						Name: '金晶',
@@ -154,11 +160,29 @@
 			},
 			applyAdd() {
 				const clickedAcId = this.actItemList[0].acId;
-				console.log(clickedAcId);
+				// console.log(clickedAcId);
 				uni.navigateTo({
 					url: '/pages/jys/jys?acId=' + clickedAcId
 				})
 			},
+			//判断是否报名
+			btnEnroll(clickedAcId) {
+				this.$request('/selectActivityEnrollid', "POST", {
+					acId: clickedAcId,
+					openid: uni.getStorageSync('oId')
+				}).then(res => {
+					if (!res[0][0] || !res[0][0].hasOwnProperty('acId')) {
+						console.log('acId 未定义或不存在');
+						return
+					}
+					console.log(clickedAcId);
+					console.log(res[0]);
+					if (clickedAcId === res[0][0].acId) {
+						this.isButtonDisabled = true
+						this.btnText = '已加入'
+					}
+				})
+			},
 			mapTypeToText(type) {
 				if (type === 0) {
 					return "直播活动";
@@ -178,10 +202,12 @@
 					ty: 2
 				}
 				this.$request('/selectActivityID', "POST", data).then(res => {
-					console.log(res[0]);
+					// console.log(res[0]);
 					// this.activeList=[...this.activeList,...res[0]]
 					this.actItemList = res[0]
 					this.typetext = this.mapTypeToText(this.actItemList.type);
+					const clickedAcId = this.actItemList[0].acId;
+					this.btnEnroll(clickedAcId)
 				})
 			},
 		},

+ 21 - 12
store/index.js

@@ -14,7 +14,7 @@ const store = new Vuex.Store({
 	actions: {
 		//相当于异步的操作,不能直接改变state的值,只能通过触发mutations的方法才能改变
 		asyncUpdateUser(context, user) {
-			context.commit('updateUser',user);
+			context.commit('updateUser', user);
 		}
 	},
 	mutations: {
@@ -33,12 +33,20 @@ const store = new Vuex.Store({
 		// 添加聊天信息
 		addMsg(state, data) {
 			state.message.push(data)
+		},
+		// 保存发布内容
+		saveformData(state, formData) {
+			state.formData = formData;
+		},
+		removeData(state) {
+			state.formData = {};
 		}
+
 	},
 	state: {
 		//公共的变量,存储数据,这里的变量不能随便修改,只能通过触发mutations的方法才能改变
 		user: {
-			openid:'',
+			openid: '',
 			avatar: "",
 			desc: "",
 			email: "",
@@ -50,24 +58,25 @@ const store = new Vuex.Store({
 			_id: ""
 		},
 		// 聊天记录
-		message:[]
+		message: [],
+		formData: {}
 	},
 	getters: {
 		getUser(state) {
 			return state.user;
 		},
-		getMsg(state){
+		getMsg(state) {
 			return state.message;
 		}
 	},
-	 plugins: [persistedstate({
-	 // 传入参数
-	 		storage: {
-	 			getItem: (key) => uni.getStorageSync(key),
-	 			setItem: (key, val) => uni.setStorageSync(key,val),
-	 			removeItem: (key) => uni.removeStorageSync(key)
-	 		}
-	 })]
+	plugins: [persistedstate({
+		// 传入参数
+		storage: {
+			getItem: (key) => uni.getStorageSync(key),
+			setItem: (key, val) => uni.setStorageSync(key, val),
+			removeItem: (key) => uni.removeStorageSync(key)
+		}
+	})]
 })
 
 export default store