Activity.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <div class="activity">
  3. <el-loading></el-loading>
  4. <el-breadcrumb separator-class="el-icon-arrow-right">
  5. <el-breadcrumb-item>新媒体</el-breadcrumb-item>
  6. <el-breadcrumb-item>重大活动传播数据</el-breadcrumb-item>
  7. </el-breadcrumb>
  8. <br />
  9. <el-tabs
  10. tab-position="top"
  11. style="max-height: 100%;"
  12. @tab-click="selectTab"
  13. >
  14. <el-tab-pane
  15. :label="item.name"
  16. v-for="(item, i) in activitys"
  17. :key="i"
  18. :name="i + ''"
  19. >
  20. <component
  21. :is="item.component"
  22. v-if="item.componentReal === select || selectA[item.componentReal]"
  23. :item="item"
  24. ></component>
  25. </el-tab-pane>
  26. </el-tabs>
  27. </div>
  28. </template>
  29. <script>
  30. // @ is an alias to /src
  31. let sha256 = require("js-sha256").sha256;
  32. import { guijiLogin, guijiActivity, defaultAjax } from "@/api/index";
  33. import derunsanqin from "./views/derunsanqin.vue";
  34. import defaultComponent from "./views/defaultComponent.vue";
  35. import huashanyunhai from "./views/huashanyunhai.vue";
  36. import mianmianjiedao from "./views/mianmianjiedao.vue";
  37. import zhongqiuzhiye from "./views/zhongqiuzhiye.vue";
  38. import shanxijiaoao1 from "./views/shanxijiaoao1.vue";
  39. import shanxijiaoao2 from "./views/shanxijiaoao2.vue";
  40. export default {
  41. name: "Activity",
  42. data() {
  43. return {
  44. activitys: [],
  45. select: "",
  46. selectA: {},
  47. };
  48. },
  49. mounted() {
  50. if (localStorage.getItem("chinaMap")) this.init();
  51. else this.getMap();
  52. },
  53. computed: {},
  54. methods: {
  55. init() {
  56. if (localStorage.guijiToken) {
  57. return guijiActivity().then(topic => {
  58. this.getTab(topic);
  59. });
  60. }
  61. let from = new FormData();
  62. from.append("username", "lyl");
  63. from.append("sign", sha256("lyl?lyl@Q41qtjsql").toLowerCase());
  64. guijiLogin(from).then(res => {
  65. localStorage.guijiToken = res.token || "";
  66. guijiActivity().then(topic => {
  67. this.getTab(topic);
  68. });
  69. });
  70. },
  71. getMap() {
  72. defaultAjax({
  73. url:
  74. "https://dangjian-web.oss-accelerate-overseas.aliyuncs.com/dj/static/chinaMap.json",
  75. }).then(map => {
  76. localStorage.setItem("chinaMap", JSON.stringify(map.json));
  77. this.init();
  78. });
  79. },
  80. // getTab() {
  81. getTab(topic) {
  82. let activitys = [];
  83. (topic || []).map(v => {
  84. if (v.isBigdata === 0) return;
  85. activitys.push({
  86. isCollectPlatform: v.isCollectPlatform,
  87. component: "defaultComponent",
  88. componentReal: "defaultComponent" + v.activityId,
  89. activityId: v.activityId,
  90. realName: v.name,
  91. sortNo: v.sortNo,
  92. name: v.alias,
  93. });
  94. });
  95. activitys = activitys.concat([
  96. {
  97. name: "德润三秦",
  98. url: ["https://djweb.smcic.net/dj/static/t.json?" + Date.now()],
  99. component: "derunsanqin",
  100. componentReal: "derunsanqin",
  101. },
  102. {
  103. name: "华山云海音乐会",
  104. component: "huashanyunhai",
  105. componentReal: "huashanyunhai",
  106. },
  107. {
  108. name: "面面皆道",
  109. componentReal: "mianmianjiedao",
  110. component: "mianmianjiedao",
  111. },
  112. {
  113. name: "2021中秋之夜",
  114. component: "zhongqiuzhiye",
  115. componentReal: "zhongqiuzhiye",
  116. },
  117. {
  118. name: "我爱我的家乡第二季:陕西骄傲",
  119. component: "shanxijiaoao2",
  120. componentReal: "shanxijiaoao2",
  121. },
  122. {
  123. name: "我爱我的家乡第一季",
  124. component: "shanxijiaoao1",
  125. componentReal: "shanxijiaoao1",
  126. },
  127. ]);
  128. this.activitys = activitys;
  129. this.select = (this.activitys[0] || {}).componentReal;
  130. this.selectA[this.select] = true;
  131. },
  132. selectTab(tab) {
  133. try {
  134. this.select = this.activitys[tab.index].componentReal;
  135. this.selectA[this.select] = true;
  136. } catch (err) {
  137. console.error(err);
  138. }
  139. },
  140. },
  141. beforeUnmount: function() {},
  142. components: {
  143. derunsanqin,
  144. huashanyunhai,
  145. mianmianjiedao,
  146. zhongqiuzhiye,
  147. shanxijiaoao1,
  148. shanxijiaoao2,
  149. defaultComponent,
  150. },
  151. };
  152. </script>
  153. <style>
  154. .activity {
  155. padding: 10px 15px;
  156. box-sizing: border-box;
  157. }
  158. .activity .num {
  159. font-size: 42px;
  160. color: #91afc8;
  161. }
  162. .titleNum {
  163. text-align: center;
  164. }
  165. .chart {
  166. padding: 5px 3px;
  167. }
  168. .subtitle {
  169. font-size: 16px;
  170. font-weight: 600;
  171. }
  172. .wumen {
  173. height: 1.5em;
  174. overflow: hidden;
  175. border-radius: 3px;
  176. background-color: #f47f92;
  177. text-align: right;
  178. }
  179. .men {
  180. width: 50%;
  181. background-color: #11a0f8;
  182. height: 100%;
  183. }
  184. </style>