musicRecommend.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <!-- Header -->
  3. <view class="header">
  4. <view class="header-left">
  5. <!-- 播放按钮 -->
  6. <view class="play-circle">
  7. <image
  8. @click="palyBtn"
  9. style="width: 48rpx; height: 48rpx"
  10. src="/src/static//icon/fi-rr-play-alt.svg"
  11. ></image>
  12. </view>
  13. <text class="text-gray">播放全部 (22首)</text>
  14. </view>
  15. <!-- 循环播放 -->
  16. <view class="header-right">
  17. <image
  18. @click="cycleBtn"
  19. style="width: 32rpx; height: 32rpx"
  20. src="/src/static/icon/fi-rr-refresh.svg"
  21. ></image>
  22. <image style="width: 32rpx; height: 32rpx" src="/src/static/icon/fi-rr-shuffle.svg"></image>
  23. </view>
  24. </view>
  25. <!-- 当前播放 -->
  26. <view class="currently-playing">
  27. <view class="currently-playing-left">
  28. <view class="play-circle">
  29. <image
  30. @click="palyBtn"
  31. style="width: 28rpx; height: 28rpx"
  32. src="/src/static//icon/fi-rr-play.svg"
  33. v-if="type === 0"
  34. ></image>
  35. <image
  36. @click="palyBtn"
  37. style="width: 28rpx; height: 28rpx"
  38. src="/src/static//icon/fi-rr-play.svg"
  39. v-else
  40. ></image>
  41. </view>
  42. <text class="text-gray">继续播放: 小燕子(供暖版) - 贝乐虎儿歌贝乐虎儿歌贝乐虎儿歌</text>
  43. </view>
  44. <!-- 循环播放 -->
  45. <view style="display: flex; gap: 80rpx">
  46. <image
  47. @click="cycleBtn"
  48. style="width: 32rpx; height: 32rpx"
  49. src="/src/static/icon/fi-rr-pause.svg"
  50. ></image>
  51. <image
  52. style="width: 32rpx; height: 32rpx"
  53. src="/src/static/icon/fi-rr-cross-small.svg"
  54. ></image>
  55. </view>
  56. </view>
  57. <!-- 播放列表 -->
  58. <view class="playlist">
  59. <view v-for="(song, index) in songs" :key="index" class="playlist-item">
  60. <view class="album-cover">
  61. <view class="cover-inner">
  62. <image
  63. style="width: 100rpx; height: 100rpx"
  64. src="/src/static/icon/fi-rr-big-play.svg"
  65. ></image>
  66. </view>
  67. </view>
  68. <view class="song-details" @click="playFavoriteBtn(song, index)">
  69. <text class="song-name">{{ song.name }}</text>
  70. </view>
  71. <view class="song-controls">
  72. <text>{{ song.duration }}</text>
  73. <image
  74. style="width: 40rpx; height: 40rpx"
  75. v-if="type === 0"
  76. :src="
  77. song.favorite
  78. ? '/src/static/icon/fi-rr-heart-grey.svg'
  79. : '/src/static/icon/fi-rr-heart.svg'
  80. "
  81. @click="toggleFavorite(song)"
  82. ></image>
  83. <image
  84. v-else
  85. style="width: 40rpx; height: 40rpx"
  86. src="/src/static/icon/fi-rr-heart.svg"
  87. @click="toggHeartCancel(song)"
  88. ></image>
  89. </view>
  90. </view>
  91. </view>
  92. </template>
  93. <script setup>
  94. import { ref } from 'vue'
  95. import musicPlayback from './musicPlayback.vue'
  96. const props = defineProps({
  97. type: {
  98. type: Number,
  99. // eslint-disable-next-line vue/require-valid-default-prop
  100. default: true,
  101. },
  102. })
  103. const songs = ref([
  104. { name: '玛卡巴卡', duration: '3:35', favorite: false },
  105. { name: '海绵宝宝主题曲', duration: '3:35', favorite: true },
  106. { name: '开心超人', duration: '3:35', favorite: false },
  107. { name: '小燕子', duration: '3:35', favorite: true },
  108. { name: '小燕子 (哄睡版)', duration: '3:35', favorite: true },
  109. { name: '小兔子乖乖', duration: '3:35', favorite: false },
  110. { name: '两只老虎', duration: '3:35', favorite: false },
  111. { name: '小毛驴', duration: '3:35', favorite: true },
  112. { name: '我是一只小小鸟', duration: '3:35', favorite: false },
  113. { name: '小星星', duration: '3:35', favorite: true },
  114. { name: '世上只有妈妈好', duration: '3:35', favorite: false },
  115. { name: '蜗牛与黄鹂鸟', duration: '3:35', favorite: true },
  116. ])
  117. // 播放
  118. const palyBtn = () => {
  119. console.log(111, '播放')
  120. }
  121. // 循环播放
  122. const cycleBtn = () => {
  123. console.log(111, '循环播放')
  124. }
  125. // 当前列表
  126. const playFavoriteBtn = (song, index) => {
  127. const songData = encodeURIComponent(JSON.stringify(song))
  128. uni.navigateTo({
  129. url: `/pages/music/component/musicPlayback?songDate=${songData}`,
  130. })
  131. }
  132. // 切换歌曲的收藏状态
  133. const toggleFavorite = (song) => {
  134. console.log(song, 'indexindex')
  135. song.isFavorite = !song.isFavorite
  136. }
  137. // 点击取消收藏
  138. const toggHeartCancel = (song) => {
  139. console.log(song, 'songsong')
  140. }
  141. onLoad(() => {
  142. console.log(props, '111111')
  143. })
  144. </script>
  145. <style scoped>
  146. .header {
  147. display: flex;
  148. align-items: center;
  149. justify-content: space-between;
  150. border-bottom: 2rpx solid #f0f0f0;
  151. }
  152. .header-left {
  153. display: flex;
  154. align-items: center;
  155. }
  156. .play-circle {
  157. display: flex;
  158. /* justify-content: center; */
  159. align-items: center;
  160. width: 70rpx;
  161. height: 100rpx;
  162. }
  163. .orange-icon {
  164. margin-right: 16rpx;
  165. color: #f97316;
  166. }
  167. .text-gray {
  168. display: flex;
  169. align-items: center;
  170. width: 440rpx;
  171. overflow: hidden;
  172. font-family: 'PingFang SC';
  173. font-size: 24rpx;
  174. font-style: normal;
  175. font-weight: 400;
  176. color: #333;
  177. text-overflow: ellipsis;
  178. white-space: nowrap;
  179. }
  180. .header-right {
  181. display: flex;
  182. gap: 32rpx;
  183. }
  184. .gray-icon {
  185. color: #6b7280;
  186. cursor: pointer;
  187. }
  188. /* 播发 */
  189. .currently-playing {
  190. display: flex;
  191. align-items: center;
  192. justify-content: space-between;
  193. }
  194. .currently-playing-left {
  195. display: flex;
  196. align-items: center;
  197. }
  198. /* 列表 */
  199. .playlist {
  200. height: calc(100vh - 630rpx);
  201. overflow: auto;
  202. }
  203. .playlist::-webkit-scrollbar {
  204. display: none;
  205. }
  206. .playlist-item {
  207. display: flex;
  208. align-items: center;
  209. padding: 24rpx 0px;
  210. cursor: pointer;
  211. border-bottom: 2rpx solid #f0f0f0;
  212. }
  213. .playlist-item:hover {
  214. background-color: #f9fafb;
  215. }
  216. .album-cover {
  217. width: 100rpx;
  218. height: 100rpx;
  219. margin-right: 24rpx;
  220. overflow: hidden;
  221. }
  222. .cover-inner {
  223. display: flex;
  224. align-items: center;
  225. width: 100%;
  226. height: 100%;
  227. }
  228. .song-details {
  229. flex: 1;
  230. }
  231. .song-name {
  232. font-family: 'PingFang SC';
  233. font-size: 32rpx;
  234. font-style: normal;
  235. font-weight: 400;
  236. color: #333;
  237. }
  238. .song-controls {
  239. display: flex;
  240. gap: 32rpx;
  241. align-items: center;
  242. font-size: 24rpx;
  243. font-style: normal;
  244. font-weight: 400;
  245. color: var(--999, #999);
  246. }
  247. </style>