imgswiper.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* DIY组件:Searchbar
  2. */
  3. var Nova = getApp().Nova;
  4. Component({
  5. behaviors: [],
  6. // 属性定义(详情参见下文)
  7. properties: {
  8. options: null,
  9. },
  10. data: {
  11. list: []
  12. }, // 私有数据,可用于模板渲染
  13. lifetimes: {
  14. // 生命周期函数,可以为函数,或一个在methods段中定义的方法名
  15. attached: function() {
  16. },
  17. moved: function() {},
  18. detached: function() {},
  19. },
  20. ready: function() { // 在组件布局完成后执行,确保options参数中有data信息
  21. this.loadData();
  22. },
  23. pageLifetimes: {
  24. // 组件所在页面的生命周期函数
  25. show: function() {},
  26. hide: function() {},
  27. resize: function() {},
  28. },
  29. methods: {
  30. /*********************************
  31. * 重要方法:加载数据
  32. * ******************************/
  33. async loadData() {
  34. await Nova.checkComponentsDataProperties(this);
  35. let list = await Nova.getBlockData(this.data.options.data)
  36. let { options } = this.data
  37. console.log('轮播图组', options);
  38. console.log(list)
  39. let {
  40. data,
  41. src,
  42. style,
  43. } = options
  44. let { className, filter } = data
  45. this.setData({
  46. list,
  47. style,
  48. className,
  49. filter
  50. })
  51. },
  52. /*********************************
  53. * 重要方法:链接跳转
  54. * ******************************/
  55. goNovaURL: function(ev) {
  56. let banner = ev.currentTarget.dataset.item;
  57. let url = ""
  58. console.log(banner)
  59. if (banner.url) {
  60. url = banner.url
  61. } else {
  62. if (banner.shopGoods) {
  63. url = "/nova-shop/pages/shop-goods/goods-detail/index?id=" + banner.shopGoods.objectId
  64. } else if (banner.article) {
  65. url = "/common-page/pages/cates/article-detail/index?id=" + banner.article.objectId
  66. }
  67. }
  68. Nova.goNovaURL(url);
  69. }
  70. }
  71. })