index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. <template>
  2. <div style="font-size: 0; background-color: #fff">
  3. <div class="Advertisement" style="padding: 0">
  4. <img
  5. class="item"
  6. :src="
  7. 'https://cxzx.smcic.net/zhoubao/assets/guanggao' +
  8. $route.query.date +
  9. '.jpg'
  10. "
  11. width="100%"
  12. style="margin-bottom: 1em; display: block"
  13. alt=""
  14. />
  15. <div :style="'height: ' + fontSize + 'px;'"></div>
  16. </div>
  17. <div
  18. v-if="orgin.html"
  19. :style="'font-size: ' + fontSize + 'px;'"
  20. class="Advertisement"
  21. >
  22. <!-- <div class="item" style="text-align: center; padding-top: 1em">
  23. <p v-text="orgin.company"></p>
  24. <p v-text="orgin.name"></p>
  25. <p v-text="orgin.cycle"></p>
  26. </div> -->
  27. <div class="item">
  28. <section class="title">
  29. <section>电视广告投放简析</section>
  30. <img
  31. src="../../../assets/image/640.png"
  32. width="96.9922px"
  33. style="float: right"
  34. />
  35. </section>
  36. <br />
  37. <div class="article" v-html="orgin.html"></div>
  38. </div>
  39. <div class="item">
  40. <section class="title">
  41. <section>细分信息对比</section>
  42. <img
  43. src="../../../assets/image/640.png"
  44. width="96.9922px"
  45. style="float: right"
  46. />
  47. </section>
  48. <div class="card">
  49. <h4 class="xifenxinxiTitle">
  50. <div class="right"></div>
  51. <div class="left">
  52. <span v-text="orgin.day_hb.name"> </span>
  53. </div>
  54. </h4>
  55. <br />
  56. <div ref="adRingRatioCanvas"></div>
  57. <p
  58. :style="
  59. ' font-weight: 700; word-break: normal;text-align: justify;padding: 0.5em 3px;font-size: ' +
  60. fontSize +
  61. 'px;'
  62. "
  63. v-html="orgin.day_hb.desc"
  64. ></p>
  65. </div>
  66. <div class="card">
  67. <h4 class="xifenxinxiTitle">
  68. <div class="right"></div>
  69. <div class="left">
  70. <span v-text="orgin.brand_top.name"> </span>
  71. </div>
  72. </h4>
  73. <br />
  74. <van-row v-if="orgin.brand_top" class="tableHead">
  75. <van-col span="3">排名</van-col>
  76. <van-col span="7">品牌</van-col>
  77. <van-col span="7">费用(元)</van-col>
  78. <van-col span="7" style="text-align: right; padding-right: 3px"
  79. >环比</van-col
  80. >
  81. </van-row>
  82. <div v-if="orgin.brand_top">
  83. <van-row
  84. class="tableBody"
  85. v-for="(item, i) in orgin.brand_top.list || []"
  86. :key="item.name + i"
  87. >
  88. <van-col span="3" v-text="i + 1"></van-col>
  89. <van-col span="7" v-text="item.name"></van-col>
  90. <van-col
  91. span="7"
  92. :style="
  93. item.huanbi > 0
  94. ? 'color: red'
  95. : item.huanbi < 0
  96. ? 'color: green'
  97. : ''
  98. "
  99. >
  100. {{ item.fee }}
  101. </van-col>
  102. <van-col
  103. span="7"
  104. :style="
  105. item.huanbi > 0
  106. ? 'color: red;text-align: right;padding-right: 3px;'
  107. : item.huanbi < 0
  108. ? 'color: green;text-align: right;padding-right: 3px;'
  109. : ''
  110. "
  111. >
  112. {{ item.huanbi }}%
  113. </van-col>
  114. </van-row>
  115. </div>
  116. <p
  117. :style="
  118. ' font-weight: 700;word-break: normal;text-align: justify; padding: 0.5em 3px;font-size: ' +
  119. fontSize +
  120. 'px;'
  121. "
  122. v-html="orgin.brand_top.desc"
  123. ></p>
  124. </div>
  125. <div class="card">
  126. <h4 class="xifenxinxiTitle">
  127. <div class="right"></div>
  128. <div class="left">
  129. <span v-text="orgin.brand_hb.name"> </span>
  130. </div>
  131. </h4>
  132. <br />
  133. <div ref="adTop10" class="">
  134. <div ref="adTop10Canvas"></div>
  135. </div>
  136. <p
  137. :style="
  138. ' font-weight: 700; word-break: normal;text-align: justify;padding: 0.5em 3px;font-size: ' +
  139. fontSize +
  140. 'px;'
  141. "
  142. v-html="orgin.brand_hb.desc"
  143. ></p>
  144. </div>
  145. <div class="card">
  146. <h4 class="xifenxinxiTitle">
  147. <div class="right"></div>
  148. <div class="left">
  149. <span v-text="orgin.month_thb.name"> </span>
  150. </div>
  151. </h4>
  152. <br />
  153. <div ref="adTop10" class="">
  154. <div ref="adFeeCanvas"></div>
  155. </div>
  156. <p
  157. :style="
  158. ' font-weight: 700; word-break: normal;text-align: justify;padding: 0.5em 3px;font-size: ' +
  159. fontSize +
  160. 'px;'
  161. "
  162. v-html="orgin.month_thb.desc"
  163. ></p>
  164. </div>
  165. <div class="bottom">
  166. 本数据由<span style="color: red">“陕西广电融媒体集团大数据平台”</span
  167. >提供。
  168. <p>
  169. 技术支持:
  170. <span style="white-space: nowrap">白帆13325452244 </span>
  171. <span style="white-space: nowrap">陈科18629350958。</span>
  172. </p>
  173. </div>
  174. </div>
  175. </div>
  176. </div>
  177. </template>
  178. <script>
  179. // @ is an alias to /src
  180. import watermark from "watermark-package";
  181. import { Col as vanCol, Row as vanRow } from "vant";
  182. import "vant/lib/col/style/index";
  183. import "vant/lib/row/style/index";
  184. import {
  185. advertisementSpendInit,
  186. advertisementRingRatioInit,
  187. advertisementFeeInit,
  188. } from "./Charts";
  189. import { jsonAdvertisement } from "@/api/index";
  190. export default {
  191. name: "Advertisement",
  192. data() {
  193. return {
  194. orgin: {},
  195. fontSize: 17,
  196. };
  197. },
  198. mounted() {
  199. if (
  200. this.$route.query.auto !==
  201. "06fd56cdf5a6cfc3a2139cc8514d05aa0439ee8c1fb4d81145bc9647"
  202. )
  203. return;
  204. this.fontSize = (document.body.offsetWidth / 24).toFixed(2) - 0;
  205. if (document.body.offsetWidth > 677) this.fontSize = 20;
  206. watermark.setWaterMark({
  207. w_texts: ["陕西视听大数据"],
  208. w_options: {
  209. w_opacity: "0.1",
  210. w_width: 360,
  211. w_height: 280,
  212. },
  213. });
  214. jsonAdvertisement({
  215. date: this.$route.query.date,
  216. time: Date.now(),
  217. }).then(r => {
  218. const Res = r || {};
  219. const brand_top = Res.brand_top || { list: [] };
  220. for (let i = 0; i < brand_top.list.length; i++) {
  221. brand_top.list[i].fee = this.formatType(brand_top.list[i].fee, 2, true);
  222. brand_top.list[i].huanbi = (brand_top.list[i].huanbi * 100).toFixed(2);
  223. }
  224. Res.brand_top = brand_top;
  225. this.orgin = Res;
  226. console.log(this.orgin);
  227. this.$nextTick(() => {
  228. this.createChart();
  229. window.onresize = () => {
  230. watermark.setWaterMark({
  231. w_texts: ["陕西视听大数据"],
  232. w_options: {
  233. w_opacity: "0.1",
  234. },
  235. });
  236. };
  237. });
  238. });
  239. },
  240. computed: {},
  241. methods: {
  242. formatNum(num, w) {
  243. if (isNaN(num)) return 0;
  244. return Number(num).toFixed(w || 4) - 0;
  245. },
  246. formatType(num, W) {
  247. let N = this.formatNum(num, 2);
  248. if (N >= 100000000) {
  249. N = (N / 100000000).toFixed(W || 2) + "亿";
  250. } else if (N >= 10000) {
  251. N = (N / 10000).toFixed(W || 2) + "万";
  252. }
  253. return N;
  254. },
  255. createChart() {
  256. let width = this.$refs.adTop10.offsetWidth,
  257. height = (width / 16) * 9;
  258. this.$refs.adTop10Canvas.style = `width:${width}px;height:${width}px`;
  259. this.$refs.adFeeCanvas.style = `width:${width}px;height:${width}px`;
  260. this.$refs.adRingRatioCanvas.style = `width:${width}px;height:${height}px`;
  261. const ringRatioF = [];
  262. const ringRatioL = [];
  263. const day_hb = this.orgin.day_hb ? this.orgin.day_hb.list : [];
  264. for (let i = 0; i < day_hb.length; i++) {
  265. const v = day_hb[i];
  266. const type = (v.pdt || "").split("-");
  267. const type1 = (v.dt || "").split("-");
  268. v.pfee &&
  269. ringRatioF.push({
  270. date: v.pdt || "",
  271. type: [type[0], type[1]].join("-"),
  272. value: v.pfee * 1,
  273. });
  274. v.fee &&
  275. ringRatioL.push({
  276. date: v.dt || "",
  277. type: [type1[0], type1[1]].join("-"),
  278. value: v.fee * 1,
  279. });
  280. }
  281. const lineF = [];
  282. const lineL = [];
  283. const brand_hb = this.orgin.brand_hb ? this.orgin.brand_hb.list : [];
  284. for (let i = 0; i < brand_hb.length; i++) {
  285. const v = brand_hb[i];
  286. // lineF.push({
  287. // date: v.industry_name || "",
  288. // type: v.pstart_time,
  289. // value: v.pfee * 1,
  290. // });
  291. lineL.push({
  292. date: v.industry_name || "",
  293. type: "环比" + v.start_time + " vs " + v.pstart_time,
  294. value: v.huanbi * 100,
  295. });
  296. }
  297. const line1F = [];
  298. const line1L = [];
  299. const month_thb = this.orgin.month_thb ? this.orgin.month_thb.list : [];
  300. for (let i = 0; i < month_thb.length; i++) {
  301. const v = month_thb[i];
  302. line1F.push({
  303. date: v.name || "",
  304. type: "同比",
  305. t: "同比",
  306. value: v.tb * 100,
  307. });
  308. line1L.push({
  309. date: v.name || "",
  310. type: "环比",
  311. t: "环比",
  312. value: v.hb * 100,
  313. });
  314. }
  315. lineL.length &&
  316. advertisementSpendInit(this.$refs.adTop10Canvas, {
  317. L: lineL,
  318. F: lineF,
  319. name: this.orgin.brand_hb.name,
  320. });
  321. ringRatioF.length &&
  322. ringRatioL.length &&
  323. advertisementRingRatioInit(this.$refs.adRingRatioCanvas, {
  324. L: ringRatioL,
  325. F: ringRatioF,
  326. name: this.orgin.day_hb.name,
  327. });
  328. line1L.length &&
  329. line1F.length &&
  330. advertisementFeeInit(this.$refs.adFeeCanvas, {
  331. L: line1L,
  332. F: line1F,
  333. name: this.orgin.month_thb.name,
  334. });
  335. },
  336. },
  337. beforeUnmount: function () {},
  338. components: { vanCol, vanRow },
  339. };
  340. </script>
  341. <style>
  342. .Advertisement {
  343. height: 100%;
  344. padding: 0px 5px 12px 5px;
  345. background-color: #fff;
  346. }
  347. .Advertisement .article {
  348. word-break: normal;
  349. text-align: justify;
  350. }
  351. .Advertisement .item {
  352. max-width: 677px;
  353. margin: 0 auto;
  354. font-weight: 700;
  355. padding-bottom: 1em;
  356. }
  357. .Advertisement section {
  358. font-weight: 700;
  359. }
  360. .Advertisement .title {
  361. background-color: #d11e16;
  362. width: 196px;
  363. margin: 0 auto;
  364. }
  365. .Advertisement .title section {
  366. background-color: rgba(255, 255, 255, 0.1);
  367. color: #fff;
  368. height: 35px;
  369. line-height: 35px;
  370. width: 166px;
  371. text-align: center;
  372. }
  373. .xifenxinxiTitle {
  374. color: #ffffff;
  375. height: 34px;
  376. line-height: 34px;
  377. position: relative;
  378. }
  379. .xifenxinxiTitle .left {
  380. background-color: #d11e16;
  381. padding-left: 1em;
  382. width: 90%;
  383. position: relative;
  384. z-index: 1;
  385. overflow: hidden;
  386. white-space: nowrap;
  387. text-overflow: ellipsis;
  388. }
  389. .xifenxinxiTitle .right {
  390. background-color: #595959;
  391. width: 10%;
  392. height: 34px;
  393. line-height: 34px;
  394. position: absolute;
  395. z-index: 0;
  396. right: 0;
  397. top: 5px;
  398. }
  399. .Advertisement .tableHead {
  400. color: #fff;
  401. background-color: #cf827f;
  402. }
  403. .tableHead .van-col,
  404. .tableBody .van-col {
  405. height: 2em;
  406. line-height: 2em;
  407. text-align: center;
  408. white-space: nowrap;
  409. }
  410. .card {
  411. box-shadow: 0 0 5px 5px #eee;
  412. margin-top: 1em;
  413. padding: 1em 0;
  414. }
  415. .bottom {
  416. border: 4px solid #0983a8;
  417. background-color: #cdcdcd;
  418. margin-top: 1em;
  419. padding: 10px;
  420. font-size: 0.85rem;
  421. padding-left: 5px;
  422. font-weight: 600;
  423. overflow: hidden;
  424. }
  425. </style>