123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. import React, { useState, useEffect } from 'react'
  2. import Taro, { useRouter } from '@tarojs/taro'
  3. import request, { apis } from '@/utils/request'
  4. import { useModel } from '@/store'
  5. import toolclass from '@/utils/toolclass.js'
  6. import SlidePopup from '@/components/SlidePopup/index'
  7. import { Textarea } from '@tarojs/components'
  8. import Page from '@/layouts'
  9. import { getShareObject } from '@/utils/share.js'
  10. import '@/assets/css/reset.less'
  11. import '@/assets/css/iconfont.less'
  12. import './index.less'
  13. export default function BaoXiuDetail () {
  14. const { user } = useModel('user')
  15. const [CurrnetBaoXiuId] = useState(useRouter().params.id)
  16. const [DetailInfo, setDetailInfo] = useState(null)
  17. const [PhoneList, setPhoneList] = useState([])
  18. const [ShowPopup, setShowPopup] = useState(false)
  19. const [ShowPingJiaPopup, setShowPingJiaPopup] = useState(false)
  20. const [StarIndex, setStarIndex] = useState(0)
  21. const [Comment, setComment] = useState(null)
  22. const [ReplyContent, setReplyContent] = useState(null)
  23. const [DataLock, setDataLock] = useState(false)
  24. const [ShowReplyPopup, setShowReplyPopup] = useState(false)
  25. const [CurrentReplyId, setCurrentReplyId] = useState(null)
  26. Taro.useShareAppMessage(() => {
  27. return getShareObject({
  28. title: DetailInfo.ticketTitle,
  29. id: CurrnetBaoXiuId,
  30. image: null
  31. }, user)
  32. })
  33. useEffect(() => {
  34. Init()
  35. }, [])
  36. useEffect(() => {
  37. if (CurrentReplyId !== null) {
  38. setReplyContent(null)
  39. setShowReplyPopup(true)
  40. }
  41. }, [CurrentReplyId])
  42. const Init = () => {
  43. request({ ...apis.getGongDanDetail, args: { orgId: user.orgId }, params: { ticketId: CurrnetBaoXiuId } }).then((res) => { // 获取工单详情
  44. setDetailInfo(res)
  45. request({ ...apis.getWuYePhone, params: { type: 'prop' } }).then((cRes) => { // 获取物业电话
  46. setPhoneList(cRes || [])
  47. })
  48. })
  49. }
  50. const SelectStar = (index) => {
  51. return () => {
  52. setStarIndex(index)
  53. }
  54. }
  55. const ReplyChange = (e) => {
  56. setReplyContent(e.detail.value)
  57. }
  58. const CommentChange = (e) => {
  59. setComment(e.detail.value)
  60. }
  61. const ToReply = () => {
  62. if (DataLock) return
  63. setDataLock(true)
  64. request({ ...apis.ReplyTicket, args: { orgId: user.orgId }, data: { ticketId: CurrnetBaoXiuId, content: ReplyContent, ticketRecordCommentId: CurrentReplyId } }).then((res) => { // 获取工单详情
  65. Taro.showToast({ title: '回复成功', icon: 'none' })
  66. Init()
  67. setDataLock(false)
  68. setShowReplyPopup(false)
  69. }).catch((res) => {
  70. Taro.showToast({ title: res, icon: 'none' })
  71. setDataLock(false)
  72. })
  73. }
  74. const ToPingJia = () => {
  75. if (DataLock) return
  76. setDataLock(true)
  77. request({ ...apis.PostGongDanPingJia, args: { orgId: user.orgId }, params: { ticketId: CurrnetBaoXiuId }, data: { score: StarIndex - 0 + 1, comment: Comment } }).then((res) => { // 获取工单详情
  78. Taro.showToast({ title: '评价成功', icon: 'none' })
  79. Init()
  80. setDataLock(false)
  81. setShowPingJiaPopup(false)
  82. }).catch((res) => {
  83. Taro.showToast({ title: res, icon: 'none' })
  84. setDataLock(false)
  85. })
  86. }
  87. const StepClick = (item) => {
  88. return () => {
  89. if (DetailInfo.status - 0 < 4) {
  90. setCurrentReplyId(item.id)
  91. }
  92. }
  93. }
  94. return (
  95. <Page>
  96. <view className='BaoXiuDetail'>
  97. <view className='TopLine'></view>
  98. {/* 概况 */}
  99. <view className='TopInfo'>
  100. <view className='flex-h'>
  101. <text className='flex-item'>{DetailInfo === null ? null : DetailInfo.ticketTitle}</text>
  102. <text className='iconfont iconjiantouright'></text>
  103. </view>
  104. <view className='flex-h'>
  105. <text className='flex-item'>报修单号</text>
  106. <text>{DetailInfo === null ? null : DetailInfo.id}</text>
  107. </view>
  108. <view className='flex-h'>
  109. <text className='flex-item'>报修时间</text>
  110. <text>{DetailInfo === null ? null : toolclass.FormatDate(DetailInfo.createDate)}</text>
  111. </view>
  112. </view>
  113. {/* 详情 */}
  114. <view className='Detail'>
  115. <text>处理进度</text>
  116. <view className='flex-h'>
  117. <view className='Line'><view></view></view>
  118. <view className='flex-item'>
  119. <view>
  120. {
  121. DetailInfo !== null && DetailInfo.ticketRecordList !== null &&
  122. DetailInfo.ticketRecordList.map((item, index) => (
  123. <view className='StepList' key={`StepList-${index}`} onClick={StepClick(item)}>
  124. <view className='Title flex-h'>
  125. <text className='flex-item Red'>{item.ticketStatusName}</text>
  126. <text>{toolclass.FormatDate(item.createDate)}</text>
  127. </view>
  128. <view className='Text'>{item.content}</view>
  129. {
  130. item.ticketRecordCommentList.map((subItem, subIndex) => (
  131. <view className='ReplyList' key={`Reply-${subIndex}`}>
  132. <view className='flex-h'>
  133. <view>
  134. <text>{subItem.userName}</text>
  135. </view>
  136. <view className='flex-item'>
  137. <text>回复:</text>
  138. </view>
  139. <view>
  140. <text>{toolclass.FormatDate(subItem.createDate)}</text>
  141. </view>
  142. </view>
  143. <view className='ReplyContent'>
  144. <text>{subItem.content}</text>
  145. </view>
  146. </view>
  147. ))
  148. }
  149. {/* <view className='Text'>您的报修正在分配物业处理人员,若长时间无人处理,请联系物业。<text className='Blue'>物业电话薄</text><text className='Blue iconfont iconjiantouright'></text></view> */}
  150. {/* <view className='ImgList'>
  151. <view></view>
  152. <view></view>
  153. <view></view>
  154. <view></view>
  155. <view></view>
  156. <view></view>
  157. </view> */}
  158. </view>
  159. ))
  160. }
  161. </view>
  162. </view>
  163. </view>
  164. {/* 更多操作 */}
  165. <view className='BottomBtn active'>
  166. {
  167. DetailInfo !== null && DetailInfo.billInvoiceId !== null &&
  168. <text onClick={() => { Taro.navigateTo({ url: `/pages/WuYe/BaoXiuFeiYong/index?id=${CurrnetBaoXiuId}` }) }}>费用详情</text>
  169. }
  170. </view>
  171. {/* 更多操作 */}
  172. <view className='BottomBtn active'>
  173. {
  174. DetailInfo !== null && DetailInfo.status - 0 === 4 && user && user.personType !== PERSON_TYPE.LIFE_CONSULTANT &&
  175. <text onClick={() => { setShowPingJiaPopup(true) }}>评价</text>
  176. }
  177. </view>
  178. {/* 更多操作 */}
  179. <view className='BottomBtn'>
  180. <text onClick={() => { setShowPopup(true) }}>与物业沟通</text>
  181. </view>
  182. </view>
  183. <SlidePopup Close={() => { setShowReplyPopup(false) }} Show={ShowReplyPopup}>
  184. <view className='ReplyPopup'>
  185. <Textarea placeholder='请输入您的回复' onInput={ReplyChange} value={ReplyContent}></Textarea>
  186. <text className='Btn' onClick={ToReply}>回复</text>
  187. </view>
  188. </SlidePopup>
  189. <SlidePopup Close={() => { setShowPingJiaPopup(false) }} Show={ShowPingJiaPopup}>
  190. <view className='PinJiaPopup'>
  191. <text className='Title'>请对此次服务进行评分</text>
  192. <view className='StarLine'>
  193. {
  194. ['', '', '', '', ''].map((item, index) => (
  195. <text className={index > StarIndex ? 'iconfont iconxingxing' : 'iconfont iconxingxing active'} key={`Star-${index}`} onClick={SelectStar(index)}></text>
  196. ))
  197. }
  198. </view>
  199. <Textarea placeholder='请输入您的评价' onInput={CommentChange} value={Comment}></Textarea>
  200. <text className='Btn' onClick={ToPingJia}>提交</text>
  201. </view>
  202. </SlidePopup>
  203. <SlidePopup Close={() => { setShowPopup(false) }} Show={ShowPopup}>
  204. <view className='LianXiPopup'>
  205. <text>联系物业</text>
  206. <text>对此费用有疑问</text>
  207. {
  208. PhoneList.map((item, index) => (
  209. <view className='flex-h' key={`PhoneList-${index}`} onClick={() => { Taro.makePhoneCall({ phoneNumber: item.tel }) }}>
  210. <text className='flex-item'>{item.name}</text>
  211. <text>{item.tel}</text>
  212. <text className='iconfont icondianhua'></text>
  213. </view>
  214. ))
  215. }
  216. </view>
  217. </SlidePopup>
  218. </view>
  219. </Page>
  220. )
  221. }