HeaderOne.vue 5.6 KB

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