index.vue 8.8 KB

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