// components/listItem/listItem.js const app = getApp() Component({ /** * 组件的属性列表 */ properties: { // 数据 item: { type: Object, }, // index => 首页 detatil => 详情 homepage => 个人主页 pageStatus: { type: String, value: 'index', }, // 是否收藏 isCollect: { type: Boolean, value:false, }, // 是否显示收藏 isShowCollect:{ type: Boolean, value:false, }, // 是否其他查看主页---用于是否显示聊一聊 isOther:{ type: Boolean, value:true, }, // 类名 listClass: { type: String, value: "", }, }, /** * 组件的初始数据 */ data: { }, /** * 组件的方法列表 */ methods: { // 进入详情 goDetails(e) { if (this.data.listClass == 'disabled-model-view') { return } let dataset = e.currentTarget.dataset; this.triggerEvent('getItem', dataset.item); }, // 进入个人主页 goHomePage(e) { let customerid = e.currentTarget.dataset.customerid; wx.navigateTo({ url: '/pages/index/components/homepage/homepage', success: function (res) { // 通过eventChannel向被打开页面传送数据 res.eventChannel.emit('customerid', { customerid }) } }) }, // 收藏 productCollect(e) { this.triggerEvent('changeCollect'); }, // 聊一聊 goToChat(e) { if (!app.globalData.customerId) { app.goLogin(); return } console.log(`点击了聊一聊`) let item = e.currentTarget.dataset.item; wx.navigateTo({ url:"/pages/msgModule/wechat2/wechat2", success: function (res) { // 通过eventChannel向被打开页面传送数据 res.eventChannel.emit('customerid', { customerid:item.customerId,businessCommunicationDemandId:item.businessCommunicationDemandId }) } }) }, } })