searchGuide.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta
  6. name="viewport"
  7. content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
  8. />
  9. <title></title>
  10. <script src="./js/vue.min.js"></script>
  11. <script src="./js/axios.min.js"></script>
  12. <style>
  13. body {
  14. margin: 0;
  15. }
  16. div {
  17. box-sizing: border-box;
  18. }
  19. ::-webkit-scrollbar {
  20. /*滚动条整体样式*/
  21. width: 3px;
  22. /*高宽分别对应横竖滚动条的尺寸*/
  23. height: 1px;
  24. }
  25. ::-webkit-scrollbar-thumb {
  26. /*滚动条里面小方块*/
  27. border-radius: 10px;
  28. -webkit-box-shadow: inset 0 0 5px transparent;
  29. background: #f0d89c;
  30. }
  31. ::-webkit-scrollbar-track {
  32. /*滚动条里面轨道*/
  33. -webkit-box-shadow: inset 0 0 5px transparent;
  34. border-radius: 10px;
  35. background: transparent;
  36. }
  37. #app {
  38. width: 100vw;
  39. height: 100vh;
  40. box-sizing: border-box;
  41. overflow: hidden;
  42. display: flex;
  43. justify-content: flex-end;
  44. }
  45. .search {
  46. width: 60%;
  47. height: 100%;
  48. background: linear-gradient(
  49. 89deg,
  50. rgba(158, 135, 90, 0.35) 22%,
  51. rgba(141, 127, 100, 0.56) 80%,
  52. rgba(141, 127, 100, 0.56) 100%
  53. );
  54. backdrop-filter: blur(20px);
  55. padding: 15px 15px;
  56. border-radius: 10px;
  57. position: relative;
  58. }
  59. .close-box {
  60. width: 25px;
  61. height: 25px;
  62. position: absolute;
  63. top: 2px;
  64. right: 2px;
  65. cursor: pointer;
  66. }
  67. .search-box {
  68. width: 100%;
  69. height: 30px;
  70. border-radius: 5px;
  71. background: #ffffff47;
  72. padding: 5px 10px;
  73. display: flex;
  74. justify-content: space-between;
  75. align-items: center;
  76. }
  77. .tips {
  78. width: 100%;
  79. display: flex;
  80. justify-content: left;
  81. margin-top: 5px;
  82. }
  83. .tips-item {
  84. margin-left: 10px;
  85. font-size: 12px;
  86. color: #ffffff80;
  87. }
  88. .welcome-title {
  89. font-size: 18px;
  90. color: #ffffff;
  91. font-weight: bold;
  92. margin-top: 10px;
  93. }
  94. .search-content {
  95. border: none;
  96. width: 75%;
  97. height: 100%;
  98. background: none;
  99. line-height: 45px;
  100. font-size: 14px;
  101. color: white;
  102. }
  103. input:focus {
  104. outline: none;
  105. }
  106. input::placeholder {
  107. color: rgb(201, 201, 201);
  108. }
  109. .content-right {
  110. display: flex;
  111. justify-content: center;
  112. align-items: center;
  113. }
  114. .line {
  115. height: 25px;
  116. width: 2px;
  117. background: linear-gradient(transparent, white, transparent);
  118. margin-right: 10px;
  119. }
  120. .search-icon {
  121. height: 20px;
  122. width: 20px;
  123. }
  124. .options {
  125. width: 100%;
  126. display: flex;
  127. margin-top: 5px;
  128. justify-content: space-around;
  129. }
  130. .options-item {
  131. color: white;
  132. font-size: 15px;
  133. line-height: 1.5rem;
  134. cursor: pointer;
  135. }
  136. .list-box {
  137. width: 100%;
  138. height: 80%;
  139. overflow: auto;
  140. }
  141. .list-box-item {
  142. width: 100%;
  143. height: 40px;
  144. display: flex;
  145. justify-content: space-between;
  146. align-items: center;
  147. cursor: pointer;
  148. }
  149. .item-title {
  150. font-size: 16px;
  151. font-weight: bold;
  152. color: white;
  153. overflow: hidden;
  154. white-space: nowrap;
  155. text-overflow: ellipsis;
  156. }
  157. .item-disc {
  158. font-size: 13px;
  159. color: #ffffff75;
  160. min-width: 20%;
  161. }
  162. .dialog {
  163. /* width: 5%;
  164. height: 20%;
  165. position: relative; */
  166. }
  167. /* //制作尖角原理:把容器的长和宽都设置为零,然后利用其border制作小三角,两个三角形重叠,一个与背景颜色相同,另一个与边框颜色相同,即可展示出尖角的效果 */
  168. .dialog:before {
  169. content: "";
  170. width: 0;
  171. height: 0;
  172. border-bottom: 40px solid rgba(141, 127, 100, 0.56);
  173. border-right: 30px solid #fff0;
  174. backdrop-filter: blur(20px);
  175. }
  176. /* .dialog:after {
  177. content: "";
  178. width: 0;
  179. height: 0;
  180. position: absolute;
  181. top: 4.3em;
  182. left: 0;
  183. border-bottom: 2rem solid #fff;
  184. border-right: 5rem solid #fff0;
  185. } */
  186. img {
  187. height: 100%;
  188. }
  189. </style>
  190. <style></style>
  191. </head>
  192. <body>
  193. <div id="app">
  194. <!-- 搜索框 -->
  195. <div
  196. class="search"
  197. v-if="isShow"
  198. :style="{padding: clientWidth < 700 ? '10px 10px':''}"
  199. >
  200. <!-- <div class="close-box" @click="() => {isShow = false}">
  201. <img src="./img/icon/close.png" alt="" />
  202. </div> -->
  203. <!-- 搜索框 -->
  204. <div
  205. class="search-box"
  206. :style="{height: clientWidth < 700 ? '25px':''}"
  207. >
  208. <input
  209. class="search-content"
  210. type="text"
  211. placeholder="请输入关键字"
  212. :value="searchKey"
  213. v-model="searchKey"
  214. @input="searchFu"
  215. />
  216. <!-- <input class="search-content">{{searchKey}}</input> -->
  217. <div class="content-right">
  218. <div class="line"></div>
  219. <img
  220. class="search-icon"
  221. src="./img/icon/close.png"
  222. alt=""
  223. @click="() => {isShow = false}"
  224. />
  225. </div>
  226. </div>
  227. <!-- 文物 知识选择 -->
  228. <div class="options" :style="{marginTop: clientWidth < 700 ? '2px':''}">
  229. <div
  230. class="options-item"
  231. @click="()=>{optionValue = '文物'}"
  232. :style="{color: optionValue == '文物' ? '#f0d89c' : '#fff',fontSize: clientWidth < 700 ? '13px':''}"
  233. >
  234. 文物
  235. </div>
  236. <div
  237. class="options-item"
  238. @click="()=>{optionValue = '知识'}"
  239. :style="{color: optionValue == '文物' ? '#f0d89c' : '#fff',fontSize: clientWidth < 700 ? '13px':''}"
  240. >
  241. 知识
  242. </div>
  243. </div>
  244. <div class="list-box">
  245. <div
  246. class="list-box-item"
  247. v-for="(item, index) in showList"
  248. :style="{borderBottom: index != showList.length - 1? '1px #ffffff75 dashed': '',height: clientWidth < 700 ?'25px':''}"
  249. @click="goDetail(optionValue == '知识' ? item.channelId : item.id)"
  250. >
  251. <span
  252. class="item-title"
  253. :title="item.name"
  254. :style="{fontSize: clientWidth < 700 ? '12px':''}"
  255. >{{item.name}}</span
  256. >
  257. <!-- <div class="item-disc">{{`[${optionValue}]`}}</div> -->
  258. </div>
  259. </div>
  260. </div>
  261. <div class="dialog" v-if="isShow"></div>
  262. <div class="figure-box">
  263. <img src="./img/yb/yb.png" alt="" @click="() => {isShow = !isShow}" />
  264. </div>
  265. </div>
  266. <script>
  267. var app = new Vue({
  268. el: "#app",
  269. data() {
  270. return {
  271. title: "导向",
  272. isShow: false,
  273. searchKey: "",
  274. optionValue: "文物",
  275. culturalsList: [],
  276. showList: [],
  277. timer: null,
  278. isFocus: true,
  279. keyTips: ["海战博物馆", "虎门硝烟", "鸦片战争"],
  280. clientWidth: 0,
  281. };
  282. },
  283. mounted() {
  284. console.log(
  285. "父窗口宽度",
  286. window.parent.document.documentElement.clientWidth
  287. );
  288. window.onresize = () => {
  289. return (() => {
  290. this.clientWidth =
  291. window.parent.document.documentElement.clientWidth;
  292. })();
  293. };
  294. },
  295. beforCreat() {},
  296. created() {
  297. this.getCulturalRelics();
  298. },
  299. watch: {
  300. optionValue(newValue, oldValue) {
  301. if (newValue == "文物") {
  302. this.getCulturalRelics(this.searchKey);
  303. } else if (newValue == "知识") {
  304. this.getKnows(this.searchKey);
  305. }
  306. },
  307. isShow(newValue, oldValue) {
  308. var appbox = document.getElementById("app");
  309. if (newValue) {
  310. // pc端
  311. if (this.clientWidth > 700) {
  312. window.parent.postMessage(
  313. {
  314. params: {
  315. num: "26",
  316. },
  317. },
  318. "*"
  319. );
  320. } else {
  321. window.parent.postMessage(
  322. {
  323. params: {
  324. num: "80",
  325. },
  326. },
  327. "*"
  328. );
  329. }
  330. } else {
  331. if (this.clientWidth > 700) {
  332. window.parent.postMessage(
  333. {
  334. params: {
  335. num: "10",
  336. },
  337. },
  338. "*"
  339. );
  340. } else {
  341. window.parent.postMessage(
  342. {
  343. params: {
  344. num: "20",
  345. },
  346. },
  347. "*"
  348. );
  349. }
  350. }
  351. },
  352. },
  353. methods: {
  354. // 进入详情链接
  355. goDetail(id) {
  356. console.log(id);
  357. window.open(
  358. `/pc/#/${this.optionValue == "文物" ? "goods" : "know"}?id=${id}`
  359. );
  360. },
  361. // 搜索防抖计时器清除
  362. clearTimer() {
  363. if (this.timer) {
  364. clearTimeout(this.timer);
  365. }
  366. },
  367. // 进行搜索
  368. searchFu() {
  369. this.clearTimer();
  370. this.isFocus = true;
  371. this.timer = setTimeout(() => {
  372. if (this.optionValue == "文物") {
  373. this.getCulturalRelics(this.searchKey);
  374. } else if (this.optionValue == "知识") {
  375. this.getKnows(this.searchKey);
  376. }
  377. }, 500);
  378. },
  379. // 获取文物链接
  380. getCulturalRelics(searchKey) {
  381. let _this = this;
  382. _this.showList = [];
  383. const data = {
  384. dictAge: "",
  385. dictTexture: "",
  386. pageNum: 0,
  387. pageSize: 10000000,
  388. searchKey: searchKey,
  389. type: "",
  390. };
  391. axios
  392. .post(`https://ypbwg.4dage.com/api/show/goods/pageList`, data)
  393. .then(function (resp) {
  394. _this.showList = resp.data.data.records;
  395. });
  396. },
  397. // 获取知识链接
  398. getKnows(searchKey) {
  399. let _this = this;
  400. _this.showList = [];
  401. const data = {
  402. pageNum: 0,
  403. pageSize: 10000000,
  404. searchKey: searchKey,
  405. tagType: "",
  406. };
  407. axios
  408. .post(`https://ypbwg.4dage.com/api/show/getKnowledge`, data)
  409. .then(function (resp) {
  410. _this.showList = resp.data.data.records;
  411. });
  412. },
  413. },
  414. });
  415. </script>
  416. </body>
  417. </html>