index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <div class="SilkRoadData">
  3. <div class="topImg" v-if="width">
  4. <van-image :width="width" :height="height" @load="load" :src="isOnlyDay" />
  5. <span class="days">{{ times.join(" 到 ") }}</span>
  6. </div>
  7. <van-cell-group inset>
  8. <template #title> </template>
  9. <div
  10. class="mainCell"
  11. style="margin-top: 0.5em"
  12. v-for="item in centerList"
  13. :key="item.centerName + 'c'"
  14. >
  15. <div class="headTitle" v-text="item.centerName"></div>
  16. <div class="label">
  17. <div class="label-left">
  18. <van-row>
  19. <van-col span="8">
  20. 实发 / <span style="color: red">应发</span>(件)
  21. </van-col>
  22. <van-col span="8">完成率</van-col>
  23. <van-col span="8">传播量(次)</van-col>
  24. </van-row>
  25. <van-row>
  26. <van-col span="8">
  27. {{ item.onTimeNum | formmate }} /
  28. <span style="color: red">{{ item.taskNum | formmate }}</span>
  29. </van-col>
  30. <van-col span="8">
  31. {{ ((item.onTimeNum / item.taskNum).toFixed(2) - 0) * 100 }}%
  32. </van-col>
  33. <van-col span="8">{{ item.readNum | formmate }}</van-col>
  34. </van-row>
  35. </div>
  36. <van-button
  37. style="vertical-align: middle"
  38. size="mini"
  39. hairline
  40. plain
  41. type="primary"
  42. @click="() => toDetail(item)"
  43. >
  44. 查看详情
  45. </van-button>
  46. </div>
  47. </div>
  48. </van-cell-group>
  49. </div>
  50. </template>
  51. <script>
  52. import { getSilkRoadData } from '@/api/index.js';
  53. import watermark from 'watermark-package';
  54. import report from '../mixin/index.js';
  55. import {
  56. Image as VanImage,
  57. CellGroup as VanCellGroup,
  58. Button as VanButton,
  59. Col as VanCol,
  60. Row as VanRow,
  61. } from 'vant';
  62. import 'vant/lib/col/style/index';
  63. import 'vant/lib/row/style/index';
  64. import 'vant/lib/image/style/index';
  65. import 'vant/lib/cell-group/style/index';
  66. import 'vant/lib/button/style/index';
  67. export default {
  68. name: 'SilkRoadData',
  69. data() {
  70. return {
  71. width: 0,
  72. height: 0,
  73. times: [],
  74. centerList: [],
  75. isOnlyDay: undefined,
  76. };
  77. },
  78. props: ['type', 'time'],
  79. mixins: [report],
  80. watch: {},
  81. mounted() {},
  82. computed: {},
  83. filters: {
  84. formmate(num) {
  85. if (isNaN(num)) return 0;
  86. if (num >= 100000000) return (num / 100000000).toFixed(2) - 0 + '亿';
  87. if (num >= 10000) return (num / 10000).toFixed(2) - 0 + '万';
  88. return num.toFixed(0) - 0;
  89. },
  90. },
  91. methods: {
  92. init() {
  93. watermark.setWaterMark({
  94. w_texts: ['陕西视听大数据'],
  95. w_options: {
  96. w_opacity: '0.1',
  97. },
  98. });
  99. // this.$route.params.date --> default 日期可选 orther 根据传入日期
  100. this.width = document.body.clientWidth;
  101. this.height = (this.width / 16) * 9;
  102. let times = (this.$route.params.time || '').split('+');
  103. if(times.length > 1 && times[0] === times[1]) times = [times[0]];
  104. this.times = times;
  105. console.log(window.matchMedia('(prefers-color-scheme: dark)'))
  106. if (this.times.length > 1)
  107. this.isOnlyDay = require('@/assets/image/2023slcw.jpg');
  108. else this.isOnlyDay = require('@/assets/image/2023slcw-day.jpg');
  109. getSilkRoadData({
  110. start: this.times[0],
  111. end: this.times.length > 1 ? this.times[1] : this.times[0],
  112. }).then(r => {
  113. this.centerList = r || [];
  114. });
  115. },
  116. load(e) {
  117. const ele = e.path[0];
  118. this.height = this.width * (ele.naturalHeight / ele.naturalWidth);
  119. },
  120. toDetail(item) {
  121. this.$router.push({
  122. path: `/SilkRoadDetail/${item.centerName}/${this.$route.params.time}?auto=${this.$route.query.auto}`,
  123. });
  124. },
  125. },
  126. beforeUnmount() {},
  127. components: {
  128. VanCol,
  129. VanRow,
  130. VanImage,
  131. VanButton,
  132. VanCellGroup,
  133. },
  134. };
  135. </script>
  136. <style scoped>
  137. .SilkRoadData {
  138. width: 100%;
  139. height: 100%;
  140. font-size: 16px;
  141. overflow-y: auto;
  142. background-color: #eee;
  143. padding-bottom: .5em;
  144. }
  145. .SilkRoadData .mainCell {
  146. padding: 0.5em;
  147. font-weight: 500;
  148. }
  149. .SilkRoadData .headTitle {
  150. padding: 0 0 0.5em 0;
  151. }
  152. .SilkRoadData .label {
  153. font-size: 12px;
  154. line-height: 1.5em;
  155. text-align: center;
  156. color: #969799;
  157. white-space: nowrap;
  158. }
  159. .SilkRoadData .label-left{
  160. display: inline-block;
  161. width: calc(100% - 56px);
  162. vertical-align: middle;
  163. }
  164. .SilkRoadData .topImg{
  165. position: relative;
  166. }
  167. .SilkRoadData .days{
  168. position: absolute;
  169. left: 5%;
  170. top: 72%;
  171. color: #ffffff;
  172. font-size: 14px;
  173. }
  174. </style>