|
@@ -6,10 +6,30 @@ import Spring from "@components/Spring";
|
|
|
import styles from "./styles.module.scss";
|
|
import styles from "./styles.module.scss";
|
|
|
import codiicon from "@assets/pay/mx/codiicon.png";
|
|
import codiicon from "@assets/pay/mx/codiicon.png";
|
|
|
import {formatDate} from "@utils/helpers";
|
|
import {formatDate} from "@utils/helpers";
|
|
|
|
|
+import html2canvas from "html2canvas";
|
|
|
|
|
+import {toast} from "react-toastify";
|
|
|
const i18n=global.i18n;
|
|
const i18n=global.i18n;
|
|
|
|
|
|
|
|
const MXOrderQR=({close})=>{
|
|
const MXOrderQR=({close})=>{
|
|
|
const orderInfo=useSelector(getCurrPayOrder);
|
|
const orderInfo=useSelector(getCurrPayOrder);
|
|
|
|
|
+ const savePayQR = () => {
|
|
|
|
|
+ const style = document.createElement('style');
|
|
|
|
|
+ document.head.appendChild(style);
|
|
|
|
|
+ style.sheet?.insertRule('body > div:last-child img { display: inline-block; }');
|
|
|
|
|
+ // 获取需要截图的元素
|
|
|
|
|
+ const element = document.getElementById('payQR');
|
|
|
|
|
+
|
|
|
|
|
+ // 使用 html2canvas 捕获元素并生成图片
|
|
|
|
|
+ html2canvas(element,{
|
|
|
|
|
+ }).then(canvas => {
|
|
|
|
|
+ // 创建一个链接元素
|
|
|
|
|
+ const link = document.createElement('a');
|
|
|
|
|
+ link.href = canvas.toDataURL('image/png'); // 获取图片数据 URL
|
|
|
|
|
+ link.download = 'payQR.png'; // 设置下载的文件名
|
|
|
|
|
+ link.click(); // 触发下载
|
|
|
|
|
+ toast.success(i18n.t("deposit.order_info_mx.qr_save_success"));
|
|
|
|
|
+ });
|
|
|
|
|
+ };
|
|
|
const renderTitle=()=>{
|
|
const renderTitle=()=>{
|
|
|
return (
|
|
return (
|
|
|
<div className={styles.title_con}>
|
|
<div className={styles.title_con}>
|
|
@@ -22,11 +42,13 @@ const MXOrderQR=({close})=>{
|
|
|
let qrdata=`data:image/png;base64,${orderInfo.payQrImg}`;
|
|
let qrdata=`data:image/png;base64,${orderInfo.payQrImg}`;
|
|
|
return (
|
|
return (
|
|
|
<div className={styles.qr_con}>
|
|
<div className={styles.qr_con}>
|
|
|
- <div className={styles.qr_content}>
|
|
|
|
|
|
|
+ <div id={"payQR"} className={styles.qr_content}>
|
|
|
<img className={styles.qr_img} src={qrdata}/>
|
|
<img className={styles.qr_img} src={qrdata}/>
|
|
|
<img className={styles.codi_img} src={codiicon}/>
|
|
<img className={styles.codi_img} src={codiicon}/>
|
|
|
</div>
|
|
</div>
|
|
|
- {/*<button className={"button-green"}></button>*/}
|
|
|
|
|
|
|
+ <button onClick={()=>{
|
|
|
|
|
+ savePayQR();
|
|
|
|
|
+ }} className={`button-green ${styles.save_btn}`}>{i18n.t("deposit.order_info_mx.qr_save")}</button>
|
|
|
</div>
|
|
</div>
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|