index.html 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <!DOCTYPE html>
  2. <html lang="ch-zh">
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  4. <meta name="viewport"
  5. content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  6. <link rel="shortcut icon" href="./img/favicon.ico" type="image/x-icon">
  7. <link rel="stylesheet" href="./index.css">
  8. <head>
  9. <title>模型</title>
  10. <script src="./4dage.js"></script>
  11. <style>
  12. html {
  13. overflow: hidden;
  14. }
  15. .outerImg {
  16. transition: all 1s;
  17. opacity: 1;
  18. position: absolute;
  19. z-index: 998;
  20. top: 0;
  21. left: 0;
  22. width: 100%;
  23. height: 100%;
  24. background-color: #1a1b20;
  25. }
  26. .outerImg img {
  27. position: absolute;
  28. width: 100%;
  29. height: 100%;
  30. object-fit: cover;
  31. }
  32. </style>
  33. </head>
  34. <body>
  35. <div class="outerImg">
  36. <img src="./bg.jpg" alt="">
  37. </div>
  38. <div id="ui">
  39. </div>
  40. <script>
  41. const baseUrl = window.location.origin
  42. // const baseUrl = 'https://bengbubwg.4dage.com'
  43. const url = window.location.search
  44. // 获取地址栏参数
  45. const urlParameter = (data) => {
  46. if (data) {
  47. const query = data.substring(data.indexOf("?") + 1);
  48. const arr = query.split("&");
  49. const params = {};
  50. arr.forEach((v) => {
  51. const key = v.substring(0, v.indexOf("="));
  52. const val = v.substring(v.indexOf("=") + 1);
  53. params[key] = val;
  54. });
  55. return params;
  56. } else return {};
  57. };
  58. const urlObj = urlParameter(url)
  59. if (urlObj.id) {
  60. fetch(`${baseUrl}/api/show/goods/detail/${urlObj.id}`)
  61. .then(response => response.json())
  62. .then(res => {
  63. const thumb = res.data.entity.thumb
  64. let modelUrl = ''
  65. res.data.file.forEach(v => {
  66. if (v.type === 'model') {
  67. modelUrl = v.filePath
  68. }
  69. })
  70. // 设置背景封面
  71. document.querySelector('.outerImg img').setAttribute('src', thumb)
  72. // 加载模型
  73. if (urlObj.r) window.autoRotate = true;
  74. fdage.embed(modelUrl, {
  75. width: 800,
  76. height: 600,
  77. autoStart: true,
  78. fullFrame: true,
  79. pagePreset: false
  80. });
  81. // console.log(res)
  82. });
  83. } else alert('id is null!')
  84. </script>
  85. </body>
  86. </html>