NewMedia.jsx 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. import { onMount, createSignal, createEffect, For } from "solid-js";
  2. import utils from "../../../utils/index"
  3. import "../../../assets/style/CommonBigScreenHome.css"
  4. import wx from "../../../assets/img/微信.png";
  5. import wxo from "../../../assets/img/微信-o.png";
  6. import ks from "../../../assets/img/快手.png";
  7. import kso from "../../../assets/img/快手-o.png";
  8. import qdxw from "../../../assets/img/起点新闻.png";
  9. import qdxwo from "../../../assets/img/起点新闻-o.png";
  10. import ssp from "../../../assets/img/闪视频.png";
  11. import sspo from "../../../assets/img/闪视频-o.png";
  12. import sxtt from "../../../assets/img/陕西头条.png";
  13. import sxtto from "../../../assets/img/陕西头条-o.png";
  14. import tt from "../../../assets/img/头条.png";
  15. import tto from "../../../assets/img/头条-o.png";
  16. import wb from "../../../assets/img/微博.png";
  17. import wbo from "../../../assets/img/微博-o.png";
  18. import dy from "../../../assets/img/抖音.png";
  19. import dyo from "../../../assets/img/抖音-o.png";
  20. let timeout = undefined;
  21. function NewMedia(prop) {
  22. function getlist() {
  23. const setli = [];
  24. for (let i = 0; i < Math.floor((prop.height - 42) / 40); i++) {
  25. const v = ((prop.list[act()] || {}).data || [])[i];
  26. if (!v) break
  27. setli.push({
  28. userName: v.userName,
  29. depName: v.depName,
  30. readCount: v.readCount
  31. })
  32. }
  33. return setli
  34. }
  35. const [act, setact] = createSignal(0)
  36. const [TableList, setTableList] = createSignal(getlist())
  37. onMount(() => { })
  38. function imgClick(index) {
  39. setact(index);
  40. setTableList(getlist())
  41. }
  42. function timeoutFun() {
  43. return setTimeout(() => {
  44. if (timeout) clearTimeout(timeout)
  45. const i = act() + 1 >= prop.list.length ? 0 : act() + 1;
  46. imgClick(i);
  47. timeout = timeoutFun();
  48. }, 3000);
  49. }
  50. timeout = timeoutFun()
  51. let p = {};
  52. createEffect(() => {
  53. if (prop.styleCss) p = prop.styleCss;
  54. if (prop.width) p.width = `${prop.width}px`;
  55. if (prop.height) p.height = `${prop.height + 40}px`;
  56. })
  57. const getimg = (text, isSelect) => {
  58. if (text === '微信') return isSelect ? wxo : wx;
  59. if (text === '微博') return isSelect ? wbo : wb;
  60. if (text === '抖音') return isSelect ? dyo : dy;
  61. if (text === '头条') return isSelect ? tto : tt;
  62. if (text === '快手') return isSelect ? kso : ks;
  63. if (text === '陕西头条') return isSelect ? sxtto : sxtt;
  64. if (text === '闪视频') return isSelect ? sspo : ssp;
  65. if (text === '起点新闻') return isSelect ? qdxwo : qdxw;
  66. }
  67. return (
  68. <div class="livRang newMdia" style={p}>
  69. <div class="head">{prop.title}</div>
  70. <div style={{ "white-space": "nowrap", "display": "flex" }}>
  71. <For each={prop.list}>{(item, i) => <div class="TabBtn">
  72. <img onClick={() => imgClick(i())} class="tabIcon" src={getimg(item.name, act() === i())} />
  73. {/* <span style="vertical-align: middle;">{item.name}</span> */}
  74. </div>}</For>
  75. </div>
  76. <div class="table" >
  77. <div class="tr" style={{ "background-color": "#03375e" }}>
  78. <div class='td'>序号</div>
  79. <div class='td' style={{ "flex": "2" }}>部门</div>
  80. <div class='td' style={{ "flex": "2" }}>账号</div>
  81. <div class='td' style={{ "flex": "2" }}>当月阅读量</div>
  82. </div>
  83. <div style={{
  84. height: `${prop.height - 82}px`,
  85. overflow: 'hidden'
  86. }}>
  87. <For each={TableList()}>{(item, i) => <div class="tr trColor">
  88. <div class='td'>{i() + 1}</div>
  89. <div class='td' style={{ "flex": "2" }}>
  90. {item.depName}
  91. </div>
  92. <div class='td' style={{ "flex": "2" }}>
  93. {/* <Show when={maxlen <= item.userName.length}>
  94. <marquee behavior="scroll">{item.userName}</marquee>
  95. </Show>
  96. <Show when={maxlen > item.userName.length}> */}
  97. {item.userName}
  98. {/* </Show> */}
  99. </div>
  100. <div class='td' style={{ "flex": "2" }}>{utils.formatNum(item.readCount)}</div>
  101. </div>}</For>
  102. </div>
  103. </div>
  104. </div>
  105. );
  106. }
  107. export default NewMedia;