index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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">搜索</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">消息</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 toLogout = () => {
  159. userStore.logOut()
  160. router.push('/login')
  161. }
  162. // provide
  163. provide('selectMenu', selectMenu)
  164. </script>
  165. <style scoped lang="scss">
  166. .common-layout {
  167. height: 100%;
  168. width: 100%;
  169. .top {
  170. position: sticky;
  171. top: 0;
  172. z-index: 100;
  173. padding: 10px 80px;
  174. background: #ffffff;
  175. .current {
  176. border-bottom: 2px solid #409eff;
  177. color: #409eff !important;
  178. }
  179. .top_1 {
  180. display: flex;
  181. align-items: center;
  182. .image {
  183. height: 45px;
  184. width: 45px;
  185. margin: 0 5px 0 0;
  186. }
  187. .content {
  188. margin: 0 0 0 5px;
  189. .title {
  190. margin: 0 0 5px 0;
  191. font-size: 23px;
  192. font-weight: bold;
  193. }
  194. .english {
  195. margin: 0 0 0 5px;
  196. font-size: 12px;
  197. opacity: 0.8;
  198. color: #1c66e7;
  199. }
  200. }
  201. }
  202. :deep(.ant-tabs-nav) {
  203. margin: 0 !important;
  204. }
  205. :deep(.ant-tabs-nav::before) {
  206. border: 0 !important;
  207. }
  208. :deep(.el-menu) {
  209. border: none !important;
  210. }
  211. .top_3 {
  212. display: flex;
  213. justify-content: space-between;
  214. .example-showcase .el-dropdown-link {
  215. cursor: pointer;
  216. color: #1c66e7;
  217. display: flex;
  218. align-items: center;
  219. }
  220. }
  221. }
  222. .center {
  223. min-height: 77.3vh;
  224. }
  225. .bottom {
  226. width: 100%;
  227. padding: 7px 0;
  228. font-size: 14px;
  229. background-color: #2e3546;
  230. color: #f0f2f5;
  231. font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
  232. 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
  233. 'Noto Color Emoji';
  234. font-variant: tabular-nums;
  235. line-height: 1.5715;
  236. font-feature-settings: 'tnum', 'tnum';
  237. .image {
  238. width: 78px;
  239. height: 78px;
  240. }
  241. .footTitle {
  242. margin: 5px 0 0 0;
  243. .footSpan {
  244. margin-bottom: 3px;
  245. }
  246. }
  247. .footTop {
  248. font-size: 18px;
  249. margin-bottom: 12px;
  250. }
  251. }
  252. .footflex {
  253. display: flex;
  254. align-items: center;
  255. justify-content: space-evenly;
  256. }
  257. .footflex1 {
  258. display: flex;
  259. align-items: center;
  260. justify-content: space-between;
  261. }
  262. }
  263. </style>