index.vue 9.0 KB

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