|
|
|
|
@ -64,6 +64,15 @@
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
|
|
|
|
|
<!-- 签到成功 → 今日未抽奖则弹出抽奖弹窗(抽过则不再弹,避免重复打扰) -->
|
|
|
|
|
<LotteryDialog
|
|
|
|
|
v-model="lotteryVisible"
|
|
|
|
|
:drawable="!hasDrawn"
|
|
|
|
|
:batch-goal="500"
|
|
|
|
|
:batch-current="0"
|
|
|
|
|
@success="onLotterySuccess"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
@ -73,6 +82,7 @@ import { ElMessage } from "element-plus";
|
|
|
|
|
import { signIn, getPoints } from "@/service/modular/hospital";
|
|
|
|
|
import { useSignInDialogStore } from "@/stores/signInDialog";
|
|
|
|
|
import { useRewardResultStore } from "@/stores/rewardResult";
|
|
|
|
|
import LotteryDialog from "@/views/hospital/LotteryDialog.vue";
|
|
|
|
|
import checkIcon from "@/assets/image/hospital/ponits/coin.svg";
|
|
|
|
|
import iconSign from "@/assets/image/hospital/ponits/icon-sign-large.svg";
|
|
|
|
|
|
|
|
|
|
@ -88,6 +98,8 @@ const props = defineProps({
|
|
|
|
|
signInRank: { type: Number, default: 0 },
|
|
|
|
|
// 击败医院百分比 0-100,0 表示未上榜(接口字段:beatPercent)
|
|
|
|
|
beatPercent: { type: Number, default: 0 },
|
|
|
|
|
// 今日是否已抽奖(来自 summary.isDraw);未抽过奖时签到成功会顺带弹抽奖
|
|
|
|
|
hasDrawn: { type: Boolean, default: false },
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits(["update:modelValue", "success"]);
|
|
|
|
|
@ -144,6 +156,7 @@ watch(
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const submitting = ref(false);
|
|
|
|
|
const lotteryVisible = ref(false);
|
|
|
|
|
const signInDialogStore = useSignInDialogStore();
|
|
|
|
|
const rewardResultStore = useRewardResultStore();
|
|
|
|
|
|
|
|
|
|
@ -156,7 +169,7 @@ const onClosed = () => {
|
|
|
|
|
submitting.value = false;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 取最新积分(用于结果区进度条)
|
|
|
|
|
// 取最新积分(用于签到成功结果区进度条)
|
|
|
|
|
const fetchLatestPoints = async () => {
|
|
|
|
|
try {
|
|
|
|
|
const res = unwrap(await getPoints());
|
|
|
|
|
@ -166,6 +179,11 @@ const fetchLatestPoints = async () => {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 抽奖成功后:刷新 summary(让 hasDrawn/isDraw 等状态同步)
|
|
|
|
|
const onLotterySuccess = async () => {
|
|
|
|
|
await signInDialogStore.refreshSummary();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// ============ 签到 ============
|
|
|
|
|
const handleSignIn = async () => {
|
|
|
|
|
if (props.signedIn) {
|
|
|
|
|
@ -179,21 +197,26 @@ const handleSignIn = async () => {
|
|
|
|
|
// 重新生成 7 天(刷新签到状态)
|
|
|
|
|
days.value = buildSignInDays(props.consecutiveSignInDays, props.signedIn);
|
|
|
|
|
|
|
|
|
|
// 取最新积分 + 关闭签到弹窗 + 打开全局奖励结果弹窗
|
|
|
|
|
// 取最新积分,用于签到成功结果区进度条 / 后续场景
|
|
|
|
|
const totalPoints = await fetchLatestPoints();
|
|
|
|
|
|
|
|
|
|
// 先关闭签到弹窗(在父层),再下一帧 open 全局结果
|
|
|
|
|
// 先关闭签到弹窗(在父层),再下一帧按是否抽过奖选择弹哪个反馈
|
|
|
|
|
emit("update:modelValue", false);
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
rewardResultStore.open({
|
|
|
|
|
title: "签到成功",
|
|
|
|
|
icon: iconSign,
|
|
|
|
|
points: 1,
|
|
|
|
|
batchGoal: 500,
|
|
|
|
|
batchCurrent: totalPoints,
|
|
|
|
|
rewardName: "康小虎 AI 吉祥物",
|
|
|
|
|
});
|
|
|
|
|
if (!props.hasDrawn) {
|
|
|
|
|
// 未抽过奖 → 弹抽奖弹窗(抽完后内部会自己弹奖励结果)
|
|
|
|
|
lotteryVisible.value = true;
|
|
|
|
|
} else {
|
|
|
|
|
// 已抽过奖 → 弹签到成功的奖励结果(原注释里那块的复用)
|
|
|
|
|
// rewardResultStore.open({
|
|
|
|
|
// title: "签到成功",
|
|
|
|
|
// icon: iconSign,
|
|
|
|
|
// points: 1,
|
|
|
|
|
// batchGoal: 500,
|
|
|
|
|
// batchCurrent: totalPoints,
|
|
|
|
|
// rewardName: "康小虎 AI 吉祥物",
|
|
|
|
|
// });
|
|
|
|
|
}
|
|
|
|
|
}, 100);
|
|
|
|
|
|
|
|
|
|
// 通知外层 signInDialogStore 触发 onSigned 回调(同步刷新 summary)
|
|
|
|
|
@ -211,11 +234,11 @@ const handleSignIn = async () => {
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
/* ============ 所有样式都嵌套在 .signin-dialog 下 ============ */
|
|
|
|
|
.signin-dialog {
|
|
|
|
|
min-width: 502px;
|
|
|
|
|
padding: 0;
|
|
|
|
|
background: transparent;
|
|
|
|
|
box-shadow: none;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
min-width: 502px !important;
|
|
|
|
|
padding: 0 !important;
|
|
|
|
|
background: transparent !important;
|
|
|
|
|
box-shadow: none !important;
|
|
|
|
|
overflow: hidden !important;
|
|
|
|
|
|
|
|
|
|
.el-dialog__header {
|
|
|
|
|
display: none;
|
|
|
|
|
|