showingStand.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <div class="w-screen pad:w-full">
  3. <big-title>{{lang===langType.cn?"关于我们":getAbbrText("关于我们")}}</big-title>
  4. <div class="container mx-auto showing">
  5. <a
  6. v-for="(item,i) in chunkItems"
  7. :class="`chunk imgBox chunk${(i+1)}`"
  8. :key="item.id"
  9. :href="item.href"
  10. >
  11. <!-- 实时管理(物联网) -->
  12. <img :src="item.img" alt="imgNotFound">
  13. <p class="chunkText">
  14. <span class="title">{{lang===langType.cn?item.title:getAbbrText(item.title)}}</span>
  15. <span class="subTitle">{{lang===langType.cn?item.subTitle:getAbbrText(item.subTitle)}}</span>
  16. <span class="chunkMore">
  17. {{lang===langType.cn?"了解更多":getAbbrText("了解更多")}}
  18. </span>
  19. </p>
  20. </a>
  21. </div>
  22. </div>
  23. </template>
  24. <script>
  25. import langMap from "~/map/langMap";
  26. import {showingStandData} from "@/map/showingData";
  27. export default {
  28. name: "showingStand",
  29. props: {
  30. lang:{
  31. default: langMap.lang.cn
  32. },
  33. },
  34. data(){
  35. return {
  36. langType: langMap.lang,
  37. // chunk 1-7
  38. chunkItems:showingStandData,
  39. baseWidth: 425,
  40. baseHeight: 350,
  41. }
  42. },
  43. directives: {
  44. // 为元素设定比例
  45. ratio: {
  46. bind: function (el, binding) {
  47. // 如果没有传入比例值,则默认为1
  48. let ratio = binding.value || 1;
  49. let width = el.offsetWidth;
  50. let finalHeight = width * ratio;
  51. // 防止高度过低导致影响美观
  52. if (width < 1000) {
  53. finalHeight+= 50;
  54. }
  55. el.style.height = finalHeight + 'px'
  56. }
  57. }
  58. },
  59. methods: {
  60. getLangText(str) {
  61. return langMap.getText(this.lang, str);
  62. },
  63. getAbbrText(str) {
  64. return langMap.getAbbrText(this.lang, str);
  65. },
  66. }
  67. }
  68. </script>
  69. <style scoped>
  70. .showing{
  71. display: flex;
  72. flex-direction: column;
  73. align-items: center;
  74. }
  75. .showing .chunk {
  76. box-shadow: 1px 1px 3px black;
  77. /*box-sizing: border-box;*/
  78. /*padding:5px;*/
  79. position: relative;
  80. overflow: hidden;
  81. cursor: pointer;
  82. width: 96%;
  83. aspect-ratio:425/350;
  84. margin-bottom: 10px;
  85. }
  86. .showing .chunk:hover > img{
  87. left: -20px;
  88. top: -20px;
  89. max-width: calc(100% + 40px);
  90. width: calc(100% + 40px);
  91. height: calc(100% + 40px);
  92. }
  93. .showing .chunk .chunkText{
  94. display: block;
  95. position: absolute;
  96. width: 100%;
  97. height: 150px;
  98. bottom: -50px;
  99. /*background: #000;*/
  100. color: white;
  101. transition: all .5s;
  102. padding: 0 15px;
  103. background-image: linear-gradient(rgba(0,0,0,0) 0,rgba(0,0,0,0.5) 75% );
  104. }
  105. .showing .chunk:hover .chunkText{
  106. bottom: 0;
  107. background-image: linear-gradient(rgba(0,0,0,0) 0,rgba(0,0,0,0.66) 66% 15% 80% );
  108. }
  109. .showing .chunk .chunkText .title{
  110. height: 40px;
  111. font-size: 1.5em;
  112. display: flex;
  113. /*justify-content: center;*/
  114. align-items: center;
  115. }
  116. .showing .chunk .chunkText .subTitle{
  117. padding: 5px 0;
  118. min-height: 35px;
  119. max-height: 80px;
  120. font-size: 1.2em;
  121. }
  122. .showing .chunk .chunkText .chunkMore{
  123. margin-top: 20px;
  124. height: 30px;
  125. font-size: 0.9em;
  126. color: #ff6e3f;
  127. }
  128. .showing .chunk .chunkText .chunkMore:hover{
  129. color: orangered;
  130. }
  131. .showing .chunk .chunkText > *{
  132. display: block;
  133. }
  134. .showing .chunk1 {
  135. grid-area: a;
  136. }
  137. .showing .chunk2{
  138. grid-area: b;
  139. }
  140. .showing .chunk3{
  141. grid-area: c;
  142. aspect-ratio:425/710;
  143. }
  144. .showing .chunk4{
  145. grid-area: d;
  146. aspect-ratio:870/340;
  147. }
  148. .showing .chunk5{
  149. grid-area: e;
  150. }
  151. .showing .chunk6{
  152. grid-area: f;
  153. }
  154. .showing .chunk7{
  155. grid-area: g;
  156. }
  157. @media screen and (min-width: 1024px) {
  158. /* 其他针对移动设备的样式 */
  159. .showing{
  160. display: grid;
  161. grid-template-columns: repeat(3, 425px);
  162. grid-template-rows: repeat(3, 350px);
  163. grid-template-areas:
  164. 'a b c'
  165. 'd d c'
  166. 'e f g';
  167. grid-gap: 20px;
  168. }
  169. .showing .chunk {
  170. box-shadow: 1px 1px 3px black;
  171. box-sizing: border-box;
  172. /*padding:5px;*/
  173. position: relative;
  174. overflow: hidden;
  175. cursor: pointer;
  176. aspect-ratio:425/350;
  177. margin-bottom: 0;
  178. width: 100%;
  179. }
  180. .showing .chunk:hover{
  181. box-shadow: 1px 1px 3px deepskyblue;
  182. }
  183. .showing .chunk3{
  184. grid-area: c;
  185. aspect-ratio:425/710;
  186. }
  187. .showing .chunk4{
  188. grid-area: d;
  189. aspect-ratio:870/340;
  190. }
  191. }
  192. </style>