quality.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  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. @click="lookInfo(item)"
  34. class="row"
  35. :title="item.name"
  36. v-for="item in data"
  37. :key="item.id"
  38. >
  39. <img v-lazy="`/data/goods/${item.id}.jpg`" alt="" />
  40. <p>{{ item.name }}</p>
  41. </div>
  42. </div>
  43. <!-- 分页 -->
  44. <div class="pagination" v-if="!isMobile">
  45. <el-pagination
  46. layout="prev,pager,next,jumper"
  47. :page-size="8"
  48. :current-page="formData.pageNum"
  49. @current-change="currentChange"
  50. :total="total"
  51. >
  52. </el-pagination>
  53. </div>
  54. </div>
  55. </div>
  56. <!-- 点击之后出来的藏品信息 -->
  57. <div class="infoBox" v-if="infoShow">
  58. <!-- 查看图片 -->
  59. <viewer class="viewerCla" ref="viewer" :images="lookPics">
  60. <img :src="lookPics[0]" alt="" />
  61. </viewer>
  62. <div class="imgBox">
  63. <img
  64. v-lazy="`/data/goods/${goodInfo.id}.jpg`"
  65. alt=""
  66. @click="loogImg(goodInfo.id)"
  67. />
  68. </div>
  69. <div class="txtBox">
  70. <h3>{{ goodInfo.name }}</h3>
  71. <p v-html="goodInfo.txt"></p>
  72. </div>
  73. <!-- 关闭按钮 -->
  74. <i class="el-icon-close" @click="infoShow = false"></i>
  75. </div>
  76. </div>
  77. </template>
  78. <script>
  79. import { qualityData, qualityDataEn } from "./quality.js";
  80. export default {
  81. name: "qualityCom",
  82. components: {},
  83. data() {
  84. //这里存放数据
  85. return {
  86. input: "",
  87. formData: {
  88. pageNum: 1,
  89. pageSize: 8,
  90. },
  91. dataAll: [],
  92. data: [],
  93. total: 0,
  94. // 关于点击藏品出来的页面数据
  95. goodInfo: {},
  96. infoShow: false,
  97. lookPics: [],
  98. };
  99. },
  100. //监听属性 类似于data概念
  101. computed: {},
  102. //监控data中的数据变化
  103. watch: {},
  104. //方法集合
  105. methods: {
  106. // 点击藏品里面的图片查看大图
  107. loogImg(id) {
  108. let dom = this.$refs.viewer.$viewer;
  109. this.lookPics = [`/data/goods/${id}.jpg`];
  110. dom.show();
  111. },
  112. // 点击藏品
  113. lookInfo(item) {
  114. this.goodInfo = item;
  115. this.infoShow = true;
  116. },
  117. // 点击重置
  118. reset() {
  119. this.input = "";
  120. this.pageChange(1);
  121. },
  122. // 分页器方法
  123. currentChange(val) {
  124. this.pageChange(val);
  125. },
  126. // 封装一个控制分页的方法
  127. pageChange(i) {
  128. let temp = this.dataAll.filter((v) => v.name.includes(this.input));
  129. this.total = temp.length;
  130. if (this.isMobile) this.data = [...temp];
  131. else this.data = temp.slice((i - 1) * 8, i * 8);
  132. },
  133. },
  134. //生命周期 - 创建完成(可以访问当前this实例)
  135. created() {},
  136. //生命周期 - 挂载完成(可以访问DOM元素)
  137. mounted() {
  138. // 控制分页器的英文版文字
  139. if (!this.Mylangue) {
  140. // 英文版
  141. this.dataAll = qualityDataEn;
  142. let dom = document.getElementsByClassName("el-pagination__jump");
  143. if (dom && dom[0]) {
  144. dom[0].childNodes[0].nodeValue = "Jump to";
  145. dom[0].childNodes[2].nodeValue = "page";
  146. }
  147. } else this.dataAll = qualityData;
  148. this.pageChange(1);
  149. },
  150. beforeCreate() {}, //生命周期 - 创建之前
  151. beforeMount() {}, //生命周期 - 挂载之前
  152. beforeUpdate() {}, //生命周期 - 更新之前
  153. updated() {}, //生命周期 - 更新之后
  154. beforeDestroy() {}, //生命周期 - 销毁之前
  155. destroyed() {}, //生命周期 - 销毁完成
  156. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  157. };
  158. </script>
  159. <style lang='less' scoped>
  160. ::-webkit-scrollbar-thumb {
  161. outline: 2px solid #165491;
  162. }
  163. .quality {
  164. background-color: rgba(0, 0, 0, 0.5);
  165. position: fixed;
  166. top: 0;
  167. left: 0;
  168. z-index: 9998;
  169. width: 100vw;
  170. height: 100vh;
  171. .main {
  172. padding: 20px;
  173. padding-top: 100px;
  174. border-radius: 3px;
  175. position: absolute;
  176. top: 50%;
  177. left: 50%;
  178. transform: translate(-50%, -50%);
  179. z-index: 9999;
  180. width: 1100px;
  181. height: 800px;
  182. background: url("../../../assets/img/bg.png");
  183. background-size: 100% 100%;
  184. }
  185. .top {
  186. margin-bottom: 20px;
  187. display: flex;
  188. justify-content: space-between;
  189. align-items: center;
  190. color: #165491;
  191. font-weight: 700;
  192. font-size: 22px;
  193. & > i {
  194. cursor: pointer;
  195. font-size: 30px;
  196. }
  197. }
  198. .conten {
  199. padding: 30px 20px;
  200. border-radius: 3px;
  201. width: 100%;
  202. height: 610px;
  203. background-color: rgba(22, 84, 145, 0.5);
  204. .search {
  205. display: flex;
  206. width: 500px;
  207. margin: 0 auto;
  208. /deep/.el-input__icon {
  209. line-height: 30px;
  210. color: #165491;
  211. font-size: 18px;
  212. }
  213. }
  214. .noneInfo {
  215. margin-top: 40px;
  216. display: flex;
  217. justify-content: center;
  218. align-items: center;
  219. color: #fff;
  220. font-size: 30px;
  221. height: 420px;
  222. }
  223. .rowAll {
  224. margin-top: 40px;
  225. display: flex;
  226. flex-wrap: wrap;
  227. height: 420px;
  228. .row {
  229. cursor: pointer;
  230. margin-right: 10px;
  231. margin-bottom: 20px;
  232. overflow: hidden;
  233. border-radius: 5px;
  234. background-color: #fff;
  235. width: 247px;
  236. height: 190px;
  237. & > img {
  238. width: 247px;
  239. height: 150px;
  240. object-fit: cover;
  241. }
  242. & > p {
  243. width: 95%;
  244. background: url("../../../assets/img/come.png") no-repeat right center;
  245. padding: 0 30px 0 10px;
  246. height: 40px;
  247. line-height: 40px;
  248. overflow: hidden;
  249. text-overflow: ellipsis;
  250. white-space: nowrap;
  251. color: #999999;
  252. font-size: 16px;
  253. }
  254. &:nth-of-type(4n) {
  255. margin-right: 0;
  256. }
  257. &:hover {
  258. background-color: #165491;
  259. & > p {
  260. background: url("../../../assets/img/comeAc.png") no-repeat right
  261. center;
  262. color: #fff;
  263. }
  264. }
  265. }
  266. }
  267. .pagination {
  268. margin-top: 20px;
  269. width: 100%;
  270. display: flex;
  271. justify-content: center;
  272. }
  273. }
  274. .infoBox {
  275. z-index: 9999;
  276. position: absolute;
  277. top: 0;
  278. left: 0;
  279. background-color: rgba(0, 0, 0, 0.8);
  280. width: 100%;
  281. height: 100%;
  282. .viewerCla img {
  283. display: none;
  284. }
  285. .imgBox {
  286. padding-top: 20px;
  287. width: 100%;
  288. height: 70vh;
  289. display: flex;
  290. justify-content: center;
  291. align-items: center;
  292. & > img {
  293. cursor: pointer;
  294. max-width: 100%;
  295. max-height: 100%;
  296. }
  297. }
  298. .txtBox {
  299. padding-right: 15px;
  300. color: #fff;
  301. width: 80%;
  302. margin: 20px auto 0;
  303. padding-bottom: 20px;
  304. overflow-y: auto;
  305. height: calc(30vh - 20px);
  306. & > h3 {
  307. font-size: 20px;
  308. font-weight: 700;
  309. }
  310. & > p {
  311. line-height: 24px;
  312. margin-top: 10px;
  313. font-size: 16px;
  314. }
  315. }
  316. .el-icon-close {
  317. cursor: pointer;
  318. position: absolute;
  319. font-size: 30px;
  320. top: 30px;
  321. right: 30px;
  322. color: #fff;
  323. }
  324. }
  325. }
  326. @media only screen and (max-width: 800px) {
  327. .quality {
  328. .main {
  329. top: 60px;
  330. transform: translate(-50%, 0);
  331. max-height: 640px;
  332. width: 100%;
  333. max-width: 350px;
  334. height: calc(100vh - 150px);
  335. background: url("../../../assets/imgM/bg.png");
  336. background-size: 100% 100%;
  337. padding-top: 70px;
  338. }
  339. .top {
  340. margin-bottom: 5px;
  341. }
  342. .conten {
  343. height: calc(100% - 30px);
  344. padding: 10px;
  345. .search {
  346. width: 100%;
  347. button {
  348. width: 56px !important;
  349. padding: 5px 8px !important;
  350. }
  351. }
  352. .noneInfo {
  353. margin-top: 20px;
  354. height: calc(100% - 42px);
  355. }
  356. .rowAll {
  357. justify-content: center;
  358. margin-top: 20px;
  359. height: calc(100% - 42px);
  360. overflow-y: auto;
  361. .row {
  362. margin-right: 0;
  363. margin-bottom: 10px;
  364. }
  365. }
  366. }
  367. .infoBox {
  368. .imgBox{
  369. height: 60vh;
  370. padding-top: 35px;
  371. }
  372. .txtBox{
  373. height: calc(40vh - 20px);
  374. }
  375. .el-icon-close {
  376. right: 10px;
  377. top: 10px;
  378. }
  379. }
  380. }
  381. }
  382. </style>