Activity.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. let from = new FormData();
  57. from.append("username", "admin");
  58. from.append("sign", sha256("adminabc123456").toLowerCase());
  59. if (localStorage.guijiToken) {
  60. return guijiActivity().then(topic => {
  61. this.getTab(topic);
  62. });
  63. }
  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(topic) {
  81. let activitys = [];
  82. (topic || []).map(v => {
  83. activitys.push({
  84. isCollectPlatform: v.isCollectPlatform,
  85. component: "defaultComponent",
  86. componentReal: "defaultComponent" + v.activityId,
  87. activityId: v.activityId,
  88. realName: v.name,
  89. sortNo: v.sortNo,
  90. name: v.alias,
  91. });
  92. });
  93. activitys = activitys.concat([
  94. {
  95. name: "德润三秦",
  96. url: ["https://djweb.smcic.net/dj/static/t.json?" + Date.now()],
  97. component: "derunsanqin",
  98. componentReal: "derunsanqin",
  99. },
  100. {
  101. name: "华山云海音乐会",
  102. component: "huashanyunhai",
  103. componentReal: "huashanyunhai",
  104. },
  105. {
  106. name: "面面皆道",
  107. componentReal: "mianmianjiedao",
  108. component: "mianmianjiedao",
  109. },
  110. {
  111. name: "2021中秋之夜",
  112. component: "zhongqiuzhiye",
  113. componentReal: "zhongqiuzhiye",
  114. },
  115. {
  116. name: "我爱我的家乡第二季:陕西骄傲",
  117. component: "shanxijiaoao2",
  118. componentReal: "shanxijiaoao2",
  119. },
  120. {
  121. name: "我爱我的家乡第一季",
  122. component: "shanxijiaoao1",
  123. componentReal: "shanxijiaoao1",
  124. },
  125. ]);
  126. this.activitys = activitys;
  127. this.select = (this.activitys[0] || {}).componentReal;
  128. this.selectA[this.select] = true;
  129. },
  130. selectTab(tab) {
  131. try {
  132. this.select = this.activitys[tab.index].component;
  133. this.selectA[this.select] = true;
  134. } catch (err) {
  135. console.log(err);
  136. }
  137. },
  138. },
  139. beforeUnmount: function() {},
  140. components: {
  141. derunsanqin,
  142. huashanyunhai,
  143. mianmianjiedao,
  144. zhongqiuzhiye,
  145. shanxijiaoao1,
  146. shanxijiaoao2,
  147. defaultComponent,
  148. },
  149. };
  150. </script>
  151. <style>
  152. .activity {
  153. padding: 10px 15px;
  154. box-sizing: border-box;
  155. }
  156. .activity .num {
  157. font-size: 42px;
  158. color: #91afc8;
  159. }
  160. .titleNum {
  161. text-align: center;
  162. }
  163. .chart {
  164. padding: 5px 3px;
  165. }
  166. .subtitle {
  167. font-size: 16px;
  168. font-weight: 600;
  169. }
  170. .wumen {
  171. height: 1.5em;
  172. overflow: hidden;
  173. border-radius: 3px;
  174. background-color: #f47f92;
  175. text-align: right;
  176. }
  177. .men {
  178. width: 50%;
  179. background-color: #11a0f8;
  180. height: 100%;
  181. }
  182. </style>