home.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. // pages/home/home.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. name:"图图",
  8. list:[
  9. {
  10. name:"图图",
  11. age:3
  12. },
  13. {
  14. name:"Lucy",
  15. age:13
  16. },
  17. {
  18. name:"Tom",
  19. age:22
  20. }
  21. ],
  22. age: 19,
  23. background: ['demo-text-1', 'demo-text-2', 'demo-text-3'],
  24. indicatorDots: true,
  25. vertical: false,
  26. autoplay: false,
  27. interval: 2000,
  28. duration: 500
  29. },
  30. handleBox: function() {
  31. console.log("box")
  32. },
  33. handleBox1: function(event) {
  34. console.log(event,'wwww')
  35. console.log("box1")
  36. // event.stopPropagation();
  37. // event.cancleBubble = true;
  38. // event.preventDefault();
  39. // event.returnValue = false;
  40. },
  41. handleUser:function() {
  42. wx.setStorageSync('user', '图图')
  43. },
  44. getUser:function() {
  45. console.log(wx.getStorageSync('user'))
  46. },
  47. goDetail:function() {
  48. console.log("触发")
  49. wx.navigateTo({
  50. url: '/pages/detail/detail',
  51. // url: '/pages/detail/detail?id=123&name=Tom',
  52. })
  53. },
  54. goDetail1:function() {
  55. let users = {name:"图图",age:3}
  56. wx.redirectTo({
  57. url: '/pages/detail/detail?user=' + JSON.stringify(users),
  58. })
  59. },
  60. goMy:function() {
  61. wx.switchTab({
  62. url: '/pages/my/my',
  63. })
  64. },
  65. goMy2:function() {
  66. wx.reLaunch({
  67. url: '/pages/detail/detail',
  68. })
  69. },
  70. /**
  71. * 生命周期函数--监听页面加载
  72. * 页面加载时触发 一个页面只会调用一次
  73. */
  74. onLoad(options) {
  75. console.log("1")
  76. },
  77. /**
  78. * 生命周期函数--监听页面初次渲染完成
  79. * 一个页面只会触发一次
  80. */
  81. onReady() {
  82. console.log("2")
  83. },
  84. /**
  85. * 生命周期函数--监听页面显示
  86. * 页面显示 切入/切除时触发
  87. * 触发n次
  88. */
  89. onShow() {
  90. console.log('3')
  91. },
  92. /**
  93. * 生命周期函数--监听页面隐藏
  94. */
  95. onHide() {
  96. console.log("4");
  97. },
  98. /**
  99. * 生命周期函数--监听页面卸载
  100. */
  101. onUnload() {
  102. console.log("5")
  103. },
  104. /**
  105. * 页面相关事件处理函数--监听用户下拉动作
  106. */
  107. onPullDownRefresh() {
  108. console.log("6")
  109. },
  110. /**
  111. * 页面上拉触底事件的处理函数
  112. */
  113. onReachBottom() {
  114. },
  115. /**
  116. * 用户点击右上角分享
  117. */
  118. onShareAppMessage() {
  119. }
  120. })