index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <div class="calendar" :style="'font-size:' + fontSize + 'px'">
  3. <div
  4. class="group content bg"
  5. v-for="(item, index) in dataOne"
  6. :key="item.title + index"
  7. >
  8. <img
  9. :src="item.img_url"
  10. alt=""
  11. style="
  12. width: 79vw;
  13. max-width: 527px;
  14. display: block;
  15. margin: 3.6vh auto 0 auto;
  16. "
  17. />
  18. <p class="headTitle" v-text="item.title"></p>
  19. <div v-if="item.data.length">
  20. <div v-for="(v1, i1) in item.data" :key="i1">
  21. <!-- 月历主页 -->
  22. <div class="monthlyCalendar" >
  23. <div style="display: flex;" >
  24. <div class="title" style="flex: 1;" v-text="v1.month"></div>
  25. </div>
  26. <div class="CalenMain">
  27. <div class="CalenRow CalenHead">
  28. <div class="CalenCol">
  29. <p>一</p>
  30. <!-- <p>MON</p> -->
  31. </div>
  32. <div class="CalenCol">
  33. <p>二</p>
  34. <!-- <p>TUE</p> -->
  35. </div>
  36. <div class="CalenCol">
  37. <p>三</p>
  38. <!-- <p>WED</p> -->
  39. </div>
  40. <div class="CalenCol">
  41. <p>四</p>
  42. <!-- <p>THU</p> -->
  43. </div>
  44. <div class="CalenCol">
  45. <p>五</p>
  46. <!-- <p>FRI</p> -->
  47. </div>
  48. <div class="CalenCol">
  49. <p>六</p>
  50. <!-- <p>SAT</p> -->
  51. </div>
  52. <div class="CalenCol">
  53. <p>日</p>
  54. <!-- <p>SUN</p> -->
  55. </div>
  56. </div>
  57. <div
  58. class="CalenRow CalenBody"
  59. v-for="(v, i) in v1.list"
  60. :key="i"
  61. >
  62. <div v-for="(son, o) in v" :key="o" class="CalenCol">
  63. <div v-if="son" style="color: #000">
  64. <div class="dayDate">
  65. <div
  66. class="dayDate_son"
  67. :style="
  68. son.weeks == 0 || son.weeks == 6
  69. ? 'color:#c31212'
  70. : ''
  71. "
  72. >
  73. {{ son.day }}
  74. </div>
  75. </div>
  76. <div class="text" v-text="son.value"></div>
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. </div>
  85. <img
  86. src="@/assets/image/logo.png"
  87. style="width: 18.8vw; max-width: 125px; margin: 1em auto; display: block"
  88. alt=""
  89. />
  90. <div class="bottom content">
  91. 本数据由“陕西广电融媒体集团大数据平台”提供。
  92. <p>
  93. 技术支持 <span style="white-space: nowrap">白帆13325452244;</span
  94. ><span style="white-space: nowrap">陈科18629350958。</span>
  95. </p>
  96. </div>
  97. </div>
  98. </template>
  99. <script>
  100. // @ is an alias to /src
  101. import watermark from "watermark-package";
  102. import DayJs from "dayjs";
  103. // import {} from "../utils/tool";
  104. import { jsonCalendarOne } from "../../../api/index";
  105. // import echarts from "../../../utils/echarts";
  106. export default {
  107. name: "Calendar",
  108. data() {
  109. return {
  110. fontSize: 17,
  111. dataOne: [],
  112. };
  113. },
  114. watch: {},
  115. mounted() {
  116. if (
  117. this.$route.query.auto !==
  118. "06fd56cdf5a6cfc3a2139cc8514d05aa0439ee8c1fb4d81145bc9647"
  119. )
  120. return;
  121. this.fontSize = (document.body.offsetWidth / 24).toFixed(2) - 0;
  122. if (document.body.offsetWidth > 677) this.fontSize = 22;
  123. watermark.setWaterMark({
  124. w_texts: ["陕西新媒体大数据"],
  125. w_options: {
  126. w_opacity: "0.1",
  127. },
  128. });
  129. jsonCalendarOne({
  130. date: this.$route.params.date,
  131. time: Date.now(),
  132. }).then(res => {
  133. let dataOne = res || [];
  134. for (let i = 0; i < dataOne.length; i++) {
  135. const item1 = dataOne[i].data ? dataOne[i].data || [] : [];
  136. for (let o = 0; o < item1.length; o++) {
  137. const item2 =
  138. dataOne[i].data && dataOne[i].data
  139. ? dataOne[i].data[o] || []
  140. : undefined;
  141. if (item2 === undefined) continue;
  142. const dayjs_Start =
  143. item2.list[0] && item2.list[0].dt
  144. ? new DayJs(item2.list[0].dt)
  145. : undefined;
  146. const item2_Length = item2.list.length ? item2.list.length - 1 : 0;
  147. const dayjs_Last = item2.list[item2_Length]
  148. ? new DayJs(item2.list[item2_Length].dt)
  149. : undefined;
  150. let first = dayjs_Start ? dayjs_Start.format("d") : undefined;
  151. let last = dayjs_Last ? dayjs_Last.format("d") : undefined;
  152. last && last != 0 && (last = 7 - last);
  153. first && dataOne[i].data[o].list.unshift(...new Array(first - 1));
  154. last && dataOne[i].data[o].list.push(...new Array(last - 0));
  155. let li = [];
  156. for (let p = 0; p < dataOne[i].data[o].list.length; p++) {
  157. const item3 = dataOne[i].data[o].list[p] || undefined;
  158. if (p % 7 === 0) li.push([]);
  159. let end = li.length ? li.length - 1 : 0;
  160. if (!item3) {
  161. li[end].push(undefined);
  162. continue;
  163. }
  164. let dt3 = new DayJs(item3.dt);
  165. item3.day = dt3.format("D");
  166. item3.weeks = dt3.format("d");
  167. li[end].push(item3);
  168. }
  169. dataOne[i].data[o].list = li;
  170. }
  171. }
  172. this.dataOne = dataOne;
  173. });
  174. },
  175. computed: {},
  176. methods: {},
  177. beforeUnmount() {},
  178. components: {},
  179. };
  180. </script>
  181. <style scoped>
  182. .calendar {
  183. background-color: #f5b379;
  184. height: 100%;
  185. overflow-y: auto;
  186. box-sizing: border-box;
  187. color: #000;
  188. }
  189. .bottom {
  190. border: 4px solid #0983a8;
  191. margin-top: 1em;
  192. padding: 10px;
  193. font-size: 0.9rem;
  194. padding-left: 5px;
  195. font-weight: 600;
  196. overflow: hidden;
  197. }
  198. .content {
  199. margin: 0 auto;
  200. max-width: 667px;
  201. }
  202. .group {
  203. margin-bottom: 2em;
  204. }
  205. .headTitle {
  206. font-size: 1.5rem;
  207. text-align: center;
  208. font-family: SourceHanSansCN;
  209. font-weight: bold;
  210. color: #be651a;
  211. line-height: 30px;
  212. text-shadow: 0 0 10px #fff, 0 0 20px #fff, 0 0 30px #fff;
  213. }
  214. .headSubTitle {
  215. text-align: center;
  216. font-size: 1.2rem;
  217. font-family: SourceHanSansCN;
  218. font-weight: 400;
  219. color: #a22626;
  220. line-height: 30px;
  221. }
  222. .bg {
  223. background-image: url("../../../assets/image/bg.png");
  224. background-size: 100% 100%;
  225. padding-bottom: 1.5em;
  226. }
  227. .monthlyCalendar {
  228. background-image: url("../../../assets/image/C_bg.png");
  229. background-size: 100% 100%;
  230. width: 82.5%;
  231. height: calc((82.5% - 10px) * 1.5);
  232. padding: 1.5em 1px 0 1px;
  233. max-width: 614px;
  234. margin: 0 auto;
  235. margin-top: 1.5em;
  236. /* width: 92vw;
  237. height: 117vw; */
  238. }
  239. .title {
  240. font-size: 1rem;
  241. font-family: STHupo;
  242. font-weight: 600;
  243. line-height: 30px;
  244. padding: .5em .8em;
  245. }
  246. .CalenRow {
  247. display: flex;
  248. overflow: hidden;
  249. }
  250. .CalenCol {
  251. flex: 1;
  252. text-align: center;
  253. border-left: 1px solid #fff;
  254. }
  255. .CalenHead {
  256. font-size: 0.9rem;
  257. height: 1.5em;
  258. line-height: 1.5em;
  259. font-weight: 400;
  260. color: #fff;
  261. background-color: #dc721a;
  262. border-radius: 3px;
  263. }
  264. .dayDate {
  265. box-sizing: border-box;
  266. width: 1.3em;
  267. height: 1.3em;
  268. line-height: 1.3em;
  269. font-size: 1.1rem;
  270. font-family: Adobe Heiti Std;
  271. color: #000;
  272. background-color: #f4f4f4;
  273. transform: rotate(45deg);
  274. margin: 0 auto .3em auto;
  275. }
  276. .dayDate_son {
  277. width: 100%;
  278. height: 100%;
  279. transform: rotate(-45deg);
  280. }
  281. .CalenBody .CalenCol {
  282. padding: 10px 0;
  283. font-weight: bold;
  284. border-left: 1px solid #eee;
  285. border-bottom: 1px solid #eee;
  286. }
  287. .text {
  288. background-image: url("../../../assets/image/text.png");
  289. background-size: 100% 100%;
  290. margin: 0.5em 1px 0 1px;
  291. padding: 1px 0;
  292. font-size: 0.7rem;
  293. height: 1.3em;
  294. line-height: 1.3em;
  295. color: #c31212;
  296. overflow: hidden;
  297. white-space: nowrap;
  298. text-overflow: ellipsis;
  299. }
  300. </style>
  301. <style></style>