custom-layout.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  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> 个人中心 </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" 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. </el-col>
  76. </el-col>
  77. </div>
  78. <div class="main">
  79. <slot></slot>
  80. </div>
  81. <div class="footer" v-if="is_foot">
  82. <div class="footer_1">
  83. <div class="left">
  84. <el-image class="image" v-if="footInfos && footInfos.Logo && footInfos.Logo.length > 0" :src="getUrl(footInfos.Logo)" fit="fill" />
  85. <el-image class="image" v-else :src="footInfo.Logo" fit="fill" />
  86. <div class="title">电话:{{ footInfos.Phone || footInfo.Phone }}</div>
  87. <div class="title">邮箱:{{ footInfos.Email || footInfo.Email }}</div>
  88. <div class="title">地址:{{ footInfos.Address || footInfo.Address }}</div>
  89. </div>
  90. <div class="right">
  91. <el-image class="image" v-if="footInfos && footInfos.Code && footInfos.Code.length > 0" :src="getUrl(footInfos.Code)" fit="fill" />
  92. <el-image class="image" v-else :src="footInfo.Code" fit="fill" />
  93. <div class="title" @click="toHelp">关于我们</div>
  94. </div>
  95. </div>
  96. <div class="footer_2">
  97. {{ footInfo.Copyright }}
  98. </div>
  99. </div>
  100. </div>
  101. </template>
  102. <script setup>
  103. import { ArrowDown } from '@element-plus/icons-vue'
  104. import { siteInfo, footInfo, menuList } from '@/layout/site'
  105. // 接口
  106. import { DesignStore } from '@/store/api/platform/design'
  107. const designStore = DesignStore()
  108. import { UserStore } from '@/store/user'
  109. const userStore = UserStore()
  110. const user = computed(() => userStore.user)
  111. const router = useRouter()
  112. const route = useRoute()
  113. const $checkRes = inject('$checkRes')
  114. const props = defineProps({
  115. is_foot: { type: Boolean, default: () => true }
  116. })
  117. const configInfo = ref({})
  118. const footInfos = ref({})
  119. const data = ref([])
  120. const info = ref({})
  121. // 请求
  122. onMounted(async () => {
  123. search()
  124. })
  125. const search = async () => {
  126. for (const val of menuList) {
  127. if (route.name === val.route) val.hover = true
  128. else val.hover = false
  129. }
  130. data.value = menuList
  131. // 基础设置
  132. const result = await designStore.query({})
  133. if ($checkRes(result)) {
  134. configInfo.value = result.data[0] || {}
  135. footInfo.value = result.data[0].footInfo || {}
  136. }
  137. }
  138. // 登录|注册
  139. const toLogin = (status) => {
  140. router.push({ path: '/login', query: { status } })
  141. }
  142. const selectMenu = (item, query) => {
  143. for (const val of data.value) {
  144. if (route.name === val.route) val.hover = true
  145. else val.hover = false
  146. }
  147. if (item == 'brain') window.open(`/cxyyWeb/brain`)
  148. else router.push({ path: `/${item}`, query })
  149. }
  150. // 关于我们
  151. const toHelp = () => {
  152. router.push({ path: `/help` })
  153. }
  154. // 消息
  155. const toChat = () => {
  156. router.push({ path: `/chat` })
  157. }
  158. const handleMouseOver = (index) => {
  159. data.value[index].hover = true
  160. info.value = data.value[index]
  161. }
  162. const handleMousOut = (index) => {
  163. data.value[index].hover = false
  164. const arr = data.value.every((i) => i.hover === false)
  165. if (arr) {
  166. for (const val of data.value) {
  167. if (route.name === val.route) val.hover = true
  168. else val.hover = false
  169. }
  170. }
  171. }
  172. const getUrl = (item) => {
  173. if (item && item.length > 0) return `${import.meta.env.VITE_APP_HOST}${item[0].uri}`
  174. }
  175. // 退出登录
  176. const toOut = () => {
  177. userStore.logOut()
  178. router.push('/login')
  179. }
  180. </script>
  181. <style lang="scss" scoped>
  182. #c-layout {
  183. .header {
  184. padding: 0;
  185. position: sticky;
  186. top: 0;
  187. z-index: 1000;
  188. padding: 5px 0;
  189. background: $global-color-fff;
  190. .header_1 {
  191. display: flex;
  192. justify-content: space-between;
  193. .left {
  194. display: flex;
  195. .image {
  196. height: 60px;
  197. width: 240px;
  198. margin: 0 5px 0 0;
  199. }
  200. .content {
  201. padding: 10px 0 0 0;
  202. font-size: $global-font-size-34;
  203. font-family: 'Comic Sans MS', cursive;
  204. }
  205. }
  206. .right {
  207. display: flex;
  208. font-size: $global-font-size-18;
  209. cursor: pointer; /* 改变鼠标样式为手形 */
  210. .right_1 {
  211. display: flex;
  212. align-items: center;
  213. color: $global-color-107;
  214. margin: 0 10px 0 0;
  215. span {
  216. margin: 0 5px;
  217. }
  218. .el-dropdown-link {
  219. font-size: $global-font-size-18;
  220. cursor: pointer;
  221. color: #409eff;
  222. display: flex;
  223. align-items: center;
  224. }
  225. }
  226. .right_2 {
  227. display: flex;
  228. align-items: center;
  229. margin: 0 5px;
  230. span {
  231. margin: 0 0 0 5px;
  232. }
  233. }
  234. }
  235. }
  236. .header_2 {
  237. .list {
  238. display: flex;
  239. justify-content: space-around;
  240. .text {
  241. text-align: center;
  242. padding: 0 10px;
  243. height: 58px;
  244. line-height: 58px;
  245. font-family: Microsoft YaHei;
  246. font-size: $global-font-size-24;
  247. color: #333333;
  248. cursor: pointer; /* 改变鼠标样式为手形 */
  249. }
  250. }
  251. .info {
  252. display: none;
  253. .info_1 {
  254. position: absolute;
  255. left: 0;
  256. top: 128px;
  257. display: flex;
  258. padding: 10px 0;
  259. background: $global-color-107;
  260. width: 700px;
  261. .list_1 {
  262. margin: 0 10px 0 0;
  263. .title {
  264. margin: 5px 0;
  265. font-size: $global-font-size-20;
  266. font-weight: 600;
  267. text-align: center;
  268. color: #fff;
  269. cursor: pointer; /* 改变鼠标样式为手形 */
  270. }
  271. .list_1_1 {
  272. display: flex;
  273. flex-wrap: wrap;
  274. justify-content: center;
  275. margin: 5px 0;
  276. .title1 {
  277. width: 120px;
  278. margin: 5px;
  279. padding: 5px;
  280. text-align: center;
  281. color: #ffffff;
  282. font-size: $global-font-size-18;
  283. cursor: pointer; /* 改变鼠标样式为手形 */
  284. }
  285. }
  286. }
  287. }
  288. .info_2 {
  289. position: absolute;
  290. left: 68.1%;
  291. top: 128px;
  292. display: flex;
  293. padding: 10px 0;
  294. background: $global-color-107;
  295. width: 145px;
  296. .list_2 {
  297. display: flex;
  298. flex-direction: column;
  299. align-items: center;
  300. margin: 5px 0;
  301. .title1 {
  302. width: 110px;
  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. }
  314. }
  315. .header:hover {
  316. .header_2 {
  317. .info {
  318. display: block !important;
  319. }
  320. }
  321. }
  322. .main {
  323. min-height: 62vh;
  324. }
  325. .footer {
  326. padding: 0 5px 10px 5px;
  327. background-color: $global-color-2D2;
  328. color: $global-color-fff;
  329. font-size: $global-font-size-18;
  330. .footer_1 {
  331. padding: 10px 0;
  332. display: flex;
  333. justify-content: space-between;
  334. border-bottom: 1px solid $global-color-bbb;
  335. .left {
  336. .image {
  337. width: 393px;
  338. height: 70px;
  339. }
  340. .title {
  341. margin: 5px 0 0 0;
  342. }
  343. }
  344. .right {
  345. text-align: center;
  346. .image {
  347. width: 130px;
  348. height: 130px;
  349. }
  350. .title {
  351. margin: 5px 0 0 0;
  352. }
  353. }
  354. }
  355. .footer_2 {
  356. padding: 10px 0 0 0;
  357. }
  358. }
  359. }
  360. @media screen and (max-width: 1280px) {
  361. #c-layout {
  362. min-width: 1920px;
  363. margin: 0 auto;
  364. }
  365. }
  366. @media screen and (min-width: 1921px) {
  367. #c-layout {
  368. max-width: 1920px;
  369. margin: 0 auto;
  370. }
  371. }
  372. </style>