四零语境前端代码仓库
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.

187 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. },
  67. confirmSelection() {
  68. console.log('确认选择音色:', this.selectedVoiceId)
  69. // 这里可以保存选择的音色到本地存储或发送到服务器
  70. uni.navigateBack()
  71. },
  72. async getVoice(){
  73. const listRes = await this.$api.music.list()
  74. if (listRes.code === 200) {
  75. this.voiceList = listRes.result
  76. }
  77. }
  78. },
  79. onLoad() {
  80. this.getVoice()
  81. }
  82. }
  83. </script>
  84. <style scoped lang="scss">
  85. .music-container {
  86. background: #fff;
  87. min-height: 100vh;
  88. display: flex;
  89. flex-direction: column;
  90. padding-bottom: 120rpx;
  91. }
  92. .voice-list {
  93. flex: 1;
  94. padding: 40rpx 32rpx 120rpx;
  95. display: flex;
  96. flex-direction: column;
  97. gap: 32rpx;
  98. }
  99. .voice-item {
  100. display: flex;
  101. align-items: center;
  102. padding: 32rpx 0;
  103. border-bottom: 4rpx solid #F8F8F8;
  104. position: relative;
  105. background: #F8F8F8;
  106. gap: 12px;
  107. opacity: 1;
  108. border-radius: 8px;
  109. padding: 8px;
  110. transition: all 0.3s ease;
  111. &:last-child {
  112. border-bottom: none;
  113. }
  114. &.selected {
  115. border-bottom: 4rpx solid $primary-color;
  116. }
  117. }
  118. .voice-avatar {
  119. width: 136rpx;
  120. height: 136rpx;
  121. border-radius: 50%;
  122. background: #666;
  123. display: flex;
  124. align-items: center;
  125. justify-content: center;
  126. // margin-right: 32rpx;
  127. position: relative;
  128. }
  129. .play-icon {
  130. display: flex;
  131. width: 60rpx;
  132. height: 60rpx;
  133. border-radius: 100rpx;
  134. background: white;
  135. align-items: center;
  136. justify-content: center;
  137. }
  138. .voice-info {
  139. flex: 1;
  140. }
  141. .voice-name {
  142. font-family: PingFang SC;
  143. font-weight: 600;
  144. font-size: 36rpx;
  145. color: #262626;
  146. margin-bottom: 8rpx;
  147. }
  148. .voice-desc {
  149. font-family: PingFang SC;
  150. font-weight: 400;
  151. font-size: 28rpx;
  152. color: #999;
  153. }
  154. .selected-tag {
  155. background: $primary-color;
  156. color: #fff;
  157. font-size: 24rpx;
  158. padding: 8rpx 16rpx;
  159. border-radius: 20rpx;
  160. font-family: PingFang SC;
  161. font-weight: 500;
  162. }
  163. .bottom-bar {
  164. position: fixed;
  165. bottom: 0;
  166. left: 0;
  167. right: 0;
  168. background: #fff;
  169. padding: 24rpx 50rpx;
  170. z-index: 999;
  171. border-top: 2rpx solid #F1F1F1
  172. }
  173. </style>