anchor.js 1.4 KB
import event from '../../../utils/event';
// const router = global.router;
import { jumpByUrl } from '../../../libs/urlRoute';
Component({
    properties: {
        url: {
            type: String,
            value: ''
        },
        hasUrl: {
          type: Boolean,
          value: true
        },
        isFloor: {
            type: Number,
            value: 0
        },
        floorData: Object,
        floorIdx: Number,
        itemIdx: Number,
    },
    methods: {
        jumpTo: function() {
            if (this.data.isFloor) {
                
                const {
                    template_id,
                    template_name,
                } = this.data.floorData;
                
                let reportParams = {
                    F_ID: template_id || '0',
                    F_NAME: template_name || '',
                    F_URL: this.data.url || '',
                    F_INDEX: (this.data.floorIdx || 0) + 1 ,
                    I_INDEX: (this.data.itemIdx || 0) + 1
                };

                event.emit('anchor-click', reportParams);
            }
            
            
            // this.data.url && router.goUrl(this.data.url);

          if(this.data.hasUrl) {
            this.data.url && jumpByUrl(this.data.url, 'home');
          } else {
            wx.navigateTo({
              url: this.data.url
            });
          }
          
        }
    }
});