journey.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <view class="app-page">
  3. <view class="page-title">我们的故事</view>
  4. <view class="html-typed" v-html="html">内容渲染</view>
  5. <scroll-btn bottom="160rpx" :scrollTop.sync="scrollTop"></scroll-btn>
  6. </view>
  7. </template>
  8. <script>
  9. import ScrollBtn from '@/components/scroll-btn/scroll-btn.vue';
  10. export default {
  11. components: {
  12. ScrollBtn
  13. },
  14. data() {
  15. return {
  16. scrollTop: 0,
  17. html: '',
  18. timer: null
  19. };
  20. },
  21. computed: {
  22. loveConfig() {
  23. return this.$tm.vx.getters().getConfigs.loveConfig;
  24. }
  25. },
  26. watch: {
  27. loveConfig: {
  28. deep: true,
  29. immediate: true,
  30. handler(newVal, oldVal) {
  31. if (!newVal) return;
  32. this.fnInit();
  33. }
  34. }
  35. },
  36. onPageScroll(e) {
  37. this.scrollTop = e.scrollTop;
  38. },
  39. onBackPress() {
  40. clearTimeout(this.timer);
  41. },
  42. methods: {
  43. fnInit() {
  44. clearTimeout(this.timer);
  45. const _html = this.loveConfig.ourStory.content;
  46. let _index = 0;
  47. const _typing = () => {
  48. this.timer = setTimeout(() => {
  49. if (_index >= _html.length) {
  50. clearTimeout(this.timer);
  51. } else {
  52. this.html += _html.substring(_index, _index + 1);
  53. _index += 1;
  54. _typing();
  55. }
  56. }, 100);
  57. };
  58. _typing();
  59. }
  60. }
  61. };
  62. </script>
  63. <style scoped lang="scss">
  64. .app-page {
  65. width: 100vw;
  66. min-height: 100vh;
  67. box-sizing: border-box;
  68. padding: 36rpx;
  69. /* #ifdef APP-PLUS */
  70. padding-top: 100rpx;
  71. /* #endif */
  72. /* #ifdef H5 */
  73. padding-top: 80rpx;
  74. /* #endif */
  75. /* #ifdef MP-WEIXIN */
  76. padding-top: 120rpx;
  77. /* #endif */
  78. background: linear-gradient(-45deg,
  79. rgba(247, 149, 51, 0.1),
  80. rgba(243, 112, 85, 0.1) 15%,
  81. rgba(239, 78, 123, 0.1) 30%,
  82. rgba(161, 102, 171, 0.1) 44%,
  83. rgba(80, 115, 184, 0.1) 58%,
  84. rgba(16, 152, 173, 0.1) 72%,
  85. rgba(7, 179, 155, 0.1) 86%,
  86. rgba(109, 186, 130, 0.1));
  87. color: rgba(26, 26, 26, 1);
  88. }
  89. .page-title {
  90. font-size: 42rpx;
  91. font-weight: bold;
  92. text-align: center;
  93. text-shadow: 0rpx 4rpx 24rpx #bfe9ef;
  94. }
  95. .html-typed {
  96. margin-top: 52rpx;
  97. line-height: 1.8;
  98. font-size: 30rpx;
  99. }
  100. </style>