CharacterDialog.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <custom-dialog :visible.sync="dialogVisible" title="角色信息" @close="onClose">
  3. <view class="character-content">
  4. <view class="character-info">
  5. <view class="avatar-section">
  6. <image class="avatar" src="/static/avatar/default.png" mode="aspectFit"></image>
  7. <text class="level">Lv.{{level}}</text>
  8. </view>
  9. <view class="info-section">
  10. <view class="info-item">
  11. <text class="label">名称:</text>
  12. <text class="value">{{name}}</text>
  13. </view>
  14. <view class="info-item">
  15. <text class="label">经验:</text>
  16. <text class="value">{{exp}}/{{nextLevelExp}}</text>
  17. </view>
  18. <view class="progress-bar">
  19. <view class="progress" :style="{width: expProgress + '%'}"></view>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="stats-section">
  24. <view class="stat-item" v-for="(stat, index) in stats" :key="index">
  25. <text class="stat-label">{{stat.label}}</text>
  26. <text class="stat-value">{{stat.value}}</text>
  27. </view>
  28. </view>
  29. </view>
  30. </custom-dialog>
  31. </template>
  32. <script>
  33. import CustomDialog from '../CustomDialog/CustomDialog.vue'
  34. export default {
  35. name: 'CharacterDialog',
  36. components: {
  37. CustomDialog
  38. },
  39. props: {
  40. visible: {
  41. type: Boolean,
  42. default: false
  43. }
  44. },
  45. data() {
  46. return {
  47. dialogVisible: false,
  48. name: '玩家名称',
  49. level: 1,
  50. exp: 100,
  51. nextLevelExp: 200,
  52. stats: [
  53. { label: '力量', value: 10 },
  54. { label: '敏捷', value: 8 },
  55. { label: '智力', value: 12 },
  56. { label: '体力', value: 15 }
  57. ]
  58. }
  59. },
  60. computed: {
  61. expProgress() {
  62. return (this.exp / this.nextLevelExp) * 100
  63. }
  64. },
  65. watch: {
  66. visible(val) {
  67. this.dialogVisible = val
  68. },
  69. dialogVisible(val) {
  70. this.$emit('update:visible', val)
  71. }
  72. },
  73. methods: {
  74. onClose() {
  75. this.dialogVisible = false
  76. }
  77. }
  78. }
  79. </script>
  80. <style lang="scss" scoped>
  81. .character-content {
  82. .character-info {
  83. display: flex;
  84. padding: 20rpx;
  85. gap: 30rpx;
  86. .avatar-section {
  87. position: relative;
  88. .avatar {
  89. width: 160rpx;
  90. height: 160rpx;
  91. border-radius: 80rpx;
  92. border: 4rpx solid #eee;
  93. }
  94. .level {
  95. position: absolute;
  96. bottom: -10rpx;
  97. left: 50%;
  98. transform: translateX(-50%);
  99. background: #007AFF;
  100. color: white;
  101. padding: 4rpx 16rpx;
  102. border-radius: 20rpx;
  103. font-size: 24rpx;
  104. }
  105. }
  106. .info-section {
  107. flex: 1;
  108. .info-item {
  109. margin-bottom: 16rpx;
  110. .label {
  111. color: #666;
  112. font-size: 28rpx;
  113. }
  114. .value {
  115. color: #333;
  116. font-size: 28rpx;
  117. }
  118. }
  119. .progress-bar {
  120. height: 16rpx;
  121. background: #eee;
  122. border-radius: 8rpx;
  123. overflow: hidden;
  124. margin-top: 10rpx;
  125. .progress {
  126. height: 100%;
  127. background: #007AFF;
  128. transition: width 0.3s ease;
  129. }
  130. }
  131. }
  132. }
  133. .stats-section {
  134. display: grid;
  135. grid-template-columns: repeat(2, 1fr);
  136. gap: 20rpx;
  137. padding: 20rpx;
  138. background: #f8f8f8;
  139. border-radius: 12rpx;
  140. margin: 20rpx;
  141. .stat-item {
  142. display: flex;
  143. justify-content: space-between;
  144. align-items: center;
  145. padding: 10rpx 20rpx;
  146. .stat-label {
  147. color: #666;
  148. font-size: 28rpx;
  149. }
  150. .stat-value {
  151. color: #333;
  152. font-size: 28rpx;
  153. font-weight: 500;
  154. }
  155. }
  156. }
  157. }
  158. </style>