camera.js 821 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // pages/camera/camera.js
  2. const request = require('../../utils/http')
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. result: {}
  9. },
  10. /**
  11. * 生命周期函数--监听页面加载
  12. */
  13. onLoad(options) {
  14. },
  15. /**
  16. * 生命周期函数--监听页面初次渲染完成
  17. */
  18. onReady() {
  19. },
  20. /**
  21. * 生命周期函数--监听页面显示
  22. */
  23. onShow() {
  24. this.getTags()
  25. },
  26. // 获取 电影标签数据
  27. async getTags() {
  28. wx.showLoading({
  29. title: '加载中...',
  30. })
  31. let res = await request({
  32. url: 'http://v.juhe.cn/toutiao/index?type=top&key=acf8f2ff52da5cb4aa65eb8b7c51583d',
  33. })
  34. console.log(res)
  35. setTimeout(() => {
  36. wx.hideLoading()
  37. }, 300)
  38. if(res.error_code === 0){
  39. this.setData({result: res.result})
  40. }
  41. }
  42. })