sex.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <div>
  3. <img v-if="step === 4" src="../../../assets/img/next.png" class="next" />
  4. <div class="sex" :style="'background-image: url(' + bgimg + ')'">
  5. <img
  6. :src="kuangimg"
  7. :style="
  8. step === 2
  9. ? 'opacity: 1'
  10. : step === 3 || step === 4
  11. ? 'width: 25%;transform: translate(0, 0);opacity: 1; top: 1em; left: 1em'
  12. : 'opacity: 0'
  13. "
  14. class="firstImg"
  15. />
  16. <transition name="fade">
  17. <div
  18. class="sImg img"
  19. v-if="step === 1"
  20. :style="'width:' + width + 'px;'"
  21. >
  22. <template v-for="(item, i) in text.texts" :key="i">
  23. <p
  24. v-text="item"
  25. :style="
  26. stepBody >= i
  27. ? 'opacity: 1;color: ' + text.color
  28. : 'color: ' + text.color
  29. "
  30. ></p>
  31. <br />
  32. </template>
  33. </div>
  34. </transition>
  35. <img
  36. :src="text2img"
  37. :style="step === 4 ? 'opacity: 1' : ''"
  38. class="tImg"
  39. />
  40. <div class="btns" v-if="step === 4">
  41. <div
  42. class="btn"
  43. @click="showDown"
  44. style="margin-left: 0"
  45. :stype="'border-color:' + text.color + ';color:' + text.color"
  46. >
  47. 下载壁纸
  48. </div>
  49. <div
  50. class="btn"
  51. @click="showDown"
  52. :stype="'border-color:' + text.color + ';color:' + text.color"
  53. >
  54. 生成海报
  55. </div>
  56. </div>
  57. </div>
  58. <div class="model" v-show="showImg !== undefined" @click="close">
  59. <van-icon
  60. color="#fff"
  61. size="26"
  62. name="close"
  63. class="close"
  64. @click="close"
  65. />
  66. <img :src="showImg" class="modelImg" alt="" />
  67. </div>
  68. </div>
  69. </template>
  70. <script setup>
  71. import { ref, reactive } from "vue";
  72. import data from "../data/data.json";
  73. // import { onMounted, reactive } from "vue";
  74. // import { isIpad, isIpod, isIphone } from "../../utils/isTerminal";
  75. /**
  76. * window.$originData.orginParames.title 页面标题
  77. * window.$originData.orginParames.parameters 固定参数值
  78. * window.$originData.urlParames url参数
  79. */
  80. const showImg = ref(undefined);
  81. let width = window.$originData.orginParames.availWidth * 0.7;
  82. const type = Math.floor(Math.random() * 12 + 1);
  83. let ori = data[type - 1] || { texts: [] };
  84. let max = 0;
  85. for (let i = 0; i < ori.texts.length; i++) {
  86. max < ori.texts[i].length && (max = ori.texts[i].length);
  87. }
  88. width = 14 * max;
  89. const text = reactive({
  90. ...data[type - 1],
  91. width,
  92. });
  93. const url = {
  94. bg: require("@/assets/img/12/" + type + "-1.png"),
  95. kuang: require("@/assets/img/12/" + type + ".kuang.png"),
  96. text2: require("@/assets/img/12/" + type + ".text2.png"),
  97. };
  98. const bgimg = ref(url.bg);
  99. const kuangimg = ref(url.kuang);
  100. const text2img = ref(url.text2);
  101. const step = ref(0);
  102. const stepBody = ref(0);
  103. let t = setTimeout(() => {
  104. clearTimeout(t);
  105. step.value += 1;
  106. t = setInterval(() => {
  107. stepBody.value += 1;
  108. if (stepBody.value === text.texts.length) {
  109. clearInterval(t);
  110. autoStep();
  111. }
  112. }, 2000);
  113. }, 200);
  114. function autoStep() {
  115. t = setInterval(() => {
  116. step.value += 1;
  117. if (step.value === 4) {
  118. clearInterval(t);
  119. t = setTimeout(() => {
  120. // 跳转下一页
  121. }, 2000);
  122. }
  123. }, 3000);
  124. }
  125. function showDown() {
  126. showImg.value = url.bg;
  127. }
  128. function close() {
  129. showImg.value = undefined;
  130. }
  131. </script>
  132. <style lang="scss" scoped>
  133. .sex {
  134. @font-face {
  135. font-family: OPPOSans;
  136. src: url(../../../assets/css/OPPOSans-R.ttf);
  137. }
  138. width: 100%;
  139. height: 100%;
  140. background-size: 100% 100%;
  141. position: relative;
  142. img,
  143. .img {
  144. width: 50%;
  145. transition-property: all;
  146. transition-duration: 2s;
  147. opacity: 0;
  148. position: absolute;
  149. top: 50%;
  150. left: 50%;
  151. transform: translate(-50%, -50%);
  152. }
  153. .firstImg {
  154. transition-delay: 1s;
  155. -moz-transition-delay: 1s; /* Firefox 4 */
  156. -webkit-transition-delay: 1s; /* Safari 和 Chrome */
  157. -o-transition-delay: 1s; /* Opera */
  158. }
  159. .sImg {
  160. width: 70%;
  161. color: #ffffff;
  162. font-family: OPPOSans;
  163. font-size: 14px;
  164. line-height: 2em;
  165. opacity: 1;
  166. p {
  167. display: inline-block;
  168. white-space: nowrap;
  169. transition-property: all;
  170. transition-duration: 2s;
  171. opacity: 0;
  172. }
  173. }
  174. .tImg {
  175. width: 80%;
  176. transition-delay: 1s;
  177. -moz-transition-delay: 1s; /* Firefox 4 */
  178. -webkit-transition-delay: 1s; /* Safari 和 Chrome */
  179. -o-transition-delay: 1s; /* Opera */
  180. }
  181. .btns {
  182. position: absolute;
  183. text-align: center;
  184. bottom: 10vh;
  185. width: 100%;
  186. > div {
  187. display: inline-block;
  188. border: 1px solid #fff;
  189. border-radius: 2em;
  190. font-weight: 600;
  191. color: #fff;
  192. padding: 5px 15px;
  193. margin-left: 2em;
  194. }
  195. }
  196. .fade-enter-from,
  197. .fade-leave-to {
  198. opacity: 0;
  199. }
  200. .fade-enter-active,
  201. .fade-leave-active {
  202. transition: opacity 1s ease;
  203. }
  204. .fade-enter-to,
  205. .fade-leave-from {
  206. opacity: 1;
  207. }
  208. }
  209. .next {
  210. bottom: 10px;
  211. left: 50%;
  212. transform: translateX(-50%);
  213. top: inherit;
  214. width: 2em;
  215. z-index: 1;
  216. position: fixed;
  217. animation-name: an;
  218. animation-duration: 1s;
  219. animation-timing-function: linear;
  220. animation-iteration-count: infinite;
  221. animation-direction: alternate;
  222. }
  223. @keyframes an {
  224. from {
  225. bottom: 10px;
  226. }
  227. to {
  228. bottom: 15px;
  229. }
  230. }
  231. .model {
  232. position: fixed;
  233. top: 0;
  234. left: 0;
  235. bottom: 0;
  236. right: 0;
  237. z-index: 10;
  238. background-color: #00000040;
  239. .modelImg {
  240. position: absolute;
  241. top: 50%;
  242. left: 50%;
  243. transform: translate(-50%, -50%);
  244. width: 80%;
  245. }
  246. .close {
  247. position: absolute;
  248. top: 1em;
  249. right: 1em;
  250. }
  251. }
  252. </style>