index.vue 10 KB

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