mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-student.git
synced 2025-12-11 20:06:49 +08:00
直播签到
This commit is contained in:
@@ -50,7 +50,9 @@
|
|||||||
background: `${new Date(data.liveStartTime).getTime() > new Date().getTime() ? '#999' : 'rgb(59, 191, 252)'}`,
|
background: `${new Date(data.liveStartTime).getTime() > new Date().getTime() ? '#999' : 'rgb(59, 191, 252)'}`,
|
||||||
}" @click="showClick">观看
|
}" @click="showClick">观看
|
||||||
</botton>
|
</botton>
|
||||||
<botton class="btn" :style="{
|
<botton v-if="!isAllowSign" class="btn" style="margin-right: 20px; background: #999" @click="signClick">签到
|
||||||
|
</botton>
|
||||||
|
<botton v-else class="btn" :style="{
|
||||||
background: `${new Date(data.liveStartTime).getTime() > new Date().getTime() ? '#999' : data.signFlag ? '#999' : 'rgb(57, 146, 249)'}`,
|
background: `${new Date(data.liveStartTime).getTime() > new Date().getTime() ? '#999' : data.signFlag ? '#999' : 'rgb(57, 146, 249)'}`,
|
||||||
}" @click="signClick">{{ data.signFlag ? "已签到" : "签到" }}
|
}" @click="signClick">{{ data.signFlag ? "已签到" : "签到" }}
|
||||||
</botton>
|
</botton>
|
||||||
|
|||||||
@@ -45,13 +45,9 @@
|
|||||||
<div style="margin-left: 8px">{{ data?.activityAddress }}</div>
|
<div style="margin-left: 8px">{{ data?.activityAddress }}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<botton
|
<botton v-if="!isAllowSign" class="btn" style="margin-right: 20px; background: #999" @click="signClick">签到
|
||||||
class="btn"
|
</botton>
|
||||||
:style="{
|
<botton class="btn" :style="{background: `${data.signFlag ? '#999' : 'rgb(57, 146, 249)'}`, }" @click="signClick" >{{ data.signFlag ? "已签到" : "签到" }}
|
||||||
background: `${data.signFlag ? '#999' : 'rgb(57, 146, 249)'}`,
|
|
||||||
}"
|
|
||||||
@click="signClick"
|
|
||||||
>{{ data.signFlag ? "已签到" : "签到" }}
|
|
||||||
</botton>
|
</botton>
|
||||||
</div>
|
</div>
|
||||||
<!-- 基本信息 -->
|
<!-- 基本信息 -->
|
||||||
@@ -147,6 +143,7 @@ import { request, useRequest } from "@/api/request";
|
|||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
import { useRoute } from "vue-router/dist/vue-router";
|
import { useRoute } from "vue-router/dist/vue-router";
|
||||||
import { ElMessage } from "element-plus";
|
import { ElMessage } from "element-plus";
|
||||||
|
import { reactive, onUnmounted } from "vue";
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const returnclick = () => {
|
const returnclick = () => {
|
||||||
router.back();
|
router.back();
|
||||||
@@ -154,7 +151,10 @@ const returnclick = () => {
|
|||||||
const {
|
const {
|
||||||
query: { courseId: activityId, id: taskId, type, pName, sName },
|
query: { courseId: activityId, id: taskId, type, pName, sName },
|
||||||
} = useRoute();
|
} = useRoute();
|
||||||
|
const state = reactive({
|
||||||
|
|
||||||
|
isAllowSign: false,
|
||||||
|
});
|
||||||
const { data } = useRequest(ACTIVITY, { activityId });
|
const { data } = useRequest(ACTIVITY, { activityId });
|
||||||
const signClick = (tab, event) => {
|
const signClick = (tab, event) => {
|
||||||
if (data.value.signFlag) {
|
if (data.value.signFlag) {
|
||||||
@@ -168,6 +168,57 @@ const signClick = (tab, event) => {
|
|||||||
type,
|
type,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
let timer = null;
|
||||||
|
//判断能否签到
|
||||||
|
function isSignClick() {
|
||||||
|
timer = setInterval(() => {
|
||||||
|
let beginTime = new Date(data.activityStartTime).getTime();
|
||||||
|
let endTime = !data.afterSignIn
|
||||||
|
? new Date(data.activityEndTime).getTime()
|
||||||
|
: new Date(data.activityStartTime).getTime();
|
||||||
|
let nowTime = new Date().getTime();
|
||||||
|
if (data.beforeSignIn && data.afterSignIn) {
|
||||||
|
//有开始前有开始后
|
||||||
|
beginTime = beginTime - data.beforeSignIn * 60 * 1000;
|
||||||
|
endTime = endTime + data.afterSignIn * 60 * 1000;
|
||||||
|
console.log("1111");
|
||||||
|
} else if (
|
||||||
|
data.beforeSignIn &&
|
||||||
|
!data.afterSignIn
|
||||||
|
) {
|
||||||
|
//只有开始前无开始后
|
||||||
|
beginTime = beginTime - data.beforeSignIn * 60 * 1000;
|
||||||
|
console.log("11112222");
|
||||||
|
} else if (
|
||||||
|
!data.beforeSignIn &&
|
||||||
|
data.afterSignIn
|
||||||
|
) {
|
||||||
|
//无开始前有开始后
|
||||||
|
endTime = endTime + data.afterSignIn * 60 * 1000;
|
||||||
|
console.log("1111333");
|
||||||
|
}
|
||||||
|
if (nowTime < endTime && nowTime > beginTime) {
|
||||||
|
state.isAllowSign = true;
|
||||||
|
} else {
|
||||||
|
state.isAllowSign = false;
|
||||||
|
}
|
||||||
|
// console.log(
|
||||||
|
// "isAllowSign",
|
||||||
|
// state.isAllowSign,
|
||||||
|
// nowTime,
|
||||||
|
// endTime,
|
||||||
|
// beginTime,
|
||||||
|
// nowTime < endTime,
|
||||||
|
// nowTime > beginTime
|
||||||
|
// );
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
isSignClick();
|
||||||
|
onUnmounted(() => {
|
||||||
|
if (timer) {
|
||||||
|
clearInterval(timer);
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
||||||
|
|||||||
Reference in New Issue
Block a user