| | |
| | | // pages/webView/index.js |
| | | |
| | | import { |
| | | } from '../../api/index' |
| | | Page({ |
| | | |
| | | /** |
| | |
| | | hasUserInfo: true, |
| | | userInfo: {}, |
| | | id: '', |
| | | link: '' |
| | | linkUrl: '' |
| | | }, |
| | | |
| | | onLoad: function (options) { |
| | | let that = this |
| | | const eventChannel = this.getOpenerEventChannel() |
| | | |
| | | if (options.link) { |
| | | that.setData({ link: options.link, id: options.id || '' }) |
| | | } else { |
| | | // 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据 |
| | | eventChannel.on('acceptDataFromOpenerPage', function(data) { |
| | | console.log('参数', data) |
| | | if (data.title) wx.setNavigationBarTitle({ title: data.title }) |
| | | that.setData({ link: data.link, id: data.id }) |
| | | // saveBannerLookNum({ id: data.id }) |
| | | }) |
| | | } |
| | | var that = this |
| | | const eventChannel = this.getOpenerEventChannel() |
| | | if(eventChannel){ |
| | | eventChannel.on('data', function (res) { |
| | | console.log(res)//传递参数 |
| | | if(res){ |
| | | that.setData({ linkUrl: res.link}) |
| | | console.log(that.data.linkUrl) |
| | | } |
| | | }); |
| | | } |
| | | }, |
| | | |
| | | /** |