index.tsx 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. import React, { useCallback, useEffect, useState } from 'react'
  2. import styles from './index.module.scss'
  3. import ZexhiBtn from '@/components/ZexhiBtn'
  4. import noImg from '@/assets/img/exhibit/no.png'
  5. import { B2_APIcancel, B2_APIgetList } from '@/store/action/all'
  6. import { B2ListType, B2SonListType } from './type'
  7. import history from '@/utils/history'
  8. import classNames from 'classnames'
  9. import MyPopconfirm from '@/components/MyPopconfirm'
  10. import { MessageFu } from '@/utils/message'
  11. import { QRCode } from 'antd'
  12. import { CloseCircleOutlined } from '@ant-design/icons'
  13. function B2myz() {
  14. const [loding, setLoding] = useState(false)
  15. const [list, setList] = useState<B2ListType[]>([])
  16. const getListFu = useCallback(async () => {
  17. const res = await B2_APIgetList()
  18. if (res.code === 0) {
  19. setLoding(true)
  20. setList(res.data)
  21. }
  22. }, [])
  23. useEffect(() => {
  24. getListFu()
  25. }, [getListFu])
  26. const sonList = useCallback((val: string) => {
  27. let arr: B2SonListType[] = []
  28. arr = JSON.parse(val)
  29. return arr
  30. }, [])
  31. // 点击撤回预约
  32. const recallFu = useCallback(
  33. async (id: number) => {
  34. const res = await B2_APIcancel(id)
  35. if (res.code === 0) {
  36. MessageFu.success('撤回成功!')
  37. getListFu()
  38. }
  39. },
  40. [getListFu]
  41. )
  42. // 出示二维码
  43. const [code, setCode] = useState('')
  44. return (
  45. <div className={styles.B2myz}>
  46. <div className='B2main'>
  47. {list.length ? (
  48. <>
  49. {list.map(item => (
  50. <div className='B2row' key={item.id}>
  51. <div className='B2row1'>
  52. <p>
  53. <span>预约日期:</span>
  54. {item.bookDate}
  55. </p>
  56. <p>
  57. <span>入馆时间:</span>
  58. {item.time}
  59. </p>
  60. <p style={{ width: '100%' }}>
  61. <span>来自地区:</span>
  62. {item.province + '-' + item.city}
  63. </p>
  64. <p>
  65. <span>预约类型:</span>
  66. {item.type === 'person' ? '个人预约' : '团体预约'}
  67. </p>
  68. <div className={classNames('B2row1Sta', item.status === 1 ? 'B2row1StaHe' : '')}>
  69. {item.status === 0 ? '未核销' : '已核销'}
  70. </div>
  71. </div>
  72. <div className='B2row2Box mySorrl'>
  73. {sonList(item.rtf).map((item2, index2) => (
  74. <div className='B2row2' key={index2}>
  75. <div className='B2row2_1'>
  76. {item.type === 'person' ? `参观人信息${index2 + 1}` : '负责人信息'}
  77. </div>
  78. <p>
  79. {item.type === 'person' ? '参观人' : '负责人'}姓名:{item2.name}
  80. </p>
  81. <p>联系方式:{item2.phone}</p>
  82. <p>
  83. {item2.papers || '证件号码'}:{item2.identity}
  84. </p>
  85. </div>
  86. ))}
  87. {/* 团队预约才有的 */}
  88. {item.type === 'team' ? (
  89. <div className='B2row2 B2row2T'>
  90. <p>参团人数:{item.pcs}</p>
  91. {item.teamDesc ? (
  92. <div className='B2row2Tdesc'>
  93. <div className='B2row2Tdesc1'>团队描述:</div>
  94. <div className='B2row2Tdesc2'>{item.teamDesc}</div>
  95. </div>
  96. ) : null}
  97. </div>
  98. ) : null}
  99. </div>
  100. <div className='B2rowCheBox'>
  101. {item.status === 0 ? (
  102. <>
  103. <MyPopconfirm
  104. txtK='撤回'
  105. onConfirm={() => recallFu(item.id)}
  106. Dom={<div className='B2rowChe'>撤回预约</div>}
  107. />
  108. <div
  109. className='B2rowChe B2rowCodeBtn'
  110. onClick={() => setCode(`HQ_CODE/${item.id}`)}
  111. >
  112. 出示二维码
  113. </div>
  114. </>
  115. ) : null}
  116. </div>
  117. </div>
  118. ))}
  119. <div className='B2dian'>联系方式:17722062600</div>
  120. </>
  121. ) : (
  122. <div className='B2No' hidden={!loding}>
  123. <img src={noImg} alt='' />
  124. <p>暂无预约信息</p>
  125. </div>
  126. )}
  127. </div>
  128. <ZexhiBtn onlyBack nextFu={() => {}} backFu={() => history.push('/exhi')} />
  129. {/* 出示二维码 */}
  130. {code ? (
  131. <div className='B2codeBox'>
  132. <QRCode value={code || '-'} size={240} />
  133. <CloseCircleOutlined onClick={() => setCode('')} />
  134. </div>
  135. ) : null}
  136. </div>
  137. )
  138. }
  139. const MemoB2myz = React.memo(B2myz)
  140. export default MemoB2myz