searchGuide.html 11 KB

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