custom-layout.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. <template>
  2. <div id="c-layout">
  3. <div class="header">
  4. <el-col :span="24" class="header_1">
  5. <div class="left">
  6. <el-image class="image" v-if="configInfo && configInfo.logoUrl && configInfo.logoUrl.length > 0" :src="getUrl(configInfo.logoUrl)" fit="fill" />
  7. <el-image class="image" v-else :src="siteInfo.logoUrl" fit="fill" />
  8. <div class="content">
  9. <text class="title">{{ configInfo.zhTitle || siteInfo.zhTitle }}</text>
  10. </div>
  11. </div>
  12. <div class="right">
  13. <div class="right_1" v-if="user && user.id">
  14. <el-dropdown>
  15. <span class="el-dropdown-link">
  16. {{ user.nick_name || '暂无昵称' }}
  17. <el-icon class="el-icon--right">
  18. <arrow-down />
  19. </el-icon>
  20. </span>
  21. <template #dropdown>
  22. <el-dropdown-menu>
  23. <el-dropdown-item @click="toCenter"> 个人中心 </el-dropdown-item>
  24. <el-dropdown-item @click="toOut"> 退出登录 </el-dropdown-item>
  25. </el-dropdown-menu>
  26. </template>
  27. </el-dropdown>
  28. </div>
  29. <div class="right_1" v-else>
  30. <span @click="toLogin('0')">注册</span>
  31. <span>|</span>
  32. <span @click="toLogin('1')">登录</span>
  33. </div>
  34. <div class="right_2" @click="toChat">
  35. <el-icon><Bell /></el-icon>
  36. <span>消息</span>
  37. </div>
  38. </div>
  39. </el-col>
  40. <el-col :span="24" class="header_2">
  41. <el-col :span="24" class="list">
  42. <div
  43. class="text"
  44. v-for="(item, index) in data"
  45. @click="selectMenu(item.route)"
  46. :style="{
  47. backgroundColor: item.hover ? '#1073ff' : 'transparent',
  48. color: item.hover ? '#ffffff' : ''
  49. }"
  50. :key="index"
  51. @mouseover="handleMouseOver(index)"
  52. @mouseout="handleMousOut(index)"
  53. >
  54. <span>{{ item.title }}</span>
  55. </div>
  56. </el-col>
  57. <el-col :span="24" class="info">
  58. <!-- <div class="info_1" v-if="info.key == '3'">
  59. <el-col :span="12" class="list_1" v-for="(agg, index) in info.children" :key="index">
  60. <div class="title">{{ agg.title }}</div>
  61. <div class="list_1_1">
  62. <div v-for="(tag, indexs) in agg.children" :key="indexs" class="title1" @click="selectMenu(tag.route)">
  63. {{ tag.title }}
  64. </div>
  65. </div>
  66. </el-col>
  67. </div> -->
  68. <!-- <div class="info_2" :class="[user && user.id && isIncubator ? 'info_3' : '']" v-if="info.key == '10'">
  69. <el-col :span="24" class="list_2">
  70. <div v-for="(tag, indexs) in info.children" :key="indexs" class="title1" @click="selectMenu(tag.route)">
  71. {{ tag.title }}
  72. </div>
  73. </el-col>
  74. </div> -->
  75. <div class="info_4" v-if="info.key == '10'">
  76. <div class="w_1300 list4">
  77. <div v-for="(tag, indexs) in info.children" :key="indexs" class="list_1" @click="selectMenu(tag.route)">
  78. <el-image class="image" :src="tag.url" fit="fill" />
  79. <span class="title"> {{ tag.title }}</span>
  80. </div>
  81. </div>
  82. </div>
  83. </el-col>
  84. </el-col>
  85. </div>
  86. <div class="main">
  87. <slot></slot>
  88. </div>
  89. <div class="footer" v-if="is_foot">
  90. <div class="footer_1">
  91. <div class="left">
  92. <el-image class="image" v-if="footInfos && footInfos.Logo && footInfos.Logo.length > 0" :src="getUrl(footInfos.Logo)" fit="fill" />
  93. <el-image class="image" v-else :src="footInfo.Logo" fit="fill" />
  94. <div class="title">电话:{{ footInfos.Phone || footInfo.Phone }}</div>
  95. <div class="title">邮箱:{{ footInfos.Email || footInfo.Email }}</div>
  96. <div class="title">地址:{{ footInfos.Address || footInfo.Address }}</div>
  97. </div>
  98. <div class="right">
  99. <el-image class="image" v-if="footInfos && footInfos.Code && footInfos.Code.length > 0" :src="getUrl(footInfos.Code)" fit="fill" />
  100. <el-image class="image" v-else :src="footInfo.Code" fit="fill" />
  101. <div class="title" @click="toHelp">关于我们</div>
  102. </div>
  103. </div>
  104. <div class="footer_2">
  105. {{ footInfo.Copyright }}
  106. </div>
  107. </div>
  108. </div>
  109. </template>
  110. <script setup>
  111. import { ArrowDown } from '@element-plus/icons-vue'
  112. import { cloneDeep, get } from 'lodash-es'
  113. import { siteInfo, footInfo, menuList } from '@/layout/site'
  114. // 接口
  115. import { DesignStore } from '@/store/api/platform/design'
  116. const designStore = DesignStore()
  117. import { UserStore } from '@/store/user'
  118. const userStore = UserStore()
  119. const user = computed(() => userStore.user)
  120. const router = useRouter()
  121. const route = useRoute()
  122. const $checkRes = inject('$checkRes')
  123. const props = defineProps({
  124. is_foot: { type: Boolean, default: () => true }
  125. })
  126. const configInfo = ref({})
  127. const footInfos = ref({})
  128. const data = ref([])
  129. const info = ref({})
  130. const isIncubator = ref(false)
  131. // 请求
  132. onMounted(async () => {
  133. search()
  134. })
  135. const search = async () => {
  136. for (const val of menuList) {
  137. if (route.name === val.route) val.hover = true
  138. else val.hover = false
  139. }
  140. let menus = cloneDeep(menuList)
  141. // 判断, 如果没有孵化器角色, 则不显示孵化器菜单
  142. if (user.value) {
  143. const hasIncubator = get(user.value, 'role', []).find((f) => f === 'Incubator')
  144. if (hasIncubator) isIncubator.value = true
  145. }
  146. if (!isIncubator.value) menus = menus.filter((f) => f.key !== '11')
  147. data.value = menus
  148. // 基础设置
  149. const result = await designStore.query({})
  150. if ($checkRes(result)) {
  151. configInfo.value = result.data[0] || {}
  152. footInfo.value = result.data[0].footInfo || {}
  153. }
  154. }
  155. // 登录|注册
  156. const toLogin = (status) => {
  157. router.push({ path: '/login', query: { status } })
  158. }
  159. const selectMenu = (item, query) => {
  160. for (const val of data.value) {
  161. if (route.name === val.route) val.hover = true
  162. else val.hover = false
  163. }
  164. if (item == 'brain') window.open(`/cxyyWeb/brain`)
  165. else router.push({ path: `/${item}`, query })
  166. }
  167. // 关于我们
  168. const toHelp = () => {
  169. router.push({ path: `/help` })
  170. }
  171. // 个人中心
  172. const toCenter = () => {
  173. router.push({ path: `/center` })
  174. }
  175. // 消息
  176. const toChat = () => {
  177. if (user.value && user.value.id) {
  178. router.push({ path: `/chat` })
  179. } else {
  180. router.push({ path: '/login', query: { status: '1' } })
  181. }
  182. }
  183. const handleMouseOver = (index) => {
  184. data.value[index].hover = true
  185. info.value = data.value[index]
  186. }
  187. const handleMousOut = (index) => {
  188. data.value[index].hover = false
  189. const arr = data.value.every((i) => i.hover === false)
  190. if (arr) {
  191. for (const val of data.value) {
  192. if (route.name === val.route) val.hover = true
  193. else val.hover = false
  194. }
  195. }
  196. }
  197. const getUrl = (item) => {
  198. if (item && item.length > 0) return `${import.meta.env.VITE_APP_HOST}${item[0].uri}`
  199. }
  200. // 退出登录
  201. const toOut = () => {
  202. userStore.logOut()
  203. router.push({ path: '/login', query: { status: '1' } })
  204. }
  205. </script>
  206. <style lang="scss" scoped>
  207. #c-layout {
  208. .header {
  209. padding: 0;
  210. position: sticky;
  211. top: 0;
  212. z-index: 1000;
  213. padding: 5px 0;
  214. background: $global-color-fff;
  215. .header_1 {
  216. display: flex;
  217. justify-content: space-between;
  218. .left {
  219. display: flex;
  220. .image {
  221. height: 60px;
  222. width: 240px;
  223. margin: 0 5px 0 0;
  224. }
  225. .content {
  226. padding: 10px 0 0 0;
  227. font-size: $global-font-size-34;
  228. font-family: 'Comic Sans MS', cursive;
  229. }
  230. }
  231. .right {
  232. display: flex;
  233. font-size: $global-font-size-18;
  234. cursor: pointer; /* 改变鼠标样式为手形 */
  235. .right_1 {
  236. display: flex;
  237. align-items: center;
  238. color: $global-color-107;
  239. margin: 0 10px 0 0;
  240. span {
  241. margin: 0 5px;
  242. }
  243. .el-dropdown-link {
  244. font-size: $global-font-size-18;
  245. cursor: pointer;
  246. color: #409eff;
  247. display: flex;
  248. align-items: center;
  249. }
  250. }
  251. .right_2 {
  252. display: flex;
  253. align-items: center;
  254. margin: 0 5px;
  255. span {
  256. margin: 0 0 0 5px;
  257. }
  258. }
  259. }
  260. }
  261. .header_2 {
  262. .list {
  263. display: flex;
  264. justify-content: space-around;
  265. .text {
  266. text-align: center;
  267. padding: 0 10px;
  268. height: 58px;
  269. line-height: 58px;
  270. font-family: Microsoft YaHei;
  271. font-size: $global-font-size-24;
  272. color: #333333;
  273. cursor: pointer; /* 改变鼠标样式为手形 */
  274. }
  275. }
  276. .info {
  277. display: none;
  278. .info_1 {
  279. position: absolute;
  280. left: 0;
  281. top: 128px;
  282. display: flex;
  283. padding: 10px 0;
  284. background: $global-color-107;
  285. width: 700px;
  286. .list_1 {
  287. margin: 0 10px 0 0;
  288. .title {
  289. margin: 5px 0;
  290. font-size: $global-font-size-20;
  291. font-weight: 600;
  292. text-align: center;
  293. color: #fff;
  294. cursor: pointer; /* 改变鼠标样式为手形 */
  295. }
  296. .list_1_1 {
  297. display: flex;
  298. flex-wrap: wrap;
  299. justify-content: center;
  300. margin: 5px 0;
  301. .title1 {
  302. width: 120px;
  303. margin: 5px;
  304. padding: 5px;
  305. text-align: center;
  306. color: #ffffff;
  307. font-size: $global-font-size-18;
  308. cursor: pointer; /* 改变鼠标样式为手形 */
  309. }
  310. }
  311. }
  312. }
  313. .info_2 {
  314. position: absolute;
  315. left: 73.3%;
  316. top: 128px;
  317. display: flex;
  318. padding: 10px 0;
  319. background: $global-color-107;
  320. width: 145px;
  321. .list_2 {
  322. display: flex;
  323. flex-direction: column;
  324. align-items: center;
  325. margin: 5px 0;
  326. .title1 {
  327. width: 110px;
  328. margin: 5px;
  329. padding: 5px;
  330. text-align: center;
  331. color: #ffffff;
  332. font-size: $global-font-size-18;
  333. cursor: pointer; /* 改变鼠标样式为手形 */
  334. }
  335. }
  336. }
  337. .info_3 {
  338. left: 68.1%;
  339. }
  340. .info_4 {
  341. position: absolute;
  342. left: 0;
  343. top: 128px;
  344. width: 100%;
  345. background: $global-color-fff;
  346. background: -webkit-linear-gradient(top, white, #6ea6f5, #3b86ee);
  347. cursor: pointer; /* 改变鼠标样式为手形 */
  348. .list4 {
  349. display: flex;
  350. justify-content: center;
  351. .list_1 {
  352. padding: 20px 0;
  353. position: relative;
  354. margin: 0 10px;
  355. span {
  356. position: absolute;
  357. top: 40px;
  358. left: 0;
  359. width: 100%;
  360. text-align: center;
  361. font-size: 20px;
  362. color: #000;
  363. }
  364. }
  365. }
  366. }
  367. }
  368. }
  369. }
  370. .header:hover {
  371. .header_2 {
  372. .info {
  373. display: block !important;
  374. }
  375. }
  376. }
  377. .main {
  378. min-height: 62vh;
  379. }
  380. .footer {
  381. padding: 0 5px 10px 5px;
  382. background-color: $global-color-2D2;
  383. color: $global-color-fff;
  384. font-size: $global-font-size-18;
  385. .footer_1 {
  386. padding: 10px 0;
  387. display: flex;
  388. justify-content: space-between;
  389. border-bottom: 1px solid $global-color-bbb;
  390. .left {
  391. .image {
  392. width: 393px;
  393. height: 70px;
  394. }
  395. .title {
  396. margin: 5px 0 0 0;
  397. }
  398. }
  399. .right {
  400. text-align: center;
  401. .image {
  402. width: 130px;
  403. height: 130px;
  404. }
  405. .title {
  406. margin: 5px 0 0 0;
  407. }
  408. }
  409. }
  410. .footer_2 {
  411. padding: 10px 0 0 0;
  412. }
  413. }
  414. }
  415. @media screen and (max-width: 1280px) {
  416. #c-layout {
  417. min-width: 1920px;
  418. margin: 0 auto;
  419. }
  420. }
  421. @media screen and (min-width: 1921px) {
  422. #c-layout {
  423. max-width: 1920px;
  424. margin: 0 auto;
  425. }
  426. }
  427. </style>