index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. <template>
  2. <div class="bookShelf">
  3. <Header
  4. :headerBg="'#1F1F1F'"
  5. :headerBorder="'#5C5C5C'"
  6. :userBg="'rgba(0, 0, 0, 0.24)'"
  7. :LoginNavIndex="1"
  8. />
  9. <ul class="option">
  10. <li class="option-item" :class="[typeIndex===indexo?'active':'']" v-for="(itemo,indexo) in optionList" :key="indexo" @click="handleClick(itemo,indexo)">
  11. <svg-icon :icon-class="itemo.img" className="icon-img"></svg-icon>
  12. <span>{{itemo.label}}</span>
  13. <b>{{itemo.number}}</b>
  14. </li>
  15. </ul>
  16. <div class="main">
  17. <div class="searchChangebox">
  18. <div class="searchChange-box">
  19. <div class="searchChange" :class="[item.sortName==sortField?'active':'']" v-for="(item,indexC) in changeList" :key="indexC">
  20. <span>
  21. {{
  22. item.name
  23. }}
  24. </span>
  25. <div :class="['sort']">
  26. <div>
  27. <svg-icon icon-class="up" className="icon-up" :class="[item.sort=='up'?'active':'']" @click="SortEvent('up', item.name, item.sortName)"></svg-icon>
  28. </div>
  29. <div>
  30. <svg-icon icon-class="down" className="icon-down" :class="[item.sort=='down'?'active':'']" @click="SortEvent('down', item.name, item.sortName)"></svg-icon>
  31. </div>
  32. </div>
  33. </div>
  34. </div>
  35. <el-input placeholder="输入名称" v-model="searchNameValue" class="input-search">
  36. <el-button slot="append" icon="el-icon-search" @click="getSearch"></el-button>
  37. </el-input>
  38. </div>
  39. <h5 class="show-title" v-if="typeIndex!==0">{{optionList[typeIndex].label}}<b>{{optionList[typeIndex].number}}</b></h5>
  40. <div class="list" v-if="BookList.length>0">
  41. <!-- v-infinite-scroll="load" -->
  42. <div
  43. v-for="(item,index) in BookList"
  44. :key="index+'todayNew'"
  45. v-infinite-scroll="load"
  46. infinite-scroll-disabled="disabled"
  47. :style="{
  48. marginLeft:index==0||index%5==0?'0':'50px',
  49. }"
  50. >
  51. <BookCard
  52. :item="item"
  53. type='bookShelf'
  54. :headerBg="'#1F1F1F'"
  55. :headerBorder="'#5C5C5C'"
  56. :userBg="'rgba(0, 0, 0, 0.24)'"
  57. :LoginNavIndex="1"
  58. :previousPage="'书架'"
  59. :cardType="item.course_type"
  60. :isBuy="true"
  61. />
  62. </div>
  63. <p v-if="loading" class="tips">加载中...</p>
  64. <p v-if="noMore" class="tips">没有更多了</p>
  65. </div>
  66. <div class="nodata" v-else>
  67. <img src="../../assets/nodata.png" />
  68. <p>找不到文件</p>
  69. </div>
  70. </div>
  71. </div>
  72. </template>
  73. <script>
  74. //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  75. //例如:import 《组件名称》from ‘《组件路径》';
  76. import Header from "../../components/Header.vue";
  77. import BookCard from "@/components/common/BookCard.vue"
  78. import { getLogin } from "@/api/ajax";
  79. export default {
  80. //import引入的组件需要注入到对象中才能使用
  81. components: { Header, BookCard },
  82. props: {},
  83. data() {
  84. //这里存放数据
  85. return {
  86. BookList: [
  87. {
  88. skeleton: true
  89. },
  90. {
  91. skeleton: true
  92. },
  93. {
  94. skeleton: true
  95. },
  96. {
  97. skeleton: true
  98. },
  99. {
  100. skeleton: true
  101. }
  102. ],
  103. optionList: [
  104. {
  105. label: '全部',
  106. img: 'quanbu',
  107. number: 0,
  108. value: -1
  109. },
  110. {
  111. label: '画刊',
  112. img: 'huakan',
  113. number: 0,
  114. },
  115. {
  116. label: '报纸',
  117. img: 'baozhi',
  118. number: 0,
  119. value: 2
  120. },
  121. {
  122. label: '练习册',
  123. img: 'xiti',
  124. number: 0
  125. },
  126. {
  127. label: '课程',
  128. img: 'kecheng',
  129. number: 0,
  130. value: 10
  131. }
  132. // ,
  133. // {
  134. // label: '合刊',
  135. // img: 'hekan',
  136. // number: '6'
  137. // }
  138. ],
  139. typeValue: -1,
  140. changeList: [
  141. {
  142. name: "按购买时间",
  143. sort: "down",
  144. sortName: "buy_time",
  145. },
  146. {
  147. name: "按名称",
  148. sort: "",
  149. sortName: "name",
  150. },
  151. {
  152. name: "最近使用",
  153. sort: "",
  154. sortName: "last_use_time",
  155. },
  156. ],
  157. sortField: "",
  158. searchNameValue: '', // 搜索名称值
  159. loading: false,
  160. noMore: false,
  161. pageNumber: 1,
  162. pageSize: 30,
  163. typeIndex: 0
  164. }
  165. },
  166. //计算属性 类似于data概念
  167. computed: {
  168. disabled () {
  169. return this.loading || this.noMore
  170. }
  171. },
  172. //监控data中数据变化
  173. watch: {},
  174. //方法集合
  175. methods: {
  176. handleClick(item,index){
  177. this.typeIndex = index
  178. this.pageNumber = 1
  179. if(item.hasOwnProperty("value")){
  180. this.typeValue = item.value
  181. if(item.number>0){
  182. this.BookList = [
  183. {
  184. skeleton: true
  185. },
  186. {
  187. skeleton: true
  188. },
  189. {
  190. skeleton: true
  191. },
  192. {
  193. skeleton: true
  194. },
  195. {
  196. skeleton: true
  197. }
  198. ]
  199. this.getList()
  200. }else{
  201. this.BookList = []
  202. }
  203. }else{
  204. this.BookList = []
  205. }
  206. $(".list").animate({
  207. scrollTop: 0
  208. }, 200);
  209. },
  210. // 搜索查询
  211. getSearch(){
  212. this.pageNumber = 1
  213. this.BookList = [
  214. {
  215. skeleton: true
  216. },
  217. {
  218. skeleton: true
  219. },
  220. {
  221. skeleton: true
  222. },
  223. {
  224. skeleton: true
  225. },
  226. {
  227. skeleton: true
  228. }
  229. ]
  230. $(".list").animate({
  231. scrollTop: 0
  232. }, 200);
  233. this.getList()
  234. },
  235. SortEvent(type, name, sortName) {
  236. let sort = "";
  237. this.changeList.forEach((item) => {
  238. if (item.name == name) {
  239. // if (!item.sort || item.sort == "up") {
  240. // item.sort = "down";
  241. // sort = "down";
  242. // } else if (item.sort == "down") {
  243. // item.sort = "up";
  244. // sort = "up";
  245. // }
  246. item.sort = type;
  247. sort = type;
  248. } else {
  249. item.sort = "";
  250. }
  251. });
  252. if (sort == "down") {
  253. this.sortType = 1;
  254. } else {
  255. this.sortType = 0;
  256. }
  257. this.sortField = sortName;
  258. $(".list").animate({
  259. scrollTop: 0
  260. }, 200);
  261. this.pageNumber = 1
  262. this.getList()
  263. },
  264. // 查询列表
  265. getList(){
  266. this.loading = true
  267. let MethodName = "/ShopServer/Client/BookshelfQuery/PageQueryMyGoodsList";
  268. let order_column_list = []
  269. if(this.sortField !== ''){
  270. if(this.sortType===1){
  271. order_column_list = [this.sortField + ':desc']
  272. }else if(this.sortType===0){
  273. // 升序不传值
  274. order_column_list = [this.sortField]
  275. }
  276. }
  277. let data = {
  278. goods_name: this.searchNameValue.trim(),
  279. goods_type: this.typeValue,
  280. page_capacity:this.pageSize,
  281. cur_page:this.pageNumber,
  282. order_column_list: order_column_list
  283. }
  284. getLogin(MethodName, data)
  285. .then((res) => {
  286. this.loading = false
  287. if(res.status===1){
  288. if(this.pageNumber===1){
  289. this.BookList = []
  290. this.noMore = false
  291. }
  292. this.BookList = this.BookList.concat(res.goods_list)
  293. if(res.total_page<=this.pageNumber){
  294. this.noMore = true
  295. }
  296. }
  297. })
  298. .catch(() => {
  299. this.loading = false
  300. });
  301. },
  302. load () {
  303. this.pageNumber++
  304. this.getList()
  305. },
  306. // 获取商品个数
  307. getNumber(){
  308. let MethodName = "/ShopServer/Client/BookshelfQuery/GetMyGoodsCount"
  309. getLogin(MethodName, {}).then((res) => {
  310. if(res.status===1){
  311. this.optionList= [
  312. {
  313. label: '全部',
  314. img: 'quanbu',
  315. number: res.count_all,
  316. value: -1
  317. },
  318. {
  319. label: '画刊',
  320. img: 'huakan',
  321. number: 0,
  322. },
  323. {
  324. label: '报纸',
  325. img: 'baozhi',
  326. number: res.count_issue,
  327. value: 2
  328. },
  329. {
  330. label: '练习册',
  331. img: 'xiti',
  332. number: 0
  333. },
  334. {
  335. label: '课程',
  336. img: 'kecheng',
  337. number: res.count_course,
  338. value: 10
  339. }
  340. // ,
  341. // {
  342. // label: '合刊',
  343. // img: 'hekan',
  344. // number: '6'
  345. // }
  346. ]
  347. }
  348. })
  349. .catch(() => {
  350. this.loading = false
  351. });
  352. }
  353. },
  354. //生命周期 - 创建完成(可以访问当前this实例)
  355. created() {
  356. this.getNumber()
  357. this.getList()
  358. },
  359. //生命周期 - 挂载完成(可以访问DOM元素)
  360. mounted() {
  361. },
  362. //生命周期-创建之前
  363. beforeCreated() { },
  364. //生命周期-挂载之前
  365. beforeMount() { },
  366. //生命周期-更新之前
  367. beforUpdate() { },
  368. //生命周期-更新之后
  369. updated() { },
  370. //生命周期-销毁之前
  371. beforeDestory() { },
  372. //生命周期-销毁完成
  373. destoryed() { },
  374. //如果页面有keep-alive缓存功能,这个函数会触发
  375. activated() { }
  376. }
  377. </script>
  378. <style lang="scss" scoped>
  379. /* @import url(); 引入css类 */
  380. .bookShelf {
  381. background: #F7F8FA;
  382. height: calc(100vh - 64px);
  383. .option{
  384. list-style: none;
  385. display: flex;
  386. justify-content: center;
  387. margin: 0;
  388. padding: 0;
  389. background: #17171A;
  390. li{
  391. display: flex;
  392. align-items: center;
  393. border-radius: 30px;
  394. height: 36px;
  395. padding: 7px 20px;
  396. margin: 8px 4px;
  397. cursor: pointer;
  398. &:hover{
  399. background: rgba(255, 255, 255, 0.08);
  400. }
  401. &.active{
  402. background: rgba(255, 255, 255, 0.08);
  403. .icon-img,span,b{
  404. color: rgba(255, 255, 255, 0.9);
  405. }
  406. }
  407. .icon-img{
  408. width: 14px;
  409. height: 14px;
  410. margin: 1px 8px 0 0;
  411. color: rgba(255, 255, 255, 0.5);
  412. }
  413. span{
  414. color: rgba(255, 255, 255, 0.5);
  415. font-size: 14px;
  416. line-height: 22px;
  417. }
  418. b{
  419. font-weight: 400;
  420. font-size: 14px;
  421. line-height: 22px;
  422. color: rgba(255, 255, 255, 0.5);
  423. margin-left: 5px;
  424. }
  425. }
  426. }
  427. .main {
  428. width: 1200px;
  429. margin: 0 auto;
  430. padding: 24px 0 0 0;
  431. .searchChangebox{
  432. display: flex;
  433. justify-content: space-between;
  434. .searchChange-box{
  435. display: flex;
  436. }
  437. .searchChange {
  438. display: flex;
  439. align-items: center;
  440. justify-content: space-between;
  441. padding: 4px 12px;
  442. height: 32px;
  443. margin-right: 16px;
  444. border: 1px solid #E5E6EB;
  445. border-radius: 20px;
  446. &.active{
  447. background: #175DFF;
  448. > span{
  449. color: #FFFFFF;
  450. }
  451. .sort {
  452. > div {
  453. svg{
  454. color: #5E89EF;
  455. &.active{
  456. color: #FFFFFF;
  457. }
  458. }
  459. }
  460. }
  461. }
  462. > span{
  463. font-weight: 400;
  464. font-size: 16px;
  465. line-height: 22px;
  466. color: #000;
  467. margin-right: 4px;
  468. }
  469. .sort {
  470. cursor: pointer;
  471. height: 20px;
  472. > div {
  473. font-size: 0;
  474. svg {
  475. width: 11px;
  476. height: 11px;
  477. color: #C2C2C2;
  478. padding: 3px 2px 2px 2px;
  479. &.icon-down{
  480. height: 9px;
  481. padding: 0 2px 2px 2px;
  482. }
  483. }
  484. }
  485. }
  486. }
  487. .input-search{
  488. width: 220px;
  489. }
  490. }
  491. .show-title{
  492. color: #1F2C5C;
  493. margin: 24px 0 0 0;
  494. font-weight: 500;
  495. font-size: 24px;
  496. line-height: 32px;
  497. b{
  498. margin-left: 16px;
  499. color: #ED5F00;
  500. }
  501. }
  502. .list {
  503. margin-top: 28px;
  504. display: flex;
  505. flex-wrap: wrap;
  506. height: calc(100vh - 256px);
  507. overflow-y: scroll;
  508. &::-webkit-scrollbar {
  509. display: none;
  510. }
  511. > div {
  512. width: 200px;
  513. height: 352px;
  514. border-radius: 8px;
  515. overflow: hidden;
  516. background: #ffffff;
  517. margin-bottom: 24px;
  518. }
  519. .tips{
  520. width: 100%;
  521. text-align: center;
  522. font-size: 12px;
  523. color: #929CA8;
  524. }
  525. }
  526. }
  527. .nodata{
  528. text-align: center;
  529. img{
  530. width: 329px;
  531. }
  532. p{
  533. color: #A8A8A8;
  534. font-size: 14px;
  535. font-weight: 400;
  536. line-height: 22px;
  537. margin: 30px 0;
  538. }
  539. }
  540. }
  541. </style>
  542. <style lang="scss">
  543. .bookShelf{
  544. .searchChangebox{
  545. .input-search{
  546. .el-input__inner{
  547. height: 32px;
  548. color: #1D2129;
  549. background: #F2F3F5;
  550. border: none;
  551. line-height: 32px;
  552. }
  553. .el-input-group__append{
  554. border: none;
  555. width: 32px;
  556. height: 32px;
  557. background: #165DFF;
  558. text-align: center;
  559. cursor: pointer;
  560. &:hover{
  561. background: #4080FF;
  562. }
  563. &:focus{
  564. background: #0E42D2;
  565. }
  566. }
  567. .el-button{
  568. padding: 10px 12px;
  569. color: #ffffff;
  570. }
  571. }
  572. }
  573. }
  574. </style>