index.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. <template>
  2. <div class="common-layout">
  3. <div class="top">
  4. <el-row :gutter="20" align="middle">
  5. <el-col :span="6" class="top_1">
  6. <el-image class="image" :src="siteInfo.logoUrl" fit="fill" />
  7. <div class="content">
  8. <text class="title">{{ siteInfo.zhTitle }}</text>
  9. <!-- <text class="english">{{ siteInfo.zhBrief }}</text> -->
  10. </div>
  11. </el-col>
  12. <el-col :span="14">
  13. <el-menu :default-active="current" mode="horizontal" @select="selectMenu">
  14. <template v-for="item in data" :key="item._id">
  15. <template v-if="item.type === '0'">
  16. <el-sub-menu :index="item._id" :class="[current == item.href ? 'current' : '']">
  17. <template #title>
  18. <span @click="selectMenu(item.href)">{{ item.title }}</span>
  19. </template>
  20. <el-menu-item v-for="tag in item.children" :key="tag._id" :index="tag.href">{{
  21. tag.title
  22. }}</el-menu-item>
  23. </el-sub-menu>
  24. </template>
  25. <template v-else-if="item.type === '1'">
  26. <el-menu-item :index="item.href"> {{ item.title }}</el-menu-item>
  27. </template>
  28. </template>
  29. </el-menu>
  30. </el-col>
  31. <el-col :span="4">
  32. <el-row :gutter="20">
  33. <el-col :span="6" class="top_2">
  34. <el-button :icon="Search" size="small" @click="toCommon(0)">搜索</el-button>
  35. </el-col>
  36. <el-col :span="6" class="top_2">
  37. <el-dropdown>
  38. <el-button size="small" :icon="Edit">发布</el-button>
  39. <template #dropdown>
  40. <el-dropdown-menu>
  41. <el-dropdown-item>发布需求</el-dropdown-item>
  42. <el-dropdown-item>发布成果</el-dropdown-item>
  43. <el-dropdown-item>发布项目</el-dropdown-item>
  44. </el-dropdown-menu>
  45. </template>
  46. </el-dropdown>
  47. </el-col>
  48. <el-col :span="6" class="top_2" v-if="user && user._id">
  49. <el-button :icon="Bell" size="small" @click="toCommon(1)">消息</el-button>
  50. </el-col>
  51. <el-col :span="6" v-if="user && user._id" class="top_3">
  52. <el-dropdown>
  53. <el-button size="small" :icon="User" type="primary">
  54. {{ user.nick_name || '游客' }}
  55. </el-button>
  56. <template #dropdown>
  57. <el-dropdown-menu>
  58. <el-dropdown-item @click="toOpen">管理中心</el-dropdown-item>
  59. <el-dropdown-item @click="toCenter">我的收藏</el-dropdown-item>
  60. <el-dropdown-item @click="toCenter">个人中心</el-dropdown-item>
  61. <el-dropdown-item @click="toLogout">注销</el-dropdown-item>
  62. </el-dropdown-menu>
  63. </template>
  64. </el-dropdown>
  65. </el-col>
  66. <el-col :span="10" v-else class="top_3">
  67. <el-button @click="toLogin(1)" type="primary" size="small">登录</el-button>
  68. <el-button @click="toLogin(2)" type="primary" size="small">注册</el-button>
  69. </el-col>
  70. </el-row>
  71. </el-col>
  72. </el-row>
  73. </div>
  74. <div class="center">
  75. <el-col :span="24" class="container">
  76. <router-view :style="viewStyle"></router-view>
  77. </el-col>
  78. </div>
  79. <div class="bottom">
  80. <div class="w_1200 footflex">
  81. <el-image class="image" :src="unit" fit="fill" />
  82. <el-col :span="12" class="foot_1">
  83. <div class="footTitle">
  84. <span>业务洽谈:{{ footInfo.Phone }}</span>
  85. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  86. <span>企业邮箱:{{ footInfo.Email }}</span>
  87. </div>
  88. <div class="footTitle">地 址:{{ footInfo.Address }}</div>
  89. <div class="footTitle">版权所有:{{ footInfo.Copyright }}</div>
  90. <div class="footTitle">技术支持:{{ footInfo.Company }}</div>
  91. </el-col>
  92. <el-col :span="3" class="foot_2">
  93. <div class="footTop">关于我们</div>
  94. <div class="footTitle footflex1">
  95. <span class="footSpan" @click="toHelp('1')">关于我们</span>
  96. <span class="footSpan" @click="toHelp('2')">意见反馈</span>
  97. </div>
  98. <div class="footTitle footflex1">
  99. <span class="footSpan" @click="toHelp('3')">联系我们</span>
  100. <span class="footSpan" @click="toHelp('4')">法律条款</span>
  101. </div>
  102. </el-col>
  103. <el-col :span="4" class="foot_3 footflex">
  104. <el-image class="image" :src="code" fit="fill" />
  105. <el-image class="image" :src="code" fit="fill" />
  106. </el-col>
  107. </div>
  108. </div>
  109. </div>
  110. </template>
  111. <script setup>
  112. import { siteInfo, footInfo, menuList } from '@/layout/site'
  113. import { Search, Edit, User, Bell } from '@element-plus/icons-vue'
  114. // 接口
  115. import { TagsStore } from '@/store/api/system/tags'
  116. const store = TagsStore()
  117. const router = useRouter()
  118. const route = useRoute()
  119. const current = ref(route.name || 'home')
  120. import { UserStore } from '@/store/user'
  121. const userStore = UserStore()
  122. const user = computed(() => userStore.user)
  123. const data = ref([])
  124. // 图片引入
  125. import code from '@/assets/code.png'
  126. import unit from '@/assets/unit.png'
  127. // 请求
  128. onMounted(async () => {
  129. await search()
  130. })
  131. const search = async () => {
  132. const res = await store.query({ is_use: '0' })
  133. if (res.errcode == '0' && res.total > 0) data.value = res.data
  134. else data.value = menuList
  135. }
  136. const selectMenu = (item) => {
  137. current.value = item
  138. router.push({ path: `/${item}` })
  139. }
  140. // 登录|注册
  141. const toLogin = (status) => {
  142. if (status === 1) router.push({ path: '/login' })
  143. else router.push({ path: '/register' })
  144. }
  145. // 帮助中心
  146. const toHelp = (type) => {
  147. router.push({ path: '/help', query: { type } })
  148. }
  149. // 打开管理端
  150. const toOpen = async () => {
  151. window.location.href = import.meta.env.VITE_APP_HOME
  152. }
  153. // 个人中心
  154. const toCenter = () => {
  155. router.push('/center')
  156. }
  157. // 聊天记录
  158. const toCommon = (type) => {
  159. if (type == '0') router.push('/search')
  160. else router.push('/chat')
  161. }
  162. // 聊天记录
  163. const toChat = () => {
  164. router.push('/chat')
  165. }
  166. // 退出登录
  167. const toLogout = () => {
  168. userStore.logOut()
  169. router.push('/login')
  170. }
  171. // provide
  172. provide('selectMenu', selectMenu)
  173. </script>
  174. <style scoped lang="scss">
  175. .common-layout {
  176. height: 100%;
  177. width: 100%;
  178. .top {
  179. position: sticky;
  180. top: 0;
  181. z-index: 100;
  182. padding: 10px 80px;
  183. background: #ffffff;
  184. .current {
  185. border-bottom: 2px solid #409eff;
  186. background-color: #ecf5ff;
  187. :deep(.el-sub-menu__title) {
  188. color: #409eff !important;
  189. }
  190. }
  191. .top_1 {
  192. display: flex;
  193. align-items: center;
  194. .image {
  195. height: 45px;
  196. width: 45px;
  197. margin: 0 5px 0 0;
  198. }
  199. .content {
  200. margin: 0 0 0 5px;
  201. .title {
  202. margin: 0 0 5px 0;
  203. font-size: 23px;
  204. font-weight: bold;
  205. }
  206. .english {
  207. margin: 0 0 0 5px;
  208. font-size: 12px;
  209. opacity: 0.8;
  210. color: #1c66e7;
  211. }
  212. }
  213. }
  214. :deep(.ant-tabs-nav) {
  215. margin: 0 !important;
  216. }
  217. :deep(.ant-tabs-nav::before) {
  218. border: 0 !important;
  219. }
  220. :deep(.el-menu) {
  221. border: none !important;
  222. }
  223. .top_3 {
  224. display: flex;
  225. justify-content: space-between;
  226. .example-showcase .el-dropdown-link {
  227. cursor: pointer;
  228. color: #1c66e7;
  229. display: flex;
  230. align-items: center;
  231. }
  232. }
  233. }
  234. .center {
  235. min-height: 77.3vh;
  236. }
  237. .bottom {
  238. width: 100%;
  239. padding: 7px 0;
  240. font-size: 14px;
  241. background-color: #2e3546;
  242. color: #f0f2f5;
  243. font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
  244. 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
  245. 'Noto Color Emoji';
  246. font-variant: tabular-nums;
  247. line-height: 1.5715;
  248. font-feature-settings: 'tnum', 'tnum';
  249. .image {
  250. width: 78px;
  251. height: 78px;
  252. }
  253. .footTitle {
  254. margin: 5px 0 0 0;
  255. .footSpan {
  256. margin-bottom: 3px;
  257. }
  258. }
  259. .footTop {
  260. font-size: 18px;
  261. margin-bottom: 12px;
  262. }
  263. }
  264. .footflex {
  265. display: flex;
  266. align-items: center;
  267. justify-content: space-evenly;
  268. }
  269. .footflex1 {
  270. display: flex;
  271. align-items: center;
  272. justify-content: space-between;
  273. }
  274. }
  275. </style>