const _Http = getApp().globalData.http;
Component({
    properties: {
        add: {
            type: Boolean
        }, //是否允许新增
        ownertable: {
            type: String
        },
        ownerid: {
            type: String
        },
        onGetList: {
            type: Function
        }
    },
    data: {
        datatag: [],
        systemtag: [],
    },
    lifetimes: {
        attached() {
            getApp().globalData.Language.getLanguagePackage(this)
        }
    },
    methods: {
        /* 获取标签 */
        getTags() {
            return new Promise((resolve, reject) => {
                _Http.basic({
                    "id": 20220929085401,
                    "content": {
                        nocache: true,
                        ownertable: this.data.ownertable,
                        ownerid: this.data.ownerid
                    }
                }).then(res => {
                    console.log("标签列表", res)
                    if (res.code != '1') return wx.showToast({
                        title: res.data,
                        icon: "none"
                    });
                    resolve(res.code != '1' ? {datatag:[],option:[],systemtag:[]} : res.data)
                    this.triggerEvent("onGetList", res)
                    this.setData({
                        ...res.data
                    })
                })
            })
        },
        addTags() {
            wx.navigateTo({
                url: `/pages/tags/index?ownertable=${this.data.ownertable}&ownerid=${this.data.ownerid}`
            })
        },
        returnTags() {
            return {
                datatag: this.data.datatag,
                systemtag: this.data.systemtag
            }
        }
    }
})