quality.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <template>
  2. <div class="quality">
  3. <div class="main">
  4. <div class="top">
  5. <h2>{{ Mylangue ? "精品典藏" : "Collections" }}</h2>
  6. <i class="el-icon-close" @click="$emit('close')"></i>
  7. </div>
  8. <div class="conten">
  9. <div class="search" @keyup.enter="pageChange(1)">
  10. <el-input
  11. v-model="input"
  12. :placeholder="Mylangue ? '请输入藏品名称...' : 'Enter title here'"
  13. suffix-icon="el-icon-search"
  14. ></el-input>
  15. <el-button
  16. type="primary"
  17. size="small"
  18. style="margin-left: 15px"
  19. @click="pageChange(1)"
  20. >{{ Mylangue ? "搜索" : "Search" }}</el-button
  21. >
  22. <el-button size="small" @click="reset">{{
  23. Mylangue ? "重置" : "Reset"
  24. }}</el-button>
  25. </div>
  26. <!-- 没有数据 -->
  27. <div class="noneInfo" v-if="data.length === 0">
  28. <p>{{ Mylangue ? "暂无数据..." : "no data..." }}</p>
  29. </div>
  30. <!-- 内容 -->
  31. <div class="rowAll" v-else>
  32. <div
  33. class="row"
  34. :title="item.name"
  35. v-for="item in data"
  36. :key="item.id"
  37. >
  38. <img v-lazy="`/data/goods/${item.id}.jpg`" alt="" />
  39. <p>{{ item.name }}</p>
  40. </div>
  41. </div>
  42. <!-- 分页 -->
  43. <div class="pagination" v-if="!isMobile">
  44. <el-pagination
  45. layout="prev,pager,next,jumper"
  46. :page-size="8"
  47. :current-page="formData.pageNum"
  48. @current-change="currentChange"
  49. :total="total"
  50. >
  51. </el-pagination>
  52. </div>
  53. </div>
  54. </div>
  55. </div>
  56. </template>
  57. <script>
  58. import { qualityData, qualityDataEn } from "./quality";
  59. export default {
  60. name: "quality",
  61. components: {},
  62. data() {
  63. //这里存放数据
  64. return {
  65. input: "",
  66. formData: {
  67. pageNum: 1,
  68. pageSize: 8,
  69. },
  70. dataAll: [],
  71. data: [],
  72. total: 0,
  73. };
  74. },
  75. //监听属性 类似于data概念
  76. computed: {},
  77. //监控data中的数据变化
  78. watch: {},
  79. //方法集合
  80. methods: {
  81. // 点击重置
  82. reset() {
  83. this.input = "";
  84. this.pageChange(1);
  85. },
  86. // 分页器方法
  87. currentChange(val) {
  88. this.pageChange(val);
  89. },
  90. // 封装一个控制分页的方法
  91. pageChange(i) {
  92. let temp = this.dataAll.filter((v) => v.name.includes(this.input));
  93. this.total = temp.length;
  94. if (this.isMobile) this.data = [...temp];
  95. else this.data = temp.slice((i - 1) * 8, i * 8);
  96. },
  97. },
  98. //生命周期 - 创建完成(可以访问当前this实例)
  99. created() {},
  100. //生命周期 - 挂载完成(可以访问DOM元素)
  101. mounted() {
  102. // 控制分页器的英文版文字
  103. if (!this.Mylangue) {
  104. // 英文版
  105. this.dataAll = qualityDataEn;
  106. let dom = document.getElementsByClassName("el-pagination__jump");
  107. if (dom && dom[0]) {
  108. dom[0].childNodes[0].nodeValue = "Jump to";
  109. dom[0].childNodes[2].nodeValue = "page";
  110. }
  111. } else this.dataAll = qualityData;
  112. this.pageChange(1);
  113. },
  114. beforeCreate() {}, //生命周期 - 创建之前
  115. beforeMount() {}, //生命周期 - 挂载之前
  116. beforeUpdate() {}, //生命周期 - 更新之前
  117. updated() {}, //生命周期 - 更新之后
  118. beforeDestroy() {}, //生命周期 - 销毁之前
  119. destroyed() {}, //生命周期 - 销毁完成
  120. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  121. };
  122. </script>
  123. <style lang='less' scoped>
  124. ::-webkit-scrollbar-thumb {
  125. outline: 2px solid #165491;
  126. }
  127. .quality {
  128. background-color: rgba(0, 0, 0, 0.5);
  129. position: fixed;
  130. top: 0;
  131. left: 0;
  132. z-index: 9999;
  133. width: 100vw;
  134. height: 100vh;
  135. .main {
  136. padding: 20px;
  137. padding-top: 100px;
  138. border-radius: 3px;
  139. position: absolute;
  140. top: 50%;
  141. left: 50%;
  142. transform: translate(-50%, -50%);
  143. z-index: 9999;
  144. width: 1100px;
  145. height: 800px;
  146. background: url("../../../assets/img/bg.png");
  147. background-size: 100% 100%;
  148. }
  149. .top {
  150. margin-bottom: 20px;
  151. display: flex;
  152. justify-content: space-between;
  153. align-items: center;
  154. color: #165491;
  155. font-weight: 700;
  156. font-size: 22px;
  157. & > i {
  158. cursor: pointer;
  159. font-size: 30px;
  160. }
  161. }
  162. .conten {
  163. padding: 30px 20px;
  164. border-radius: 3px;
  165. width: 100%;
  166. height: 610px;
  167. background-color: rgba(22, 84, 145, 0.5);
  168. .search {
  169. display: flex;
  170. width: 500px;
  171. margin: 0 auto;
  172. /deep/.el-input__icon {
  173. line-height: 30px;
  174. color: #165491;
  175. font-size: 18px;
  176. }
  177. }
  178. .noneInfo {
  179. margin-top: 40px;
  180. display: flex;
  181. justify-content: center;
  182. align-items: center;
  183. color: #fff;
  184. font-size: 30px;
  185. height: 420px;
  186. }
  187. .rowAll {
  188. margin-top: 40px;
  189. display: flex;
  190. flex-wrap: wrap;
  191. height: 420px;
  192. .row {
  193. cursor: pointer;
  194. margin-right: 10px;
  195. margin-bottom: 20px;
  196. overflow: hidden;
  197. border-radius: 5px;
  198. background-color: #fff;
  199. width: 247px;
  200. height: 190px;
  201. & > img {
  202. width: 247px;
  203. height: 150px;
  204. object-fit: cover;
  205. }
  206. & > p {
  207. width: 95%;
  208. background: url("../../../assets/img/come.png") no-repeat right center;
  209. padding: 0 30px 0 10px;
  210. height: 40px;
  211. line-height: 40px;
  212. overflow: hidden;
  213. text-overflow: ellipsis;
  214. white-space: nowrap;
  215. color: #999999;
  216. font-size: 16px;
  217. }
  218. &:nth-of-type(4n) {
  219. margin-right: 0;
  220. }
  221. &:hover {
  222. background-color: #165491;
  223. & > p {
  224. background: url("../../../assets/img/comeAc.png") no-repeat right
  225. center;
  226. color: #fff;
  227. }
  228. }
  229. }
  230. }
  231. .pagination {
  232. margin-top: 20px;
  233. width: 100%;
  234. display: flex;
  235. justify-content: center;
  236. }
  237. }
  238. }
  239. @media only screen and (max-width: 800px) {
  240. .quality {
  241. .main {
  242. top: 60px;
  243. transform: translate(-50%, 0);
  244. max-height: 640px;
  245. width: 100%;
  246. max-width: 350px;
  247. height: calc(100vh - 150px);
  248. background: url("../../../assets/imgM/bg.png");
  249. background-size: 100% 100%;
  250. padding-top: 70px;
  251. }
  252. .top {
  253. margin-bottom: 5px;
  254. }
  255. .conten {
  256. height: calc(100% - 30px);
  257. padding: 10px;
  258. .search {
  259. width: 100%;
  260. button {
  261. width: 56px !important;
  262. padding: 5px 8px !important;
  263. }
  264. }
  265. .noneInfo {
  266. margin-top: 20px;
  267. height: calc(100% - 42px);
  268. }
  269. .rowAll {
  270. justify-content: center;
  271. margin-top: 20px;
  272. height: calc(100% - 42px);
  273. overflow-y: auto;
  274. .row {
  275. margin-right: 0;
  276. margin-bottom: 10px;
  277. }
  278. }
  279. }
  280. }
  281. }
  282. </style>