12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- /* DIY组件:Searchbar
- */
- var Parse = getApp().Parse;
- var Nova = getApp().Nova;
- Component({
- behaviors: [],
- // 属性定义(详情参见下文)
- properties: {
- options: null,
- },
- data: {
- list: [],
- }, // 私有数据,可用于模板渲染
- lifetimes: {
- // 生命周期函数,可以为函数,或一个在methods段中定义的方法名
- attached: function () {
- console.log("diy-icongroup", this.data);
- },
- moved: function () { },
- detached: function () { },
- },
- ready: function () {
- // 在组件布局完成后执行,确保options参数中有data信息
- console.log("ready");
- 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: async function (ev) {
- let item = ev.currentTarget.dataset.item;
- let url = "";
- if (item.url) {
- console.log(item.url);
- if (item.name) {
- url = item.url + '?title=' + item.name;
- } else {
- url = item.url
- }
- Nova.goNovaURL(url);
- return;
- }
- if (item.type == "shop") {
- url = `/nova-shop/pages/shop-list/index?title=${item.name}&cid=${item.objectId}`;
- } else if (item.type == "article") {
- let Article = new Parse.Query("Article");
- Article.select('objectId')
- Article.equalTo("category", item.objectId);
- let articles = await Article.find();
- if (articles && articles.length == 1) {
- url = `/common-page/pages/cates/article-detail/index?title=${item.name}&aid=${articles[0].objectId}`;
- } else if (articles && articles.length > 1) {
- url = `/common-page/pages/cates/article-list/index?title=${item.name}&cid=${item.objectId}`;
- }
- }
- Nova.goNovaURL(url);
- },
- },
- });
|