antique.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. <template>
  2. <div class="antique" :class="{ full: smBtn }">
  3. <!-- 毛玻璃 -->
  4. <div class="meanPageMBL"></div>
  5. <div class="main">
  6. <div class="top">
  7. <div class="row">类型:</div>
  8. <div
  9. class="row"
  10. v-for="item in topData"
  11. @click="cutType(item.type)"
  12. :key="item.name"
  13. :class="{ active: item.type === formData.type }"
  14. >
  15. {{ item.name }}
  16. </div>
  17. <div class="search" @keyup.enter="mySearch">
  18. <el-input
  19. prefix-icon="el-icon-search"
  20. type="text"
  21. placeholder="搜索"
  22. v-model="formData.searchKey"
  23. maxlength="10"
  24. />
  25. <span class="btnn" @click="mySearch"></span>
  26. </div>
  27. </div>
  28. <!-- 没有数据的时候 -->
  29. <div class="hint" v-if="myArr.length === 0">
  30. <img src="@/assets/img/serachNull.png" alt="" />
  31. <p>暂时没有数据</p>
  32. <p>请试一下其他关键字</p>
  33. </div>
  34. <!-- 渲染的内容 -->
  35. <div class="infoBox" v-else>
  36. <div
  37. @click="lookInfo(item)"
  38. class="infoRow"
  39. :title="item.name"
  40. v-for="item in myArr"
  41. :key="item.id"
  42. >
  43. <img :src="baseURL + item.thumb" alt="" />
  44. <p>{{ item.name }}</p>
  45. </div>
  46. </div>
  47. <!-- 分页 -->
  48. <div class="paging" v-show="myArr.length !== 0">
  49. <el-pagination
  50. layout="prev,pager,next,jumper"
  51. :total="total"
  52. :current-page="formData.pageNum"
  53. @current-change="currentChange"
  54. @size-change="sizeChange"
  55. >
  56. </el-pagination>
  57. </div>
  58. <!-- 关闭按钮 -->
  59. <div class="close el-icon-close" @click="$emit('close')"></div>
  60. </div>
  61. <!-- 模型和图片 -->
  62. <div class="model" v-if="modelShow">
  63. <div class="ifrCon" ref="ifrCon">
  64. <img :src="baseURL + txtInfo.thumb" alt="" v-if="txtInfo.type==='img'">
  65. <iframe :src="mySrc" frameborder="0" v-else></iframe>
  66. <!-- 全屏按钮 -->
  67. <div class="full" @click="screen" v-if="txtInfo.type==='model'">
  68. <img src="@/assets/img/tab3FullX.png" alt="" v-if="fullscreen" />
  69. <img src="@/assets/img/tab3Full.png" alt="" v-else />
  70. </div>
  71. </div>
  72. <div class="rightTxt">
  73. <h3>{{ txtInfo.name }}</h3>
  74. <p>{{txtInfo.description}}</p>
  75. </div>
  76. <!-- 返回按钮 -->
  77. <div class="close el-icon-arrow-left" @click="modelShow = false"></div>
  78. </div>
  79. </div>
  80. </template>
  81. <script>
  82. import axios from "@/utils/request";
  83. import { goodList } from "@/utils/api";
  84. export default {
  85. name: "antique",
  86. props: {
  87. smBtn: {
  88. type: Boolean,
  89. default: false,
  90. },
  91. },
  92. components: {},
  93. data() {
  94. //这里存放数据
  95. return {
  96. total: 0,
  97. baseURL: "",
  98. topData: [
  99. { name: "全部", type: "" },
  100. { name: "精品图片", type: "img" },
  101. { name: "三维模型", type: "model" },
  102. ],
  103. formData: {
  104. pageNum: 1,
  105. pageSize: 10,
  106. searchKey: "",
  107. type: "",
  108. },
  109. myArr: [],
  110. // 有关三维模型的数据
  111. mySrc: "",
  112. modelShow: false,
  113. fullscreen: false,
  114. txtInfo: {},
  115. };
  116. },
  117. //监听属性 类似于data概念
  118. computed: {},
  119. //监控data中的数据变化
  120. watch: {},
  121. //方法集合
  122. methods: {
  123. // 点击模型全屏
  124. screen() {
  125. const element = this.$refs.ifrCon; // 获取容器
  126. if (this.fullscreen) {
  127. // 如果已经全屏了就退出全屏
  128. if (document.exitFullscreen) {
  129. document.exitFullscreen();
  130. } else if (document.webkitCancelFullScreen) {
  131. document.webkitCancelFullScreen();
  132. } else if (document.mozCancelFullScreen) {
  133. document.mozCancelFullScreen();
  134. } else if (document.msExitFullscreen) {
  135. document.msExitFullscreen();
  136. }
  137. } else {
  138. // 如果不是全屏就变成全屏
  139. if (element.requestFullscreen) {
  140. element.requestFullscreen();
  141. } else if (element.webkitRequestFullScreen) {
  142. element.webkitRequestFullScreen();
  143. } else if (element.mozRequestFullScreen) {
  144. element.mozRequestFullScreen();
  145. } else if (element.msRequestFullscreen) {
  146. // IE11
  147. element.msRequestFullscreen();
  148. }
  149. }
  150. this.fullscreen = !this.fullscreen;
  151. },
  152. lookInfo(item) {
  153. this.txtInfo = item;
  154. // 三维模型
  155. this.mySrc ="4dage/Model.html?m=" + item.filePath;
  156. this.modelShow = true;
  157. },
  158. mySearch() {
  159. this.formData.pageNum = 1;
  160. this.goodList(this.formData);
  161. },
  162. cutType(type) {
  163. this.formData.type = type;
  164. this.formData.pageNum = 1;
  165. this.goodList(this.formData);
  166. },
  167. // 分页器方法
  168. currentChange(val) {
  169. // console.log('当前页改变了', val)
  170. this.formData.pageNum = val;
  171. this.goodList(this.formData);
  172. },
  173. sizeChange(val) {
  174. // console.log('条数改变了', val)
  175. this.formData.pageNum = 1;
  176. this.formData.pageSize = val;
  177. this.goodList(this.formData);
  178. },
  179. // 封装获取列表函数
  180. async goodList(data) {
  181. const res = await goodList(data);
  182. this.total = res.data.total;
  183. this.myArr = res.data.records;
  184. },
  185. },
  186. //生命周期 - 创建完成(可以访问当前this实例)
  187. created() {
  188. // 获取服务器前缀地址
  189. this.baseURL = axios.defaults.baseURL;
  190. this.goodList(this.formData);
  191. // 设置一个全局变量控制空格建的监听
  192. window.myKeyBlank =true
  193. },
  194. //生命周期 - 挂载完成(可以访问DOM元素)
  195. mounted() {},
  196. beforeCreate() {}, //生命周期 - 创建之前
  197. beforeMount() {}, //生命周期 - 挂载之前
  198. beforeUpdate() {}, //生命周期 - 更新之前
  199. updated() {}, //生命周期 - 更新之后
  200. beforeDestroy() {
  201. window.myKeyBlank =false
  202. }, //生命周期 - 销毁之前
  203. destroyed() {}, //生命周期 - 销毁完成
  204. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  205. };
  206. </script>
  207. <style lang='less' scoped>
  208. .antique {
  209. transition: width 0.3s;
  210. color: #fff6d2;
  211. position: fixed;
  212. top: 0;
  213. left: 0;
  214. z-index: 998;
  215. width: calc(100% - 200px);
  216. height: 100%;
  217. // m毛玻璃
  218. .meanPageMBL {
  219. position: absolute;
  220. left: 0;
  221. top: 0;
  222. width: 100%;
  223. height: 100%;
  224. background: rgba(161, 101, 59, 0.8);
  225. backdrop-filter: blur(4px);
  226. z-index: -1;
  227. }
  228. .close {
  229. color: #cc946d;
  230. font-size: 34px;
  231. cursor: pointer;
  232. position: absolute;
  233. right: 40px;
  234. top: 55px;
  235. }
  236. .main {
  237. color: #774926;
  238. padding: 55px 26px 0;
  239. position: absolute;
  240. top: 50%;
  241. left: 50%;
  242. transform: translate(-50%, -50%);
  243. width: 1200px;
  244. height: 700px;
  245. background: url("../../../assets/img/goodBg.png");
  246. background-size: 100% 100%;
  247. .top {
  248. height: 36px;
  249. display: flex;
  250. align-items: center;
  251. font-size: 16px;
  252. .row {
  253. cursor: pointer;
  254. height: 36px;
  255. line-height: 36px;
  256. padding: 0 20px;
  257. border-radius: 18px;
  258. margin-right: 15px;
  259. &:nth-of-type(1) {
  260. pointer-events: none;
  261. margin-right: 0;
  262. }
  263. }
  264. .active {
  265. background-color: #cc946d;
  266. color: #fff6d2;
  267. }
  268. .search {
  269. position: relative;
  270. /deep/.el-icon-search {
  271. color: #774926;
  272. font-size: 20px;
  273. margin-top: -1px;
  274. }
  275. .btnn {
  276. z-index: 10;
  277. cursor: pointer;
  278. position: absolute;
  279. left: 0;
  280. top: 0;
  281. height: 36px;
  282. width: 36px;
  283. border-radius: 50%;
  284. background-color: transparent;
  285. }
  286. }
  287. }
  288. .hint {
  289. text-align: center;
  290. margin-top: 100px;
  291. width: 100%;
  292. height: 380px;
  293. & > p {
  294. color: #cc946d;
  295. font-size: 20px;
  296. margin-top: 20px;
  297. }
  298. }
  299. .infoBox {
  300. display: flex;
  301. flex-wrap: wrap;
  302. margin-top: 55px;
  303. width: 100%;
  304. height: 410px;
  305. .infoRow {
  306. margin-right: 12px;
  307. margin-bottom: 26px;
  308. cursor: pointer;
  309. overflow: hidden;
  310. width: 220px;
  311. height: 192px;
  312. border-radius: 6px;
  313. background-color: #fff;
  314. & > img {
  315. width: 100%;
  316. height: 154px;
  317. object-fit: cover;
  318. }
  319. & > p {
  320. padding: 0 10px;
  321. width: 100%;
  322. height: 38px;
  323. line-height: 38px;
  324. font-size: 14px;
  325. text-align: center;
  326. overflow: hidden;
  327. text-overflow: ellipsis;
  328. white-space: nowrap;
  329. }
  330. &:nth-of-type(5n) {
  331. margin-right: 0;
  332. }
  333. &:hover {
  334. & > p {
  335. color: #cc946d;
  336. }
  337. }
  338. }
  339. }
  340. .paging {
  341. position: absolute;
  342. bottom: 70px;
  343. left: 0;
  344. width: 100%;
  345. display: flex;
  346. justify-content: center;
  347. }
  348. }
  349. // 模型
  350. .model {
  351. color: #774926;
  352. padding: 110px 26px 0;
  353. position: absolute;
  354. top: 50%;
  355. left: 50%;
  356. transform: translate(-50%, -50%);
  357. width: 1200px;
  358. height: 700px;
  359. background: url("../../../assets/img/goodBg.png");
  360. background-size: 100% 100%;
  361. display: flex;
  362. .ifrCon {
  363. position: relative;
  364. width: 558px;
  365. height: 478px;
  366. iframe {
  367. width: 100%;
  368. height: 100%;
  369. }
  370. &>img{
  371. max-width: 100%;
  372. max-height: 100%;
  373. position: absolute;
  374. left: 50%;
  375. top: 50%;
  376. transform: translate(-50%,-50%);
  377. }
  378. .full {
  379. width: 30px;
  380. height: 30px;
  381. cursor: pointer;
  382. position: absolute;
  383. right: 10px;
  384. bottom: 10px;
  385. color: #fff;
  386. & > img {
  387. width: 30px;
  388. height: 30px;
  389. }
  390. }
  391. }
  392. .rightTxt {
  393. padding-right: 20px;
  394. height: 478px;
  395. flex: 1;
  396. margin-left: 110px;
  397. display: flex;
  398. flex-direction: column;
  399. justify-content: center;
  400. align-items: center;
  401. &>h3{
  402. width: 100%;
  403. word-break:break-all;
  404. font-size: 30px;
  405. margin-bottom: 30px;
  406. }
  407. &>P{
  408. width: 100%;
  409. word-break:break-all;
  410. color: #CC946D;
  411. font-size: 14px;
  412. }
  413. }
  414. }
  415. }
  416. .full {
  417. width: 100%;
  418. }
  419. </style>