index.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. swiperCurrent: 0,
  19. },
  20. //轮播图改变事件
  21. swiperChange: function(e){
  22. //console.log(e.detail.current);
  23. this.setData({
  24. swiperCurrent: e.detail.current
  25. })
  26. },
  27. /**
  28. * 生命周期函数--监听页面加载
  29. */
  30. onLoad: function (options) {
  31. var that = this;
  32. wx.request({
  33. url: 'http://mobile.ximalaya.com/mobile/discovery/v3/recommend/hotAndGuess?code=43_310000_3100&device=android&version=5.4.45',
  34. data: {},
  35. header: {'content-type':'application/json'},
  36. method: 'GET',
  37. dataType: 'json',
  38. responseType: 'text',
  39. success: (result)=>{
  40. console.log(result);
  41. that.setData({
  42. xiaoshuocontent:result.data.hotRecommends.list[0].list,
  43. xiangshengcontent:result.data.hotRecommends.list[2].list,
  44. tuokocontent:result.data.hotRecommends.list[4].list
  45. })
  46. },
  47. fail: ()=>{},
  48. complete: ()=>{}
  49. });
  50. },
  51. goToBangDan:function(){
  52. wx.navigateTo({
  53. url: '/pages/index/bangdan/bangdan',
  54. })
  55. }
  56. })