添加搜素
parent
85f3152457
commit
8aa78e6e1d
@ -0,0 +1,7 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function search(query) {
|
||||
return request({
|
||||
url: '/portal/search', method: 'get', params: query
|
||||
})
|
||||
}
|
||||
@ -0,0 +1,149 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="searchBtn">
|
||||
<el-button @click="dialogVisible = true" size="small" icon="el-icon-search" circle></el-button>
|
||||
</div>
|
||||
<el-dialog top="5vh" width="80%" :append-to-body="true" title="搜索" :visible.sync="dialogVisible">
|
||||
<el-input @keyup.enter.native="onSubmit" style="width: 100%" v-model="form.keyword" placeholder="搜索内容">
|
||||
<i slot="suffix" class="el-input__icon el-icon-search" @click="onSubmit"></i>
|
||||
</el-input>
|
||||
<div style="width: 100%;text-align: center;font-size: 1.4vw;line-height: 3vw;font-weight: 600">{{
|
||||
list.length || 0
|
||||
}}个相关结果
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="classify" v-if="list.length > 0">
|
||||
<div class="classifyName">
|
||||
行业方案
|
||||
</div>
|
||||
<div class="item" v-for="i in list" @click="toLink(i.link)">
|
||||
<div class="itemTitle" v-html="i.snippet">
|
||||
</div>
|
||||
<div class="itemText">
|
||||
{{ i.title }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="classify" v-if="list1.length > 0">
|
||||
<div class="classifyName">
|
||||
产品中心
|
||||
</div>
|
||||
<div class="item" v-for="i in list1" @click="toLink1(i.link)">
|
||||
<div class="itemTitle" v-html="i.snippet">
|
||||
</div>
|
||||
<div class="itemText">
|
||||
{{ i.title }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import {search} from '@/api/search'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
form: {},
|
||||
list: [],
|
||||
list1: [],
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onSubmit() {
|
||||
search(this.form).then(res => {
|
||||
this.list = []
|
||||
this.list1 = []
|
||||
res.data?.rows?.forEach(e => {
|
||||
if (e.sourceType === 'web1') {
|
||||
this.list1.push({
|
||||
snippet: e.snippet,
|
||||
title: e.title,
|
||||
link: e.title.split('详情#')?.[1]?.split('-')
|
||||
})
|
||||
}
|
||||
if (e.sourceType === 'web') {
|
||||
this.list.push({
|
||||
snippet: e.snippet,
|
||||
title: e.title,
|
||||
link: e.routeQuery?.id
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
toLink(e) {
|
||||
this.$router.push(`/test?id=${e}`)
|
||||
this.dialogVisible = false
|
||||
},
|
||||
toLink1(e) {
|
||||
this.$router.push(`/productCenter/detail?type=${e[0]}&typeId=${e[1]}&id=${e[2]}`)
|
||||
this.dialogVisible = false
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style scoped lang="less">
|
||||
.searchBtn {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
right: 20px;
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
|
||||
.container {
|
||||
width: calc(100% - 40px);
|
||||
background-color: #0001;
|
||||
height: calc(80vh - 125px - 3vw);
|
||||
padding: 0 20px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
em {
|
||||
color: red;
|
||||
background: yellow;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
.classify {
|
||||
position: relative;
|
||||
|
||||
.classifyName {
|
||||
background-color: #eee;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
color: #42b983;
|
||||
font-size: 1.2vw;
|
||||
line-height: 4vw;
|
||||
}
|
||||
|
||||
.item {
|
||||
width: 100%;
|
||||
background-color: #fff;
|
||||
border-bottom: 1px solid #ddd;
|
||||
cursor: pointer;
|
||||
|
||||
.itemTitle {
|
||||
line-height: 3vw;
|
||||
font-size: 1vw;
|
||||
font-weight: bold;
|
||||
|
||||
/deep/ em {
|
||||
color: #42b983;
|
||||
font-style: normal;
|
||||
}
|
||||
}
|
||||
|
||||
.itemText {
|
||||
width: 100%;
|
||||
font-size: 0.8vw;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -1,139 +0,0 @@
|
||||
<template>
|
||||
<div class="card">
|
||||
<div class="card-title">
|
||||
<i class="fas fa-users"></i>
|
||||
推荐好友
|
||||
</div>
|
||||
<div class="contact-list">
|
||||
<div class="contact-item" v-for="contact in contacts" :key="contact.id">
|
||||
<div class="avatar">{{ contact.avatar }}</div>
|
||||
<div class="contact-info">
|
||||
<div class="contact-name">{{ contact.name }}</div>
|
||||
<div class="contact-id">微信号: {{ contact.wechatId }}</div>
|
||||
</div>
|
||||
<button class="add-btn" @click="$emit('add-contact', contact)" :disabled="contact.adding">
|
||||
<span class="loading" v-if="contact.adding"></span>
|
||||
{{ contact.adding ? '添加中...' : '添加' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'ContactList',
|
||||
props: {
|
||||
contacts: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.card {
|
||||
background: #1f1f1f;
|
||||
border-radius: 10px;
|
||||
padding: 20px;
|
||||
margin-bottom: 20px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.card-title {
|
||||
font-size: 18px;
|
||||
margin-bottom: 15px;
|
||||
color: #07C160;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.card-title i {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.contact-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.contact-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 15px;
|
||||
background: #333;
|
||||
border-radius: 8px;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
.contact-item:hover {
|
||||
transform: translateY(-2px);
|
||||
background: #3a3a3a;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
border-radius: 50%;
|
||||
background: #07C160;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-right: 15px;
|
||||
color: white;
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.contact-info {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.contact-name {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.contact-id {
|
||||
font-size: 14px;
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
.add-btn {
|
||||
background: #07C160;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 8px 15px;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-weight: 600;
|
||||
transition: background 0.3s;
|
||||
}
|
||||
|
||||
.add-btn:hover {
|
||||
background: #06ae56;
|
||||
}
|
||||
|
||||
.add-btn:disabled {
|
||||
background: #555;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.loading {
|
||||
display: inline-block;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border: 3px solid rgba(255,255,255,.3);
|
||||
border-radius: 50%;
|
||||
border-top-color: #fff;
|
||||
animation: spin 1s ease-in-out infinite;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
</style>
|
||||
@ -1,116 +0,0 @@
|
||||
<template>
|
||||
<div class="card">
|
||||
<div class="card-title">
|
||||
<i class="fas fa-search"></i>
|
||||
搜索添加好友
|
||||
</div>
|
||||
<div class="search-box">
|
||||
<input
|
||||
type="text"
|
||||
class="search-input"
|
||||
:value="value"
|
||||
@input="$emit('input', $event.target.value)"
|
||||
placeholder="请输入微信号、手机号或昵称"
|
||||
@keyup.enter="$emit('search')"
|
||||
>
|
||||
<button class="search-btn" @click="$emit('search')" :disabled="searching">
|
||||
<span class="loading" v-if="searching"></span>
|
||||
{{ searching ? '搜索中...' : '搜索' }}
|
||||
</button>
|
||||
</div>
|
||||
<p>通过微信号、手机号或昵称搜索添加好友</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'SearchBox',
|
||||
props: {
|
||||
value: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
searching: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.card {
|
||||
background: #1f1f1f;
|
||||
border-radius: 10px;
|
||||
padding: 20px;
|
||||
margin-bottom: 20px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.card-title {
|
||||
font-size: 18px;
|
||||
margin-bottom: 15px;
|
||||
color: #07C160;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.card-title i {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.search-box {
|
||||
display: flex;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
flex: 1;
|
||||
padding: 12px 15px;
|
||||
background: #333;
|
||||
border: 1px solid #444;
|
||||
border-radius: 8px 0 0 8px;
|
||||
color: #e0e0e0;
|
||||
font-size: 16px;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.search-input:focus {
|
||||
border-color: #07C160;
|
||||
}
|
||||
|
||||
.search-btn {
|
||||
background: #07C160;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 0 20px;
|
||||
border-radius: 0 8px 8px 0;
|
||||
cursor: pointer;
|
||||
font-weight: 600;
|
||||
transition: background 0.3s;
|
||||
}
|
||||
|
||||
.search-btn:hover {
|
||||
background: #06ae56;
|
||||
}
|
||||
|
||||
.search-btn:disabled {
|
||||
background: #555;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.loading {
|
||||
display: inline-block;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border: 3px solid rgba(255,255,255,.3);
|
||||
border-radius: 50%;
|
||||
border-top-color: #fff;
|
||||
animation: spin 1s ease-in-out infinite;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
</style>
|
||||
@ -1,46 +0,0 @@
|
||||
<template>
|
||||
<div class="status-message" :class="type">
|
||||
{{ message }}
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'StatusMessage',
|
||||
props: {
|
||||
message: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
default: 'info',
|
||||
validator: (value) => ['success', 'error', 'info'].includes(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.status-message {
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
margin-top: 10px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.success {
|
||||
background: #d4edda;
|
||||
color: #155724;
|
||||
}
|
||||
|
||||
.error {
|
||||
background: #f8d7da;
|
||||
color: #721c24;
|
||||
}
|
||||
|
||||
.info {
|
||||
background: #cce7ff;
|
||||
color: #004085;
|
||||
}
|
||||
</style>
|
||||
@ -1,16 +1,18 @@
|
||||
const {defineConfig} = require('@vue/cli-service')
|
||||
module.exports = defineConfig({
|
||||
transpileDependencies: true, runtimeCompiler: true,
|
||||
transpileDependencies: true, runtimeCompiler: true,
|
||||
|
||||
devServer: {
|
||||
host: "0.0.0.0", port: 8899, open: true, https: false, proxy: {
|
||||
// detail: https://cli.vuejs.org/config/#devserver-proxy
|
||||
'/dev-api': {
|
||||
// target: `http://175.27.215.92:8899/prod-api`,
|
||||
target: `http://1.13.177.47:8899/prod-api`, changeOrigin: true, pathRewrite: {
|
||||
["^" + '/dev-api']: "",
|
||||
devServer: {
|
||||
host: "0.0.0.0", port: 8899, open: true, https: false, proxy: {
|
||||
// detail: https://cli.vuejs.org/config/#devserver-proxy
|
||||
'/prod-api': {
|
||||
// target: `http://175.27.215.92:8899/prod-api`,
|
||||
target: `http://192.168.137.1:9081`,
|
||||
// target: `http://1.13.177.47:8899/prod-api`,
|
||||
changeOrigin: true, pathRewrite: {
|
||||
["^" + '/prod-api']: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
Loading…
Reference in New Issue