index.jsx 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import { AtModal, AtModalContent } from "taro-ui";
  2. import { View, Image, Text } from "@tarojs/components";
  3. import { addLog } from "../../service";
  4. import { formatDate } from "../../common/time";
  5. import { isDebounce } from "../../common/debounce";
  6. import "./index.less";
  7. import Taro from "@tarojs/taro";
  8. import selectStep from "../../images/productDetail/selectStep.png";
  9. import xianyu from "../../images/productDetail/xianyu.png";
  10. import stepThree from "../../images/productDetail/stepThree.png";
  11. export default function Modal(props) {
  12. const { productPromotion, isOpened, title, linkText, id, shareUserId,isSeckill } =
  13. props;
  14. const handleCopyLink = () => {
  15. if (!isDebounce(500)) return; // 如果在300ms内重复触发,直接返回
  16. Taro.setClipboardData({
  17. data: productPromotion.short_tpwd,
  18. }).then(() => {
  19. Taro.showToast({
  20. title: "口令已复制",
  21. icon: "success",
  22. });
  23. if (isSeckill) {
  24. const dayid = formatDate(new Date(), "YYYY-MM-DD");
  25. let userId = "";
  26. if (Taro.getStorageSync("loginInfo")) {
  27. userId = Taro.getStorageSync("loginInfo").id;
  28. }
  29. let ext = "";
  30. if (shareUserId) {
  31. ext = JSON.stringify({
  32. share_users_id: shareUserId,
  33. });
  34. }
  35. addLog({
  36. event_type: "buy_product_link",
  37. event_type_title: "点击购买",
  38. goods_id: Number(id),
  39. ext,
  40. dayid,
  41. users_id: userId||0,
  42. });
  43. }
  44. });
  45. };
  46. return (
  47. <AtModal isOpened={isOpened} closeOnClickOverlay={true}>
  48. <AtModalContent>
  49. <View className="container">
  50. <View className="title">{title}</View>
  51. <View className="content">
  52. <View className="link-text">{linkText}</View>
  53. <View className="steps">
  54. <View className="step-item">
  55. <View className="step-title">
  56. <Text className="number">1</Text>
  57. <Text className="desc">点击复制口令</Text>
  58. </View>
  59. <View className="step-box">
  60. <View className="step-One">复制口令</View>
  61. <Image className="step-img-one" src={selectStep} />
  62. </View>
  63. </View>
  64. <View className="step-item">
  65. <View className="step-title">
  66. <Text className="number">2</Text>
  67. <Text className="desc">打开闲鱼APP</Text>
  68. </View>
  69. <View className="step-box">
  70. <Image className="step-img-t" src={xianyu} />
  71. <Image className="step-img-two" src={selectStep} />
  72. </View>
  73. </View>
  74. <View className="step-item">
  75. <View className="step-title">
  76. <Text className="number">3</Text>
  77. <Text className="desc">自动识别口令</Text>
  78. </View>
  79. <View className="step-box">
  80. <Image
  81. mode="heightFix"
  82. className="step-img-three"
  83. src={stepThree}
  84. />
  85. </View>
  86. </View>
  87. </View>
  88. {/* 复制口令 */}
  89. <View className="copy-link" onClick={handleCopyLink}>
  90. 复制口令
  91. </View>
  92. </View>
  93. </View>
  94. </AtModalContent>
  95. </AtModal>
  96. );
  97. }