index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. <template>
  2. <view class="recommend-container page-background">
  3. <view class="bg-black">
  4. <cu-custom bgColor="#000000"><view slot="content" style="color: #ffffff">UU睡眠</view></cu-custom>
  5. </view>
  6. <scroll-view :style="{ height: height }" class="main-container" scroll-y>
  7. <view class="bg-black">
  8. <view class="banner-wrapper">
  9. <swiper class="screen-swiper square-dot" style="min-height: 317upx;" :indicator-dots="true" :circular="true" :autoplay="true" interval="5000" duration="500">
  10. <swiper-item v-for="item in swiperList" :key="item.bannerId">
  11. <image :src="item.pic || item.imageUrl" mode="scaleToFill" class="banner-img"></image>
  12. </swiper-item>
  13. </swiper>
  14. </view>
  15. </view>
  16. <view class="music-wrapper" v-if="recommendList.length > 0">
  17. <box-title title="UU推荐" buttonName="更多" iconName="right" @handlePlay="handleNative('../songList/index')"></box-title>
  18. <song-list :currentList="recommendList"></song-list>
  19. </view>
  20. <view class="music-wrapper" v-if="dayRecommendList.length > 0">
  21. <box-title title="睡眠音乐" buttonName="更多" iconName="kaishi2" @handlePlay="handlePlay('dayRecommendList')"></box-title>
  22. <music-list :currentList="dayRecommendList"></music-list>
  23. </view>
  24. <view class="music-wrapper" v-if="dayRecommendList.length > 0">
  25. <box-title title="睡眠小知识" buttonName="更多" iconName="kaishi2" @handlePlay="handlePlay('dayRecommendList')"></box-title>
  26. <view class="flex-col justify-start knowledge-list">
  27. <view class="flex-row items-center space-x-14 knowledge-item">
  28. <view class="flex-col flex-auto space-y-8">
  29. <text class="self-start font_4 knowledge-item-title">睡眠科普:你真的了解睡眠吗?</text>
  30. <text class="knowledge-item-desc">
  31. 套用模型省时省力,不用冥思苦想,但是,每一个需要设计的内容和体系应该是迥然不同的,所以每一个设计方案也…
  32. </text>
  33. </view>
  34. <image
  35. class="shrink-0 image_12"
  36. src="https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/649415135a7e3f0310661c1e/649415b654fe0000116ae544/16874496879438729687.png"
  37. />
  38. </view>
  39. <view class="flex-row items-center space-x-14 knowledge-item">
  40. <view class="flex-col flex-auto space-y-8">
  41. <text class="self-start font_4 knowledge-item-title">睡眠科普:你真的了解睡眠吗?</text>
  42. <text class="knowledge-item-desc">
  43. 套用模型省时省力,不用冥思苦想,但是,每一个需要设计的内容和体系应该是迥然不同的,所以每一个设计方案也…
  44. </text>
  45. </view>
  46. <image
  47. class="shrink-0 image_12"
  48. src="https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/649415135a7e3f0310661c1e/649415b654fe0000116ae544/16874496879438729687.png"
  49. />
  50. </view>
  51. <view class="flex-row items-center space-x-14 knowledge-item">
  52. <view class="flex-col flex-auto space-y-8">
  53. <text class="self-start font_4 knowledge-item-title">睡眠科普:你真的了解睡眠吗?</text>
  54. <text class="knowledge-item-desc">
  55. 套用模型省时省力,不用冥思苦想,但是,每一个需要设计的内容和体系应该是迥然不同的,所以每一个设计方案也…
  56. </text>
  57. </view>
  58. <image
  59. class="shrink-0 image_12"
  60. src="https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/649415135a7e3f0310661c1e/649415b654fe0000116ae544/16874496879438729687.png"
  61. />
  62. </view>
  63. </view>
  64. </view>
  65. </scroll-view>
  66. <music-control />
  67. <!-- <tab-bar currentPage="index" /> -->
  68. </view>
  69. </template>
  70. <script>
  71. import songList from './components/songList.vue';
  72. import musicList from './components/musicList.vue';
  73. import { getImage, getName } from '@/utils/index.js';
  74. export default {
  75. data() {
  76. return {
  77. //轮播图
  78. swiperList: [
  79. {
  80. "pic": "http://p1.music.126.net/ZuDmYz9gKTes67weCA6roQ==/109951168702825545.jpg",
  81. "bannerId": "1687869567089252"
  82. },
  83. {
  84. "pic": "http://p1.music.126.net/vrPXmAQsg-aW5I3EEFcKcw==/109951168702819867.jpg",
  85. "bannerId": "1687869640017460"
  86. },
  87. {
  88. "pic": "http://p1.music.126.net/xK69a1N5DCqNQXts64y3xA==/109951168703821815.jpg",
  89. "bannerId": "1687869708598159"
  90. }
  91. ],
  92. recommendList: [
  93. {
  94. "id": 331841455,
  95. "type": 0,
  96. "name": "深度睡眠 |重度失眠者专用歌单",
  97. "copywriter": "",
  98. "picUrl": "https://p2.music.126.net/g2_Gv0dtAicJ3ChTYu28_g==/1393081239628722.jpg",
  99. "canDislike": true,
  100. "trackNumberUpdateTime": 1552746520361,
  101. "playCount": 72862600,
  102. "trackCount": 32,
  103. "highQuality": true,
  104. "alg": "alg_high_quality"
  105. },
  106. {
  107. "id": 5338700800,
  108. "type": 0,
  109. "name": "一个双子座的听歌列表",
  110. "copywriter": "",
  111. "picUrl": "https://p2.music.126.net/SATl5PH1NpEPHsYaB24t5A==/109951166269856073.jpg",
  112. "canDislike": true,
  113. "trackNumberUpdateTime": 1685028754372,
  114. "playCount": 29329484,
  115. "trackCount": 361,
  116. "highQuality": false,
  117. "alg": "alg_high_quality"
  118. },
  119. {
  120. "id": 2042205655,
  121. "type": 0,
  122. "name": "愿还会有人,做个傻子陪你浪费一生",
  123. "copywriter": "",
  124. "picUrl": "https://p2.music.126.net/AWcDI5wc9fkS2bZt6wIm-Q==/109951163212638897.jpg",
  125. "canDislike": true,
  126. "trackNumberUpdateTime": 1679320967844,
  127. "playCount": 25818546,
  128. "trackCount": 41,
  129. "highQuality": false,
  130. "alg": "alg_high_quality"
  131. },
  132. {
  133. "id": 2139324915,
  134. "type": 0,
  135. "name": "歌词唱透了心声,回忆模糊了眼眸",
  136. "copywriter": "",
  137. "picUrl": "https://p2.music.126.net/pa1t9G_Mt2xJm_xqUUjvIw==/109951163676905233.jpg",
  138. "canDislike": true,
  139. "trackNumberUpdateTime": 1687945378874,
  140. "playCount": 69736672,
  141. "trackCount": 514,
  142. "highQuality": false,
  143. "alg": "alg_high_quality"
  144. }
  145. ],
  146. dayRecommendList: [
  147. {
  148. "id": 159400773,
  149. "name": "JJ的咖啡调调, Vol. 2",
  150. "picUrl": "http://p2.music.126.net/4x-65bnidSKyEMDBmGtn8g==/109951168466764238.jpg"
  151. },
  152. {
  153. "id": 160760191,
  154. "name": "我们的歌",
  155. "picUrl": "http://p2.music.126.net/Gm2v1KrDe2TwplzxcmTxYg==/109951168428025131.jpg"
  156. },
  157. {
  158. "id": 78938226,
  159. "name": "听闻余生",
  160. "picUrl": "http://p2.music.126.net/DK1_4sP_339o5rowMdPXdw==/109951164071024476.jpg"
  161. },
  162. {
  163. "id": 129849508,
  164. "name": "时光背面的我",
  165. "picUrl": "http://p2.music.126.net/VOcPF6uCGAlwESFyyGqHrg==/109951166141514551.jpg"
  166. },
  167. {
  168. "id": 160760191,
  169. "name": "我们的歌",
  170. "picUrl": "http://p2.music.126.net/Gm2v1KrDe2TwplzxcmTxYg==/109951168428025131.jpg"
  171. },
  172. {
  173. "id": 78938226,
  174. "name": "听闻余生",
  175. "picUrl": "http://p2.music.126.net/DK1_4sP_339o5rowMdPXdw==/109951164071024476.jpg"
  176. },
  177. {
  178. "id": 129849508,
  179. "name": "时光背面的我",
  180. "picUrl": "http://p2.music.126.net/VOcPF6uCGAlwESFyyGqHrg==/109951166141514551.jpg"
  181. }
  182. ],
  183. dayRecommendMusicList: [],
  184. newSongList: [],
  185. hotSingerList: [],
  186. selectData: [],
  187. };
  188. },
  189. components: {
  190. songList,
  191. musicList
  192. },
  193. computed: {
  194. cookie() {
  195. return this.$store.state.cookie;
  196. },
  197. height() {
  198. let height = this.CustomBar / (uni.upx2px(this.CustomBar) / this.CustomBar) + 220;
  199. return `calc(100% - ${height}rpx)`;
  200. }
  201. },
  202. onShow() {
  203. // this.getDayRecommendData();
  204. // this.getDayRecommendMusicData();
  205. },
  206. created() {
  207. // this.getData();
  208. },
  209. onPullDownRefresh() {
  210. // this.getData();
  211. setTimeout(() => {
  212. uni.stopPullDownRefresh();
  213. }, 1000);
  214. },
  215. methods: {
  216. getData() {
  217. this.getBannerData();
  218. this.getRecommendData();
  219. this.getNewSongData();
  220. this.getSelectionData();
  221. this.getHotSingerData();
  222. },
  223. //播放全部 猜你喜欢
  224. handlePlay(key) {
  225. const list = this[key].map(item => {
  226. return {
  227. src: '',
  228. title: item.name,
  229. singer: getName(item),
  230. coverImgUrl: getImage(item),
  231. id: item.id
  232. };
  233. });
  234. this.$store.dispatch('playAllMUsic', list);
  235. },
  236. handleNative(val) {
  237. uni.navigateTo({
  238. url: val
  239. });
  240. },
  241. // 获取轮播图数据
  242. async getBannerData() {
  243. const data = await this.$api.getBanner();
  244. this.swiperList = data.banners || [];
  245. },
  246. //获取推荐歌单数据
  247. async getRecommendData() {
  248. const data = await this.$api.getRecommendList();
  249. this.recommendList = data.result.slice(0, 8);
  250. },
  251. //获取猜你喜欢歌曲
  252. async getDayRecommendData() {
  253. const { data } = await this.$api.getDayRecommendList();
  254. console.log('data recommend');
  255. console.log(data);
  256. this.dayRecommendList = data.dailySongs;
  257. },
  258. //获取推荐歌单
  259. async getDayRecommendMusicData() {
  260. const data = await this.$api.getDayRecommendMusicList();
  261. this.dayRecommendMusicList = data.recommend || [];
  262. },
  263. //获取新歌数据
  264. async getNewSongData() {
  265. const data = await this.$api.getNewSongList();
  266. this.newSongList = data.result.slice(0, 9);
  267. },
  268. //获取网友精选歌单
  269. async getSelectionData() {
  270. const data = await this.$api.getSelectionData();
  271. this.selectData = data.playlists || [];
  272. },
  273. //获取热门歌手数据
  274. async getHotSingerData() {
  275. const data = await this.$api.getHotSingerList();
  276. this.hotSingerList = (data.artists || []).slice(0, 10);
  277. },
  278. toSearch() {
  279. uni.navigateTo({
  280. url: '../search/index'
  281. });
  282. }
  283. }
  284. };
  285. </script>
  286. <style lang="scss" scoped>
  287. .bg-black {
  288. background-color: #000000;
  289. }
  290. .recommend-container {
  291. position: relative;
  292. background-color: #000000;
  293. height: 100%;
  294. padding-bottom: 100px;
  295. .main-container {
  296. position: relative;
  297. .banner-wrapper {
  298. box-sizing: border-box;
  299. padding: 10px;
  300. .banner-img {
  301. height: 158px;
  302. border-radius: 6px;
  303. }
  304. }
  305. .list-wrapper {
  306. margin-top: 8px;
  307. padding-bottom: 12px;
  308. .list-item {
  309. text-align: center;
  310. font-size: 24rpx;
  311. }
  312. .list-ico {
  313. font-size: 72rpx;
  314. margin-bottom: 6px;
  315. }
  316. .list-title {
  317. font-size: 28rpx;
  318. }
  319. }
  320. .music-wrapper {
  321. margin-top: 5px;
  322. background: #000000;
  323. box-sizing: border-box;
  324. padding: 15px;
  325. &:last-of-type {
  326. margin-bottom: 0;
  327. }
  328. }
  329. }
  330. .knowledge-list {
  331. margin-top: 1rem;
  332. .space-x-14 {
  333. & > view:not(:first-child),
  334. & > text:not(:first-child),
  335. & > image:not(:first-child) {
  336. margin-left: 0.88rem;
  337. }
  338. .space-y-8 {
  339. & > view:not(:first-child),
  340. & > text:not(:first-child),
  341. & > image:not(:first-child) {
  342. margin-top: 0.5rem;
  343. }
  344. .font_4 {
  345. font-size: 0.88rem;
  346. font-family: PingFangSC;
  347. line-height: 0.81rem;
  348. color: #ffffff;
  349. }
  350. .knowledge-item-title {
  351. opacity: 0.8;
  352. }
  353. .knowledge-item-desc {
  354. color: #4d4b5e;
  355. font-size: 0.63rem;
  356. font-family: PingFangSC;
  357. line-height: 0.88rem;
  358. }
  359. }
  360. .image_12 {
  361. margin-right: 1.25rem;
  362. width: 3.75rem;
  363. height: 3.75rem;
  364. }
  365. }
  366. .knowledge-item {
  367. margin-left: 3px;
  368. margin-bottom: 20px;
  369. }
  370. }
  371. }
  372. </style>