业务交流通
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

listItem.js 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // components/listItem/listItem.js
  2. const app = getApp()
  3. Component({
  4. /**
  5. * 组件的属性列表
  6. */
  7. properties: {
  8. // 数据
  9. item: {
  10. type: Object,
  11. },
  12. // index => 首页 detatil => 详情 homepage => 个人主页
  13. pageStatus: {
  14. type: String,
  15. default: 'index',
  16. },
  17. // 是否收藏
  18. isCollect: {
  19. type: Boolean,
  20. default: false
  21. },
  22. // 类名
  23. listClass: {
  24. type: String,
  25. default: "",
  26. },
  27. },
  28. /**
  29. * 组件的初始数据
  30. */
  31. data: {
  32. },
  33. /**
  34. * 组件的方法列表
  35. */
  36. methods: {
  37. // 进入详情
  38. goDetails(e) {
  39. if (this.data.listClass == 'disabled-model-view') {
  40. return
  41. }
  42. let dataset = e.currentTarget.dataset;
  43. this.triggerEvent('getItem', dataset.item);
  44. },
  45. // 进入个人主页
  46. goHomePage(e) {
  47. let customerid = e.currentTarget.dataset.customerid;
  48. wx.navigateTo({
  49. url: '/pages/index/components/homepage/homepage',
  50. success: function (res) {
  51. // 通过eventChannel向被打开页面传送数据
  52. res.eventChannel.emit('customerid', { customerid })
  53. }
  54. })
  55. },
  56. // 收藏
  57. productCollect(e) {
  58. this.triggerEvent('changeCollect');
  59. },
  60. // 聊一聊
  61. goToChat() {
  62. if (!app.globalData.customerId) {
  63. app.goLogin();
  64. return
  65. }
  66. console.log(`点击了聊一聊`)
  67. wx.navigateTo({
  68. url:"/pages/msgModule/wechat2/wechat2",
  69. success: function (res) {
  70. // 通过eventChannel向被打开页面传送数据
  71. res.eventChannel.emit('customerid', { customerid })
  72. }
  73. })
  74. },
  75. }
  76. })