BambooBookScene2.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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 lastX = ref(0)
  32. // 开始滑动
  33. const handletouchstart = (event) => {
  34. lastX.value = event.changedTouches[0].pageX
  35. }
  36. // 监听活动
  37. const touchMove = (event) => {
  38. let currentX = event.changedTouches[0].pageX
  39. let tx = currentX - lastX.value
  40. if (tx < 0) {
  41. } else if (tx > 0) {
  42. emit('slide-left')
  43. }
  44. }
  45. // 叶子图片适应
  46. const x = window.innerWidth / window.innerHeight
  47. const {
  48. windowSizeInCssForRef,
  49. windowSizeWhenDesignForRef,
  50. } = useSizeAdapt()
  51. </script>
  52. <template>
  53. <div
  54. class="screen-box"
  55. @touchstart="handletouchstart($event)"
  56. @touchmove="touchMove($event)"
  57. >
  58. <!-- <transition name="fade-in-out" /> -->
  59. <div class="screen-box2">
  60. <div class="title-disc">
  61. 当前展示内容
  62. </div>
  63. <Transition name="fade-out">
  64. <img
  65. v-show="curPart === 0"
  66. class="detail-img"
  67. :style="{ width: x > 0.5 ? '100%' : '' }"
  68. :src="moren"
  69. alt=""
  70. >
  71. </Transition>
  72. <Transition name="fade-in-out">
  73. <img
  74. v-show="curPart == 1"
  75. class="detail-img"
  76. :style="{ width: x > 0.5 ? '100%' : '' }"
  77. :src=" ganImg"
  78. alt=""
  79. @click="emit('next', curPart)"
  80. >
  81. </Transition>
  82. <Transition name="fade-in-out">
  83. <img
  84. v-show="curPart == 2"
  85. class="detail-img"
  86. :style="{ width: x > 0.5 ? '100%' : '' }"
  87. :src=" zhiImg"
  88. alt=""
  89. @click="emit('next', curPart)"
  90. >
  91. </Transition>
  92. <Transition name="fade-in-out">
  93. <img
  94. v-show="curPart == 3"
  95. class="detail-img"
  96. :style="{ width: x > 0.5 ? '100%' : '' }"
  97. :src=" yeImg"
  98. alt=""
  99. @click="emit('next', curPart)"
  100. >
  101. </Transition>
  102. <!-- 竹子部分选择 -->
  103. <div class="options-box">
  104. <div
  105. :class="{ 'active': curPart == 1 }"
  106. @click="() => { curPart = 1 }"
  107. >
  108. </div>
  109. <div
  110. :class="{ 'active': curPart == 2 }"
  111. @click="() => { curPart = 2 }"
  112. >
  113. </div>
  114. <div
  115. :class="{ 'active': curPart == 3 }"
  116. @click="() => { curPart = 3 }"
  117. >
  118. </div>
  119. </div>
  120. <div
  121. :style="{ opacity: curPart == 0 ? '0' : '1' }"
  122. class="index3-income"
  123. @click="emit('next', curPart)"
  124. >
  125. 查看画法
  126. </div>
  127. <div class="system-btns">
  128. <BtnBack
  129. :color="`green`"
  130. @click="emit('close')"
  131. />
  132. </div>
  133. </div>
  134. </div>
  135. </template>
  136. <style lang='less' scoped>
  137. .screen-box {
  138. width: 100%;
  139. height: 100%;
  140. position: absolute;
  141. left: 0;
  142. top: 0;
  143. .screen-box2 {
  144. width: 100%;
  145. height: 100%;
  146. display: flex;
  147. flex-direction: column;
  148. justify-content: center;
  149. align-items: center;
  150. background-image: url(@/assets/images/screen-box2.png);
  151. background-size: 100% 100%;
  152. position: relative;
  153. .title-disc {
  154. width: 100%;
  155. color: #ffffffa6;
  156. text-align: center;
  157. // position: absolute;
  158. font-size: calc(20 /v-bind(windowSizeWhenDesignForRef)* v-bind(windowSizeInCssForRef));
  159. line-height: calc(23 /v-bind(windowSizeWhenDesignForRef)* v-bind(windowSizeInCssForRef));
  160. font-family: 'KaiTi';
  161. position: absolute;
  162. top: calc(50 /v-bind(windowSizeWhenDesignForRef)* v-bind(windowSizeInCssForRef));
  163. }
  164. .detail-img {
  165. width: calc(428 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  166. height: calc(506 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  167. object-fit: cover;
  168. object-position: left;
  169. position: absolute;
  170. top: 5%;
  171. }
  172. .options-box {
  173. width: 100%;
  174. display: flex;
  175. justify-content: space-evenly;
  176. align-items: center;
  177. color: #474747;
  178. font-size: calc(28 /v-bind(windowSizeWhenDesignForRef)* v-bind(windowSizeInCssForRef));
  179. line-height: calc(32 /v-bind(windowSizeWhenDesignForRef)* v-bind(windowSizeInCssForRef));
  180. font-family: 'KingHwa_OldSong';
  181. margin: calc(58 / v-bind(windowSizeWhenDesignForRef)*v-bind(windowSizeInCssForRef)) auto;
  182. position: absolute;
  183. bottom: 14%;
  184. >.active {
  185. width: calc(55 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  186. height: calc(55 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  187. background-image: url(@/assets/images/btn_active.png);
  188. // padding: calc(8 / v-bind(windowSizeWhenDesignForRef) * v-bind(windowSizeInCssForRef));
  189. background-size: 100% 100%;
  190. transform: scale(1.2);
  191. color: #ffffff;
  192. display: flex;
  193. justify-content: center;
  194. align-items: center;
  195. text-shadow: 2px 4px 4px rgba(71, 100, 70, 0.5);
  196. font-size: calc(36 / v-bind(windowSizeWhenDesignForRef) * v-bind(windowSizeWhenDesignForRef));
  197. font-family: calc(42 / v-bind(windowSizeWhenDesignForRef) * v-bind(windowSizeWhenDesignForRef));
  198. }
  199. }
  200. .index3-income {
  201. width: calc(132 /v-bind(windowSizeWhenDesignForRef) * v-bind(windowSizeInCssForRef));
  202. height: calc(48 /v-bind(windowSizeWhenDesignForRef)* v-bind(windowSizeInCssForRef));
  203. display: flex;
  204. justify-content: center;
  205. align-items: center;
  206. font-size: calc(20 /v-bind(windowSizeWhenDesignForRef)* v-bind(windowSizeInCssForRef));
  207. line-height: calc(23 /v-bind(windowSizeWhenDesignForRef)* v-bind(windowSizeInCssForRef));
  208. color: #476446;
  209. background-image: url(@/assets/images/btn_more.png);
  210. background-size: 100% 100%;
  211. font-family: 'KaiTi';
  212. position: absolute;
  213. bottom: 8%;
  214. }
  215. .system-btns {
  216. width: 100%;
  217. padding: 0 calc(20 / v-bind(windowSizeWhenDesignForRef) * v-bind(windowSizeInCssForRef));
  218. display: flex;
  219. justify-content: space-between;
  220. position: absolute;
  221. bottom: calc(20 /v-bind(windowSizeWhenDesignForRef) * v-bind(windowSizeInCssForRef));
  222. z-index: 2;
  223. }
  224. }
  225. }
  226. </style>