AccountHeader.tsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. "use client";
  2. import Link from "next/link";
  3. import { useState } from "react";
  4. import type {CustomerVipGrowthData,CustomerProfileUser} from "@/types/api/customer/profile/type";
  5. import SettingModal from "@/components/customer/SettingModal";
  6. import AccountVipPopup from "./AccountVipPopup";
  7. import Image from "next/image";
  8. interface AccountHeaderProps {
  9. user: CustomerProfileUser;
  10. points: number;
  11. coupon_count: number;
  12. wishlist_count?: number;
  13. vipData: CustomerVipGrowthData;
  14. }
  15. export default function AccountHeader({
  16. user,
  17. points,
  18. coupon_count,
  19. vipData
  20. }: AccountHeaderProps) {
  21. const [showSetting, setShowSetting] = useState(false);
  22. const [showVip, setShowVip] = useState(false);
  23. let progressPercent = 0;
  24. let progressText = "";
  25. if (vipData.next_level.min_growth_value > 0) {
  26. const rawPercent = (vipData.growth_value / vipData.next_level.min_growth_value) * 100;
  27. progressPercent = Math.min(Math.max(rawPercent, 0), 100);
  28. progressText = `growth value ${vipData.growth_value}/${vipData.next_level.min_growth_value}`;
  29. } else {
  30. progressText = String(vipData.growth_to_next_level);
  31. progressPercent = 0;
  32. }
  33. return (
  34. <>
  35. {/* 顶部浅橙色背景 */}
  36. <div className="text-center relative pb-8 bg-[url('/image/account/202608271600.png')] bg-no-repeat bg-size-[100%_100%]">
  37. {/* 标题 + 设置 */}
  38. {/* <h1 className="absolute top-2.5 left-4 margin-0 text-base">
  39. My Account
  40. </h1> */}
  41. <div
  42. className="absolute top-4 right-4 z-[9]"
  43. onClick={() => {
  44. setShowSetting(true);
  45. }}
  46. >
  47. <svg
  48. className="text-2xl w-6 h-6 "
  49. viewBox="0 0 1024 1024"
  50. version="1.1"
  51. xmlns="http://www.w3.org/2000/svg"
  52. p-id="3492"
  53. width="200"
  54. height="200"
  55. fill="#FFFFFF"
  56. >
  57. <path
  58. d="M0 0h1024v1024H0z"
  59. fill="#FFFFFF"
  60. fillOpacity="0.01"
  61. p-id="3493"
  62. ></path>
  63. <path
  64. d="M629.077333 935.253333a21.333333 21.333333 0 0 1-20.309333-14.848 105.728 105.728 0 0 0-201.386667 0 21.333333 21.333333 0 0 1-26.410666 13.952 445.354667 445.354667 0 0 1-193.365334-117.930666 21.333333 21.333333 0 0 1-0.938666-28.544 105.685333 105.685333 0 0 0-80.64-173.824c-3.498667 0-7.04 0-10.496 0.512a21.333333 21.333333 0 0 1-22.997334-17.066667 448 448 0 0 1 11.349334-222.976 21.333333 21.333333 0 0 1 20.650666-14.933333h1.493334a105.813333 105.813333 0 0 0 105.514666-105.557334 104.618667 104.618667 0 0 0-10.837333-46.677333 21.333333 21.333333 0 0 1 4.608-25.045333 445.909333 445.909333 0 0 1 183.850667-102.869334 21.333333 21.333333 0 0 1 24.704 10.88 105.728 105.728 0 0 0 188.416 0 21.333333 21.333333 0 0 1 24.704-10.88 445.909333 445.909333 0 0 1 183.850666 102.869334 21.333333 21.333333 0 0 1 4.608 25.045333 104.618667 104.618667 0 0 0-10.837333 46.677333 105.813333 105.813333 0 0 0 105.685333 105.642667h1.493334a21.333333 21.333333 0 0 1 20.650666 14.933333 448 448 0 0 1 11.349334 222.976 21.333333 21.333333 0 0 1-22.997334 17.066667 107.392 107.392 0 0 0-10.496-0.512 105.685333 105.685333 0 0 0-80.810666 173.781333 21.333333 21.333333 0 0 1-0.938667 28.544 445.354667 445.354667 0 0 1-193.450667 117.845334 21.333333 21.333333 0 0 1-6.016 0.938666z m-398.08-135.850666A402.901333 402.901333 0 0 0 374.826667 887.466667a148.48 148.48 0 0 1 266.709333 0 402.901333 402.901333 0 0 0 143.701333-88.064 148.352 148.352 0 0 1 120.021334-227.925334A405.717333 405.717333 0 0 0 896 401.664a148.48 148.48 0 0 1-125.184-198.058667 403.584 403.584 0 0 0-139.562667-78.421333 148.437333 148.437333 0 0 1-246.186666 0 403.584 403.584 0 0 0-139.605334 78.464 148.48 148.48 0 0 1-125.184 198.058667 405.717333 405.717333 0 0 0-9.258666 169.813333 148.352 148.352 0 0 1 120.021333 227.925333z"
  65. p-id="3494"
  66. ></path>
  67. <path
  68. d="M508.074667 677.589333a169.514667 169.514667 0 1 1 169.514666-169.514666 169.728 169.728 0 0 1-169.514666 169.514666z m0-296.362666a126.848 126.848 0 1 0 126.848 126.848 126.976 126.976 0 0 0-126.848-126.848z"
  69. p-id="3495"
  70. ></path>
  71. </svg>
  72. </div>
  73. {/* 头像 + 用户信息 */}
  74. <div className="flex items-center h-26 box-unset mt-0 pt-4 p-4 pb-0">
  75. <div className="relative text-5xl w-17.5 h-17.5 rounded-full bg-[rgba(249,249,249,1)] mr-3 uppercase flex items-center justify-center">
  76. <Image
  77. className=" block"
  78. src={ user.image_url || "/image/account/202608271601.png" }
  79. alt={"userphoto"}
  80. width={48}
  81. height={48}
  82. />
  83. </div>
  84. <div className="align-left leading-5">
  85. <h2 className="font-semibold text-lg text-white"> {user.name}</h2>
  86. <p className="text-xs mt-1.5 text-white"> {user.email}</p>
  87. </div>
  88. </div>
  89. {/* 积分 / 优惠券 / 余额 */}
  90. <div className="flex justify-between items-center p-4 pt-0 pb-0 mt-5 text-sm ">
  91. <Link
  92. className="leading-5 text-xs pt-1 w-26.5 h-11 rounded-2xl bg-[rgba(0,0,0,0.3)] shadow-[0px_1px_4px_rgba(0,0,0,0.25)] text-white"
  93. href="/customer/account/mypoints"
  94. aria-label="Go to customer account mypoints page"
  95. >
  96. <strong> {points}</strong> <br />{" "}
  97. <span className="flex items-center justify-center">
  98. {" "}
  99. Points{" "}
  100. <svg
  101. xmlns="http://www.w3.org/2000/svg"
  102. width="12"
  103. height="12"
  104. viewBox="0 0 12 12"
  105. fill="none"
  106. >
  107. <path
  108. stroke="rgba(255, 255, 255, 1)"
  109. stroke-width="1"
  110. stroke-linejoin="round"
  111. stroke-linecap="square"
  112. d="M4.5 9L7.5 6L4.5 3"
  113. ></path>
  114. </svg>
  115. </span>
  116. </Link>
  117. {/* <div>|</div> */}
  118. <Link
  119. className="leading-5 text-xs pt-1 w-26.5 h-11 rounded-2xl bg-[rgba(0,0,0,0.3)] shadow-[0px_1px_4px_rgba(0,0,0,0.25)] text-white"
  120. href="/customer/account/mycoupon"
  121. aria-label="Go to customer account mycoupon page"
  122. >
  123. <strong className="coupons-number"> {coupon_count}</strong> <br />{" "}
  124. <span className="flex items-center justify-center">
  125. {" "}
  126. Coupon{" "}
  127. <svg
  128. xmlns="http://www.w3.org/2000/svg"
  129. width="12"
  130. height="12"
  131. viewBox="0 0 12 12"
  132. fill="none"
  133. >
  134. <path
  135. stroke="rgba(255, 255, 255, 1)"
  136. stroke-width="1"
  137. stroke-linejoin="round"
  138. stroke-linecap="square"
  139. d="M4.5 9L7.5 6L4.5 3"
  140. ></path>
  141. </svg>
  142. </span>
  143. </Link>
  144. {/* <div>|</div> */}
  145. <Link
  146. className="leading-5 text-xs pt-1 flex flex-col items-center w-26.5 h-11 rounded-2xl bg-[rgba(0,0,0,0.3)] shadow-[0px_1px_4px_rgba(0,0,0,0.25)] text-white"
  147. href="/koc/user/mybalance"
  148. aria-label="Go to koc user mybalance page"
  149. >
  150. 0
  151. {/* <svg
  152. xmlns="http://www.w3.org/2000/svg"
  153. className="h-6 w-6 "
  154. fill="none"
  155. viewBox="0 0 24 24"
  156. stroke="currentColor"
  157. >
  158. <path
  159. strokeLinecap="round"
  160. strokeLinejoin="round"
  161. strokeWidth={1.5}
  162. d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z"
  163. />
  164. </svg> */}
  165. <span className="flex items-center justify-center">
  166. Wishlist
  167. <svg
  168. xmlns="http://www.w3.org/2000/svg"
  169. width="12"
  170. height="12"
  171. viewBox="0 0 12 12"
  172. fill="none"
  173. >
  174. <path
  175. stroke="rgba(255, 255, 255, 1)"
  176. stroke-width="1"
  177. stroke-linejoin="round"
  178. stroke-linecap="square"
  179. d="M4.5 9L7.5 6L4.5 3"
  180. ></path>
  181. </svg>
  182. </span>
  183. {/* <strong>$0</strong> <br /> Balance */}
  184. </Link>
  185. </div>
  186. </div>
  187. {/* VIP 等级 */}
  188. <div
  189. onClick={() => {
  190. setShowVip(true);
  191. console.log("aaaa", showVip, showSetting);
  192. }}
  193. className=" block relative
  194. w-83 h-18
  195. mx-auto -mt-3 mb-8
  196. text-center text-white
  197. text-base leading-14
  198. rounded-[18px] bg-white shadow-[0px_2px_12px_rgba(0,0,0,0.1)]
  199. "
  200. // bg-[url('https://cdn.alipearlhair.com/media/wysiwyg/wap/202308221143.png')] bg-no-repeat bg-[length:100%_100%]
  201. >
  202. <span
  203. className=" absolute
  204. top-4 left-4
  205. text-black
  206. font-semibold
  207. text-4.5
  208. leading-normal"
  209. >
  210. {vipData.level_name}
  211. </span>
  212. <p className="text-black text-right pr-10" >{progressText}</p>
  213. <svg
  214. className="absolute top-4 right-4 text-4 w-5 h-5"
  215. viewBox="0 0 1024 1024"
  216. version="1.1"
  217. xmlns="http://www.w3.org/2000/svg"
  218. p-id="1446"
  219. width="200"
  220. height="200"
  221. fill="#000"
  222. >
  223. <path
  224. d="M761.055557 532.128047c0.512619-0.992555 1.343475-1.823411 1.792447-2.848649 8.800538-18.304636 5.919204-40.703346-9.664077-55.424808L399.935923 139.743798c-19.264507-18.208305-49.631179-17.344765-67.872168 1.888778-18.208305 19.264507-17.375729 49.631179 1.888778 67.872168l316.960409 299.839269L335.199677 813.631716c-19.071845 18.399247-19.648112 48.767639-1.247144 67.872168 9.407768 9.791372 21.984142 14.688778 34.560516 14.688778 12.000108 0 24.000215-4.479398 33.311652-13.439914l350.048434-337.375729c0.672598-0.672598 0.927187-1.599785 1.599785-2.303346 0.512619-0.479935 1.056202-0.832576 1.567101-1.343475C757.759656 538.879828 759.199462 535.391265 761.055557 532.128047z"
  225. // fill="#ffffff"
  226. p-id="1447"
  227. ></path>
  228. </svg>
  229. <div className="relative h-1 w-75 bg-[#E5E5E5FF] ml-4">
  230. {/* <div
  231. className="w-4 h-4 rounded-full bg-black absolute top-1/2 -translate-y-1/2 block"
  232. style={{ left: `${progressPercent}%` }}
  233. ></div> */}
  234. <div
  235. className="rounded-[1.2821vw] h-full bg-[#01754AFF]"
  236. style={{ width: `${progressPercent}%` }}
  237. ></div>
  238. </div>
  239. </div>
  240. {/* 弹窗组件 */}
  241. <SettingModal
  242. visible={showSetting}
  243. onClose={() => setShowSetting(false)}
  244. />
  245. <AccountVipPopup visible={showVip} onClose={() => setShowVip(false)} />
  246. </>
  247. );
  248. }