Viewmore.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. <template>
  2. <!-- 查看更多 -->
  3. <div class="Viewmore">
  4. <div class="header">
  5. <Header />
  6. <div class="shade"></div>
  7. </div>
  8. <HeaderOne :changeKeycode="changeKeycode" :keycode="keycode" :text="text" />
  9. <div class="main" v-loading="loading">
  10. <!--
  11. prefix-icon="el-icon-user "-->
  12. <div class="select">
  13. <div
  14. :class="seleIndex == i ? 'sele' : ''"
  15. v-for="(item, i) in seleList"
  16. :key="i + item"
  17. @click="seletEvent(item, i)"
  18. >
  19. <span>
  20. {{ item.name }}
  21. </span>
  22. <img
  23. v-if="seleIndex != i"
  24. src="../../assets/teacherdev/updown3.png"
  25. alt=""
  26. />
  27. <img
  28. v-if="seleIndex == i && item.isUp"
  29. src="../../assets/teacherdev/updown1.png"
  30. alt=""
  31. />
  32. <img
  33. v-if="seleIndex == i && !item.isUp"
  34. src="../../assets/teacherdev/updown2.png"
  35. alt=""
  36. />
  37. </div>
  38. <div class="selectpeople" @click="selePeople">
  39. <img src="../../assets/teacherdev/selepeople.png" alt="" />
  40. <el-autocomplete
  41. class="inline-input"
  42. v-model="TeacherName"
  43. :fetch-suggestions="querySearch"
  44. placeholder="请输入内容"
  45. :trigger-on-focus="false"
  46. @select="handleSelect"
  47. ></el-autocomplete>
  48. </div>
  49. </div>
  50. <div class="list" v-if="DataList">
  51. <template v-if="DataList.data">
  52. <Teaching type="1" :classList="DataList.data" />
  53. <div class="paging">
  54. <el-pagination
  55. background
  56. @size-change="handleSizeChange"
  57. @current-change="handleCurrentChange"
  58. layout="prev, pager, next"
  59. :current-page="pageNum"
  60. :page-size="pageSize"
  61. :total="DataList.total"
  62. >
  63. </el-pagination>
  64. <span> | </span>
  65. <span>
  66. <span class="number">{{ Math.ceil(DataList.total / 10) }}</span>
  67. </span>
  68. <span> | </span>
  69. <span>
  70. 每页
  71. <span class="number"> {{ pageSize }} </span>
  72. <span> 个 </span>
  73. </span>
  74. <span>|</span>
  75. <span> 跳转 </span>
  76. <span>
  77. <el-input
  78. @input="toPageChange"
  79. v-model="gotoPage"
  80. :maxlength="1"
  81. class="gotoPage"
  82. type="text"
  83. />
  84. </span>
  85. <span>页</span>
  86. </div>
  87. </template>
  88. <template v-else>
  89. <div class="nomore">
  90. <img src="../../assets/teacherdev/noSeekResult.png" alt="" />
  91. <p class="p1">对不起,我找不到相关内容。</p>
  92. <!-- <p class="p2">Try the following keywords</p> -->
  93. <!-- <div class="keywords">
  94. <span>live lesson</span>
  95. <span>live lesson</span>
  96. <span>live lesson</span>
  97. </div> -->
  98. </div>
  99. </template>
  100. </div>
  101. <!--
  102. :total="CourseList.total"
  103. {{ Math.ceil(CourseList.total / 20) }}
  104. -->
  105. </div>
  106. </div>
  107. </template>
  108. <script>
  109. //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  110. //例如:import 《组件名称》from ‘《组件路径》';
  111. import Header from "@/components/Header";
  112. import HeaderOne from "@/components/teacher-dev/HeaderOne";
  113. import Teaching from "@/components/teacher-dev/Teaching";
  114. import { materiallist, teacherlist } from "@/api/api";
  115. export default {
  116. //import引入的组件需要注入到对象中才能使用
  117. components: {
  118. Header,
  119. HeaderOne,
  120. Teaching,
  121. },
  122. props: {},
  123. data() {
  124. //这里存放数据
  125. return {
  126. seleIndex: null, //筛选索引
  127. seleList: [
  128. {
  129. name: "名称",
  130. isUp: null, //是不是升序
  131. },
  132. {
  133. name: "发布时间",
  134. isUp: null, //是不是升序
  135. },
  136. {
  137. name: "浏览次数",
  138. isUp: null, //是不是升序
  139. },
  140. ],
  141. selePeole: "", //筛选的名字
  142. gotoPage: "", //前往某一页
  143. DataList: null,
  144. pageNum: 1,
  145. pageSize: 10,
  146. tag: [],
  147. SeekSuggest: [
  148. { value: "三全鲜食(北新泾店)", address: "长宁区新渔路144号" },
  149. {
  150. value: "Hot honey 首尔炸鸡(仙霞路)",
  151. address: "上海市长宁区淞虹路661号",
  152. },
  153. {
  154. value: "新旺角茶餐厅",
  155. address: "上海市普陀区真北路988号创邑金沙谷6号楼113",
  156. },
  157. { value: "泷千家(天山西路店)", address: "天山西路438号" },
  158. {
  159. value: "胖仙女纸杯蛋糕(上海凌空店)",
  160. address: "上海市长宁区金钟路968号1幢18号楼一层商铺18-101",
  161. },
  162. { value: "贡茶", address: "上海市长宁区金钟路633号" },
  163. {
  164. value: "豪大大香鸡排超级奶爸",
  165. address: "上海市嘉定区曹安公路曹安路1685号",
  166. },
  167. {
  168. value: "茶芝兰(奶茶,手抓饼)",
  169. address: "上海市普陀区同普路1435号",
  170. },
  171. { value: "十二泷町", address: "上海市北翟路1444弄81号B幢-107" },
  172. { value: "星移浓缩咖啡", address: "上海市嘉定区新郁路817号" },
  173. { value: "阿姨奶茶/豪大大", address: "嘉定区曹安路1611号" },
  174. { value: "新麦甜四季甜品炸鸡", address: "嘉定区曹安公路2383弄55号" },
  175. ],
  176. keycode: "",
  177. TeacherName: "",
  178. orderType: "", // DESC降序 ASC升序
  179. orderColumn: "", //1 名称 2 发布时间 3 浏览次数
  180. text: "",
  181. };
  182. },
  183. //计算属性 类似于data概念
  184. computed: {},
  185. //监控data中数据变化
  186. watch: {},
  187. //方法集合
  188. methods: {
  189. // 模糊查询搜索
  190. querySearch(queryString, cb) {
  191. queryString = queryString.trim();
  192. let results;
  193. teacherlist({
  194. pageNum: 1,
  195. pageSize: 10,
  196. teacherList: [`${queryString}`],
  197. })
  198. .then((res) => {
  199. if (res.data.data) {
  200. results = res.data.data;
  201. } else {
  202. results = [];
  203. }
  204. // 调用 callback 返回建议列表的数据
  205. cb(results);
  206. })
  207. .catch((res) => {
  208. this.loading = false;
  209. });
  210. },
  211. // 模糊查询选择 根据选择的老师进行查询学习资料 需要把当前页数改成1 因为可能当前不在第一页
  212. handleSelect(item) {
  213. this.pageNum = 1;
  214. this.getdata();
  215. },
  216. changeKeycode(val) {
  217. this.keycode = val;
  218. this.pageNum = 1;
  219. this.getdata();
  220. },
  221. // 选择名称时间浏览次数排序
  222. seletEvent(item, i) {
  223. if (typeof item.isUp == "boolean") {
  224. if (this.seleIndex != i) {
  225. item.isUp = false;
  226. } else {
  227. item.isUp = !item.isUp;
  228. }
  229. this.seleIndex = i;
  230. } else {
  231. item.isUp = false;
  232. this.seleIndex = i;
  233. }
  234. switch (item.name) {
  235. case "名称":
  236. this.orderColumn = "1";
  237. case "发布时间":
  238. this.orderColumn = "2";
  239. case "浏览次数":
  240. this.orderColumn = "3";
  241. }
  242. if (item.isUp) {
  243. this.orderType = "ASC";
  244. } else {
  245. this.orderType = "DESC";
  246. }
  247. this.getdata();
  248. },
  249. // 选择作者
  250. selePeople() {
  251. this.seleIndex = null;
  252. },
  253. handleSizeChange(val) {
  254. console.log(`每页 ${val} 条`);
  255. },
  256. // 点击跳转到某一页
  257. handleCurrentChange(val) {
  258. this.pageNum = val;
  259. this.getdata();
  260. },
  261. // 输入跳转到某一页
  262. toPageChange() {
  263. this.gotoPage = this.gotoPage.replace(/[^\d]/g, ""); //使用空字符串去替换非数字的字符
  264. if (this.gotoPage > Math.ceil(this.DataList.total / 10)) {
  265. return;
  266. } else if (this.gotoPage != this.pageNum) {
  267. this.pageNum = this.gotoPage * 1;
  268. this.getdata();
  269. }
  270. },
  271. getdata() {
  272. this.loading = true;
  273. materiallist({
  274. pageNum: this.pageNum,
  275. pageSize: this.pageSize,
  276. keyWord: this.keycode,
  277. tagList: this.tag,
  278. orderType: this.orderType,
  279. orderColumn: this.orderColumn,
  280. teacherList: this.TeacherName ? [`${this.TeacherName}`] : [],
  281. })
  282. .then((res) => {
  283. this.DataList = res.data;
  284. this.loading = false;
  285. })
  286. .catch((res) => {
  287. this.loading = false;
  288. });
  289. },
  290. },
  291. //生命周期 - 创建完成(可以访问当前this实例)
  292. created() {
  293. if (this.$route.query.classify) {
  294. if (this.$route.query.classify == "TEXTBOOK") {
  295. this.text = "教材";
  296. }
  297. if (this.$route.query.classify == "TEACHING") {
  298. this.text = "教学";
  299. }
  300. this.tag.push(this.$route.query.classify);
  301. }
  302. if (this.$route.query.keyWord) {
  303. this.text = "搜索结果";
  304. this.keycode = this.$route.query.keyWord;
  305. }
  306. this.getdata();
  307. },
  308. //生命周期 - 挂载完成(可以访问DOM元素)
  309. mounted() {},
  310. //生命周期-创建之前
  311. beforeCreated() {},
  312. //生命周期-挂载之前
  313. beforeMount() {},
  314. //生命周期-更新之前
  315. beforUpdate() {},
  316. //生命周期-更新之后
  317. updated() {},
  318. //生命周期-销毁之前
  319. beforeDestory() {},
  320. //生命周期-销毁完成
  321. destoryed() {},
  322. //如果页面有keep-alive缓存功能,这个函数会触发
  323. activated() {},
  324. };
  325. </script>
  326. <style lang="scss" scoped>
  327. /* @import url(); 引入css类 */
  328. .Viewmore {
  329. .header {
  330. height: 64px;
  331. background: url("../../assets/teacherdev/Homebg2.png") no-repeat;
  332. background-size: 100% 100%;
  333. position: relative;
  334. .shade {
  335. position: absolute;
  336. top: 0;
  337. width: 100%;
  338. height: 100%;
  339. background: rgba(0, 0, 0, 0.5);
  340. display: flex;
  341. color: #fff;
  342. font-weight: bold;
  343. font-size: 18px;
  344. justify-content: space-around;
  345. align-items: center;
  346. .el-menu-demo {
  347. background: rgba(0, 0, 0, 0);
  348. li:hover {
  349. background: none;
  350. }
  351. li {
  352. background: none;
  353. }
  354. }
  355. }
  356. }
  357. .main {
  358. background: #e5e5e5;
  359. min-height: 568px;
  360. padding-top: 24px;
  361. padding-bottom: 20px;
  362. .select {
  363. width: 1200px;
  364. margin: 0 auto;
  365. margin-bottom: 24px;
  366. display: flex;
  367. > div {
  368. cursor: pointer;
  369. font-size: 16px;
  370. color: #000000;
  371. border: 1px solid rgba(0, 0, 0, 0.15);
  372. background: #fff;
  373. border-radius: 8px;
  374. padding: 0 16px;
  375. height: 40px;
  376. line-height: 40px;
  377. margin-right: 24px;
  378. display: flex;
  379. align-items: center;
  380. span {
  381. margin-right: 8px;
  382. }
  383. img {
  384. width: 24px;
  385. }
  386. }
  387. .selectpeople {
  388. cursor: default;
  389. border: none;
  390. position: relative;
  391. img {
  392. position: absolute;
  393. left: 16px;
  394. }
  395. }
  396. .sele {
  397. color: #ffffff;
  398. background: #ff9900;
  399. }
  400. }
  401. .paging {
  402. // position: fixed;
  403. // bottom: 0;
  404. display: flex;
  405. align-items: center;
  406. height: 150px;
  407. padding-left: 170px;
  408. color: darkgrey;
  409. .number {
  410. color: black;
  411. }
  412. span {
  413. margin-left: 10px;
  414. }
  415. .gotoPage {
  416. width: 40px;
  417. text-align: center;
  418. }
  419. }
  420. .nomore {
  421. // margin-top: 80px;
  422. text-align: center;
  423. .p1 {
  424. font-weight: 600;
  425. font-size: 32px;
  426. color: #2c2c2c;
  427. margin-top: 20px;
  428. }
  429. .p2 {
  430. font-size: 28px;
  431. color: #2c2c2c;
  432. margin-top: 20px;
  433. }
  434. .keywords {
  435. span {
  436. display: inline-block;
  437. // width: 129px;
  438. // height: 55px;
  439. padding: 16px;
  440. background: rgba(44, 44, 44, 0.1);
  441. border-radius: 31px;
  442. color: rgba(44, 44, 44, 0.5);
  443. font-size: 18px;
  444. // line-height: 55px;
  445. margin: 20px 20px 20px 20px;
  446. cursor: pointer;
  447. }
  448. }
  449. }
  450. }
  451. }
  452. </style>
  453. <style lang="scss">
  454. .selectpeople {
  455. border: none;
  456. position: relative;
  457. .el-input__inner {
  458. width: 80%;
  459. margin-left: 30px;
  460. border: none;
  461. height: 100%;
  462. }
  463. }
  464. </style>