Explorar el Código

fix: 更新轮盘ui

Before hace 7 meses
padre
commit
7c776e1dcc

+ 1 - 0
package.json

@@ -24,6 +24,7 @@
   },
   "dependencies": {
     "@lucky-canvas/react": "^0.1.13",
+    "@number-flow/react": "^0.4.2",
     "ahooks": "^3.8.0",
     "antd-mobile": "^5.37.1",
     "axios": "^1.7.2",

+ 31 - 3
pnpm-lock.yaml

@@ -11,6 +11,9 @@ importers:
       '@lucky-canvas/react':
         specifier: ^0.1.13
         version: 0.1.13
+      '@number-flow/react':
+        specifier: ^0.4.2
+        version: 0.4.2(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
       ahooks:
         specifier: ^3.8.0
         version: 3.8.0(react@18.3.1)
@@ -496,6 +499,12 @@ packages:
     resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==}
     engines: {node: '>= 8'}
 
+  '@number-flow/react@0.4.2':
+    resolution: {integrity: sha512-lCAkLuK/3+Nlhb/oy1tpRnadp1vvfc/cWTtWUL9hMksHsJOGh+1T5Y/dyeQhyCD0heaWTjNYWX2ndBKLJwuC0A==}
+    peerDependencies:
+      react: ^18 || ^19.0.0-rc-915b914b3a-20240515
+      react-dom: ^18
+
   '@pkgjs/parseargs@0.11.0':
     resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==}
     engines: {node: '>=14'}
@@ -1073,6 +1082,9 @@ packages:
     engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
     hasBin: true
 
+  esm-env@1.2.1:
+    resolution: {integrity: sha512-U9JedYYjCnadUlXk7e1Kr+aENQhtUaoaV9+gZm1T8LC/YBAPJx3NSPIAurFOC0U5vrdSevnUJS2/wUVxGwPhng==}
+
   espree@9.6.1:
     resolution: {integrity: sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==}
     engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
@@ -1615,6 +1627,9 @@ packages:
     resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==}
     engines: {node: '>=0.10.0'}
 
+  number-flow@0.4.1:
+    resolution: {integrity: sha512-d39o1tWL7mMMBLuOfHswtQ8r0fj9eUcatb4G1Spdv0ZO/I30kg9DBdSzSPjNG6hrj1slQ6KA3TQXk1RmOq4qOA==}
+
   object-assign@4.1.1:
     resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==}
     engines: {node: '>=0.10.0'}
@@ -2760,6 +2775,13 @@ snapshots:
       '@nodelib/fs.scandir': 2.1.5
       fastq: 1.17.1
 
+  '@number-flow/react@0.4.2(react-dom@18.3.1(react@18.3.1))(react@18.3.1)':
+    dependencies:
+      esm-env: 1.2.1
+      number-flow: 0.4.1
+      react: 18.3.1
+      react-dom: 18.3.1(react@18.3.1)
+
   '@pkgjs/parseargs@0.11.0':
     optional: true
 
@@ -3386,7 +3408,7 @@ snapshots:
       eslint: 8.57.0
       eslint-import-resolver-node: 0.3.9
       eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1(eslint@8.57.0))(eslint@8.57.0)
-      eslint-plugin-import: 2.29.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1(eslint@8.57.0))(eslint@8.57.0))(eslint@8.57.0)
+      eslint-plugin-import: 2.29.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0)
       eslint-plugin-jsx-a11y: 6.9.0(eslint@8.57.0)
       eslint-plugin-react: 7.34.4(eslint@8.57.0)
       eslint-plugin-react-hooks: 4.6.2(eslint@8.57.0)
@@ -3414,7 +3436,7 @@ snapshots:
       enhanced-resolve: 5.17.0
       eslint: 8.57.0
       eslint-module-utils: 2.8.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1(eslint@8.57.0))(eslint@8.57.0))(eslint@8.57.0)
-      eslint-plugin-import: 2.29.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1(eslint@8.57.0))(eslint@8.57.0))(eslint@8.57.0)
+      eslint-plugin-import: 2.29.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0)
       fast-glob: 3.3.2
       get-tsconfig: 4.7.5
       is-core-module: 2.14.0
@@ -3436,7 +3458,7 @@ snapshots:
     transitivePeerDependencies:
       - supports-color
 
-  eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1(eslint@8.57.0))(eslint@8.57.0))(eslint@8.57.0):
+  eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0):
     dependencies:
       array-includes: 3.1.8
       array.prototype.findlastindex: 1.2.5
@@ -3560,6 +3582,8 @@ snapshots:
     transitivePeerDependencies:
       - supports-color
 
+  esm-env@1.2.1: {}
+
   espree@9.6.1:
     dependencies:
       acorn: 8.12.1
@@ -4116,6 +4140,10 @@ snapshots:
 
   normalize-path@3.0.0: {}
 
+  number-flow@0.4.1:
+    dependencies:
+      esm-env: 1.2.1
+
   object-assign@4.1.1: {}
 
   object-hash@3.0.0: {}

BIN
public/wheels/active-bg.png


BIN
public/wheels/bg-light.png


+ 2 - 0
src/api/cashWheel.ts

@@ -21,6 +21,8 @@ export interface Activity {
      * 分享手机号开关
      */
     share_phone_enable: string;
+    // 短信内容
+    note: string;
 }
 
 export interface ShareConfig {

+ 11 - 3
src/app/[locale]/(TabBar)/[[...share]]/_home/HomePromotion.tsx

@@ -58,13 +58,21 @@ const HomePromotion: FC<Props> = (props) => {
                         " -translate-x-1/2"
                     }
                 >
+                    <div></div>
                     <div
                         onClick={closeHandler}
+                        style={{
+                            background:
+                                "linear-gradient(45deg, deeppink, deeppink 50%, transparent 50%, transparent 100%)",
+                        }}
                         className={
-                            "iconfont icon-guanbi absolute right-[0.2389rem] top-[0.1347rem]" +
-                            " z-20 text-[0.1389rem]"
+                            "absolute right-[0px] top-[0] h-[80px] w-[80px] bg-[linear-gradient(45deg_deeppink_deeppink_50%_transparent_50%_transparent_100%)]" +
+                            " z-20" +
+                            " border-4"
                         }
-                    ></div>
+                    >
+                        <i className={"iconfont icon-guanbi"}></i>
+                    </div>
                     <Swiper
                         loop
                         pagination={{ clickable: true }}

+ 17 - 5
src/app/[locale]/(wheel)/cashWheel/CashWheelClient.tsx

@@ -7,6 +7,7 @@ import { Link } from "@/i18n/routing";
 import { useUserInfoStore } from "@/stores/useUserInfoStore";
 import { server } from "@/utils/client";
 import { copyText, timeFormat } from "@/utils/methods";
+import NumberFlow from "@number-flow/react";
 import { useCountDown } from "ahooks";
 import { Popup, Toast } from "antd-mobile";
 import clsx from "clsx";
@@ -259,7 +260,11 @@ const WheelWallet = () => {
                         <span>{user.user_phone}</span>
                     </div>
                     <div className={"text-[0.4861rem] font-bold text-[#008213]"}>
-                        R$ <span>{wheel.activate?.amount || 0}</span>
+                        <NumberFlow
+                            value={wheel.activate?.amount! || 0}
+                            prefix={"R$ "}
+                            trend={+1}
+                        />
                     </div>
                 </div>
                 <div
@@ -269,7 +274,11 @@ const WheelWallet = () => {
                 >
                     <span className={"mr-[10px] text-[#008213]"}>Faltam para O saque</span>
                     <span className={"text-[#eef100]"}>
-                        R${(wheel.num! - wheel.activate?.amount! || 0).toFixed(2)}
+                        <NumberFlow
+                            value={wheel.num! - wheel.activate?.amount! || 0}
+                            prefix={"R$ "}
+                            trend={-1}
+                        />
                     </span>
                 </div>
                 {/*top*/}
@@ -282,10 +291,10 @@ const DrawMain = () => {
     const wheel = useContext(WheelContext);
 
     return (
-        <div className={"relative"}>
+        <div className={""}>
             <WheelWallet />
 
-            <div className={"-mt-[0.2083rem] transform"}>
+            <div className={"-mt-[0.2083rem]"}>
                 <WheelClient isRotate={true} wheel={wheel} onRotateEnd={wheel.handler!} />
             </div>
         </div>
@@ -339,6 +348,9 @@ const ShareClient = () => {
     const [visible, setVisible] = useState(false);
     const wheel = useContext(WheelContext);
     const user = useUserInfoStore((state) => state.userInfo);
+    const currentWheel = wheel.activities?.[0];
+
+    console.log(`🚀🚀🚀🚀🚀-> in CashWheelClient.tsx on 353`, wheel.phones?.join(";"));
 
     const [currentPhoneIndex, setCurrentPhoneIndex] = useState(0);
 
@@ -510,7 +522,7 @@ const ShareClient = () => {
                                     />
                                 </div>
                                 <Link
-                                    href={`sms:${wheel.phones?.join(";")}?body=message_body`}
+                                    href={`sms:${wheel.phones?.join(",")}?body=${currentWheel?.note}`}
                                     className={
                                         "flex items-center rounded-[10px] bg-[#35b2fe]" +
                                         " p-[0.0694rem] text-[#fff]"

+ 4 - 3
src/app/[locale]/(wheel)/cashWheel/style.module.scss

@@ -497,10 +497,11 @@
     .rules {
       border-radius: .04rem;
       background: #232327;
-      width: 106%;
-      margin-left: -3%;
+      //width: 106%;
+      //margin-left: -3%;
       margin-top: .04rem;
-      padding: 3.6%;
+      padding: 0.0694rem;
+
       -webkit-box-sizing: border-box;
       box-sizing: border-box;
       h2 {

+ 1 - 1
src/app/[locale]/(wheel)/sharecwbr/page.tsx

@@ -18,7 +18,7 @@ const Page = () => {
         sessionStorage.setItem("turntable_time", `${time}` || "");
     }, []);
     return (
-        <div>
+        <div className={"transform"}>
             <WheelClient isRotate={false} wheel={{}} />
             <div className={"mt-[10px] h-[1.6rem] overflow-hidden p-[0.1389rem]"}>
                 <LeftListClient />

+ 46 - 3
src/components/Box/WheelModal.module.scss

@@ -97,9 +97,9 @@
       width: .5rem
     }
     .cash {
-      width: .52rem;
-      font-weight: 700;
-      margin-right: .12rem
+      //width: .52rem;
+      //font-weight: 700;
+      //margin-right: .12rem
     }
 
   }
@@ -294,3 +294,46 @@
     transform: translateY(20px);
   }
 }
+
+.rotateAnimation{
+  animation: rotating 10s  linear  infinite ;
+}
+@keyframes rotating {
+  0% {
+    transform: rotate(0deg);
+  }
+
+  20% {
+    transform: rotate(72deg);
+  }
+
+  40% {
+    transform: rotate(144deg);
+  }
+
+  60% {
+    transform: rotate(216deg);
+  }
+
+  80% {
+    transform: rotate(288deg);
+  }
+
+  100% {
+    transform: rotate(360deg);
+  }
+
+}
+
+
+.activeAnimation{
+  animation: activing  0.3s ease  infinite alternate;
+}
+@keyframes activing {
+  0% {
+    opacity: 0;
+  }
+  100% {
+    opacity: 1;
+  }
+}

+ 54 - 21
src/components/Box/WheelModal.tsx

@@ -6,6 +6,7 @@ import { useRouter } from "@/i18n/routing";
 import { getToken } from "@/utils/Cookies";
 import { percentage, timeFormat } from "@/utils/methods";
 import { LuckyWheel } from "@lucky-canvas/react";
+import NumberFlow from "@number-flow/react";
 import { Mask } from "antd-mobile";
 import Image from "next/image";
 import { FC, forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react";
@@ -151,6 +152,9 @@ export interface WheelProps {
 }
 export const WheelClient: FC<WheelProps> = (props) => {
     const { isRotate, wheel, onRotateEnd } = props;
+
+    // 选中 dom
+    const activeRef = useRef<HTMLImageElement | null>(null);
     const wheelRef = useRef<any>();
     /*是否旋转*/
     const rotating = useRef<boolean>(false);
@@ -194,6 +198,7 @@ export const WheelClient: FC<WheelProps> = (props) => {
     };
     const endRotate = (prize: any) => {
         rotating.current = false;
+        activeRef.current!.style.display = "block";
 
         if (currentWin.current.amount > 0) {
             setButtonText(`+${currentWin.current.amount}`);
@@ -203,6 +208,7 @@ export const WheelClient: FC<WheelProps> = (props) => {
 
         setTimeout(() => {
             onRotateEnd && onRotateEnd();
+            activeRef.current!.style.display = "none";
         }, 2000);
     };
 
@@ -211,22 +217,40 @@ export const WheelClient: FC<WheelProps> = (props) => {
     }, [wheel]);
 
     return (
-        <div className={"relative w-[100%]"}>
-            <img
+        <div className={"relative w-[100%] transform"}>
+            <Image
                 src="/wheels/aura.png"
                 alt=""
+                width={750}
+                height={300}
                 className={`absolute h-[100%] ${styles.floatAnimation}`}
             />
-            <img
+            <div className={"absolute h-[3.0833rem] w-[100%] overflow-hidden"}>
+                <Image
+                    width={750}
+                    height={300}
+                    src="/wheels/bg-light.png"
+                    className={`absolute -top-[0.2778rem] left-0 -z-[1] ${styles.rotateAnimation}`}
+                    alt=""
+                />
+            </div>
+
+            <Image
+                width={750}
+                height={300}
+                alt=""
                 src={"/wheels/wheel-bg.png"}
                 className={"mx-auto h-[5.6rem] w-[100%] object-cover"}
             />
-            <img
+            <Image
+                width={750}
+                height={300}
+                alt=""
                 src={"/wheels/title.png"}
                 className={"absolute left-[11.5%] top-[41%] z-10 w-[76%]"}
             />
             {/*定位到中心圆*/}
-            <div className={"absolute bottom-[0px] h-[3.15rem] w-[100%] p-[0.1389rem]"}>
+            <div className={"absolute bottom-[0px] z-10 h-[3.15rem] w-[100%] p-[0.1389rem]"}>
                 <div className={"relative flex h-[100%] w-[100%] justify-center"}>
                     <img src="/wheels/light-1.png" alt="" className={`absolute h-[100%]`} />
                     <img
@@ -239,14 +263,33 @@ export const WheelClient: FC<WheelProps> = (props) => {
                         alt=""
                         className={`absolute h-[100%] ${styles.closeFlashing}`}
                     />
+                    <img
+                        ref={activeRef}
+                        src="/wheels/active-bg.png"
+                        className={`absolute z-10 ml-[0.0694rem] mt-[0.1389rem] hidden h-[1.3889rem] ${styles.activeAnimation}`}
+                        alt=""
+                    />
 
                     <div
                         className={
                             "relative h-[100%] w-[2.62rem] rounded-[50%] px-[0.0486rem] py-[0.1736rem]"
                         }
                     >
+                        <LuckyWheel
+                            ref={wheelRef}
+                            width="2.52rem"
+                            height="2.52rem"
+                            blocks={blocks}
+                            defaultConfig={defaultConfig}
+                            prizes={prizes}
+                            onEnd={(prize: any) => endRotate(prize)}
+                        />
+
                         <div
-                            className={"absolute bottom-[50%] left-0 z-50 w-[100%] translate-y-1/2"}
+                            className={
+                                "absolute bottom-[50%] left-0 z-[888] w-[100%] " +
+                                " translate-y-1/2"
+                            }
                         >
                             <div
                                 className={"flex justify-center"}
@@ -268,15 +311,6 @@ export const WheelClient: FC<WheelProps> = (props) => {
                                 </span>
                             </div>
                         </div>
-                        <LuckyWheel
-                            ref={wheelRef}
-                            width="2.52rem"
-                            height="2.52rem"
-                            blocks={blocks}
-                            defaultConfig={defaultConfig}
-                            prizes={prizes}
-                            onEnd={(prize: any) => endRotate(prize)}
-                        />
                     </div>
                 </div>
             </div>
@@ -327,9 +361,8 @@ const DetailClient = (props: { wheel: Partial<WheelsType>; onUnload: () => void
         <div className={`${styles.cashMain} ${styles.cashMain} ${styles.type1}`}>
             <div className={styles.haveCash}>
                 <img src="/wheel/cash.png" alt="" className={styles.cashImg} />
-                <div>
-                    {" "}
-                    R$ <span className={styles.cash}>{wheel.activate?.amount}</span>
+                <div className={styles.cash}>
+                    <NumberFlow value={wheel.activate?.amount || 0} prefix={"R$ "} trend={+1} />
                 </div>
                 <span className={styles.withdraw}>
                     <img src="/wheel/pix.png" alt="" /> SACAR{" "}
@@ -345,7 +378,7 @@ const DetailClient = (props: { wheel: Partial<WheelsType>; onUnload: () => void
             <div className={styles.needCash}>
                 Ainda e necessário{" "}
                 <span className={styles.needCashNum}>
-                    {(100 - (wheel.activate?.amount || 0)).toFixed(2)}
+                    <NumberFlow value={100 - (wheel.activate?.amount || 0)} trend={-1} />
                 </span>{" "}
                 para realizar do saque{" "}
             </div>
@@ -366,7 +399,7 @@ const DetailClient = (props: { wheel: Partial<WheelsType>; onUnload: () => void
 };
 
 const WheelModal = forwardRef<WheelModalProps, Props>(function RedPacketModal(props, ref) {
-    const [visible, setVisible] = useState(true);
+    const [visible, setVisible] = useState(false);
 
     const [detailsVisible, setDetailsVisible] = useState(false);
     const [wheel, setWheel] = useState<Partial<WheelsType>>({});
@@ -417,7 +450,7 @@ const WheelModal = forwardRef<WheelModalProps, Props>(function RedPacketModal(pr
     };
     return (
         <>
-            <Mask visible={detailsVisible} getContainer={null}>
+            <Mask visible={detailsVisible} getContainer={null} destroyOnClose={true}>
                 <div className={"absolute top-[10%] z-50 w-[100%] p-[0.1389rem]"}>
                     <div className={"rounded-[0.0694rem] bg-[#232327FF] p-[0.0694rem]"}>
                         <div className={"flex items-center"}>

+ 6 - 1
src/utils/server/index.ts

@@ -64,7 +64,12 @@ class Server {
                 },
                 body: params,
                 ...other,
-            }).then((res) => res.json());
+            })
+                .then((res) => res.json())
+                .catch((error) => {
+                    console.log(`🚀🚀🚀🚀🚀-> in index.ts on 68`, error);
+                    return {};
+                });
             return responseInterceptor<T, R>(response, options, this.BASE_URL);
         } catch (error) {
             console.log(