PaintingDetail.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. <template>
  2. <div class="hotspot-detail-2">
  3. <div
  4. class="painting-wrap"
  5. :style="{
  6. clipPath: `rect(0 100% ${AnimationProgress.value}% 0)`,
  7. }"
  8. >
  9. <img
  10. class="painting-border"
  11. src="@/assets/images/painting-border.png"
  12. alt=""
  13. draggable="false"
  14. >
  15. <div
  16. ref="paintingWrap2El"
  17. class="painting-wrap-2"
  18. >
  19. <img
  20. ref="paintingEl"
  21. class="painting"
  22. :class="{
  23. oversize: isOversize,
  24. }"
  25. :src="props.thumb"
  26. alt=""
  27. draggable="false"
  28. @click="showBigPainting"
  29. >
  30. </div>
  31. <Transition name="fade-out">
  32. <img
  33. v-show="isAnimating"
  34. class="bottom-border-for-animation"
  35. :style="{
  36. bottom: `${100 - AnimationProgress.value}%`,
  37. }"
  38. src="@/assets/images/painting-border-bottom.png"
  39. alt=""
  40. draggable="false"
  41. >
  42. </Transition>
  43. </div>
  44. <div
  45. ref="descTextEl"
  46. class="desc-text"
  47. :style="{
  48. opacity: isAnimating ? AnimationProgress.value / 100 : 1,
  49. }"
  50. >
  51. <h1>{{ props.title }}</h1>
  52. <p class="subtitle">
  53. {{ `${props.author} (${props.age})` }}
  54. </p>
  55. <p class="subtitle">
  56. {{ props.subtitle }}
  57. </p>
  58. <p class="subtitle">
  59. {{ props.location }}
  60. </p>
  61. <h2 v-if="paintingDesc">
  62. 作品简介:
  63. </h2>
  64. <div class="normal-text">
  65. {{ paintingDesc }}
  66. </div>
  67. <h2 v-if="authorDesc">
  68. 作者简介:
  69. </h2>
  70. <div class="normal-text">
  71. {{ authorDesc }}
  72. </div>
  73. </div>
  74. <OperationTip
  75. v-if="needOperationTip"
  76. class="operation-tip"
  77. text=""
  78. :is-show="isShowOperationTip"
  79. />
  80. <BtnBack
  81. v-if="canClose"
  82. @click="emit('close')"
  83. />
  84. </div>
  85. </template>
  86. <script setup>
  87. import { ref, computed, watch, onMounted, inject, onUnmounted } from "vue"
  88. import { useRoute, useRouter } from "vue-router"
  89. import { useStore } from "vuex"
  90. import useSizeAdapt from "@/useFunctions/useSizeAdapt"
  91. import TWEEN from '@tweenjs/tween.js'
  92. import { api as viewerApi } from 'v-viewer'
  93. const route = useRoute()
  94. const router = useRouter()
  95. const store = useStore()
  96. const $env = inject('$env')
  97. const emit = defineEmits(['close'])
  98. const {
  99. windowSizeInCssForRef,
  100. windowSizeWhenDesignForRef,
  101. } = useSizeAdapt()
  102. const props = defineProps({
  103. thumb: {
  104. type: String,
  105. required: true,
  106. },
  107. bigPainting: {
  108. type: String,
  109. required: true,
  110. },
  111. title: {
  112. type: String,
  113. required: true,
  114. },
  115. author: {
  116. type: String,
  117. required: true,
  118. },
  119. age: {
  120. type: String,
  121. required: true,
  122. },
  123. location: {
  124. type: String,
  125. required: true,
  126. },
  127. paintingDesc: {
  128. type: String,
  129. default: '',
  130. },
  131. authorDesc: {
  132. type: String,
  133. default: '',
  134. },
  135. canClose: {
  136. type: Boolean,
  137. default: true,
  138. },
  139. size: {
  140. type: Object,
  141. default: () => {
  142. return {
  143. width: 1,
  144. height: 1,
  145. }
  146. },
  147. },
  148. needOperationTip: {
  149. type: Boolean,
  150. default: false,
  151. },
  152. })
  153. /**
  154. * 操作提示
  155. */
  156. const needOperationTip = computed(() => {
  157. return props.needOperationTip
  158. })
  159. const isShowOperationTip = ref(true)
  160. const descTextEl = ref(null)
  161. const descTextElScrollTop = ref(0)
  162. onMounted(() => {
  163. descTextEl.value.addEventListener('scroll', (e) => {
  164. descTextElScrollTop.value = descTextEl.value.scrollTop
  165. })
  166. })
  167. const unwatch = watch(descTextElScrollTop, (v) => {
  168. isShowOperationTip.value = false
  169. unwatch()
  170. })
  171. const isAnimating = ref(true)
  172. /** 卷轴展开动画的tweening */
  173. const AnimationProgress = ref({
  174. value: 7
  175. })
  176. const tween = new TWEEN.Tween(AnimationProgress.value)
  177. tween.to({
  178. value: 100,
  179. }, 3000)
  180. tween.easing(TWEEN.Easing.Cubic.InOut)
  181. let animationRequestId = null
  182. const animate = () => {
  183. animationRequestId = requestAnimationFrame(animate)
  184. TWEEN.update()
  185. }
  186. // tween.onUpdate(function (object) {
  187. // console.log(object.value)
  188. // })
  189. onMounted(() => {
  190. tween.start()
  191. animate()
  192. })
  193. tween.onComplete(() => {
  194. isAnimating.value = false
  195. cancelAnimationFrame(animationRequestId)
  196. })
  197. onUnmounted(() => {
  198. tween.stop()
  199. cancelAnimationFrame(animationRequestId)
  200. })
  201. /**
  202. * 尺寸相关
  203. */
  204. const paintingWrapWidth = ref(329)
  205. const paintingWrapHeight = ref(561)
  206. let wrapSizeRatio = paintingWrapWidth.value / paintingWrapHeight.value
  207. if (wrapSizeRatio < 1) {
  208. wrapSizeRatio = 1 / wrapSizeRatio
  209. }
  210. let sizeRatio = props.size.width / props.size.height
  211. if (sizeRatio < 1) {
  212. sizeRatio = 1 / sizeRatio
  213. }
  214. const isOversize = ref(sizeRatio > wrapSizeRatio)
  215. const paintingWrap2El = ref(null)
  216. const paintingEl = ref(null)
  217. onMounted(() => {
  218. if (isOversize.value) {
  219. setTimeout(() => {
  220. const y = (paintingEl.value.clientHeight - paintingWrap2El.value.clientHeight) / 2
  221. paintingWrap2El.value.scrollTo({
  222. top: y,
  223. // behavior: 'smooth',
  224. })
  225. }, 0)
  226. }
  227. })
  228. function showBigPainting() {
  229. viewerApi({
  230. images: [props.bigPainting],
  231. })
  232. }
  233. </script>
  234. <style lang="less" scoped>
  235. .hotspot-detail-2{
  236. position: absolute;
  237. left: 0;
  238. top: 0;
  239. width: 100%;
  240. height: 100%;
  241. ::-webkit-scrollbar { width: 0; height: 0; }
  242. >.painting-wrap{
  243. position: absolute;
  244. left: 50%;
  245. top: calc(70 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  246. transform: translate(-50%, 0);
  247. width: calc(356 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  248. height: calc(602 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  249. overflow: hidden;
  250. >img.painting-border{
  251. position: absolute;
  252. left: 0;
  253. top: 0;
  254. width: 100%;
  255. height: 100%;
  256. }
  257. >.painting-wrap-2{
  258. position: absolute;
  259. left: 50%;
  260. top: 50%;
  261. transform: translate(-50%, -50%);
  262. width: calc(v-bind('paintingWrapWidth') / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  263. height: calc(v-bind('paintingWrapHeight') / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  264. overflow: auto;
  265. >img.painting{
  266. position: absolute;
  267. left: 50%;
  268. top: 50%;
  269. transform: translate(-50%, -50%);
  270. width: 100%;
  271. }
  272. >img.painting.oversize{
  273. position: static;
  274. left: initial;
  275. top: initial;
  276. transform: initial;
  277. }
  278. }
  279. >img.bottom-border-for-animation{
  280. position: absolute;
  281. left: 0;
  282. width: 100%;
  283. }
  284. }
  285. >.desc-text{
  286. position: absolute;
  287. left: 50%;
  288. bottom: 2%;
  289. transform: translateX(-50%);
  290. width: calc(306 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  291. height: calc(130 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  292. overflow: auto;
  293. >h1{
  294. text-align: center;
  295. font-family: KaiTi, KaiTi;
  296. font-weight: 400;
  297. font-size: calc(20 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  298. color: #FFFFFF;
  299. margin-bottom: calc(19 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  300. }
  301. >p.subtitle{
  302. text-align: center;
  303. font-family: KaiTi, KaiTi;
  304. font-weight: 400;
  305. font-size: calc(16 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  306. color: rgba(255, 255, 255, 0.8);
  307. line-height: calc(19 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  308. margin-bottom: calc(6 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  309. }
  310. >h2{
  311. display: inline-block;
  312. margin-top: calc(30 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  313. font-family: KaiTi, KaiTi;
  314. color: #FFFFFF;
  315. margin-top: 2em;
  316. margin-bottom: 0.5em;
  317. font-weight: 400;
  318. font-size: calc(20 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  319. }
  320. >.normal-text{
  321. font-family: KaiTi, KaiTi;
  322. color: #FFFFFF;
  323. font-weight: 400;
  324. font-size: calc(20 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  325. line-height: calc(25 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  326. text-align: justify;
  327. white-space: pre-line;
  328. }
  329. }
  330. >.operation-tip{
  331. position: absolute;
  332. right: calc(39 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  333. bottom: calc(49 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  334. }
  335. >.operation-tip{
  336. position: absolute;
  337. right: calc(49 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  338. bottom: calc(39 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  339. }
  340. }
  341. </style>