Viewmore.vue 12 KB

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