四零语境前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

189 lines
3.7 KiB

  1. <template>
  2. <view class="music-container">
  3. <!-- 音色列表 -->
  4. <view class="voice-list">
  5. <view
  6. v-for="(voice, index) in voiceList"
  7. :key="voice.id"
  8. class="voice-item"
  9. :class="{ 'selected': voice.id === selectedVoiceId }"
  10. @click="selectVoice(voice.id)"
  11. >
  12. <view class="voice-avatar">
  13. <view class="play-icon">
  14. <uv-icon
  15. :name="voice.id === selectedVoiceId ? 'pause' : 'play-right-fill'"
  16. size="24"
  17. color="#666666"
  18. ></uv-icon>
  19. </view>
  20. </view>
  21. <view class="voice-info">
  22. <view class="voice-name">{{ voice.name }}</view>
  23. <view class="voice-desc">{{ voice.info }}</view>
  24. </view>
  25. <view v-if="voice.id === selectedVoiceId" class="selected-tag">
  26. 已选择
  27. </view>
  28. </view>
  29. </view>
  30. <!-- 底部固定确认按钮 -->
  31. <view class="bottom-bar">
  32. <uv-button
  33. type="primary"
  34. text="确定"
  35. :custom-style="{
  36. width: '100%',
  37. height: '82rpx',
  38. borderRadius: '44rpx',
  39. backgroundColor: '#06DADC',
  40. fontSize: '36rpx',
  41. fontWeight: '500',
  42. border: '1px solid #06DADC'
  43. }"
  44. @click="confirmSelection"
  45. ></uv-button>
  46. <uv-safe-bottom></uv-safe-bottom>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. export default {
  52. data() {
  53. return {
  54. selectedVoiceId: 2, // 默认选择智小虎
  55. voiceList: [
  56. ]
  57. }
  58. },
  59. methods: {
  60. goBack() {
  61. uni.navigateBack()
  62. },
  63. selectVoice(voiceId) {
  64. this.selectedVoiceId = voiceId
  65. console.log('选择音色:', voiceId)
  66. uni.$emit('selectVoice', voiceId)
  67. },
  68. confirmSelection() {
  69. console.log('确认选择音色:', this.selectedVoiceId)
  70. // 这里可以保存选择的音色到本地存储或发送到服务器
  71. uni.navigateBack()
  72. },
  73. async getVoice(){
  74. const listRes = await this.$api.music.list()
  75. if (listRes.code === 200) {
  76. this.voiceList = listRes.result
  77. }
  78. }
  79. },
  80. onLoad() {
  81. this.getVoice()
  82. }
  83. }
  84. </script>
  85. <style scoped lang="scss">
  86. .music-container {
  87. background: #fff;
  88. min-height: 100vh;
  89. display: flex;
  90. flex-direction: column;
  91. padding-bottom: 120rpx;
  92. }
  93. .voice-list {
  94. flex: 1;
  95. padding: 40rpx 32rpx 120rpx;
  96. display: flex;
  97. flex-direction: column;
  98. gap: 32rpx;
  99. }
  100. .voice-item {
  101. display: flex;
  102. align-items: center;
  103. padding: 32rpx 0;
  104. border-bottom: 4rpx solid #F8F8F8;
  105. position: relative;
  106. background: #F8F8F8;
  107. gap: 12px;
  108. opacity: 1;
  109. border-radius: 8px;
  110. padding: 8px;
  111. transition: all 0.3s ease;
  112. &:last-child {
  113. border-bottom: none;
  114. }
  115. &.selected {
  116. border-bottom: 4rpx solid $primary-color;
  117. }
  118. }
  119. .voice-avatar {
  120. width: 136rpx;
  121. height: 136rpx;
  122. border-radius: 50%;
  123. background: #666;
  124. display: flex;
  125. align-items: center;
  126. justify-content: center;
  127. // margin-right: 32rpx;
  128. position: relative;
  129. }
  130. .play-icon {
  131. display: flex;
  132. width: 60rpx;
  133. height: 60rpx;
  134. border-radius: 100rpx;
  135. background: white;
  136. align-items: center;
  137. justify-content: center;
  138. }
  139. .voice-info {
  140. flex: 1;
  141. }
  142. .voice-name {
  143. font-family: PingFang SC;
  144. font-weight: 600;
  145. font-size: 36rpx;
  146. color: #262626;
  147. margin-bottom: 8rpx;
  148. }
  149. .voice-desc {
  150. font-family: PingFang SC;
  151. font-weight: 400;
  152. font-size: 28rpx;
  153. color: #999;
  154. }
  155. .selected-tag {
  156. background: $primary-color;
  157. color: #fff;
  158. font-size: 24rpx;
  159. padding: 8rpx 16rpx;
  160. border-radius: 20rpx;
  161. font-family: PingFang SC;
  162. font-weight: 500;
  163. }
  164. .bottom-bar {
  165. position: fixed;
  166. bottom: 0;
  167. left: 0;
  168. right: 0;
  169. background: #fff;
  170. padding: 24rpx 50rpx;
  171. z-index: 999;
  172. border-top: 2rpx solid #F1F1F1
  173. }
  174. </style>