Forráskód Böngészése

feat: 修改轮盘

year 3 hete
szülő
commit
1b217c6194
2 módosított fájl, 22 hozzáadás és 1 törlés
  1. 12 1
      src/dialog/auto.ts
  2. 10 0
      src/stores/useWheelStore.ts

+ 12 - 1
src/dialog/auto.ts

@@ -1,6 +1,7 @@
 "use client";
 import { PromotionRep } from "@/api/home";
 import { useUserInfoStore } from "@/stores/useUserInfoStore";
+import useWheelStore from "@/stores/useWheelStore";
 import { server } from "@/utils/client";
 import { Local } from "@/utils/storage";
 import dayjs from "dayjs";
@@ -28,6 +29,7 @@ const getPromotions = async () => {
 const AutoShowDialog = () => {
     const [data, setData] = React.useState<PromotionRep[]>([]);
     const { userInfo } = useUserInfoStore();
+    const wheelState = useWheelStore((state) => state);
 
     React.useEffect(() => {
         getData();
@@ -89,7 +91,7 @@ const AutoShowDialog = () => {
             popData[userInfo.id] = {};
         }
         popData[userInfo.id][popid] = true;
-        console.log(1122, keyMap[type], type);
+
         Local.setKey(keyMap[type], JSON.stringify(popData));
     };
 
@@ -104,6 +106,7 @@ const AutoShowDialog = () => {
         if (startShow > data.length - 1) {
             startShow = 0;
         }
+
         for (let i = startShow; i < data.length; i++) {
             const curData = data[i];
             // 一天只展示一次
@@ -127,6 +130,14 @@ const AutoShowDialog = () => {
                         await dialogManage.showDialog("TextDialog", curData);
                         break;
                     case 3:
+                        // 轮盘特殊处理 dialogManage.showDialog('WheelSection')
+                        console.log(wheelState.status);
+                        if (
+                            curData?.action_params?.includes("WheelSection") &&
+                            wheelState.status === 2
+                        ) {
+                            break;
+                        }
                         if (curData.action_type === 5) {
                             curData?.action_params ? await eval(curData?.action_params || "") : "";
                         }

+ 10 - 0
src/stores/useWheelStore.ts

@@ -35,6 +35,7 @@ export const useWheelStore = create<State & Action>()((set, get) => {
             if (!getToken()) return Promise.resolve(undefined);
             return getWheelApi().then((res) => {
                 const { data } = res;
+                console.log(1122334455, data);
                 if (Array.isArray(data)) {
                     set((state) => ({ ...state, ...initialState }));
                     return undefined;
@@ -49,6 +50,15 @@ export const useWheelStore = create<State & Action>()((set, get) => {
                     }));
                     return data;
                 }
+                if (data.total === 0) {
+                    set((state) => ({
+                        ...state,
+                        status: 2,
+                        currentWheel: source,
+                        receiveTarget: {},
+                    }));
+                    return data;
+                }
                 if (source.can === 1 && data.not_receive === null) {
                     set((state) => ({
                         ...state,