index.jsx 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import React from 'react';
  2. import Taro from '@tarojs/taro';
  3. import dayjs from 'dayjs';
  4. import { View, ScrollView, RichText, Image, Text } from '@tarojs/components';
  5. import { getIssueStatus } from '@/utils/biz';
  6. import icon from '@/assets/icons/marker.png';
  7. import style from './style.module.less';
  8. const colors = [
  9. ['rgba(130, 176, 254, 0.08)', 'rgba(52, 121, 237, 1)'], // 未交办
  10. ['rgba(51, 218, 156, 0.08)', 'rgba(26, 117, 101, 1)'], // 已交办
  11. ['rgba(251, 157, 75, 0.08)', 'rgba(232, 116, 16, 1)'], // 已办结
  12. ['rgba(255, 245, 245, 1)', 'rgba(255, 76, 76, 1)'], // 已逾期
  13. ['transparent', 'rgba(159, 159, 159, 1)'], // 已打回
  14. ]
  15. export default (props) => {
  16. const { detail, onClick } = props;
  17. const [
  18. content,
  19. createDate,
  20. styleColor,
  21. statusTxt,
  22. ] = React.useMemo(() => {
  23. if (!detail) return [];
  24. const {value : bizStatus = 0, label : statusText} = getIssueStatus(detail);
  25. return [
  26. (detail.content || '').replace('\r\n', '<br>').replace('\n', '<br>'),
  27. dayjs(detail.createDate).format('YYYY-MM-DD HH:mm'),
  28. colors[bizStatus],
  29. statusText,
  30. ];
  31. }, [detail]);
  32. return (
  33. <View className={style['issue-card-wrapper']} onClick={onClick}>
  34. <View className={style['issue-card-header']}>
  35. <View>问题:</View>
  36. <View>{createDate}</View>
  37. </View>
  38. <View className={style['issue-card-body']} style={{ backgroundColor: styleColor[0] }}>
  39. <ScrollView scrollY style={{ height: '100%' }}>
  40. <RichText nodes={content} />
  41. </ScrollView>
  42. </View>
  43. <View className={style['issue-card-footer']}>
  44. <View>
  45. <Image src={icon} />
  46. <Text>{detail?.addr || ''}</Text>
  47. </View>
  48. <View style={{ color: styleColor[1] }}>{statusTxt}</View>
  49. </View>
  50. </View>
  51. )
  52. }