reportSearch.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  1. <template>
  2. <view class="searchTarget-container container">
  3. <view class="searchTarget-header">
  4. <input
  5. type="text"
  6. placeholder="请输入产业名称或标的名称"
  7. placeholder-class="sea_ipt_placeholder"
  8. class="sea_ipt"
  9. v-model="searchTxt"
  10. focus="true"
  11. confirm-type="search"
  12. @confirm="searchHandle"
  13. />
  14. <icon type="search" size="15" class="sea_ico" />
  15. <view class="ipt-right">
  16. <icon type="clear" size="16" color="#E0E0E0" v-show="searchTxt" @click="clearIpt" />
  17. <text class="line">|</text>
  18. <text @click="searchHandle" style="color: #3385ff">搜索</text>
  19. </view>
  20. </view>
  21. <view class="search-cont">
  22. <template v-if="!isResult">
  23. <view class="search-cont-top" v-if="historySearchList.length">
  24. <view class="cont-tit">
  25. <text>搜索历史</text>
  26. <image src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/empty_ico.png" class="empty_ico" @click="clearHistory"></image>
  27. </view>
  28. <view class="targetList">
  29. <view class="target-item" v-for="(item, index) in historySearchList" :key="index" @click="chooseTarget(item)">{{ item }}</view>
  30. </view>
  31. </view>
  32. <view class="search-cont-top">
  33. <view class="cont-tit">
  34. <text>弘则推荐</text>
  35. </view>
  36. <view class="targetList">
  37. <view class="target-item" v-for="(item, index) in keywordList" :key="index" @click="chooseTarget(item)">{{ item }}</view>
  38. </view>
  39. </view>
  40. </template>
  41. <template v-else>
  42. <block v-if="haveResult">
  43. <view class="">
  44. <view class="report-ul" v-if="resultList.length > 0">
  45. <view class="resource">
  46. <image src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/zybico.jpg" mode=""></image>
  47. <text>弘则资源包</text>
  48. </view>
  49. <view class="report-item" v-for="(item, index) in resultList" :key="index">
  50. <view class="box-text" @click="goDetail(item)">
  51. <view class="" style="padding-left: 30rpx">
  52. {{ item.IndustryName }}
  53. </view>
  54. <view class="text-time">
  55. <text style="padding-right: 20rpx">{{ item.UpdateTime }}更新</text>
  56. <u-icon name="arrow-right" color="#BDBDBD" size="34"></u-icon>
  57. </view>
  58. </view>
  59. <view class="" v-if="item.IndustrialSubjectList.length > 6">
  60. <u-read-more :shadow-style="shadowStyle" close-text="展开" color="#D1D1D1" :show-height="item.IndustrialSubjectList.length > 6 ? 170 : 200" :toggle="true">
  61. <view class="arrow-box">
  62. <view @click="goDetail(item)" class="box-subject" v-for="key in item.IndustrialSubjectList" :key="key.RecommendedIndex">
  63. {{ key.SubjectName }}
  64. </view>
  65. </view>
  66. </u-read-more>
  67. </view>
  68. <view class="" v-else @click="goDetail(item)">
  69. <view class="arrow-box">
  70. <view class="box-subject" v-for="key in item.IndustrialSubjectList" :key="key.RecommendedIndex">
  71. {{ key.SubjectName }}
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. <view class="report-ul" v-if="indList.length > 0">
  78. <view class="resource industry-box">
  79. <image src="https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png" mode=""></image>
  80. <text>研选报告</text>
  81. </view>
  82. <view class="ind-item" v-for="item in indList" :key="item.ArticleId" @click="goDetailIndust(item.ArticleId)">
  83. <view class="">
  84. <text>{{ item.Title }}</text>
  85. <view class="time-industry">
  86. <text class="time">{{ item.PublishDate }}</text>
  87. <text>{{ item.IndustryName }}</text>
  88. </view>
  89. </view>
  90. <u-icon class="ico" name="arrow-right" color="#BDBDBD" size="34"></u-icon>
  91. </view>
  92. </view>
  93. </view>
  94. </block>
  95. <view class="nodata" v-else>
  96. <image src="@/static/img/nodata.png" mode="" class="nodata_ico"></image>
  97. <text>未找到您想搜索的内容</text>
  98. </view>
  99. </template>
  100. </view>
  101. <freeCharge class="free-charge" :isShowFreeBtn="isShowFree" />
  102. </view>
  103. </template>
  104. <script>
  105. import { Search, Reports } from "@/config/api.js";
  106. import { Debounce, Throttle } from "@/config/util.js";
  107. import freeCharge from "@/components/freeCharge";
  108. let app = getApp({ allowDefault: true });
  109. export default {
  110. data() {
  111. return {
  112. searchTxt: "", //搜索关键字
  113. isResult: false, //显示搜索结果
  114. haveResult: true, //是否有搜索数据
  115. // 历史搜索列表
  116. historySearchList: [],
  117. // 关键字列表
  118. keywordList: [],
  119. targetList: [], //所有指标列表
  120. // 搜索结果列表
  121. resultList: [],
  122. indList: [],
  123. page_no: 1,
  124. pageSize: 10,
  125. totalPage: 0,
  126. loadText: {
  127. loadmore: "上拉加载更多",
  128. loading: "加载中",
  129. nomore: "",
  130. },
  131. status: "loadmore",
  132. shadowStyle: {
  133. backgroundImage: "none",
  134. },
  135. };
  136. },
  137. watch: {
  138. searchTxt(newVal) {
  139. if (newVal.length <= 0) {
  140. this.isResult = false;
  141. }
  142. },
  143. },
  144. components: {
  145. freeCharge,
  146. },
  147. methods: {
  148. /* 获取关键词 */
  149. getKeyWord() {
  150. Search.getKeys().then((res) => {
  151. if (res.Ret === 200) {
  152. this.keywordList = res.Data.Item.ConfigValue ? res.Data.Item.ConfigValue.split(",") : [];
  153. }
  154. });
  155. },
  156. // 选择历史搜索
  157. chooseTarget(item) {
  158. this.searchTxt = item;
  159. this.SecName = item;
  160. this.resultList = [];
  161. this.indList = [];
  162. this.getDataList();
  163. },
  164. // 键盘输入过程中
  165. searchDoing() {
  166. this.isResult = false;
  167. //全部指标列表
  168. let arr = JSON.parse(JSON.stringify(this.targetList));
  169. let filterArr = [];
  170. // // 过滤出符合搜索条件的值
  171. arr.forEach((item, index) => {
  172. if (item.SecName.includes(this.searchTxt)) {
  173. item.SecName = this.join(item.SecName, this.searchTxt);
  174. filterArr.unshift(item);
  175. }
  176. });
  177. this.keywordList = filterArr;
  178. },
  179. // 拼接
  180. join(str, key) {
  181. return str.replace(new RegExp(`${key}`, "g"), `%%${key}%%`).split("%%");
  182. },
  183. // 搜索数据
  184. searchHandle: Debounce(function () {
  185. if (this.searchTxt) {
  186. //添加搜索记录
  187. if (!this.historySearchList.includes(this.searchTxt)) {
  188. this.historySearchList.unshift(this.searchTxt);
  189. this.$db.set("historySearchListReport", JSON.stringify(this.historySearchList));
  190. }
  191. this.resultList = [];
  192. this.indList = [];
  193. this.getDataList();
  194. } else {
  195. this.$util.toast("请输入关键字");
  196. }
  197. }),
  198. // 查找数据
  199. getDataList() {
  200. this.isResult = true;
  201. Reports.getIndustryAndArticle({
  202. KeyWord: this.searchTxt,
  203. }).then((res) => {
  204. if (res.Ret === 200) {
  205. this.resultList = res.Data.IndList || [];
  206. this.indList = res.Data.ArtList || [];
  207. this.haveResult = this.resultList.length > 0 || this.indList.length > 0;
  208. }
  209. });
  210. },
  211. // 点击数据列表修改数据
  212. itemClick(item) {
  213. let data = encodeURIComponent(JSON.stringify(item));
  214. uni.navigateTo({
  215. url: "/pages/recordData/recordData?data=" + data,
  216. });
  217. },
  218. /* 表单清空 */
  219. clearIpt() {
  220. this.searchTxt = "";
  221. this.isTabAct = false;
  222. },
  223. /* 历史搜索清空 */
  224. clearHistory() {
  225. this.historySearchList = [];
  226. this.$db.del("historySearchListReport");
  227. },
  228. /* 进入详情 校验是否有该品种权限 */
  229. goDetail(item) {
  230. uni.navigateTo({
  231. url: "/reportPages/IndustryReport/IndustryReport?id=" + item.IndustrialManagementId,
  232. });
  233. },
  234. goDetailIndust(id) {
  235. this.$store.dispatch("checkHandle", "/pageMy/reportDetail/reportDetail?id=" + id);
  236. },
  237. },
  238. onLoad(options) {
  239. if (options.text) {
  240. this.searchTxt = options.text;
  241. this.getDataList();
  242. }
  243. // 获取历史搜索记录
  244. if (this.$db.get("historySearchListReport")) {
  245. let historyList = JSON.parse(this.$db.get("historySearchListReport"));
  246. this.historySearchList = historyList;
  247. }
  248. },
  249. onShow() {
  250. this.$store.dispatch("statistics", { PageType: "ReportSearch" });
  251. this.getKeyWord();
  252. },
  253. /**
  254. * 用户点击分享
  255. */
  256. onShareAppMessage: function (res) {
  257. return {
  258. title: this.isHorzMobile ? "好友向您推荐此内容,上传名片享查研观向免费试用月卡!" : "报告",
  259. path: "/reportPages/reportSearch/reportSearch?text=" + this.searchTxt,
  260. success: (res) => {},
  261. fail: (err) => {},
  262. };
  263. },
  264. };
  265. </script>
  266. <style lang="scss">
  267. .searchTarget-container {
  268. background-color: #f6f6f6;
  269. padding-bottom: 30rpx;
  270. .report-ul {
  271. margin-bottom: 20rpx;
  272. }
  273. .searchTarget-header {
  274. padding: 0 34rpx;
  275. width: 100%;
  276. background-color: #fff;
  277. position: fixed;
  278. top: 0;
  279. left: 0;
  280. z-index: 99;
  281. padding: 30rpx 0;
  282. display: flex;
  283. justify-content: center;
  284. align-items: center;
  285. .sea_ipt_placeholder {
  286. color: #8d8d8d;
  287. }
  288. .sea_ipt {
  289. width: 682rpx;
  290. height: 70rpx;
  291. line-height: 70rpx;
  292. box-sizing: border-box;
  293. border: 1rpx solid #e5e5e5;
  294. background-color: rgba(245, 245, 245, 0.2);
  295. font-size: 26rpx;
  296. color: #4a4a4a;
  297. padding: 0 180rpx 0 78rpx;
  298. border-radius: 70rpx;
  299. }
  300. .sea_ico {
  301. width: 31rpx;
  302. height: 31rpx;
  303. position: absolute;
  304. left: 68rpx;
  305. top: 50%;
  306. transform: translateY(-50%);
  307. }
  308. .ipt-right {
  309. display: flex;
  310. align-items: center;
  311. position: absolute;
  312. right: 59rpx;
  313. top: 50%;
  314. transform: translateY(-50%);
  315. color: #3385ff;
  316. .line {
  317. margin: 0 21rpx;
  318. color: #e0e0e0;
  319. }
  320. }
  321. }
  322. .resource {
  323. margin-top: 4rpx;
  324. height: 91rpx;
  325. width: 100%;
  326. display: flex;
  327. align-items: center;
  328. justify-content: center;
  329. background-color: #fff;
  330. color: #333333;
  331. font-size: 30rpx;
  332. image {
  333. width: 34rpx;
  334. height: 36rpx;
  335. margin-right: 10rpx;
  336. }
  337. }
  338. .report-item {
  339. margin-top: 10rpx;
  340. width: 100%;
  341. background-color: #fff;
  342. .box-text {
  343. display: flex;
  344. justify-content: space-between;
  345. background-color: #fff;
  346. align-items: center;
  347. padding: 0 30rpx;
  348. height: 91rpx;
  349. color: #333333;
  350. font-size: 30rpx;
  351. .text-time {
  352. display: flex;
  353. color: #999999;
  354. font-size: 26rpx;
  355. }
  356. }
  357. .arrow-box {
  358. display: flex;
  359. flex-wrap: wrap;
  360. border-top: 3rpx solid #f6f6f6;
  361. padding: 30rpx 30rpx 0;
  362. .box-subject {
  363. margin-bottom: 30rpx;
  364. margin-left: 40rpx;
  365. background: url(../../static/img/report_bg.png) no-repeat;
  366. background-size: 100% 100%;
  367. width: 170rpx;
  368. height: 46rpx;
  369. color: #408fff;
  370. text-align: center !important;
  371. font-size: 24rpx;
  372. line-height: 46rpx;
  373. text-indent: 0em;
  374. }
  375. }
  376. }
  377. .industry-box {
  378. margin-bottom: 3rpx;
  379. }
  380. .ind-item {
  381. display: flex;
  382. justify-content: space-between;
  383. align-items: center;
  384. padding: 30rpx 30rpx 28rpx 58rpx;
  385. background-color: #fff;
  386. margin-bottom: 10rpx;
  387. .time-industry {
  388. display: flex;
  389. margin-top: 30rpx;
  390. font-size: 26rpx;
  391. color: #2c83ff;
  392. .time {
  393. color: #666666;
  394. margin-right: 20rpx;
  395. flex-shrink: 0;
  396. }
  397. }
  398. }
  399. .search-cont {
  400. padding-top: 130rpx;
  401. .search-cont-top {
  402. padding: 0 34rpx 0;
  403. margin-bottom: 10rpx;
  404. padding-top: 20rpx;
  405. &:last-child {
  406. margin-bottom: 0;
  407. }
  408. .cont-tit {
  409. color: #666;
  410. font-size: 28rpx;
  411. margin-bottom: 30rpx;
  412. display: flex;
  413. justify-content: space-between;
  414. .empty_ico {
  415. width: 32rpx;
  416. height: 33rpx;
  417. }
  418. }
  419. .targetList {
  420. display: flex;
  421. flex-wrap: wrap;
  422. // justify-content: space-between;
  423. .target-item {
  424. padding: 4rpx 18rpx;
  425. color: #4a4a4a;
  426. font-size: 26rpx;
  427. // border: 1rpx solid #3385ff;
  428. background-color: #f7f7f7;
  429. margin-bottom: 30rpx;
  430. margin-right: 30rpx;
  431. border-radius: 20rpx;
  432. }
  433. }
  434. }
  435. .result-cont {
  436. padding: 0 34rpx 0;
  437. padding-left: 21rpx;
  438. .result-list {
  439. display: flex;
  440. align-items: center;
  441. color: #333;
  442. padding-bottom: 30rpx;
  443. border-bottom: 1rpx solid #ebedf0;
  444. margin-bottom: 30rpx;
  445. .result_ico {
  446. width: 28rpx;
  447. height: 28rpx;
  448. margin-right: 20rpx;
  449. }
  450. text {
  451. display: inline;
  452. }
  453. .highlight {
  454. color: #3385ff;
  455. }
  456. }
  457. }
  458. .result-data {
  459. // margin-top: 80rpx;
  460. min-height: calc(100vh - 130rpx);
  461. padding: 20rpx 34rpx 40rpx;
  462. display: flex;
  463. background-color: #f7f7f7;
  464. }
  465. }
  466. .tab-cont {
  467. position: fixed;
  468. top: 128rpx;
  469. width: 100%;
  470. padding: 0 26rpx;
  471. background-color: #fff;
  472. font-size: 32rpx;
  473. z-index: 99;
  474. box-shadow: 0 3rpx 6rpx rgba(187, 216, 255, 0.2);
  475. .scroll-tab {
  476. width: 100%;
  477. white-space: nowrap;
  478. }
  479. .scroll-tab-item {
  480. // flex-grow: 1;
  481. text-align: center;
  482. display: inline-block;
  483. padding: 0 8rpx 30rpx 8rpx;
  484. margin-right: 40rpx;
  485. border-bottom: 8rpx solid transparent;
  486. position: relative;
  487. &:last-child {
  488. margin-right: 0;
  489. }
  490. &.active {
  491. border-bottom: none;
  492. color: #2c83ff;
  493. font-weight: 700;
  494. }
  495. .border_act {
  496. width: 100%;
  497. height: 8rpx;
  498. position: absolute;
  499. bottom: 0;
  500. left: 0;
  501. }
  502. }
  503. }
  504. .u-line {
  505. display: none !important;
  506. }
  507. }
  508. </style>