广州市综治平台前端
liuwh
4 days ago fa5361c6776f01975737fb5630594a9c60924fc5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
 * @Company: hugeInfo
 * @Author: ldh
 * @Date: 2022-07-20 17:44:04
 * @LastEditTime: 2022-11-30 14:31:44
 * @LastEditors: ldh
 * @Version: 1.0.0
 * @Description: 调解邀请码
 */
import React, { useState, useEffect, useRef } from 'react';
import PropTypes from 'prop-types';
import { Row, Col, Image, Typography, Space } from 'antd';
import * as $$ from '../../../utils/utility';
import { yunVideo, qrCodeImg } from '../../../assets/images/icon';
 
const { Link, Paragraph } = Typography;
 
// 获取邀请码
function handleGetScanApi(submitData) {
    return $$.ax.request({ url: 'caseInfo/getInviteCode?caseId=' + submitData, type: 'get', service: 'mediate' });
}
 
const MediationCode = ({ caseId, disputeData }) => {
    const [data, setData] = useState({});
 
    const qrCodeRef = useRef();
 
    // 下载二维码
    function handleUpload() {
        if (!data.inviteCode) {
            $$.info({ type: 'error', content: '暂无二维码' });
            return;
        }
        let raw = window.atob(data.inviteCode);
        let rawLength = raw.length;
        let uInt8Array = new Uint8Array(rawLength);
        for (let i = 0; i < rawLength; ++i) {
            uInt8Array[i] = raw.charCodeAt(i);
        }
        let url = URL.createObjectURL(new Blob([uInt8Array], { type: 'image/jpeg' }));
        qrCodeRef.current.download = '二维码.png';
        qrCodeRef.current.href = url;
    }
 
    useEffect(() => {
        // 获取邀请码
        async function handleGetScan() {
            global.setSpinning(true);
            const res = await handleGetScanApi(caseId);
            global.setSpinning(false);
            if (res.type) {
                setData(res.data || {});
            }
        }
        handleGetScan();
    }, [caseId]);
 
    return (
        <div className="mediationWindow-modal-main">
            <Row gutter={[16, 16]}>
                <Col span={6}>
                    <h5>调解案号</h5>
                    <div>{data.caseNo}</div>
                </Col>
                <Col span={6}>
                    <h5>在线视频调解房间号</h5>
                    <Space>
                        <img src={yunVideo} alt="" />
                        {disputeData.meetCloud?.roomNo ? (
                            <Paragraph style={{ margin: 0 }} copyable>
                                {disputeData.meetCloud.roomNo}
                            </Paragraph>
                        ) : (
                            <div>-</div>
                        )}
                    </Space>
                </Col>
        {/* TODO:小程序的协助调解功能暂未开启 */}
                {/* <Col span={12}>
                    <h5>调解邀请码</h5>
                    <div className="mediationWindow-modal-subtitle">使用小程序“协助调解”功能输入「调解邀请码」开展协同办案</div>
                    <Paragraph style={{ margin: '8px 0 0' }} copyable>
                        {data.inviteNum}
                    </Paragraph>
                </Col>
                <Col span={24}>
                    <h5>调解邀请二维码</h5>
                    <p style={{ marginBottom: '8px', color: 'rgba(0,0,0,0.65)' }}>使用小程序“协助调解”功能扫描「调解邀二维请码」开展协同办案</p>
                    <div style={{ marginBottom: '8px' }}>
                        <Link onClick={handleUpload} ref={qrCodeRef}>
                            下载二维码
                        </Link>
                    </div>
                    <div style={{ position: 'relative' }}>
                        <img src={qrCodeImg} alt="" />
                        <div style={{ position: 'absolute', top: 40, left: 16 }}>
                            <Image width={76} src={`data:image/jpeg;base64,${data.inviteCode}`} />
                        </div>
                    </div>
                </Col> */}
            </Row>
        </div>
    );
};
 
MediationCode.propTypes = {
    disputeData: PropTypes.object,
};
 
export default MediationCode;