Explorar el Código

新增活动签到方式

skym1024 hace 1 año
padre
commit
6e1e767b7a
Se han modificado 2 ficheros con 32 adiciones y 5 borrados
  1. 5 1
      api/activity.js
  2. 27 4
      pages/activity/details.vue

+ 5 - 1
api/activity.js

@@ -19,6 +19,10 @@ const offReport = async ({ activityId }) => {
 	const res = await request.del({ url: `/activity/report-cancel/${activityId}` });
 	return res.data;
 }
+const signIn = async ({ activityId }) => {
+	const res = await request.post({ url: `/activity/sign-in/${activityId}` });
+	return res.data;
+}
 const uploadImgs = async data => {
 	const res = await request.post({ url: `/activity/submit-photo`, data });
 	return res.data;
@@ -31,4 +35,4 @@ const getTypeList = async ({ alias }) => {
 	const res = await request.get({ url: `/cms/type/sublist/${alias}` });
 	return res.data;
 }
-export default { getActivity, getdetails, getstatus, report, offReport, uploadImgs, getPhotos, getTypeList };
+export default { getActivity, getdetails, getstatus, report, offReport, signIn, uploadImgs, getPhotos, getTypeList };

+ 27 - 4
pages/activity/details.vue

@@ -58,7 +58,8 @@
 					  color: '#fff'
 					}
 				],
-				statusInfo: true
+				statusInfo: true,
+				pointNeedPoint: false
 			}
 		},
 		mounted() {
@@ -70,7 +71,8 @@
 				const statusInfo = await request.getstatus({ activityId: this.activityId });
 				res.data.image = BASE_URL.fileUrl + res.data.image;
 				this.info = res.data;
-				this.statusInfo = statusInfo.status
+				this.statusInfo = statusInfo.status;
+				this.pointNeedPoint = false;
 				const newDateTime = new Date().getTime();
 				const endTime = Date.parse(res.data.regEndTime);
 				const startTime = Date.parse(res.data.regStartTime);
@@ -126,7 +128,13 @@
 					// 	this.buttonGroup[1].disable = true;		
 					// }
 					if(statusInfo.status && newDateTime > startActiveTime){
-						this.buttonGroup[1].text = '获取积分';
+						if(res.data.pointHowTo == '1'){
+							this.buttonGroup[1].text = '获取积分';
+							this.pointNeedPoint = true;
+						}else{
+							this.buttonGroup[1].text = '签到';
+						}
+						
 						this.buttonGroup[1].backgroundColor = '#ffa200';
 						delete this.buttonGroup[1].disable;
 					}
@@ -147,7 +155,13 @@
 					this.report();
 				} else {
 					if (e.content.disable) return;
-					this.submitPhoto();
+					
+					console.log(e.content)
+
+					if(this.pointNeedPoint)
+						this.submitPhoto();
+					else
+						this.submitSignIn();
 				}
 			},
 			async report() {
@@ -170,6 +184,15 @@
 			},
 			async submitPhoto() {
 				uni.navigateTo({ url: `/pages/activity/uploadFiel?activityId=${this.activityId}` })
+			},
+			async submitSignIn(){
+				const res = await request.signIn({ activityId: this.activityId });
+				if (res.code == 200) {
+					wx.showToast({
+						title: '签到成功'
+					})
+					this.query();
+				}
 			}
 		}
 	}