12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- var Nova = getApp().Nova
- Component({
- /**
- * 组件的属性列表
- */
- properties: {
- options: null
- },
- /**
- * 组件的初始数据
- */
- data: {
- column: 'one', // 展示形式
- list: null
- },
- lifetimes: {
- attached: function() {
- let { options } = this.data
- console.log('商品组', options)
- let { data, style, column } = options
- this.setData({
- column,
- src: data.src,
- style
- })
- }
- },
- ready: function() {
- // 在组件布局完成后执行,确保options参数中有data信息
- console.log('ready')
- this.loadData()
- },
- /**
- * 组件的方法列表
- */
- methods: {
- // 加载数据的重要方法
- loadData: async function() {
- await Nova.checkComponentsDataProperties(this)
- let list = await Nova.getBlockData(this.data.options.data)
- list = list.length > 0 ? list :this.data.options.data.list
- console.log(list)
- this.setData({
- list: list
- })
- },
- goNovaURL: function(ev) {
- console.log(ev)
- let { url, id } = ev.currentTarget.dataset
- if (id) {
- url = `/nova-shop/pages/shop-goods/goods-detail/index?id=${id}`
- }
- console.log(url)
- Nova.goNovaURL(url)
- }
- }
- })
|