PaintingDetail.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  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-new.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. // subtitle: {
  120. // type: String,
  121. // required: true,
  122. // },
  123. age: {
  124. type: String,
  125. required: true,
  126. },
  127. location: {
  128. type: String,
  129. required: true,
  130. },
  131. paintingDesc: {
  132. type: String,
  133. default: '',
  134. },
  135. authorDesc: {
  136. type: String,
  137. default: '',
  138. },
  139. canClose: {
  140. type: Boolean,
  141. default: true,
  142. },
  143. size: {
  144. type: Object,
  145. default: () => {
  146. return {
  147. width: 1,
  148. height: 1,
  149. }
  150. },
  151. },
  152. needOperationTip: {
  153. type: Boolean,
  154. default: false,
  155. },
  156. })
  157. /**
  158. * 操作提示
  159. */
  160. const needOperationTip = computed(() => {
  161. return props.needOperationTip
  162. })
  163. const isShowOperationTip = ref(true)
  164. const descTextEl = ref(null)
  165. const descTextElScrollTop = ref(0)
  166. onMounted(() => {
  167. descTextEl.value.addEventListener('scroll', (e) => {
  168. descTextElScrollTop.value = descTextEl.value.scrollTop
  169. })
  170. })
  171. const unwatch = watch(descTextElScrollTop, (v) => {
  172. isShowOperationTip.value = false
  173. unwatch()
  174. })
  175. const isAnimating = ref(true)
  176. /** 卷轴展开动画的tweening */
  177. const AnimationProgress = ref({
  178. value: 7
  179. })
  180. const tween = new TWEEN.Tween(AnimationProgress.value)
  181. tween.to({
  182. value: 100,
  183. }, 3000)
  184. tween.easing(TWEEN.Easing.Cubic.InOut)
  185. let animationRequestId = null
  186. const animate = () => {
  187. animationRequestId = requestAnimationFrame(animate)
  188. TWEEN.update()
  189. }
  190. // tween.onUpdate(function (object) {
  191. // console.log(object.value)
  192. // })
  193. onMounted(() => {
  194. tween.start()
  195. animate()
  196. })
  197. tween.onComplete(() => {
  198. isAnimating.value = false
  199. cancelAnimationFrame(animationRequestId)
  200. })
  201. onUnmounted(() => {
  202. tween.stop()
  203. cancelAnimationFrame(animationRequestId)
  204. })
  205. /**
  206. * 尺寸相关
  207. */
  208. const paintingWrapWidth = ref(268)
  209. const paintingWrapHeight = ref(426)
  210. let wrapSizeRatio = paintingWrapWidth.value / paintingWrapHeight.value
  211. if (wrapSizeRatio < 1) {
  212. wrapSizeRatio = 1 / wrapSizeRatio
  213. }
  214. let sizeRatio = props.size.width / props.size.height
  215. if (sizeRatio < 1) {
  216. sizeRatio = 1 / sizeRatio
  217. }
  218. const isOversize = ref(sizeRatio > wrapSizeRatio)
  219. const paintingWrap2El = ref(null)
  220. const paintingEl = ref(null)
  221. onMounted(() => {
  222. if (isOversize.value) {
  223. setTimeout(() => {
  224. const y = (paintingEl.value.clientHeight - paintingWrap2El.value.clientHeight) / 2
  225. paintingWrap2El.value.scrollTo({
  226. top: y,
  227. // behavior: 'smooth',
  228. })
  229. }, 0)
  230. }
  231. })
  232. function showBigPainting() {
  233. viewerApi({
  234. images: [props.bigPainting],
  235. })
  236. }
  237. </script>
  238. <style lang="less" scoped>
  239. .hotspot-detail-2{
  240. position: absolute;
  241. left: 0;
  242. top: 0;
  243. width: 100%;
  244. height: 100%;
  245. ::-webkit-scrollbar { width: 0; height: 0; }
  246. >.painting-wrap{
  247. position: absolute;
  248. left: 50%;
  249. top: calc(70 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  250. transform: translate(-50%, 0);
  251. width: calc(356 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  252. height: calc(602 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  253. overflow: hidden;
  254. >img.painting-border{
  255. position: absolute;
  256. left: 0;
  257. top: 0;
  258. width: 100%;
  259. height: 100%;
  260. }
  261. >.painting-wrap-2{
  262. position: absolute;
  263. left: 50%;
  264. top: calc(110 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  265. transform: translate(-50%, 0);
  266. width: calc(v-bind('paintingWrapWidth') / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  267. height: calc(v-bind('paintingWrapHeight') / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  268. overflow: auto;
  269. >img.painting{
  270. position: absolute;
  271. left: 50%;
  272. top: 50%;
  273. transform: translate(-50%, -50%);
  274. width: 100%;
  275. }
  276. >img.painting.oversize{
  277. position: static;
  278. left: initial;
  279. top: initial;
  280. transform: initial;
  281. }
  282. }
  283. >img.bottom-border-for-animation{
  284. position: absolute;
  285. left: 0;
  286. width: 100%;
  287. }
  288. }
  289. >.desc-text{
  290. position: absolute;
  291. left: 50%;
  292. bottom: 2%;
  293. transform: translateX(-50%);
  294. width: calc(306 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  295. height: calc(130 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  296. overflow: auto;
  297. >h1{
  298. text-align: center;
  299. font-family: KaiTi, KaiTi;
  300. font-weight: 400;
  301. font-size: calc(20 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  302. color: #FFFFFF;
  303. margin-bottom: calc(19 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  304. }
  305. >p.subtitle{
  306. text-align: center;
  307. font-family: KaiTi, KaiTi;
  308. font-weight: 400;
  309. font-size: calc(16 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  310. color: rgba(255, 255, 255, 0.8);
  311. line-height: calc(19 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  312. margin-bottom: calc(6 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  313. }
  314. >h2{
  315. display: inline-block;
  316. margin-top: calc(30 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  317. font-family: KaiTi, KaiTi;
  318. color: #FFFFFF;
  319. margin-top: 2em;
  320. margin-bottom: 0.5em;
  321. font-weight: 400;
  322. font-size: calc(20 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  323. }
  324. >.normal-text{
  325. font-family: KaiTi, KaiTi;
  326. color: #FFFFFF;
  327. font-weight: 400;
  328. font-size: calc(20 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  329. line-height: calc(25 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  330. text-align: justify;
  331. white-space: pre-line;
  332. }
  333. }
  334. >.operation-tip{
  335. position: absolute;
  336. right: calc(39 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  337. bottom: calc(49 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  338. }
  339. >.operation-tip{
  340. position: absolute;
  341. right: calc(49 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  342. bottom: calc(39 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  343. }
  344. }
  345. </style>