index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. <!-- -->
  2. <template>
  3. <div class="Goods" @click.once="music = true">
  4. <audio src="../../assets/media/bacMusic.mp3" loop id="bacMusic"></audio>
  5. <!-- 左侧搜索 -->
  6. <div class="leftTop">
  7. <div class="model">
  8. <div
  9. class="row1"
  10. @click="model = '3D'"
  11. :class="{ active: model === '3D' }"
  12. >
  13. <div class="rowll"></div>
  14. <div class="rowrr">三维文物</div>
  15. </div>
  16. <div
  17. class="row1"
  18. @click="model = '2D'"
  19. :class="{ active: model === '2D' }"
  20. >
  21. <div class="rowll"></div>
  22. <div class="rowrr">二维文物</div>
  23. </div>
  24. </div>
  25. <div class="type">
  26. <div class="typell">类型:</div>
  27. <div class="typerr">
  28. <div
  29. class="row"
  30. @click="genre = item.type"
  31. :class="{ active: item.type === genre }"
  32. v-for="(item, index) in genreList"
  33. :key="index"
  34. >
  35. {{ item.name }}
  36. </div>
  37. </div>
  38. </div>
  39. <div class="inputSearch" @keyup.enter="mySearch">
  40. <input
  41. class="searll"
  42. autofocus
  43. type="text"
  44. v-model="txt"
  45. placeholder="请输入文物名称"
  46. />
  47. <div class="searrr" @click="mySearch">
  48. <img src="../../assets/img/Goods/search.svg" alt="" />
  49. </div>
  50. </div>
  51. </div>
  52. <!-- 右侧图标 -->
  53. <div class="rightTop">
  54. <div
  55. class="row"
  56. @click="rightClisk(item.type)"
  57. v-for="item in rightList"
  58. :key="item.type"
  59. :class="{
  60. active2:
  61. (music && item.type === 2) ||
  62. (like && item.type === 3) ||
  63. (share && item.type === 4),
  64. }"
  65. >
  66. <img
  67. :src="require(`@/assets/img/Goods/inco${item.type}Ac.png`)"
  68. alt=""
  69. v-if="music && item.type === 2"
  70. />
  71. <img
  72. :src="require(`@/assets/img/Goods/inco${item.type}Ac.png`)"
  73. alt=""
  74. v-else-if="like && item.type === 3"
  75. />
  76. <img
  77. :src="require(`@/assets/img/Goods/inco${item.type}Ac.png`)"
  78. alt=""
  79. v-else-if="share && item.type === 4"
  80. />
  81. <img
  82. :src="require(`@/assets/img/Goods/inco${item.type}.png`)"
  83. alt=""
  84. v-else
  85. />
  86. <transition name="likeAddAnimate">
  87. <div class="likeMove" v-show="like && item.type === 3">+ 1</div>
  88. </transition>
  89. <p>
  90. {{ item.name }}
  91. </p>
  92. </div>
  93. </div>
  94. <div class="nullSerach" v-if="0">
  95. <div>
  96. <img src="../../assets/img/Goods/nullSearch.png" alt="" />
  97. <p>暂时没有数据</p>
  98. <p>请试一下其他关键字</p>
  99. </div>
  100. </div>
  101. <template v-else>
  102. <Three ref="ThreeRef" v-if="model === '3D'" />
  103. <Tow v-else />
  104. </template>
  105. <!-- 分享页面 -->
  106. <div class="shareBox" :class="{ shareBoxShow: share }">
  107. <div class="shareMain">
  108. <div class="close" @click="share = false"></div>
  109. <h3>分享</h3>
  110. <p>
  111. 请使用手机扫描二维码或
  112. <br />
  113. 复制分享链接
  114. </p>
  115. <img src="../../assets/img/Goods/Rcode.jpg" alt="" />
  116. <div class="btnn" @click="copyPcTxt">复制分享链接</div>
  117. </div>
  118. </div>
  119. </div>
  120. </template>
  121. <script>
  122. import Three from "./components/Three.vue";
  123. import Tow from "./components/Tow.vue";
  124. export default {
  125. name: "Goods",
  126. //import引入的组件需要注入到对象中才能使用
  127. components: { Three, Tow },
  128. data() {
  129. //这里存放数据
  130. return {
  131. model: "3D",
  132. genre: "all",
  133. txt: "",
  134. genreList: [
  135. { name: "全部", type: "all" },
  136. { name: "手稿", type: "all1" },
  137. { name: "书刊", type: "all2" },
  138. { name: "用具", type: "all3" },
  139. { name: "服装", type: "all4" },
  140. ],
  141. rightList: [
  142. { name: "首页", type: 1 },
  143. { name: "声音", type: 2 },
  144. { name: "点赞", type: 3 },
  145. { name: "分享", type: 4 },
  146. ],
  147. music: false,
  148. like: false,
  149. share: false,
  150. };
  151. },
  152. //监听属性 类似于data概念
  153. computed: {},
  154. //监控data中的数据变化
  155. watch: {
  156. share(val) {
  157. this.$refs.ThreeRef.moveShareCut(val);
  158. },
  159. music(val) {
  160. let dom = document.querySelector("#bacMusic");
  161. if (val) dom.play();
  162. else dom.pause();
  163. },
  164. model() {
  165. this.genre = "all";
  166. this.txt = "";
  167. },
  168. },
  169. //方法集合
  170. methods: {
  171. mySearch() {},
  172. rightClisk(type) {
  173. if (type === 1) this.$router.replace("/");
  174. if (type === 2) this.music = !this.music;
  175. if (type === 3) {
  176. if (this.like) return;
  177. this.like = true;
  178. setTimeout(() => {
  179. this.like = false;
  180. }, 2000);
  181. }
  182. if (type === 4) this.share = true;
  183. },
  184. //点击复制链接
  185. copyPcTxt() {
  186. // 存储传递过来的数据
  187. let OrderNumber = window.location.origin;
  188. // 创建一个input 元素
  189. // createElement() 方法通过指定名称创建一个元素
  190. let newInput = document.createElement("input");
  191. // 讲存储的数据赋值给input的value值
  192. newInput.value = OrderNumber;
  193. // appendChild() 方法向节点添加最后一个子节点。
  194. document.body.appendChild(newInput);
  195. // 选中input元素中的文本
  196. // select() 方法用于选择该元素中的文本。
  197. newInput.select();
  198. // 执行浏览器复制命令
  199. // execCommand方法是执行一个对当前文档,当前选择或者给出范围的命令
  200. document.execCommand("Copy");
  201. // 清空输入框
  202. newInput.remove();
  203. alert("复制成功");
  204. },
  205. },
  206. //生命周期 - 创建完成(可以访问当前this实例)
  207. created() {},
  208. //生命周期 - 挂载完成(可以访问DOM元素)
  209. mounted() {},
  210. beforeCreate() {}, //生命周期 - 创建之前
  211. beforeMount() {}, //生命周期 - 挂载之前
  212. beforeUpdate() {}, //生命周期 - 更新之前
  213. updated() {}, //生命周期 - 更新之后
  214. beforeDestroy() {}, //生命周期 - 销毁之前
  215. destroyed() {}, //生命周期 - 销毁完成
  216. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  217. };
  218. </script>
  219. <style lang='less' scoped>
  220. .likeAddAnimate-enter-active,
  221. .likeAddAnimate-leave-active {
  222. transition: all 2s ease;
  223. }
  224. .likeAddAnimate-enter,
  225. .likeAddAnimate-leave {
  226. transform: translateY(0) scale(0);
  227. opacity: 0;
  228. }
  229. .likeAddAnimate-enter-to,
  230. .likeAddAnimate-leave-to {
  231. transform: translateY(-30px) scale(1.2);
  232. opacity: 1;
  233. }
  234. .Goods {
  235. padding-top: 140px;
  236. width: 100%;
  237. height: 100%;
  238. background-image: url("../../assets/img/Goods/GoodsBac.png");
  239. background-size: 100% 100%;
  240. position: relative;
  241. .leftTop {
  242. position: absolute;
  243. top: 42px;
  244. left: 160px;
  245. height: 40px;
  246. display: flex;
  247. .model {
  248. color: #fff;
  249. width: 260px;
  250. height: 40px;
  251. border-radius: 20px;
  252. background-color: #930909;
  253. display: flex;
  254. justify-content: space-between;
  255. padding: 0 22px;
  256. margin-right: 50px;
  257. .row1 {
  258. cursor: pointer;
  259. display: flex;
  260. justify-content: center;
  261. align-items: center;
  262. font-size: 16px;
  263. .rowll {
  264. margin-right: 6px;
  265. width: 24px;
  266. height: 24px;
  267. border-radius: 50%;
  268. border: 1px solid #d8b275;
  269. position: relative;
  270. }
  271. .rowrr {
  272. padding-bottom: 2px;
  273. }
  274. }
  275. .active {
  276. color: #d8b275;
  277. .rowll {
  278. &::after {
  279. content: "";
  280. position: absolute;
  281. top: 50%;
  282. left: 50%;
  283. transform: translate(-50%, -50%);
  284. border-radius: 50%;
  285. width: 14px;
  286. height: 14px;
  287. background-color: #d8b275;
  288. }
  289. }
  290. }
  291. }
  292. .type {
  293. display: flex;
  294. font-size: 16px;
  295. color: #fff;
  296. background-color: #930909;
  297. height: 40px;
  298. border-radius: 20px;
  299. padding: 0 20px;
  300. margin-right: 50px;
  301. .typell {
  302. width: 50px;
  303. line-height: 38px;
  304. }
  305. .typerr {
  306. display: flex;
  307. align-items: center;
  308. padding-bottom: 4px;
  309. .row {
  310. cursor: pointer;
  311. margin: 0 10px;
  312. }
  313. .active {
  314. color: #d8b275;
  315. position: relative;
  316. &::after {
  317. content: "";
  318. position: absolute;
  319. bottom: -4px;
  320. left: 0;
  321. width: 100%;
  322. height: 2px;
  323. background-color: #d8b275;
  324. }
  325. }
  326. }
  327. }
  328. .inputSearch {
  329. overflow: hidden;
  330. display: flex;
  331. font-size: 16px;
  332. color: #fff;
  333. width: 260px;
  334. height: 40px;
  335. border-radius: 20px;
  336. display: flex;
  337. .searll {
  338. width: 214px;
  339. height: 40px;
  340. border: none;
  341. background-color: #fff;
  342. padding: 0 10px 0 20px;
  343. &:focus {
  344. outline: none;
  345. }
  346. }
  347. .searrr {
  348. cursor: pointer;
  349. background-color: #930909;
  350. width: 46px;
  351. display: flex;
  352. justify-content: center;
  353. align-items: center;
  354. padding-right: 4px;
  355. img {
  356. width: 24px;
  357. height: 24px;
  358. }
  359. }
  360. }
  361. }
  362. .rightTop {
  363. position: absolute;
  364. top: 32px;
  365. right: 160px;
  366. height: 60px;
  367. display: flex;
  368. .row {
  369. position: relative;
  370. cursor: pointer;
  371. width: 50px;
  372. text-align: center;
  373. margin-left: 24px;
  374. & > img {
  375. width: 50px;
  376. }
  377. .likeMove {
  378. color: #930909;
  379. position: absolute;
  380. top: 10px;
  381. width: 100%;
  382. text-align: center;
  383. }
  384. }
  385. .active2 {
  386. color: #930909;
  387. }
  388. }
  389. .nullSerach {
  390. width: 100%;
  391. height: 90%;
  392. display: flex;
  393. justify-content: center;
  394. align-items: center;
  395. & > div {
  396. width: 240px;
  397. & > img {
  398. width: 100%;
  399. }
  400. & > p {
  401. text-align: center;
  402. color: #666666;
  403. font-size: 24px;
  404. margin: 10px 0;
  405. }
  406. }
  407. }
  408. .shareBox {
  409. z-index: 11;
  410. position: absolute;
  411. top: 0;
  412. left: 0;
  413. width: 100%;
  414. height: 100%;
  415. opacity: 0;
  416. pointer-events: none;
  417. backdrop-filter: blur(4px);
  418. transition: opacity 0.5s;
  419. .shareMain {
  420. padding: 40px 30px 0;
  421. position: absolute;
  422. top: 50%;
  423. left: 50%;
  424. transform: translate(-50%, -50%);
  425. width: 450px;
  426. height: 650px;
  427. background-image: url("../../assets/img/Goods/shareBac.png");
  428. background-size: 100% 100%;
  429. text-align: center;
  430. .close {
  431. width: 48px;
  432. height: 48px;
  433. cursor: pointer;
  434. position: absolute;
  435. right: -24px;
  436. top: -24px;
  437. background-image: url("../../assets/img/Goods/shareClose.png");
  438. background-size: 100% 100%;
  439. }
  440. h3 {
  441. text-align: left;
  442. color: #d8b275;
  443. font-size: 24px;
  444. margin-bottom: 50px;
  445. }
  446. p {
  447. font-size: 20px;
  448. color: #ffffff;
  449. margin-bottom: 40px;
  450. }
  451. img {
  452. width: 240px;
  453. margin-bottom: 50px;
  454. }
  455. .btnn {
  456. cursor: pointer;
  457. width: 280px;
  458. margin: 0 auto;
  459. height: 60px;
  460. border-radius: 30px;
  461. border: 2px solid #d8b275;
  462. line-height: 58px;
  463. font-size: 20px;
  464. color: #ffffff;
  465. }
  466. }
  467. }
  468. .shareBoxShow {
  469. opacity: 1;
  470. pointer-events: auto;
  471. }
  472. }
  473. </style>