BambooBookScene2.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <script setup>
  2. import { ref, onMounted, watch } from 'vue'
  3. import useSizeAdapt from "@/useFunctions/useSizeAdapt"
  4. // 竹子的三个部分图片
  5. import moren from '@/assets/images/moren.png'
  6. import ganImg from '@/assets/images/gan.png'
  7. import zhiImg from '@/assets/images/zhi.png'
  8. import yeImg from '@/assets/images/ye.png'
  9. // 第二屏
  10. // 杆-1 枝-2 叶-3
  11. const curPart = ref(0)
  12. const emit = defineEmits(['next', 'close', 'slide-left'])
  13. const props = defineProps({
  14. ischange: {
  15. type: Boolean,
  16. default: false
  17. }
  18. })
  19. watch(
  20. () => props.ischange, // 第一个参数可以是一个getter函数,这里直接观察someProp的值
  21. (newVal, oldVal) => {
  22. if (newVal) {
  23. console.log('变了')
  24. setTimeout(() => {
  25. curPart.value = 1
  26. }, 300)
  27. }
  28. },
  29. { immediate: true }
  30. )
  31. const onSwipeLeft = () => {
  32. emit('slide-left')
  33. }
  34. const onSwipeRight = () => {
  35. emit('slide-left')
  36. }
  37. // 叶子图片适应
  38. const x = window.innerWidth / window.innerHeight
  39. const {
  40. windowSizeInCssForRef,
  41. windowSizeWhenDesignForRef,
  42. } = useSizeAdapt()
  43. </script>
  44. <template>
  45. <div
  46. v-touch:swipe.left="onSwipeLeft"
  47. v-touch:swipe.right="onSwipeRight"
  48. class="screen-box"
  49. >
  50. <!-- <transition name="fade-in-out" /> -->
  51. <div class="screen-box2">
  52. <div class="title-disc">
  53. 当前展示内容
  54. </div>
  55. <Transition name="fade-out">
  56. <img
  57. v-show="curPart === 0"
  58. class="detail-img"
  59. :style="{ width: x > 0.5 ? '100%' : '' }"
  60. :src="moren"
  61. alt=""
  62. >
  63. </Transition>
  64. <Transition name="fade-in-out">
  65. <img
  66. v-show="curPart == 1"
  67. class="detail-img"
  68. :style="{ width: x > 0.5 ? '100%' : '' }"
  69. :src=" ganImg"
  70. alt=""
  71. @click="emit('next', curPart)"
  72. >
  73. </Transition>
  74. <Transition name="fade-in-out">
  75. <img
  76. v-show="curPart == 2"
  77. class="detail-img"
  78. :style="{ width: x > 0.5 ? '100%' : '' }"
  79. :src=" zhiImg"
  80. alt=""
  81. @click="emit('next', curPart)"
  82. >
  83. </Transition>
  84. <Transition name="fade-in-out">
  85. <img
  86. v-show="curPart == 3"
  87. class="detail-img"
  88. :style="{ width: x > 0.5 ? '100%' : '' }"
  89. :src=" yeImg"
  90. alt=""
  91. @click="emit('next', curPart)"
  92. >
  93. </Transition>
  94. <!-- 竹子部分选择 -->
  95. <div class="options-box">
  96. <div
  97. :class="{ 'active': curPart == 1 }"
  98. @click="() => { curPart = 1 }"
  99. >
  100. </div>
  101. <div
  102. :class="{ 'active': curPart == 2 }"
  103. @click="() => { curPart = 2 }"
  104. >
  105. </div>
  106. <div
  107. :class="{ 'active': curPart == 3 }"
  108. @click="() => { curPart = 3 }"
  109. >
  110. </div>
  111. </div>
  112. <div
  113. :style="{ opacity: curPart == 0 ? '0' : '1' }"
  114. class="index3-income"
  115. @click="emit('next', curPart)"
  116. >
  117. 查看画法
  118. </div>
  119. <div class="system-btns">
  120. <BtnBack
  121. :color="`green`"
  122. @click="emit('close')"
  123. />
  124. </div>
  125. </div>
  126. </div>
  127. </template>
  128. <style lang='less' scoped>
  129. .screen-box {
  130. width: 100%;
  131. height: 100%;
  132. position: absolute;
  133. left: 0;
  134. top: 0;
  135. .screen-box2 {
  136. width: 100%;
  137. height: 100%;
  138. display: flex;
  139. flex-direction: column;
  140. justify-content: center;
  141. align-items: center;
  142. background-image: url(@/assets/images/screen-box2.png);
  143. background-size: 100% 100%;
  144. position: relative;
  145. .title-disc {
  146. width: 100%;
  147. color: #ffffffa6;
  148. text-align: center;
  149. // position: absolute;
  150. font-size: calc(20 /v-bind(windowSizeWhenDesignForRef)* v-bind(windowSizeInCssForRef));
  151. line-height: calc(23 /v-bind(windowSizeWhenDesignForRef)* v-bind(windowSizeInCssForRef));
  152. font-family: 'KaiTi';
  153. position: absolute;
  154. top: calc(50 /v-bind(windowSizeWhenDesignForRef)* v-bind(windowSizeInCssForRef));
  155. }
  156. .detail-img {
  157. width: calc(428 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  158. height: calc(506 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  159. object-fit: cover;
  160. object-position: left;
  161. position: absolute;
  162. top: 5%;
  163. }
  164. .options-box {
  165. width: 100%;
  166. display: flex;
  167. justify-content: space-evenly;
  168. align-items: center;
  169. color: #474747;
  170. font-size: calc(28 /v-bind(windowSizeWhenDesignForRef)* v-bind(windowSizeInCssForRef));
  171. line-height: calc(32 /v-bind(windowSizeWhenDesignForRef)* v-bind(windowSizeInCssForRef));
  172. font-family: 'KingHwa_OldSong';
  173. margin: calc(58 / v-bind(windowSizeWhenDesignForRef)*v-bind(windowSizeInCssForRef)) auto;
  174. position: absolute;
  175. bottom: 14%;
  176. >.active {
  177. width: calc(55 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  178. height: calc(55 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  179. background-image: url(@/assets/images/btn_active.png);
  180. // padding: calc(8 / v-bind(windowSizeWhenDesignForRef) * v-bind(windowSizeInCssForRef));
  181. background-size: 100% 100%;
  182. transform: scale(1.2);
  183. color: #ffffff;
  184. display: flex;
  185. justify-content: center;
  186. align-items: center;
  187. text-shadow: 2px 4px 4px rgba(71, 100, 70, 0.5);
  188. font-size: calc(36 / v-bind(windowSizeWhenDesignForRef) * v-bind(windowSizeWhenDesignForRef));
  189. font-family: calc(42 / v-bind(windowSizeWhenDesignForRef) * v-bind(windowSizeWhenDesignForRef));
  190. }
  191. }
  192. .index3-income {
  193. width: calc(132 /v-bind(windowSizeWhenDesignForRef) * v-bind(windowSizeInCssForRef));
  194. height: calc(48 /v-bind(windowSizeWhenDesignForRef)* v-bind(windowSizeInCssForRef));
  195. display: flex;
  196. justify-content: center;
  197. align-items: center;
  198. font-size: calc(20 /v-bind(windowSizeWhenDesignForRef)* v-bind(windowSizeInCssForRef));
  199. line-height: calc(23 /v-bind(windowSizeWhenDesignForRef)* v-bind(windowSizeInCssForRef));
  200. color: #476446;
  201. background-image: url(@/assets/images/btn_more.png);
  202. background-size: 100% 100%;
  203. font-family: 'KaiTi';
  204. position: absolute;
  205. bottom: 8%;
  206. }
  207. .system-btns {
  208. width: 100%;
  209. padding: 0 calc(20 / v-bind(windowSizeWhenDesignForRef) * v-bind(windowSizeInCssForRef));
  210. display: flex;
  211. justify-content: space-between;
  212. position: absolute;
  213. bottom: calc(20 /v-bind(windowSizeWhenDesignForRef) * v-bind(windowSizeInCssForRef));
  214. z-index: 2;
  215. }
  216. }
  217. }
  218. </style>