index.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. //index.js
  2. //获取应用实例
  3. const app = getApp()
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. imgList:[
  10. '/image/ad1.jpg',
  11. '/image/ad2.jpg',
  12. '/image/ad3.jpg',
  13. '/image/ad4.jpg',
  14. '/image/ad5.jpg',
  15. '/image/ad6.jpg',
  16. '/image/ad7.jpg'
  17. ],
  18. navList:[
  19. {icon:'/image/nav-icon/diantai.png',events:'goToBangDan',text:'榜单'},
  20. {icon:'/image/nav-icon/diantai.png',events:'goToBangDan',text:'听小说'},
  21. {icon:'/image/nav-icon/diantai.png',events:'goToBangDan',text:'情感电台'},
  22. {icon:'/image/nav-icon/diantai.png',events:'goToBangDan',text:'听知识'},
  23. ],
  24. swiperCurrent: 0,
  25. },
  26. //轮播图改变事件
  27. swiperChange: function(e){
  28. //console.log(e.detail.current);
  29. this.setData({
  30. swiperCurrent: e.detail.current
  31. })
  32. },
  33. /**
  34. * 生命周期函数--监听页面加载
  35. */
  36. onLoad: function (options) {
  37. var that = this;
  38. wx.request({
  39. url: 'http://mobile.ximalaya.com/mobile/discovery/v3/recommend/hotAndGuess?code=43_310000_3100&device=android&version=5.4.45',
  40. data: {},
  41. header: {'content-type':'application/json'},
  42. method: 'GET',
  43. dataType: 'json',
  44. responseType: 'text',
  45. success: (result)=>{
  46. console.log(result);
  47. if(result.statusCode == 200){
  48. that.setData({
  49. showitem:true,
  50. guess:result.data.paidArea.list,
  51. xiaoshuocontent:result.data.hotRecommends.list[0].list,
  52. xiangshengcontent:result.data.hotRecommends.list[2].list,
  53. tuokocontent:result.data.hotRecommends.list[4].list
  54. })
  55. }else{
  56. that.setData({
  57. showitem:false
  58. })
  59. }
  60. },
  61. });
  62. },
  63. goToBangDan:function(){
  64. wx.navigateTo({
  65. url: '/pages/index/bangdan/bangdan',
  66. })
  67. },
  68. gotoDetails(e){
  69. // console.log(e)
  70. var url = e.currentTarget.dataset.coverimg;
  71. var title = e.currentTarget.dataset.title;
  72. wx.navigateTo({
  73. url: '/pages/details/details?url='+url+'&title='+title,
  74. })
  75. }
  76. })