index.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. const fetch = require('../../utils/fetch')
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. slides: [],
  8. categories: []
  9. },
  10. /**
  11. * 生命周期函数--监听页面加载
  12. */
  13. onLoad (options) {
  14. //fetch('/slides')
  15. // .then(res => {
  16. // this.setData({ slides: res.data })
  17. // })
  18. // fetch('/categories')
  19. // .then(res => {
  20. // this.setData({ categories: res.data })
  21. // })
  22. const slides = [
  23. { image: '/assets/contest/2.jpg', link: '/pages/list/list?cat=10' },
  24. { image: '/assets/contest/1.jpg', link: '' },
  25. { image: '/assets/contest/4.jpg', link: '/pages/list/list?cat=30' },
  26. { image: '/assets/contest/3.jpg', link: '/pages/list/list?cat=20' }
  27. ]
  28. const categories = [
  29. { icon: '/assets/icons/scan.png', text: '签到扫码', category_id: 5 },
  30. { icon: '/assets/icons/art.png', text: '艺术', category_id: 1 },
  31. { icon: '/assets/icons/chemistry.png', text: '科技', category_id: 2 },
  32. { icon: '/assets/icons/math.png', text: '数学', category_id: 3 },
  33. { icon: '/assets/icons/cups.png', text: '奖杯赛', category_id: 4 },
  34. { icon: '/assets/icons/badminton.png', text: '体育', category_id: 6 },
  35. { icon: '/assets/icons/bicycle.png', text: '户外', category_id: 7 },
  36. { icon: '/assets/icons/keyboard.png', text: '创新专题', category_id: 8 },
  37. { icon: '/assets/icons/myself.png', text: '我的比赛', category_id: 9 }
  38. ]
  39. this.setData({ slides, categories })
  40. },
  41. mySomeFunc:function(){
  42. wx.scanCode({ onlyFromCamera:false, success:scanOK, fail:scanFail});
  43. },
  44. scanOK:function(){
  45. wx.showToast({title:"签到成功!"});
  46. },
  47. scanFail: function () {
  48. wx.showToast({ title: "请重新尝试!" });
  49. }
  50. })