pc.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <div class="collection" v-show="hasLoad">
  3. <img class="bg" :src="require('@/assets/images/collect_bg.png')">
  4. <img class="close" @click="$bus.$emit('toggleCollect',false)" :src="require('@/assets/images/icon/close.png')">
  5. <div class="bar1">
  6. <div class="search-con">
  7. <input v-model="key" @keyup.enter="getCollection" placeholder="搜索文物" type="text">
  8. <img class="shugang" :src="require('@/assets/images/icon/shugeng.png')" alt="">
  9. <img @click="getCollection" :src="require('@/assets/images/search_w.png')" alt="">
  10. </div>
  11. </div>
  12. <ul class="typelist">
  13. <li :class="{active:typeActive==''}" @click="typeActive=''">全部</li>
  14. <li :class="{active:item.id==typeActive.id}" @click="typeActive=item" :key="i" v-for="(item,i) in typeLi">{{item.name}}</li>
  15. </ul>
  16. <collection :data="list" @toggle="handleToggle"/>
  17. <div v-if="list.length" class="paging">
  18. <Paging
  19. v-if="paging.total"
  20. style="text-align: center;"
  21. :paging="paging"
  22. @changeCurrent="pageChange"
  23. />
  24. </div>
  25. </div>
  26. </template>
  27. <script>
  28. import collection from '@/components/collection';
  29. import Paging from "@/components/pagination";
  30. let W = window.innerWidth
  31. export default {
  32. components:{
  33. collection,
  34. Paging
  35. },
  36. props:['seachKey'],
  37. data(){
  38. return {
  39. isShowDraw:false,
  40. isShow:true,
  41. key:this.seachKey,
  42. paging: {
  43. pageSize: W>1400?8:6,
  44. pageNum: 1,
  45. total: 0,
  46. showSize: W>1400?8:6,
  47. current: 1
  48. },
  49. typeLi:[
  50. {
  51. id:1,
  52. name:'第一展区 序厅'
  53. },
  54. {
  55. id:2,
  56. name:'第二展区 历史沿革厅'
  57. },
  58. {
  59. id:3,
  60. name:'第三展区 亲切关怀厅'
  61. },
  62. {
  63. id:4,
  64. name:'第四展区 光辉历程厅'
  65. },
  66. {
  67. id:5,
  68. name:'第五展区 将星闪耀厅'
  69. },
  70. {
  71. id:6,
  72. name:'第六展区 丰碑永铸厅'
  73. }
  74. ],
  75. typeActive:'',
  76. list:[],
  77. hasLoad:false
  78. }
  79. },
  80. computed:{
  81. },
  82. watch:{
  83. typeActive(){
  84. this.getCollection()
  85. },
  86. paging:{
  87. deep:true,
  88. handler:function () {
  89. this.getCollection()
  90. }
  91. }
  92. },
  93. methods:{
  94. async getTypeLi(){
  95. let result = await this.$http({
  96. method: 'get',
  97. url: '/api/web/zoneList'
  98. })
  99. if (result.code != 0) {
  100. return this.$showAlert({
  101. tips:'获取展区列表失败'
  102. })
  103. }
  104. this.typeLi = result.data
  105. this.getCollection()
  106. },
  107. async getCollection() {
  108. let params = {
  109. pageNum:this.paging.current,
  110. pageSize: this.paging.pageSize,
  111. searchKey: this.key,
  112. zoneId:this.typeActive&&this.typeActive.id
  113. }
  114. let result = await this.$http({
  115. method: 'post',
  116. data: params,
  117. url: '/api/web/goodsList'
  118. })
  119. if (result.code != 0) {
  120. return this.$showAlert({
  121. tips:'获取文物列表失败'
  122. })
  123. }
  124. this.list = result.data.list
  125. this.paging.total = result.data.total
  126. this.hasLoad = true
  127. },
  128. handleToggle(data){
  129. this.isShow = data
  130. },
  131. pageChange(val){
  132. console.log(val);
  133. this.paging.current = val
  134. }
  135. },
  136. mounted(){
  137. this.getTypeLi()
  138. }
  139. }
  140. </script>
  141. <style lang="less" scoped>
  142. .collection{
  143. margin: 136px auto 0;
  144. width: 80%;
  145. min-height: 74vh;
  146. padding: 40px 80px;
  147. position: relative;
  148. .bg{
  149. width: 100%;
  150. height: 100%;
  151. position: absolute;
  152. top: 0;
  153. left: 0;
  154. z-index: -1;
  155. }
  156. .close{
  157. position: absolute;
  158. bottom: 50px;
  159. right: 50px;
  160. width: 20px;
  161. cursor: pointer;
  162. z-index: 9999;
  163. }
  164. .bar1{
  165. display: flex;
  166. justify-content: space-between;
  167. align-items: center;
  168. position: absolute;
  169. top: -70px;
  170. left: 0;
  171. width: 100%;
  172. text-align: center;
  173. .search-con{
  174. padding: 10px;
  175. background: rgba(0, 0, 0, 0.6);
  176. position: relative;
  177. text-align: center;
  178. display: flex;
  179. align-items: center;
  180. justify-content: space-between;
  181. border-radius: 6px;
  182. margin-top: 10px;
  183. margin: 0 auto;
  184. width: 40%;
  185. >input{
  186. background:none;
  187. outline:none;
  188. border:none;
  189. text-align: center;
  190. width: calc(100% - 20px);
  191. &::placeholder{
  192. color: rgba(255, 255, 255, 0.55);
  193. }
  194. }
  195. .shugang{
  196. width: 1px;
  197. height: 100%;
  198. cursor: auto;
  199. }
  200. >img{
  201. width: 20px;
  202. margin-left: 10px;
  203. cursor: pointer;
  204. }
  205. }
  206. }
  207. .typelist{
  208. display: flex;
  209. align-items: center;
  210. width: 100%;
  211. overflow-x: auto;
  212. overflow: hidden;
  213. >li{
  214. margin-right: 20px;
  215. padding-right: 20px;
  216. font-size: 16px;
  217. line-height: 1;
  218. cursor: pointer;
  219. border-right: 1px solid rgba(255, 255, 255, 0.55);
  220. &:last-of-type{
  221. border-right: none;
  222. padding-right: 0;
  223. margin-right: 0;
  224. }
  225. }
  226. .active{
  227. color: rgba(252, 214, 123, 1);
  228. }
  229. }
  230. .con{
  231. width: 100%;
  232. margin-top: 30px;
  233. max-height: 57vh;
  234. height: 57vh;
  235. overflow-y: auto;
  236. }
  237. .paging{
  238. margin-top: 20px;
  239. }
  240. }
  241. </style>