hot-search.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <template>
  2. <div class="hot-search">
  3. <div class="hot-search__header">
  4. <span>线上热门搜索</span>
  5. </div>
  6. <div class="hot-search__container">
  7. <el-row class="hot-search__chart" :gutter="20">
  8. <el-col :md="12" :xs="24">
  9. <div class="block">
  10. <div class="count">
  11. <div class="number">
  12. <span>搜索用户数</span>
  13. <span>1242</span>
  14. </div>
  15. <div class="rise">
  16. <i class="el-icon-top-right"></i>
  17. <span>+7%</span>
  18. </div>
  19. </div>
  20. <v-chart :option="chartOption()" autoresize />
  21. </div>
  22. </el-col>
  23. <el-col :md="12" :xs="24">
  24. <div class="block is-last">
  25. <div class="count">
  26. <div class="number">
  27. <span>关注用户数</span>
  28. <span>365</span>
  29. </div>
  30. <div class="rise">
  31. <i class="el-icon-top-right"></i>
  32. <span>+2%</span>
  33. </div>
  34. </div>
  35. <v-chart :option="chartOption()" autoresize />
  36. </div>
  37. </el-col>
  38. </el-row>
  39. <div class="hot-search__table">
  40. <cl-crud ref="Crud">
  41. <cl-table ref="Table" :border="false" />
  42. </cl-crud>
  43. </div>
  44. </div>
  45. </div>
  46. </template>
  47. <script lang="ts" setup>
  48. import * as echarts from "echarts";
  49. import { useCrud, useTable } from "@cool-vue/crud";
  50. const Crud = useCrud(
  51. {
  52. service: {
  53. page() {
  54. return Promise.resolve({
  55. list: [
  56. {
  57. keyWord: "无线耳机",
  58. users: 983,
  59. ud: 5
  60. },
  61. {
  62. keyWord: "运动耳机",
  63. users: 763,
  64. ud: -3
  65. },
  66. {
  67. keyWord: "蓝牙音箱",
  68. users: 328,
  69. ud: 7
  70. },
  71. {
  72. keyWord: "4k显示屏",
  73. users: 144,
  74. ud: 4
  75. },
  76. {
  77. keyWord: "罗技 G530",
  78. users: 121,
  79. ud: -1
  80. }
  81. ]
  82. });
  83. }
  84. }
  85. },
  86. (app) => {
  87. app.refresh();
  88. }
  89. );
  90. const Table = useTable({
  91. autoHeight: false,
  92. contextMenu: [],
  93. columns: [
  94. {
  95. label: "排名",
  96. type: "index",
  97. width: 60
  98. },
  99. {
  100. label: "搜索关键词",
  101. prop: "keyWord",
  102. minWidth: 100
  103. },
  104. {
  105. label: "用户数",
  106. prop: "users",
  107. minWidth: 100
  108. },
  109. {
  110. label: "周涨幅",
  111. prop: "ud",
  112. sortable: "desc",
  113. minWidth: 100
  114. }
  115. ]
  116. });
  117. function chartOption() {
  118. return {
  119. grid: {
  120. left: 0,
  121. top: 10,
  122. right: 0,
  123. bottom: 0
  124. },
  125. xAxis: {
  126. type: "category",
  127. data: [],
  128. boundaryGap: false
  129. },
  130. yAxis: {
  131. type: "value",
  132. splitLine: {
  133. show: false
  134. },
  135. axisTick: {
  136. show: false
  137. },
  138. axisLine: {
  139. show: false
  140. },
  141. axisLabel: {
  142. show: false
  143. }
  144. },
  145. series: [
  146. {
  147. name: "总访问量",
  148. type: "line",
  149. smooth: true,
  150. showSymbol: false,
  151. symbol: "circle",
  152. symbolSize: 6,
  153. data: new Array(12)
  154. .fill(1)
  155. .map(() => parseInt((Math.random() * 1000).toFixed(0)) + 500),
  156. areaStyle: {
  157. color: new echarts.graphic.LinearGradient(
  158. 0,
  159. 0,
  160. 0,
  161. 1,
  162. [
  163. {
  164. offset: 0,
  165. color: "#D1E5FF"
  166. },
  167. {
  168. offset: 1,
  169. color: "#FFFFFF"
  170. }
  171. ],
  172. false
  173. )
  174. },
  175. itemStyle: {
  176. color: "#4165d7"
  177. },
  178. lineStyle: {
  179. width: 2
  180. }
  181. }
  182. ]
  183. };
  184. }
  185. </script>
  186. <style lang="scss" scoped>
  187. .hot-search {
  188. &__header {
  189. display: flex;
  190. align-items: center;
  191. height: 50px;
  192. font-size: 15px;
  193. font-weight: bold;
  194. padding: 0 20px;
  195. }
  196. &__container {
  197. padding-bottom: 10px;
  198. }
  199. &__chart {
  200. padding: 0 20px;
  201. .block {
  202. .count {
  203. display: flex;
  204. align-items: center;
  205. justify-content: space-between;
  206. margin-bottom: 10px;
  207. height: 40px;
  208. .fall,
  209. .rise {
  210. display: flex;
  211. align-items: center;
  212. margin-left: 10px;
  213. font-size: 15px;
  214. }
  215. .fall {
  216. color: #13ae7c;
  217. }
  218. .rise {
  219. color: #f21e37;
  220. }
  221. .number {
  222. display: flex;
  223. align-items: center;
  224. span {
  225. font-size: 13px;
  226. &:last-child {
  227. margin-left: 10px;
  228. font-size: 15px;
  229. font-weight: bold;
  230. }
  231. }
  232. }
  233. }
  234. .echarts {
  235. height: 70px;
  236. width: 100%;
  237. }
  238. }
  239. }
  240. &__table {
  241. margin: 0 10px;
  242. }
  243. }
  244. </style>