HeaderOne.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <div :class="type ? 'HeaderTwo' : 'HeaderOne'">
  3. <div>
  4. <span class="befor" @click="gohome">
  5. <img src="../../assets/learncenter/Frame3.png" alt="" />
  6. </span>
  7. <span class="arrows" v-if="title"> > </span>
  8. <span @click="back" class="text">{{ title }}</span>
  9. <!-- <span class="text" v-if="type"> TEXTBOOK </span> -->
  10. <span class="arrows" v-if="text"> > </span>
  11. <span class="text" v-if="text">{{ name }}</span>
  12. </div>
  13. <div>
  14. <div :class="type ? 'Headseek' : 'seek'" @keydown="keyDownSeekData">
  15. <el-input
  16. style="width: 300px"
  17. placeholder="请输入内容"
  18. v-model="SeekName"
  19. >
  20. </el-input>
  21. <img
  22. v-if="!type"
  23. @click="gotoSeekResult"
  24. src="../../assets/learncenter/Group2149.png"
  25. alt=""
  26. />
  27. <img
  28. v-else
  29. @click="gotoSeekResult"
  30. src="../../assets/learncenter/Group 2148.png"
  31. alt=""
  32. />
  33. </div>
  34. </div>
  35. </div>
  36. </template>
  37. <script>
  38. //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  39. //例如:import 《组件名称》from ‘《组件路径》';
  40. export default {
  41. //import引入的组件需要注入到对象中才能使用
  42. components: {},
  43. props: ["type", "text", "title", "keycode", "changeKeycode", "name"],
  44. data() {
  45. //这里存放数据
  46. return {
  47. SeekName: "",
  48. };
  49. },
  50. //计算属性 类似于data概念
  51. computed: {},
  52. //监控data中数据变化
  53. watch: {
  54. keycode(newval, oldval) {
  55. this.SeekName = newval;
  56. },
  57. },
  58. //方法集合
  59. methods: {
  60. back() {
  61. this.$router.go(-1);
  62. },
  63. // 返回首页
  64. gohome() {
  65. this.$router.push("/");
  66. },
  67. keyDownSeekData(e) {
  68. if (e.keyCode == 13) {
  69. this.gotoSeekResult();
  70. }else{
  71. return
  72. }
  73. },
  74. gotoSeekResult() {
  75. if (this.SeekName == "") {
  76. this.$message.warning("请输入内容");
  77. return;
  78. }
  79. // 如果不是在搜索结果页面就跳到搜索结果页面
  80. if (this.$route.name != "learnCenterSeekresult") {
  81. this.$router.push({
  82. path: "/learncenter/Seekresult",
  83. query: {
  84. keycode: this.SeekName,
  85. id: this.$route.query.id,
  86. },
  87. });
  88. } else {
  89. // 如果在就把关键字传给父组件进行搜索
  90. this.changeKeycode(this.SeekName);
  91. // 修改keycode 避免刷新丢失
  92. this.$router.replace({
  93. path: "/learncenter/Seekresult",
  94. query: {
  95. keycode: this.SeekName,
  96. id: this.$route.query.id,
  97. },
  98. });
  99. }
  100. },
  101. },
  102. //生命周期 - 创建完成(可以访问当前this实例)
  103. created() {
  104. this.SeekName = this.keycode || "";
  105. },
  106. //生命周期 - 挂载完成(可以访问DOM元素)
  107. mounted() {},
  108. //生命周期-创建之前
  109. beforeCreated() {},
  110. //生命周期-挂载之前
  111. beforeMount() {},
  112. //生命周期-更新之前
  113. beforUpdate() {},
  114. //生命周期-更新之后
  115. updated() {},
  116. //生命周期-销毁之前
  117. beforeDestory() {},
  118. //生命周期-销毁完成
  119. destoryed() {},
  120. //如果页面有keep-alive缓存功能,这个函数会触发
  121. activated() {},
  122. };
  123. </script>
  124. <style lang="scss" scoped>
  125. /* @import url(); 引入css类 */
  126. .HeaderOne {
  127. display: flex;
  128. justify-content: space-between;
  129. align-items: center;
  130. padding: 0 120px 0 24px;
  131. height: 64px;
  132. background: #fff;
  133. :first-child {
  134. display: flex;
  135. align-items: center;
  136. > span {
  137. margin-left: 15px;
  138. cursor: pointer;
  139. }
  140. .befor {
  141. img {
  142. width: 24px;
  143. }
  144. }
  145. .befor::before {
  146. content: "|";
  147. width: 6px;
  148. height: 24px;
  149. color: #ff9900;
  150. background: #ff9900;
  151. position: relative;
  152. right: 10px;
  153. }
  154. .text {
  155. font-weight: bold;
  156. font-size: 16px;
  157. color: #2c2c2c;
  158. }
  159. .arrows {
  160. opacity: 0.4;
  161. }
  162. }
  163. .Headseek,
  164. .seek {
  165. position: relative;
  166. img {
  167. width: 24px;
  168. position: absolute;
  169. right: 19px;
  170. top: 7px;
  171. cursor: pointer;
  172. }
  173. }
  174. }
  175. .HeaderTwo {
  176. display: flex;
  177. justify-content: space-between;
  178. align-items: center;
  179. padding: 0 100px 0 24px;
  180. height: 64px;
  181. background: none;
  182. color: white;
  183. :first-child {
  184. display: flex;
  185. align-items: center;
  186. > span {
  187. margin-left: 15px;
  188. cursor: pointer;
  189. }
  190. .befor {
  191. img {
  192. width: 24px;
  193. }
  194. }
  195. .befor::before {
  196. content: "|";
  197. width: 6px;
  198. height: 24px;
  199. color: #ff9900;
  200. background: #ff9900;
  201. position: relative;
  202. right: 10px;
  203. }
  204. .text {
  205. font-weight: bold;
  206. font-size: 16px;
  207. color: white;
  208. }
  209. .arrows {
  210. opacity: 0.4;
  211. }
  212. }
  213. .Headseek,
  214. .seek {
  215. position: relative;
  216. img {
  217. width: 24px;
  218. position: absolute;
  219. right: 19px;
  220. top: 7px;
  221. cursor: pointer;
  222. }
  223. }
  224. }
  225. </style>
  226. <style lang="scss">
  227. .opacity {
  228. .el-input__inner {
  229. background: rgba(255, 255, 255, 0.5);
  230. border: none;
  231. color: white;
  232. }
  233. input::-webkit-input-placeholder {
  234. color: white;
  235. opacity: 0.6;
  236. }
  237. .el-input__prefix,
  238. .el-input__suffix {
  239. color: white;
  240. opacity: 0.6;
  241. }
  242. }
  243. </style>
  244. <style lang="scss">
  245. .Headseek {
  246. .el-input__inner {
  247. background: rgba(255, 255, 255, 0.1);
  248. border: none;
  249. color: white;
  250. }
  251. }
  252. </style>