index.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. if(result.statusCode == 200){
  42. that.setData({
  43. showitem:true,
  44. xiaoshuocontent:result.data.hotRecommends.list[0].list,
  45. xiangshengcontent:result.data.hotRecommends.list[2].list,
  46. tuokocontent:result.data.hotRecommends.list[4].list
  47. })
  48. }else{
  49. that.setData({
  50. showitem:false
  51. })
  52. }
  53. },
  54. fail: ()=>{},
  55. complete: ()=>{}
  56. });
  57. },
  58. goToBangDan:function(){
  59. wx.navigateTo({
  60. url: '/pages/index/bangdan/bangdan',
  61. })
  62. }
  63. })