com_search.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // pages/com_search/com_search.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. resultList: []
  8. },
  9. searchTo(){
  10. wx.navigateTo({
  11. url: '../../pages/search/search',
  12. })
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad(options) {
  18. var data = JSON.parse(decodeURIComponent(options.comList))
  19. console.log(data);
  20. this.setData({
  21. resultList: data
  22. })
  23. },
  24. //推荐商品传递数据
  25. detailTo(e) {
  26. console.log(e.currentTarget.dataset);
  27. const id = e.currentTarget.dataset.id;
  28. const title = e.currentTarget.dataset.title;
  29. const price = e.currentTarget.dataset.price;
  30. const comImg = e.currentTarget.dataset.pic;
  31. wx.navigateTo({
  32. url: '/pages/details/details?id=' + id + '&title=' + title + '&price=' + price + '&img=' + comImg,
  33. })
  34. },
  35. /**
  36. * 生命周期函数--监听页面初次渲染完成
  37. */
  38. onReady() {
  39. },
  40. /**
  41. * 生命周期函数--监听页面显示
  42. */
  43. onShow() {
  44. },
  45. /**
  46. * 生命周期函数--监听页面隐藏
  47. */
  48. onHide() {
  49. },
  50. /**
  51. * 生命周期函数--监听页面卸载
  52. */
  53. onUnload() {
  54. },
  55. /**
  56. * 页面相关事件处理函数--监听用户下拉动作
  57. */
  58. onPullDownRefresh() {
  59. },
  60. /**
  61. * 页面上拉触底事件的处理函数
  62. */
  63. onReachBottom() {
  64. },
  65. /**
  66. * 用户点击右上角分享
  67. */
  68. onShareAppMessage() {
  69. }
  70. })