index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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 @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="toCenter">我的收藏</el-dropdown-item>
  61. <el-dropdown-item @click="toCenter">个人中心</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="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="code" fit="fill" />
  106. <el-image class="image" :src="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. import code from '@/assets/code.png'
  127. import unit from '@/assets/unit.png'
  128. // 请求
  129. onMounted(async () => {
  130. await search()
  131. })
  132. const search = async () => {
  133. const res = await store.query({ is_use: '0' })
  134. if (res.errcode == '0' && res.total > 0) data.value = res.data
  135. else data.value = menuList
  136. }
  137. const selectMenu = (item) => {
  138. current.value = item
  139. router.push({ path: `/${item}` })
  140. }
  141. // 登录|注册
  142. const toLogin = (status) => {
  143. if (status === 1) router.push({ path: '/login' })
  144. else router.push({ path: '/register' })
  145. }
  146. // 帮助中心
  147. const toHelp = (type) => {
  148. router.push({ path: '/help', query: { type } })
  149. }
  150. // 打开管理端
  151. const toOpen = async () => {
  152. window.location.href = import.meta.env.VITE_APP_HOME
  153. }
  154. // 个人中心
  155. const toCenter = () => {
  156. router.push('/center')
  157. }
  158. // 基础跳转
  159. const toCommon = (type) => {
  160. if (type == '0') router.push('/search')
  161. else router.push('/chat')
  162. }
  163. // 发布
  164. const toRelease = (type) => {
  165. router.push({ path: '/release', query: { type } })
  166. }
  167. // 退出登录
  168. const toLogout = () => {
  169. userStore.logOut()
  170. router.push('/login')
  171. }
  172. watch(
  173. route,
  174. (newVal) => {
  175. if (newVal && newVal.name) selectMenu(newVal.name)
  176. },
  177. {
  178. immediate: true //初始化立即执行
  179. }
  180. )
  181. // provide
  182. provide('selectMenu', selectMenu)
  183. </script>
  184. <style scoped lang="scss">
  185. .common-layout {
  186. height: 100%;
  187. width: 100%;
  188. .top {
  189. position: sticky;
  190. top: 0;
  191. z-index: 100;
  192. padding: 10px 80px;
  193. background: #ffffff;
  194. .current {
  195. border-bottom: 2px solid #409eff;
  196. background-color: #ecf5ff;
  197. :deep(.el-sub-menu__title) {
  198. color: #409eff !important;
  199. }
  200. }
  201. .top_1 {
  202. display: flex;
  203. align-items: center;
  204. .image {
  205. height: 45px;
  206. width: 45px;
  207. margin: 0 5px 0 0;
  208. }
  209. .content {
  210. margin: 0 0 0 5px;
  211. .title {
  212. margin: 0 0 5px 0;
  213. font-size: 23px;
  214. font-weight: bold;
  215. }
  216. .english {
  217. margin: 0 0 0 5px;
  218. font-size: 12px;
  219. opacity: 0.8;
  220. color: #1c66e7;
  221. }
  222. }
  223. }
  224. :deep(.ant-tabs-nav) {
  225. margin: 0 !important;
  226. }
  227. :deep(.ant-tabs-nav::before) {
  228. border: 0 !important;
  229. }
  230. :deep(.el-menu) {
  231. border: none !important;
  232. }
  233. .top_3 {
  234. display: flex;
  235. justify-content: space-between;
  236. .example-showcase .el-dropdown-link {
  237. cursor: pointer;
  238. color: #1c66e7;
  239. display: flex;
  240. align-items: center;
  241. }
  242. }
  243. }
  244. .center {
  245. min-height: 77.3vh;
  246. }
  247. .bottom {
  248. width: 100%;
  249. padding: 7px 0;
  250. font-size: 14px;
  251. background-color: #2e3546;
  252. color: #f0f2f5;
  253. font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
  254. 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
  255. 'Noto Color Emoji';
  256. font-variant: tabular-nums;
  257. line-height: 1.5715;
  258. font-feature-settings: 'tnum', 'tnum';
  259. .image {
  260. width: 78px;
  261. height: 78px;
  262. }
  263. .footTitle {
  264. margin: 5px 0 0 0;
  265. .footSpan {
  266. margin-bottom: 3px;
  267. }
  268. }
  269. .footTop {
  270. font-size: 18px;
  271. margin-bottom: 12px;
  272. }
  273. }
  274. .footflex {
  275. display: flex;
  276. align-items: center;
  277. justify-content: space-evenly;
  278. }
  279. .footflex1 {
  280. display: flex;
  281. align-items: center;
  282. justify-content: space-between;
  283. }
  284. }
  285. </style>