index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <view class="day-recommend-container">
  3. <view class="vague-wrapper flex align-center">
  4. <!-- <image src="../../static/background.png" class="background-img"></image> -->
  5. <view class="absolve-wrapper">
  6. <cu-custom class="head-title" :isBack="true" bgColor="unset"><block slot="content">每日推荐</block></cu-custom>
  7. <view class="day-recommend-info" :style="{ 'padding-top': CustomBar + 'px' }">
  8. <image :src="bgImg" mode="widthFix" class="bgImg"></image>
  9. <view class="day-info">
  10. <text class="bold-text">{{ day }}</text>
  11. <text class="small-text">/{{ month }}</text>
  12. <view class="descript">生如蝼蚁当立鸿鹄之志,命薄似纸应有不屈之心,乾坤未定,你我皆是黑马</view>
  13. </view>
  14. </view>
  15. </view>
  16. </view>
  17. <view class="recommend-main" :class="{ hasPlayInfo: playInfo.id }">
  18. <view class="recommend-list">
  19. <view class="music-title" @click="handlePlayAllMusic">
  20. <text class="iconfont icon-kaishi3 basic-icon-color playIcon"></text>
  21. 全部播放
  22. <text class="light-text">(共{{ dayRecommendList.length }}首)</text>
  23. </view>
  24. <scroll-view scroll-y scroll-with-animation style="height: calc(100% - 55px)">
  25. <view
  26. class="music-item flex"
  27. :class="{ active: item.id == playInfo.id }"
  28. v-for="(item, index) in dayRecommendList"
  29. :key="item.id"
  30. @click="handlePlayMusic(item)"
  31. >
  32. <image :src="item.al.picUrl + '?param=60y60'" mode="widthFix" class="music-img"></image>
  33. <view class="music-info">
  34. <view class="music-name text-overflow">{{ item.name }}</view>
  35. <view class="music-singer text-overflow flex">
  36. <span class="small-icon">{{ item.id % 2 == 0 ? 'SQ' : 'HD' }}</span>
  37. {{ item.ar ? item.ar.map(item => item.name).join('/') : '' }}
  38. </view>
  39. </view>
  40. </view>
  41. </scroll-view>
  42. </view>
  43. </view>
  44. <music-control v-if="playInfo.id" />
  45. </view>
  46. </template>
  47. <script>
  48. import { getImage, getName } from '@/utils/index.js';
  49. import { getMonth, getDay } from '@/utils/date.js';
  50. import { mapState } from 'vuex';
  51. export default {
  52. data() {
  53. return {
  54. dayRecommendList: [],
  55. bgImg: '',
  56. day: getDay(),
  57. month: getMonth(),
  58. CustomBar:this.CustomBar-15
  59. };
  60. },
  61. computed: mapState({
  62. playInfo: state => state.playInfo
  63. }),
  64. created() {
  65. this.getDayRecommendData();
  66. },
  67. methods: {
  68. //获取猜你喜欢歌曲
  69. async getDayRecommendData() {
  70. const { data } = await this.$api.getDayRecommendList();
  71. this.dayRecommendList = data.dailySongs || [];
  72. if (data.dailySongs.length > 0) {
  73. this.bgImg = this.dayRecommendList[0].al.picUrl + 'param?300y300';
  74. }
  75. },
  76. //点击播放
  77. handlePlayMusic(val) {
  78. if (this.playInfo.id == val.id) {
  79. uni.navigateTo({
  80. url: '../play/index'
  81. });
  82. return;
  83. }
  84. this.$store.dispatch('playMusic', {
  85. src: '',
  86. title: val.name,
  87. singer: getName(val),
  88. coverImgUrl: getImage(val),
  89. id: val.id
  90. });
  91. },
  92. //播放全部
  93. handlePlayAllMusic() {
  94. const list = this.dayRecommendList.map(item => {
  95. return {
  96. src: '',
  97. title: item.name,
  98. singer: getName(item),
  99. coverImgUrl: getImage(item),
  100. id: item.id
  101. };
  102. });
  103. this.$store.dispatch('playAllMUsic', list);
  104. }
  105. }
  106. };
  107. </script>
  108. <style lang="scss" scoped>
  109. .day-recommend-container {
  110. width: 100%;
  111. height: 100%;
  112. .vague-wrapper {
  113. height: 30%;
  114. width: 100%;
  115. position: relative;
  116. .background-img{
  117. width: 100%;
  118. height: 100%;
  119. }
  120. .absolve-wrapper{
  121. position: absolute;
  122. left: 0;
  123. right: 0;
  124. bottom: 0;
  125. top: 0;
  126. width: 100%;
  127. height: 100%;
  128. background-color: rgba(0,0,0,0.5);
  129. }
  130. .head-title {
  131. color: #fff;
  132. position: absolute;
  133. top: 0;
  134. width: 100%;
  135. z-index: 9999;
  136. }
  137. .day-recommend-info {
  138. box-sizing: border-box;
  139. height: 100%;
  140. display: flex;
  141. align-items: center;
  142. justify-content: center;
  143. width: 100%;
  144. .bgImg {
  145. width: 200rpx;
  146. border-radius: 8px;
  147. margin-right: 20px;
  148. }
  149. .day-info {
  150. margin-bottom: 12rpx;
  151. color: #fff;
  152. max-width: calc(100% - 175px);
  153. .small-text {
  154. font-size: 42rpx;
  155. }
  156. .bold-text {
  157. font-size: 60rpx;
  158. font-weight: bold;
  159. margin-right: 3px;
  160. }
  161. .descript {
  162. font-size: 24rpx;
  163. color: #e1d7f0;
  164. margin-top: 17rpx;
  165. overflow: hidden;
  166. text-overflow: ellipsis;
  167. display: -webkit-box;
  168. -webkit-box-orient: vertical;
  169. -webkit-line-clamp: 2;
  170. line-height: 18px;
  171. }
  172. }
  173. }
  174. }
  175. .recommend-main {
  176. height: 70%;
  177. width: 100%;
  178. position: relative;
  179. &.hasPlayInfo {
  180. height: calc(70% - 110rpx);
  181. }
  182. .recommend-list {
  183. position: absolute;
  184. top: -5%;
  185. left: 0;
  186. right: 0;
  187. bottom: 0;
  188. background: #fff;
  189. border-top-left-radius: 26px;
  190. border-top-right-radius: 26px;
  191. .music-title {
  192. padding-left: 20px;
  193. margin: 15px 0;
  194. box-sizing: border-box;
  195. color: #000;
  196. font-size: 32rpx;
  197. font-weight: 600;
  198. .playIcon {
  199. margin-right: 8px;
  200. font-size: 40rpx;
  201. }
  202. .light-text {
  203. font-size: 24rpx;
  204. margin-left: 6px;
  205. color: rgba(0, 0, 0, 0.5);
  206. }
  207. }
  208. .music-item {
  209. height: 70px;
  210. box-sizing: border-box;
  211. padding: 0 20px;
  212. align-items: center;
  213. margin-bottom: 10px;
  214. position: relative;
  215. &:last-of-type {
  216. margin-bottom: 0;
  217. }
  218. &.active {
  219. background-image: linear-gradient(to right, rgba(247, 73, 79, 0.1), rgba(247, 73, 79, 0.05));
  220. .music-info {
  221. .music-name,
  222. .small-icon,
  223. .music-singer {
  224. color: #f84e51 !important;
  225. }
  226. &::before {
  227. content: '';
  228. width: 4px;
  229. height: 65px;
  230. background-image: linear-gradient(to bottom, rgb(253, 117, 102), rgb(247, 73, 79));
  231. position: absolute;
  232. left: 0px;
  233. top: 3px;
  234. }
  235. }
  236. }
  237. .music-img {
  238. width: 58px;
  239. border-radius: 6px;
  240. }
  241. .music-info {
  242. margin-left: 15px;
  243. .music-name {
  244. font-size: 30rpx;
  245. margin-bottom: 7px;
  246. color: #000;
  247. }
  248. .music-singer {
  249. color: rgba(0, 0, 0, 0.5);
  250. font-size: 24rpx;
  251. align-items: center;
  252. .small-icon {
  253. margin-right: 6px;
  254. transform: scale(0.9);
  255. color: rgba(0, 0, 0, 0.5);
  256. font-size: 12px;
  257. padding: 1px 3px;
  258. border: 1px solid rgba(0, 0, 0, 0.2);
  259. border-radius: 4px;
  260. }
  261. }
  262. }
  263. }
  264. }
  265. }
  266. }
  267. </style>