index.vue 11 KB

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