sa2kit 1.6.75 → 1.6.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import React11, { useState, useEffect, useMemo, useCallback } from 'react';
2
2
  import { View, Text, ScrollView, Image, Input, Textarea, Button } from '@tarojs/components';
3
- import Taro3, { useDidShow } from '@tarojs/taro';
3
+ import Taro2, { useDidShow } from '@tarojs/taro';
4
4
 
5
5
  // src/showmasterpiece/ui/miniapp/components/PageHeader.tsx
6
6
  var PageHeader = ({ title, subtitle, actions, cta }) => {
@@ -33,12 +33,6 @@ function CategoryTabs({
33
33
  activeValue,
34
34
  onChange
35
35
  }) {
36
- const total = items.length || 1;
37
- const activeIndex = Math.max(
38
- items.findIndex((item) => item.value === activeValue),
39
- 0
40
- );
41
- const progressWidth = `${(activeIndex + 1) / total * 100}%`;
42
36
  return /* @__PURE__ */ React11.createElement(View, { className: "mt-3" }, /* @__PURE__ */ React11.createElement(ScrollView, { scrollX: true, showScrollbar: true }, /* @__PURE__ */ React11.createElement(View, { className: "flex gap-3 pb-1" }, items.map((item) => {
43
37
  const isActive = activeValue === item.value;
44
38
  return /* @__PURE__ */ React11.createElement(
@@ -58,7 +52,7 @@ function CategoryTabs({
58
52
  " \u4E2A"
59
53
  )
60
54
  );
61
- }))), /* @__PURE__ */ React11.createElement(View, { className: "mt-2 h-2 w-full overflow-hidden rounded-full bg-prussian-blue-100" }, /* @__PURE__ */ React11.createElement(View, { className: "h-full rounded-full bg-sky-500 transition-all", style: { width: progressWidth } })));
55
+ }))));
62
56
  }
63
57
  var CategoryTabs_default = CategoryTabs;
64
58
 
@@ -556,7 +550,7 @@ var createTaroExecutor = () => {
556
550
  data,
557
551
  headers
558
552
  }) => {
559
- const response = await Taro3.request({
553
+ const response = await Taro2.request({
560
554
  url,
561
555
  method,
562
556
  data,
@@ -805,18 +799,55 @@ var ShowMasterpieceMiniappPage = ({
805
799
  cancelPopup
806
800
  } = useDeadlinePopupWechat_default("showmasterpiece", "homepage_visit", apiBaseUrl);
807
801
  useEffect(() => {
802
+ try {
803
+ Taro2.setStorageSync("__cy_mps_boot_ready__", true);
804
+ Taro2.setStorageSync("__cy_mps_boot_retry_once__", false);
805
+ } catch (error2) {
806
+ console.error("[ShowMasterpieceMiniappPage] boot ready sync failed", error2);
807
+ }
808
+ }, []);
809
+ useEffect(() => {
810
+ const withTimeout = async (task, timeoutMs, fallbackMessage) => {
811
+ let timer;
812
+ try {
813
+ return await Promise.race([
814
+ task,
815
+ new Promise((_, reject) => {
816
+ timer = setTimeout(() => reject(new Error(fallbackMessage)), timeoutMs);
817
+ })
818
+ ]);
819
+ } finally {
820
+ if (timer) {
821
+ clearTimeout(timer);
822
+ }
823
+ }
824
+ };
808
825
  const loadCollections = async () => {
809
826
  setLoading(true);
810
827
  setError(null);
811
828
  try {
812
- const [collectionData, categoryData] = await Promise.all([
813
- getCollectionsOverview(apiBaseUrl),
814
- getCategories(apiBaseUrl)
829
+ const [collectionsResult, categoriesResult] = await Promise.allSettled([
830
+ withTimeout(getCollectionsOverview(apiBaseUrl), 12e3, "\u5546\u54C1\u6570\u636E\u52A0\u8F7D\u8D85\u65F6"),
831
+ withTimeout(getCategories(apiBaseUrl), 8e3, "\u5206\u7C7B\u6570\u636E\u52A0\u8F7D\u8D85\u65F6")
815
832
  ]);
816
- setCollections(collectionData);
817
- setCategoryOptions(Array.isArray(categoryData) ? categoryData : []);
833
+ if (collectionsResult.status === "fulfilled") {
834
+ setCollections(Array.isArray(collectionsResult.value) ? collectionsResult.value : []);
835
+ } else {
836
+ setCollections([]);
837
+ setError(collectionsResult.reason instanceof Error ? collectionsResult.reason.message : "\u5546\u54C1\u52A0\u8F7D\u5931\u8D25");
838
+ }
839
+ if (categoriesResult.status === "fulfilled") {
840
+ setCategoryOptions(Array.isArray(categoriesResult.value) ? categoriesResult.value : []);
841
+ } else {
842
+ setCategoryOptions([]);
843
+ if (collectionsResult.status === "fulfilled") {
844
+ setError("\u5206\u7C7B\u52A0\u8F7D\u5931\u8D25\uFF0C\u5DF2\u4F7F\u7528\u9ED8\u8BA4\u5206\u7C7B\u5C55\u793A");
845
+ }
846
+ }
818
847
  } catch (err) {
819
848
  setError(err instanceof Error ? err.message : "\u52A0\u8F7D\u5546\u54C1\u5931\u8D25");
849
+ setCollections([]);
850
+ setCategoryOptions([]);
820
851
  } finally {
821
852
  setLoading(false);
822
853
  }
@@ -874,13 +905,13 @@ var ShowMasterpieceMiniappPage = ({
874
905
  [collections, activeCategory]
875
906
  );
876
907
  const goToCart = () => {
877
- Taro3.navigateTo({ url: "/pages/cart/index" });
908
+ Taro2.navigateTo({ url: "/pages/cart/index" });
878
909
  };
879
910
  const goToHistory = () => {
880
- Taro3.navigateTo({ url: "/pages/history/index" });
911
+ Taro2.navigateTo({ url: "/pages/history/index" });
881
912
  };
882
913
  const goToTop = () => {
883
- Taro3.pageScrollTo({ scrollTop: 0, duration: 300 });
914
+ Taro2.pageScrollTo({ scrollTop: 0, duration: 300 });
884
915
  };
885
916
  const handleAddToCart = (collection) => {
886
917
  const normalizedCollection = {
@@ -889,7 +920,7 @@ var ShowMasterpieceMiniappPage = ({
889
920
  };
890
921
  const next = addToCart(normalizedCollection, 1);
891
922
  setCartCount(next.totalQuantity);
892
- Taro3.showToast({ title: "\u5DF2\u52A0\u5165\u8D2D\u7269\u8F66", icon: "success" });
923
+ Taro2.showToast({ title: "\u5DF2\u52A0\u5165\u8D2D\u7269\u8F66", icon: "success" });
893
924
  };
894
925
  return /* @__PURE__ */ React11.createElement(View, { className: "min-h-screen bg-gradient-to-br from-white to-prussian-blue-100 pb-12 text-rich-black" }, /* @__PURE__ */ React11.createElement(
895
926
  PageHeader_default,
@@ -897,7 +928,7 @@ var ShowMasterpieceMiniappPage = ({
897
928
  title: "\u8471\u97F5\u9B54\u6CD5\u5C4B",
898
929
  subtitle: "\u8471\u97F5\u73AF\u4EAC\u7684\u8C37\u5B50\u7F51\u7AD9\uFF0C\u8BF7\u5927\u5BB6\u5C3D\u60C5\u9274\u8D4F\u8001\u5E08\u4EEC\u7684\u4F5C\u54C1\u5427\uFF01"
899
930
  }
900
- ), /* @__PURE__ */ React11.createElement(View, { className: "mx-4 mt-4 rounded-3xl border border-prussian-blue-200 bg-white p-4 shadow-sm" }, /* @__PURE__ */ React11.createElement(Text, { className: "text-base font-semibold text-rich-black" }, "\u5206\u7C7B\u6D4F\u89C8"), /* @__PURE__ */ React11.createElement(Text, { className: "mt-1 block text-xs text-prussian-blue-600" }, "\u6309\u5206\u7C7B\u5FEB\u901F\u7B5B\u9009\u5546\u54C1\u5185\u5BB9"), /* @__PURE__ */ React11.createElement(
931
+ ), /* @__PURE__ */ React11.createElement(View, { className: "mx-4 mt-4 rounded-3xl border border-teal-200 bg-teal-50 p-4 shadow-sm" }, /* @__PURE__ */ React11.createElement(Text, { className: "text-base font-semibold text-rich-black" }, "\u5206\u7C7B\u6D4F\u89C8"), /* @__PURE__ */ React11.createElement(Text, { className: "mt-1 block text-xs text-teal-700" }, "\u6309\u5206\u7C7B\u5FEB\u901F\u7B5B\u9009\u5546\u54C1\u5185\u5BB9"), /* @__PURE__ */ React11.createElement(
901
932
  CategoryTabs_default,
902
933
  {
903
934
  items: categories2,
@@ -1013,11 +1044,11 @@ var CartMiniappPage = ({ apiBaseUrl = DEFAULT_BASE_URL }) => {
1013
1044
  };
1014
1045
  const performCheckout = async () => {
1015
1046
  if (!cartItems.length) {
1016
- Taro3.showToast({ title: "\u8D2D\u7269\u8F66\u4E3A\u7A7A", icon: "none" });
1047
+ Taro2.showToast({ title: "\u8D2D\u7269\u8F66\u4E3A\u7A7A", icon: "none" });
1017
1048
  return;
1018
1049
  }
1019
1050
  if (!validateForm()) {
1020
- Taro3.showToast({ title: "\u8BF7\u5148\u4FEE\u6B63\u8868\u5355\u9519\u8BEF", icon: "none" });
1051
+ Taro2.showToast({ title: "\u8BF7\u5148\u4FEE\u6B63\u8868\u5355\u9519\u8BEF", icon: "none" });
1021
1052
  return;
1022
1053
  }
1023
1054
  setSubmitting(true);
@@ -1040,9 +1071,9 @@ var CartMiniappPage = ({ apiBaseUrl = DEFAULT_BASE_URL }) => {
1040
1071
  setNotes("");
1041
1072
  setShippingInfo("");
1042
1073
  setFormErrors({});
1043
- Taro3.showToast({ title: "\u9884\u8BA2\u63D0\u4EA4\u6210\u529F", icon: "success" });
1074
+ Taro2.showToast({ title: "\u9884\u8BA2\u63D0\u4EA4\u6210\u529F", icon: "success" });
1044
1075
  } catch (error) {
1045
- Taro3.showToast({
1076
+ Taro2.showToast({
1046
1077
  title: error instanceof Error ? error.message : "\u63D0\u4EA4\u5931\u8D25",
1047
1078
  icon: "none"
1048
1079
  });
@@ -1053,7 +1084,7 @@ var CartMiniappPage = ({ apiBaseUrl = DEFAULT_BASE_URL }) => {
1053
1084
  };
1054
1085
  const handleCheckout = async () => {
1055
1086
  if (!validateForm()) {
1056
- Taro3.showToast({ title: "\u8BF7\u5148\u4FEE\u6B63\u8868\u5355\u9519\u8BEF", icon: "none" });
1087
+ Taro2.showToast({ title: "\u8BF7\u5148\u4FEE\u6B63\u8868\u5355\u9519\u8BEF", icon: "none" });
1057
1088
  return;
1058
1089
  }
1059
1090
  const activePopups = await triggerCheck();
@@ -1088,7 +1119,7 @@ var CartMiniappPage = ({ apiBaseUrl = DEFAULT_BASE_URL }) => {
1088
1119
  const handleClearCart = () => {
1089
1120
  clearCart();
1090
1121
  setCart(getCart());
1091
- Taro3.showToast({ title: "\u8D2D\u7269\u8F66\u5DF2\u6E05\u7A7A", icon: "success" });
1122
+ Taro2.showToast({ title: "\u8D2D\u7269\u8F66\u5DF2\u6E05\u7A7A", icon: "success" });
1092
1123
  };
1093
1124
  return /* @__PURE__ */ React11.createElement(View, { className: "min-h-screen bg-gradient-to-br from-white to-prussian-blue-100 pb-12 text-rich-black" }, /* @__PURE__ */ React11.createElement(PageHeader_default, { title: "\u8D2D\u7269\u8F66", subtitle: "\u786E\u8BA4\u753B\u96C6\u6570\u91CF\u5E76\u63D0\u4EA4\u9884\u8BA2" }), /* @__PURE__ */ React11.createElement(View, { className: "mx-4 mt-5 flex flex-col gap-4" }, cartItems.length === 0 ? /* @__PURE__ */ React11.createElement(View, { className: "rounded-2xl bg-white px-4 py-8 text-center text-sm text-prussian-blue-600 shadow-md" }, "\u8D2D\u7269\u8F66\u6682\u65E0\u753B\u96C6") : cartItems.map((item) => /* @__PURE__ */ React11.createElement(
1094
1125
  CartItemCard_default,
@@ -1149,10 +1180,10 @@ var CartMiniappPage = ({ apiBaseUrl = DEFAULT_BASE_URL }) => {
1149
1180
  ), /* @__PURE__ */ React11.createElement(
1150
1181
  View,
1151
1182
  {
1152
- className: `flex h-11 flex-1 items-center justify-center rounded-xl ${submitting ? "bg-blue-300" : "bg-blue-600 shadow-lg"}`,
1183
+ className: `flex h-11 flex-1 items-center justify-center rounded-xl ${submitting ? "bg-teal-300" : "bg-teal-600 shadow-lg"}`,
1153
1184
  onClick: submitting ? void 0 : handleCheckout
1154
1185
  },
1155
- /* @__PURE__ */ React11.createElement(Text, { className: "text-sm font-semibold text-white" }, submitting ? "\u63D0\u4EA4\u4E2D..." : "\u6279\u91CF\u9884\u8BA2")
1186
+ /* @__PURE__ */ React11.createElement(Text, { className: "text-sm font-semibold text-white" }, submitting ? "\u63D0\u4EA4\u4E2D..." : "\u63D0\u4EA4\u7533\u8BF7")
1156
1187
  )), /* @__PURE__ */ React11.createElement(Text, { className: "mt-3 block text-right text-sm font-semibold text-rich-black" }, "\u5408\u8BA1\uFF1A", totalPriceLabel)), /* @__PURE__ */ React11.createElement(
1157
1188
  DeadlinePopup_default,
1158
1189
  {
@@ -1173,7 +1204,7 @@ var HistoryMiniappPage = ({ apiBaseUrl = DEFAULT_BASE_URL }) => {
1173
1204
  const [hasSearched, setHasSearched] = useState(false);
1174
1205
  const handleSearch = async () => {
1175
1206
  if (!qqNumber.trim() && !phoneNumber.trim()) {
1176
- Taro3.showToast({ title: "\u8BF7\u8F93\u5165QQ\u53F7\u6216\u624B\u673A\u53F7", icon: "none" });
1207
+ Taro2.showToast({ title: "\u8BF7\u8F93\u5165QQ\u53F7\u6216\u624B\u673A\u53F7", icon: "none" });
1177
1208
  return;
1178
1209
  }
1179
1210
  setLoading(true);
@@ -1233,7 +1264,11 @@ var HistoryMiniappPage = ({ apiBaseUrl = DEFAULT_BASE_URL }) => {
1233
1264
  ), /* @__PURE__ */ React11.createElement(
1234
1265
  View,
1235
1266
  {
1236
- className: `mt-5 flex h-10 w-full items-center justify-center rounded-full ${loading ? "bg-prussian-blue-300" : "bg-gradient-to-r from-moonstone to-cerulean shadow-lg"}`,
1267
+ className: "mt-5 flex h-10 w-full items-center justify-center rounded-full",
1268
+ style: {
1269
+ backgroundColor: loading ? "#93C5FD" : "#2563EB",
1270
+ boxShadow: loading ? "none" : "0 8px 20px rgba(37, 99, 235, 0.28)"
1271
+ },
1237
1272
  onClick: loading ? void 0 : handleSearch
1238
1273
  },
1239
1274
  /* @__PURE__ */ React11.createElement(Text, { className: "text-sm font-semibold text-white" }, loading ? "\u67E5\u8BE2\u4E2D..." : "\u67E5\u8BE2\u8BB0\u5F55")