talkGuide.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <view class="talk-guide" v-if="isShow" @click="handleClick">
  3. <view class="guide-content" :class="{ 'right-aligned': currentStep.position === 'right' }">
  4. <view class="character-container" :class="{ 'right-aligned': currentStep.position === 'right' }">
  5. <image
  6. class="character-image"
  7. :class="{ 'mirror': currentStep.isMirror }"
  8. :src="currentStep.characterImage"
  9. mode="aspectFit"
  10. />
  11. </view>
  12. <view class="dialog-box" :class="{ 'right-aligned': currentStep.position === 'right' }">
  13. <view class="character-name" :class="{ 'right-aligned': currentStep.position === 'right' }" v-if="currentStep.characterName">
  14. {{ currentStep.characterName === '我' ? playerName : currentStep.characterName }}
  15. </view>
  16. <view class="dialog-text">{{ currentStep.text }}</view>
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. name: 'TalkGuide',
  24. props: {
  25. guideData: {
  26. type: Array,
  27. default: () => []
  28. },
  29. playerName: {
  30. type: String,
  31. default: '主角'
  32. }
  33. },
  34. data() {
  35. return {
  36. currentIndex: 0,
  37. isShow: true
  38. }
  39. },
  40. computed: {
  41. currentStep() {
  42. return this.guideData[this.currentIndex] || {}
  43. },
  44. isLastStep() {
  45. return this.currentIndex === this.guideData.length - 1
  46. }
  47. },
  48. methods: {
  49. handleClick() {
  50. if (this.isLastStep) {
  51. this.isShow = false
  52. this.$emit('guide-complete')
  53. } else {
  54. this.nextStep()
  55. }
  56. },
  57. nextStep() {
  58. if (this.currentIndex < this.guideData.length - 1) {
  59. this.currentIndex++
  60. }
  61. }
  62. }
  63. }
  64. </script>
  65. <style lang="scss" scoped>
  66. .talk-guide {
  67. position: fixed;
  68. top: 0;
  69. left: 0;
  70. width: 100%;
  71. height: 100%;
  72. background-color: rgba(0, 0, 0, 0.5);
  73. z-index: 999;
  74. .guide-content {
  75. position: absolute;
  76. bottom: 40rpx;
  77. left: 0;
  78. width: 100%;
  79. padding: 0 30rpx;
  80. box-sizing: border-box;
  81. display: flex;
  82. flex-direction: column;
  83. &.right-aligned {
  84. align-items: flex-end;
  85. }
  86. }
  87. .character-container {
  88. width: 300rpx;
  89. height: 358rpx;
  90. margin-bottom: -60rpx;
  91. margin-left: -40rpx;
  92. position: relative;
  93. z-index: 1;
  94. &.right-aligned {
  95. margin-left: 0;
  96. margin-right: -40rpx;
  97. }
  98. .character-image {
  99. height: 100%;
  100. transition: transform 0.3s ease;
  101. &.mirror {
  102. transform: scaleX(-1);
  103. }
  104. }
  105. }
  106. .dialog-box {
  107. background: rgba(255,241,228,0.95);
  108. border-radius: 28rpx 28rpx 28rpx 28rpx;
  109. border: 4rpx solid #E3985A;
  110. padding: 20rpx;
  111. min-height: 120rpx;
  112. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
  113. position: relative;
  114. z-index: 2;
  115. padding-top: 30rpx;
  116. width: 100%;
  117. box-sizing: border-box;
  118. &.right-aligned {
  119. border-radius: 28rpx 28rpx 28rpx 28rpx;
  120. }
  121. .character-name {
  122. font-size: 20rpx;
  123. font-weight: bold;
  124. color: #987453;
  125. margin-bottom: 10rpx;
  126. display: inline-block;
  127. background-color: #F8F3E9;
  128. padding: 4rpx 16rpx;
  129. border-radius: 20rpx;
  130. border: 2rpx solid #DEB691;
  131. position: absolute;
  132. top: -25rpx;
  133. left: 5%;
  134. z-index: 3;
  135. width: 156rpx;
  136. height: 48rpx;
  137. text-align: center;
  138. &.right-aligned {
  139. left: auto;
  140. right: 5%;
  141. }
  142. }
  143. .dialog-text {
  144. font-size: 20rpx;
  145. font-weight: bold;
  146. color: #A95F3C;
  147. line-height: 1.5;
  148. padding: 0 20rpx;
  149. }
  150. }
  151. }
  152. </style>