123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510 |
- <template>
- <view class="searchTarget-container container">
- <view class="searchTarget-header">
- <input
- type="text"
- placeholder="请输入产业名称或标的名称"
- placeholder-class="sea_ipt_placeholder"
- class="sea_ipt"
- v-model="searchTxt"
- focus="true"
- confirm-type="search"
- @confirm="searchHandle"
- />
- <icon type="search" size="15" class="sea_ico" />
- <view class="ipt-right">
- <icon type="clear" size="16" color="#E0E0E0" v-show="searchTxt" @click="clearIpt" />
- <text class="line">|</text>
- <text @click="searchHandle" style="color: #3385ff">搜索</text>
- </view>
- </view>
- <view class="search-cont">
- <template v-if="!isResult">
- <view class="search-cont-top" v-if="historySearchList.length">
- <view class="cont-tit">
- <text>搜索历史</text>
- <image src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/empty_ico.png" class="empty_ico" @click="clearHistory"></image>
- </view>
- <view class="targetList">
- <view class="target-item" v-for="(item, index) in historySearchList" :key="index" @click="chooseTarget(item)">{{ item }}</view>
- </view>
- </view>
- <view class="search-cont-top">
- <view class="cont-tit">
- <text>弘则推荐</text>
- </view>
- <view class="targetList">
- <view class="target-item" v-for="(item, index) in keywordList" :key="index" @click="chooseTarget(item)">{{ item }}</view>
- </view>
- </view>
- </template>
- <template v-else>
- <block v-if="haveResult">
- <view class="">
- <view class="report-ul" v-if="resultList.length > 0">
- <view class="resource">
- <image src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/zybico.jpg" mode=""></image>
- <text>弘则资源包</text>
- </view>
- <view class="report-item" v-for="(item, index) in resultList" :key="index">
- <view class="box-text" @click="goDetail(item)">
- <view class="" style="padding-left: 30rpx">
- {{ item.IndustryName }}
- </view>
- <view class="text-time">
- <text style="padding-right: 20rpx">{{ item.UpdateTime }}更新</text>
- <u-icon name="arrow-right" color="#BDBDBD" size="34"></u-icon>
- </view>
- </view>
- <view class="" v-if="item.IndustrialSubjectList.length > 6">
- <u-read-more :shadow-style="shadowStyle" close-text="展开" color="#D1D1D1" :show-height="item.IndustrialSubjectList.length > 6 ? 170 : 200" :toggle="true">
- <view class="arrow-box">
- <view @click="goDetail(item)" class="box-subject" v-for="key in item.IndustrialSubjectList" :key="key.RecommendedIndex">
- {{ key.SubjectName }}
- </view>
- </view>
- </u-read-more>
- </view>
- <view class="" v-else @click="goDetail(item)">
- <view class="arrow-box">
- <view class="box-subject" v-for="key in item.IndustrialSubjectList" :key="key.RecommendedIndex">
- {{ key.SubjectName }}
- </view>
- </view>
- </view>
- </view>
- </view>
- <view class="report-ul" v-if="indList.length > 0">
- <view class="resource industry-box">
- <image src="https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png" mode=""></image>
- <text>研选报告</text>
- </view>
- <view class="ind-item" v-for="item in indList" :key="item.ArticleId" @click="goDetailIndust(item.ArticleId)">
- <view class="">
- <text>{{ item.Title }}</text>
- <view class="time-industry">
- <text class="time">{{ item.PublishDate }}</text>
- <text>{{ item.IndustryName }}</text>
- </view>
- </view>
- <u-icon class="ico" name="arrow-right" color="#BDBDBD" size="34"></u-icon>
- </view>
- </view>
- </view>
- </block>
- <view class="nodata" v-else>
- <image src="@/static/img/nodata.png" mode="" class="nodata_ico"></image>
- <text>未找到您想搜索的内容</text>
- </view>
- </template>
- </view>
- <freeCharge class="free-charge" :isShowFreeBtn="isShowFree" />
- </view>
- </template>
- <script>
- import { Search, Reports } from "@/config/api.js";
- import { Debounce, Throttle } from "@/config/util.js";
- import freeCharge from "@/components/freeCharge";
- let app = getApp({ allowDefault: true });
- export default {
- data() {
- return {
- searchTxt: "", //搜索关键字
- isResult: false, //显示搜索结果
- haveResult: true, //是否有搜索数据
- // 历史搜索列表
- historySearchList: [],
- // 关键字列表
- keywordList: [],
- targetList: [], //所有指标列表
- // 搜索结果列表
- resultList: [],
- indList: [],
- page_no: 1,
- pageSize: 10,
- totalPage: 0,
- loadText: {
- loadmore: "上拉加载更多",
- loading: "加载中",
- nomore: "",
- },
- status: "loadmore",
- shadowStyle: {
- backgroundImage: "none",
- },
- };
- },
- watch: {
- searchTxt(newVal) {
- if (newVal.length <= 0) {
- this.isResult = false;
- }
- },
- },
- components: {
- freeCharge,
- },
- methods: {
- /* 获取关键词 */
- getKeyWord() {
- Search.getKeys().then((res) => {
- if (res.Ret === 200) {
- this.keywordList = res.Data.Item.ConfigValue ? res.Data.Item.ConfigValue.split(",") : [];
- }
- });
- },
- // 选择历史搜索
- chooseTarget(item) {
- this.searchTxt = item;
- this.SecName = item;
- this.resultList = [];
- this.indList = [];
- this.getDataList();
- },
- // 键盘输入过程中
- searchDoing() {
- this.isResult = false;
- //全部指标列表
- let arr = JSON.parse(JSON.stringify(this.targetList));
- let filterArr = [];
- // // 过滤出符合搜索条件的值
- arr.forEach((item, index) => {
- if (item.SecName.includes(this.searchTxt)) {
- item.SecName = this.join(item.SecName, this.searchTxt);
- filterArr.unshift(item);
- }
- });
- this.keywordList = filterArr;
- },
- // 拼接
- join(str, key) {
- return str.replace(new RegExp(`${key}`, "g"), `%%${key}%%`).split("%%");
- },
- // 搜索数据
- searchHandle: Debounce(function () {
- if (this.searchTxt) {
- //添加搜索记录
- if (!this.historySearchList.includes(this.searchTxt)) {
- this.historySearchList.unshift(this.searchTxt);
- this.$db.set("historySearchListReport", JSON.stringify(this.historySearchList));
- }
- this.resultList = [];
- this.indList = [];
- this.getDataList();
- } else {
- this.$util.toast("请输入关键字");
- }
- }),
- // 查找数据
- getDataList() {
- this.isResult = true;
- Reports.getIndustryAndArticle({
- KeyWord: this.searchTxt,
- }).then((res) => {
- if (res.Ret === 200) {
- this.resultList = res.Data.IndList || [];
- this.indList = res.Data.ArtList || [];
- this.haveResult = this.resultList.length > 0 || this.indList.length > 0;
- }
- });
- },
- // 点击数据列表修改数据
- itemClick(item) {
- let data = encodeURIComponent(JSON.stringify(item));
- uni.navigateTo({
- url: "/pages/recordData/recordData?data=" + data,
- });
- },
- /* 表单清空 */
- clearIpt() {
- this.searchTxt = "";
- this.isTabAct = false;
- },
- /* 历史搜索清空 */
- clearHistory() {
- this.historySearchList = [];
- this.$db.del("historySearchListReport");
- },
- /* 进入详情 校验是否有该品种权限 */
- goDetail(item) {
- uni.navigateTo({
- url: "/reportPages/IndustryReport/IndustryReport?id=" + item.IndustrialManagementId,
- });
- },
- goDetailIndust(id) {
- this.$store.dispatch("checkHandle", "/pageMy/reportDetail/reportDetail?id=" + id);
- },
- },
- onLoad(options) {
- if (options.text) {
- this.searchTxt = options.text;
- this.getDataList();
- }
- // 获取历史搜索记录
- if (this.$db.get("historySearchListReport")) {
- let historyList = JSON.parse(this.$db.get("historySearchListReport"));
- this.historySearchList = historyList;
- }
- },
- onShow() {
- this.$store.dispatch("statistics", { PageType: "ReportSearch" });
- this.getKeyWord();
- },
- /**
- * 用户点击分享
- */
- onShareAppMessage: function (res) {
- return {
- title: this.isHorzMobile ? "好友向您推荐此内容,上传名片享查研观向免费试用月卡!" : "报告",
- path: "/reportPages/reportSearch/reportSearch?text=" + this.searchTxt,
- success: (res) => {},
- fail: (err) => {},
- };
- },
- };
- </script>
- <style lang="scss">
- .searchTarget-container {
- background-color: #f6f6f6;
- padding-bottom: 30rpx;
- .report-ul {
- margin-bottom: 20rpx;
- }
- .searchTarget-header {
- padding: 0 34rpx;
- width: 100%;
- background-color: #fff;
- position: fixed;
- top: 0;
- left: 0;
- z-index: 99;
- padding: 30rpx 0;
- display: flex;
- justify-content: center;
- align-items: center;
- .sea_ipt_placeholder {
- color: #8d8d8d;
- }
- .sea_ipt {
- width: 682rpx;
- height: 70rpx;
- line-height: 70rpx;
- box-sizing: border-box;
- border: 1rpx solid #e5e5e5;
- background-color: rgba(245, 245, 245, 0.2);
- font-size: 26rpx;
- color: #4a4a4a;
- padding: 0 180rpx 0 78rpx;
- border-radius: 70rpx;
- }
- .sea_ico {
- width: 31rpx;
- height: 31rpx;
- position: absolute;
- left: 68rpx;
- top: 50%;
- transform: translateY(-50%);
- }
- .ipt-right {
- display: flex;
- align-items: center;
- position: absolute;
- right: 59rpx;
- top: 50%;
- transform: translateY(-50%);
- color: #3385ff;
- .line {
- margin: 0 21rpx;
- color: #e0e0e0;
- }
- }
- }
- .resource {
- margin-top: 4rpx;
- height: 91rpx;
- width: 100%;
- display: flex;
- align-items: center;
- justify-content: center;
- background-color: #fff;
- color: #333333;
- font-size: 30rpx;
- image {
- width: 34rpx;
- height: 36rpx;
- margin-right: 10rpx;
- }
- }
- .report-item {
- margin-top: 10rpx;
- width: 100%;
- background-color: #fff;
- .box-text {
- display: flex;
- justify-content: space-between;
- background-color: #fff;
- align-items: center;
- padding: 0 30rpx;
- height: 91rpx;
- color: #333333;
- font-size: 30rpx;
- .text-time {
- display: flex;
- color: #999999;
- font-size: 26rpx;
- }
- }
- .arrow-box {
- display: flex;
- flex-wrap: wrap;
- border-top: 3rpx solid #f6f6f6;
- padding: 30rpx 30rpx 0;
- .box-subject {
- margin-bottom: 30rpx;
- margin-left: 40rpx;
- background: url(../../static/img/report_bg.png) no-repeat;
- background-size: 100% 100%;
- width: 170rpx;
- height: 46rpx;
- color: #408fff;
- text-align: center !important;
- font-size: 24rpx;
- line-height: 46rpx;
- text-indent: 0em;
- }
- }
- }
- .industry-box {
- margin-bottom: 3rpx;
- }
- .ind-item {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 30rpx 30rpx 28rpx 58rpx;
- background-color: #fff;
- margin-bottom: 10rpx;
- .time-industry {
- display: flex;
- margin-top: 30rpx;
- font-size: 26rpx;
- color: #2c83ff;
- .time {
- color: #666666;
- margin-right: 20rpx;
- flex-shrink: 0;
- }
- }
- }
- .search-cont {
- padding-top: 130rpx;
- .search-cont-top {
- padding: 0 34rpx 0;
- margin-bottom: 10rpx;
- padding-top: 20rpx;
- &:last-child {
- margin-bottom: 0;
- }
- .cont-tit {
- color: #666;
- font-size: 28rpx;
- margin-bottom: 30rpx;
- display: flex;
- justify-content: space-between;
- .empty_ico {
- width: 32rpx;
- height: 33rpx;
- }
- }
- .targetList {
- display: flex;
- flex-wrap: wrap;
- // justify-content: space-between;
- .target-item {
- padding: 4rpx 18rpx;
- color: #4a4a4a;
- font-size: 26rpx;
- // border: 1rpx solid #3385ff;
- background-color: #f7f7f7;
- margin-bottom: 30rpx;
- margin-right: 30rpx;
- border-radius: 20rpx;
- }
- }
- }
- .result-cont {
- padding: 0 34rpx 0;
- padding-left: 21rpx;
- .result-list {
- display: flex;
- align-items: center;
- color: #333;
- padding-bottom: 30rpx;
- border-bottom: 1rpx solid #ebedf0;
- margin-bottom: 30rpx;
- .result_ico {
- width: 28rpx;
- height: 28rpx;
- margin-right: 20rpx;
- }
- text {
- display: inline;
- }
- .highlight {
- color: #3385ff;
- }
- }
- }
- .result-data {
- // margin-top: 80rpx;
- min-height: calc(100vh - 130rpx);
- padding: 20rpx 34rpx 40rpx;
- display: flex;
- background-color: #f7f7f7;
- }
- }
- .tab-cont {
- position: fixed;
- top: 128rpx;
- width: 100%;
- padding: 0 26rpx;
- background-color: #fff;
- font-size: 32rpx;
- z-index: 99;
- box-shadow: 0 3rpx 6rpx rgba(187, 216, 255, 0.2);
- .scroll-tab {
- width: 100%;
- white-space: nowrap;
- }
- .scroll-tab-item {
- // flex-grow: 1;
- text-align: center;
- display: inline-block;
- padding: 0 8rpx 30rpx 8rpx;
- margin-right: 40rpx;
- border-bottom: 8rpx solid transparent;
- position: relative;
- &:last-child {
- margin-right: 0;
- }
- &.active {
- border-bottom: none;
- color: #2c83ff;
- font-weight: 700;
- }
- .border_act {
- width: 100%;
- height: 8rpx;
- position: absolute;
- bottom: 0;
- left: 0;
- }
- }
- }
- .u-line {
- display: none !important;
- }
- }
- </style>
|