head.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <div id="heads">
  3. <el-row>
  4. <div class="superbanner">
  5. <img :src="top_bg" />
  6. </div>
  7. <div class="supertop">
  8. <div class="w_1200">
  9. <!-- <el-col :span="12" class="left">
  10. <span>欢迎来到中科在线</span>
  11. <span @click="guanzhu()">关注公众号</span>
  12. </el-col>
  13. <el-col :span="12" class="right">
  14. <el-col :span="18" class="one">
  15. <span v-if="user.uid || user.suid">
  16. {{ user.name || user.adminuser }}
  17. </span>
  18. </el-col>
  19. <el-col
  20. :span="3"
  21. class="two"
  22. v-if="user.role == '2' || user.role == '3' || user.role == '4' || user.role == '5' || user.role == '6' || user.role == '7' || user.role == '8'"
  23. >
  24. <span v-if="user.uid">
  25. <button
  26. type="text"
  27. class="center"
  28. @click="tuCenter"
  29. v-if="user.role == '3' || user.role == '4' || user.role == '5' || user.role == '6' || user.role == '7' || user.role == '8'"
  30. >
  31. 个人中心
  32. </button>
  33. <button type="button" @click="zhuxiao" class="outLogin">退出</button>
  34. </span>
  35. <span v-else>
  36. <el-button type="primary" size="mini" class="loginBtn" @click="webLogin">平台登录</el-button>
  37. </span>
  38. </el-col>
  39. <el-col :span="3" class="two" v-if="user.role == '0' || user.role == '1' || user.role == '7'">
  40. <span v-if="user.uid">
  41. <button type="text" class="center" @click="tuCenter" v-if="user.role == '0' || user.role == '1' || user.role == '7'">
  42. 个人中心
  43. </button>
  44. <button type="button" @click="zhuxiao" class="outLogin">退出</button>
  45. </span>
  46. <span v-else>
  47. <el-button type="primary" size="mini" class="loginBtn" @click="adminLogin">管理登录</el-button>
  48. </span>
  49. </el-col>
  50. </el-col> -->
  51. <el-col :span="12" class="left">
  52. <span>欢迎来到中科在线</span>
  53. <span @click="guanzhu()">关注公众号</span>
  54. </el-col>
  55. <el-col :span="12" class="right">
  56. 右侧
  57. </el-col>
  58. </div>
  59. </div>
  60. <div class="superlogo">
  61. <div class="w_1200">
  62. <a href="/platlive">
  63. <img :src="logo" />
  64. <span>
  65. 中科在线
  66. </span>
  67. </a>
  68. </div>
  69. </div>
  70. <div class="supermenu">
  71. <div class="w_1200">
  72. <div class="info">
  73. <ul>
  74. <li :class="isTab('hallList') ? 'active' : ''">
  75. <a @click="turnTo('hallList')" target="">直播大厅</a>
  76. <span></span>
  77. </li>
  78. <li :class="isTab('market') ? 'active' : ''">
  79. <a @click="turnTo('market')" target="">科技超市</a>
  80. <span></span>
  81. </li>
  82. <li :class="isTab('service') ? 'active' : ''">
  83. <a @click="turnTo('service')" target="">创新服务</a>
  84. <span></span>
  85. </li>
  86. <li :class="isTab('dynamic') ? 'active' : ''">
  87. <a @click="turnTo('dynamic')" target="">动态监测</a>
  88. <span></span>
  89. </li>
  90. <li :class="isTab('technical') ? 'active' : ''">
  91. <a @click="turnTo('technical')" target="">技术交流</a>
  92. </li>
  93. </ul>
  94. </div>
  95. </div>
  96. </div>
  97. <div v-if="view" class="erweima">
  98. <img :src="qrcode" />
  99. </div>
  100. </el-row>
  101. </div>
  102. </template>
  103. <script>
  104. import { mapState, createNamespacedHelpers } from 'vuex';
  105. const { mapActions: login } = createNamespacedHelpers('login');
  106. const { mapActions: dockLogin } = createNamespacedHelpers('dockLogin');
  107. import QRCode from 'qrcode';
  108. export default {
  109. name: 'heads',
  110. props: {},
  111. components: {},
  112. data: () => {
  113. return {
  114. top_bg: require('@/assets/live/top_bg.png'),
  115. qrcode: require('@/assets/live/free-qrcode.jpg'),
  116. logo: require('@/assets/live/logo.png'),
  117. qc: '',
  118. view: false,
  119. };
  120. },
  121. created() {
  122. console.log(this.user);
  123. },
  124. methods: {
  125. ...login({ logout: 'logout', transactiondtetle: 'delete' }),
  126. ...dockLogin({ docklogout: 'logout', transactiondtetle: 'delete' }),
  127. // 跳转
  128. turnTo(type) {
  129. if (type == 'index') {
  130. } else if (type == 'hall_index') {
  131. this.$router.push({ path: '/live/hall/index' });
  132. } else if (type == 'service') {
  133. this.$router.push({ path: '/live/service' });
  134. } else {
  135. this.$router.push({ path: `/${type}/index` });
  136. }
  137. },
  138. // 选中
  139. isTab(type) {
  140. if (type == 'index') return this.$route.path.includes('/live/index');
  141. else return this.$route.path.includes(`/${type}`);
  142. },
  143. // 平台登录
  144. webLogin() {
  145. this.$router.push({ path: '/webLogin' });
  146. },
  147. // 管理登录
  148. adminLogin() {
  149. this.$router.push({ path: '/adminLogin' });
  150. },
  151. // 个人中心跳转
  152. tuCenter() {
  153. if (this.user.role == '4' || this.user.role == '5' || this.user.role == '6' || this.user.role == '7') {
  154. this.$router.push({ path: '/userCenter/index', query: { num: '1' } });
  155. } else if (this.user.role == '3') {
  156. this.$router.push({ path: '/adminCenter/index', query: { num: '1' } });
  157. } else if (this.user.role == '8') {
  158. this.$router.push({ path: '/vipCenter/index', query: { num: '1' } });
  159. } else if (this.user.role == '0' || this.user.role == '1') {
  160. this.$router.push({ path: '/superAdminCenter/index', query: { num: '1' } });
  161. } else {
  162. this.$router.push('/market/index');
  163. }
  164. },
  165. async zhuxiao() {
  166. if (this.user.role === '3' || this.user.role === '8') {
  167. this.docklogout();
  168. this.$message({
  169. message: '注销成功',
  170. type: 'success',
  171. });
  172. window.location.reload();
  173. } else {
  174. this.logout();
  175. this.$message({
  176. message: '注销成功',
  177. type: 'success',
  178. });
  179. window.location.reload();
  180. }
  181. },
  182. // 关注公众号
  183. guanzhu() {
  184. if (this.view) {
  185. this.view = false;
  186. } else {
  187. this.view = true;
  188. }
  189. },
  190. // 创建二维码
  191. async creatQrCode() {
  192. let url = `http://free.liaoningdoupo.com/api/auth/wxchat?redirect_uri=http://free.liaoningdoupo.com/platmobile/bind/&type=1&uid=${this.user.uid}`; // 需要转换为二维码的内容
  193. let el = document.getElementById('qrCodeUrl');
  194. this.qc = await QRCode.toDataURL(url, { height: 200, width: 200 });
  195. },
  196. },
  197. mounted() {
  198. // this.creatQrCode();
  199. },
  200. computed: {
  201. ...mapState(['user']),
  202. },
  203. };
  204. </script>
  205. <style lang="less" scoped>
  206. @import '~@/style/style.css';
  207. .supertop {
  208. .left {
  209. height: 40px;
  210. line-height: 40px;
  211. font-size: 16px;
  212. span:last-child {
  213. padding: 0 10px;
  214. font-weight: bold;
  215. }
  216. span:last-child:hover {
  217. cursor: pointer;
  218. color: #0085d2;
  219. font-weight: bold;
  220. }
  221. }
  222. // .right {
  223. // height: 40px;
  224. // line-height: 40px;
  225. // font-size: 16px;
  226. // color: #000;
  227. // .one {
  228. // text-align: right;
  229. // color: #000;
  230. // font-weight: bold;
  231. // }
  232. // .two {
  233. // text-align: center;
  234. // .loginBtn:hover {
  235. // cursor: pointer;
  236. // }
  237. // .center {
  238. // font-size: 15px;
  239. // font-weight: bold;
  240. // color: #fff;
  241. // }
  242. // .center:hover {
  243. // cursor: pointer;
  244. // color: #0085d2;
  245. // }
  246. // .outLogin {
  247. // margin: 0 0 0 5px;
  248. // font-weight: bold;
  249. // font-size: 14px;
  250. // }
  251. // .outLogin:hover {
  252. // cursor: pointer;
  253. // color: #0085d2;
  254. // }
  255. // }
  256. // }
  257. }
  258. .btnER {
  259. font-size: 16px;
  260. padding: 10px 10px;
  261. float: left;
  262. font-weight: bold;
  263. }
  264. .btnER:hover {
  265. color: #0085d2;
  266. font-weight: bold;
  267. cursor: pointer;
  268. }
  269. .erweima {
  270. position: fixed;
  271. top: 4%;
  272. left: 40%;
  273. z-index: 999;
  274. }
  275. </style>