From 9ddad348a549154e7b328f9d7dd9517d2abd330c Mon Sep 17 00:00:00 2001
From: PC-20250623MANY\Administrator <344137771@qq.com>
Date: Tue, 30 Sep 2025 09:47:25 +0800
Subject: [PATCH] 1
---
src/components/tabHead.vue | 140 ++++++++++++++++++++++++++++++++--------------
1 files changed, 96 insertions(+), 44 deletions(-)
diff --git a/src/components/tabHead.vue b/src/components/tabHead.vue
index 70e6750..27df46a 100644
--- a/src/components/tabHead.vue
+++ b/src/components/tabHead.vue
@@ -1,7 +1,10 @@
<template>
<div class="tab_head">
- <div class="icon" @click="searchShow = true">
- <van-icon name="search" size=".5em" />
+ <div class="head_left flex-center">
+ <div class="icon" @click="searchShow = true" v-if="leftShow" style="margin-right:.2666rem;">
+ <van-icon name="search" size=".5em" />
+ </div>
+ <slot name="left"></slot>
</div>
<div class="head_right">
<div class="icon" v-if="rightShow" @click="aRouter1">
@@ -13,18 +16,35 @@
<slot></slot>
</div>
<!-- 搜索弹窗 -->
- <van-popup v-model="searchShow" round position="bottom" :style="{ height: '80%' }">
+ <van-popup
+ v-model="searchShow"
+ round
+ position="bottom"
+ :style="{ height: '80%' }"
+ >
<div class="popup_head">
<van-icon name="arrow-left" size=".5em" @click="searchShow = false" />
<div class="popup_input">
- <van-field v-model="searchValue" :placeholder="$t('hj37')" left-icon="search" clearable />
+ <van-field
+ v-model="searchValue"
+ :placeholder="$t('hj37')"
+ left-icon="search"
+ clearable
+ />
</div>
- <van-button type="primary" round @click="submit">{{ $t("Search") }}</van-button>
+ <van-button type="primary" round @click="submit">{{
+ $t("Search")
+ }}</van-button>
</div>
- <van-list v-model="loading" :finished="finished" :finished-text="$t('hj43')" @load="onLoad"
- v-if="(lists && lists.length > 0) || !finished">
- <van-cell v-for="item in lists" :key="item.id">
+ <van-list
+ v-model="loading"
+ :finished="finished"
+ :finished-text="$t('hj43')"
+ @load="onLoad"
+ v-if="(lists && lists.length > 0) || !finished"
+ >
+ <van-cell v-for="item in lists" :key="item.id" @click="toDetails(item)">
<div class="search_item">
<div class="search_item_left">
<div class="search_item_left_name">{{ item.name }}</div>
@@ -52,40 +72,50 @@
<script>
import * as api from "@/axios/api";
import handleDt from "@/utils/deTh";
+import { Toast } from "vant";
export default {
name: "tabHead",
data() {
return {
searchShow: false, // 搜索弹窗
- searchValue: '', // 搜索内容
+ searchValue: "", // 搜索内容
lists: [], // 搜索列表
loading: false, // 是否加载
finished: true, // 是否加载完成
pageNum: 1,
- pageSize: 20,
+ pageSize: 20
};
},
props: {
- rightShow: { // 是否显示客服和设置图标
+ // 是否显示客服和设置图标
+ rightShow: {
+ type: Boolean,
+ default: true
+ },
+ // 是否显示左侧搜索
+ leftShow: {
type: Boolean,
default: true
}
},
watch: {
searchShow() {
- this.searchValue = ''
- this.init()
+ this.searchValue = "";
+ this.init();
}
},
async mounted() {
- this.init()
+ this.init();
this.getInfoSite();
},
methods: {
- aRouter1() { // 跳转客服页面
- window.open(this.onlineService);
+ // 跳转客服页面
+ aRouter1() {
+ // window.open(this.onlineService);
+ Toast(this.$t("kf1"));
},
- async getInfoSite() { // 获取客服地址
+ // 获取客服地址
+ async getInfoSite() {
let data = await api.getInfoSite();
if (data.status === 0) {
this.onlineService = data.data.onlineService;
@@ -93,48 +123,70 @@
} else {
this.$store.commit("elAlertShow", {
elAlertShow: true,
- elAlertText: data.msg,
+ elAlertText: data.msg
});
}
},
- goToTopUp() { // 跳转设置页面
+ goToTopUp() {
+ // 跳转设置页面
this.$router.push("/setting");
},
- onLoad: handleDt.throttle(async function (a, b) { // 搜索列表加载
+ onLoad: handleDt.throttle(async function(a, b) {
+ // 搜索列表加载
this.finished = false;
let opt = {
pageNum: this.pageNum,
pageSize: this.pageSize,
stockPlate: "",
keyWords: this.searchValue,
- stockType: '',
- orderBy: "",
- }
+ stockType: "",
+ orderBy: ""
+ };
let data = await api.getStockByType(opt);
this.loading = false; // 加载状态结束
if (data.status === 0 && data.data.list) {
this.lists = [...this.lists, ...data.data.list];
+ } else if (data.status != 0) {
+ this.finished = true;
}
- if (data.data.list && data.data.list.length <= 0) { // 数据全部加载完成
+ if (data.data.list && data.data.list.length <= 0) {
+ // 数据全部加载完成
this.finished = true;
-
} else {
this.pageNum++;
}
}, 500),
- init() { // 初始化
+ init() {
+ // 初始化
this.pageNum = 1;
this.lists = [];
this.finished = true;
},
- submit() { // 提交搜索
- this.init()
- this.onLoad()
+ submit() {
+ // 提交搜索
+ this.init();
+ this.onLoad();
+ },
+ // 点击进入详情
+ toDetails(item) {
+ const obj = {
+ pid: item.code || "",
+ type: item.stock_type || ""
+ };
+ window.localStorage.setItem("kLine", JSON.stringify(obj));
+
+ this.$router.push({
+ path: "/kline",
+ query: {
+ code: item.code,
+ type: item.stock_type
+ }
+ });
}
- },
+ }
};
</script>
@@ -144,7 +196,7 @@
.tab_head {
font-size: 10vw;
- padding: .266em;
+ padding: 0.266em;
display: flex;
justify-content: space-between;
align-items: center;
@@ -154,7 +206,7 @@
display: flex;
justify-content: center;
align-items: center;
- padding-top: .5em;
+ padding-top: 0.5em;
img {
width: 65%;
@@ -166,22 +218,22 @@
justify-content: center;
align-items: center;
font-size: 1.5em;
- padding: .5em 0;
+ padding: 0.5em 0;
.search_item_left {
flex: 1;
.search_item_left_hint {
- margin-top: .3em;
+ margin-top: 0.3em;
color: #969799;
- font-size: .8em;
+ font-size: 0.8em;
span {
border-radius: 0 26em 26em 0;
background: @dark_green;
color: #fff;
- padding: 0 .3em;
- margin-right: .1em;
+ padding: 0 0.3em;
+ margin-right: 0.1em;
}
}
}
@@ -193,7 +245,7 @@
color: #969799;
span {
- margin-right: .5em;
+ margin-right: 0.5em;
}
}
}
@@ -202,7 +254,7 @@
display: flex;
justify-content: center;
align-items: center;
- padding: .25em;
+ padding: 0.25em;
/deep/ .van-cell {
background: none;
@@ -222,11 +274,11 @@
@inpH: 1em;
height: @inpH;
flex: 1;
- border-radius: @inpH/2;
+ border-radius: @inpH / 2;
display: flex;
align-items: center;
- margin-left: .5em;
- margin-right: .5em
+ margin-left: 0.5em;
+ margin-right: 0.5em;
}
}
@@ -237,7 +289,7 @@
background: @grey;
display: flex;
justify-content: center;
- align-items: center
+ align-items: center;
}
.head_right {
@@ -247,7 +299,7 @@
.head_right {
.icon {
- margin-left: .266em;
+ margin-left: 0.266em;
}
}
}
--
Gitblit v1.9.3