index.vue 11 KB

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