/* DIY组件:Searchbar */ var Nova = getApp().Nova; Component({ behaviors: [], // 属性定义(详情参见下文) properties: { options: null, }, data: { list: [] }, // 私有数据,可用于模板渲染 lifetimes: { // 生命周期函数,可以为函数,或一个在methods段中定义的方法名 attached: function() { }, moved: function() {}, detached: function() {}, }, ready: function() { // 在组件布局完成后执行,确保options参数中有data信息 this.loadData(); }, pageLifetimes: { // 组件所在页面的生命周期函数 show: function() {}, hide: function() {}, resize: function() {}, }, methods: { /********************************* * 重要方法:加载数据 * ******************************/ async loadData() { await Nova.checkComponentsDataProperties(this); let list = await Nova.getBlockData(this.data.options.data) let { options } = this.data console.log('轮播图组', options); console.log(list) let { data, src, style, } = options let { className, filter } = data this.setData({ list, style, className, filter }) }, /********************************* * 重要方法:链接跳转 * ******************************/ goNovaURL: function(ev) { let banner = ev.currentTarget.dataset.item; let url = "" console.log(banner) if (banner.url) { url = banner.url } else { if (banner.shopGoods) { url = "/nova-shop/pages/shop-goods/goods-detail/index?id=" + banner.shopGoods.objectId } else if (banner.article) { url = "/common-page/pages/cates/article-detail/index?id=" + banner.article.objectId } } Nova.goNovaURL(url); } } })