home.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. // pages/home/home.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. name:"图图",
  8. users: "小明",
  9. list:[
  10. {
  11. id:1,
  12. name:"孙悟空",
  13. desc:"金箍棒"
  14. },
  15. {
  16. id:2,
  17. name:"猪八戒",
  18. desc:"九齿钉耙"
  19. },
  20. {
  21. id:3,
  22. name:"图图",
  23. desc:"翻斗花园"
  24. }
  25. ],
  26. score: 50,
  27. background: ['demo-text-1', 'demo-text-2', 'demo-text-3'],
  28. indicatorDots: true,
  29. vertical: false,
  30. autoplay: true,
  31. interval: 2000,
  32. duration: 500
  33. },
  34. handleChange: function() {
  35. console.log("触碰了")
  36. this.setData({
  37. name:"哆啦A梦"
  38. })
  39. },
  40. goDetail(event) {
  41. console.log('x',event)
  42. // wx.navigateTo({
  43. // url: `/pages/detail/detail?id=${event.target.dataset.id}`,
  44. // })
  45. wx.navigateTo({
  46. url: '/pages/detail/detail',
  47. success(res) {
  48. const channel = res.eventChannel;
  49. channel.emit('send',{
  50. name:'小明',
  51. list:[1,2,3,4]
  52. })
  53. }
  54. })
  55. },
  56. handleRead() {
  57. console.log(wx.getStorageSync('username'))
  58. },
  59. handleShow() {
  60. // wx.showToast({
  61. // title: '你好',
  62. // icon:'error'
  63. // })
  64. wx.setStorageSync('username', '小强')
  65. },
  66. handleJump() {
  67. console.log("你好")
  68. // wx.navigateTo({
  69. // url: '/pages/detail/detail',
  70. // })
  71. // wx.redirectTo({
  72. // url: '/pages/detail/detail',
  73. // })
  74. // wx.switchTab({
  75. // url: '/pages/list/list',
  76. // })
  77. wx.reLaunch({
  78. url: '/pages/list/list',
  79. })
  80. },
  81. handleInput(e) {
  82. // console.log(e,'eeee')
  83. const key = e.detail.value;
  84. this.setData({
  85. users: key
  86. })
  87. console.log(this.data.users,'sss')
  88. },
  89. handleChange(e) {
  90. console.log(e)
  91. },
  92. handleScore:function() {
  93. console.log(this.data.score,'分数')
  94. this.setData({
  95. score: this.data.score + 10
  96. })
  97. },
  98. handleBox: function() {
  99. console.log("box")
  100. },
  101. handleBox1: function() {
  102. console.log("box1")
  103. },
  104. /**
  105. * 生命周期函数--监听页面加载
  106. */
  107. onLoad(options) {
  108. console.log("111")
  109. },
  110. /**
  111. * 生命周期函数--监听页面初次渲染完成
  112. */
  113. onReady() {
  114. console.log("222")
  115. },
  116. /**
  117. * 生命周期函数--监听页面显示
  118. */
  119. onShow() {
  120. console.log("333")
  121. },
  122. /**
  123. * 生命周期函数--监听页面隐藏
  124. */
  125. onHide() {
  126. console.log("444")
  127. },
  128. /**
  129. * 生命周期函数--监听页面卸载
  130. */
  131. onUnload() {
  132. console.log("555")
  133. },
  134. /**
  135. * 页面相关事件处理函数--监听用户下拉动作
  136. */
  137. onPullDownRefresh() {
  138. console.log("666")
  139. },
  140. /**
  141. * 页面上拉触底事件的处理函数
  142. */
  143. onReachBottom() {
  144. },
  145. /**
  146. * 用户点击右上角分享
  147. */
  148. onShareAppMessage() {
  149. }
  150. })