/**
 * Created by ZHJY on 2020/6/18.
 */

var previewContainer = new Vue({
    el:"#previewContainer",
    data: {
        tabIndex:0,
        userId:'',
        shopId:'',
        isRequest:false,
        shopInfo:{},
        shopData:{},
        previewBigimage:'',
        previewThumb:[],
        previewTags:[],
        previewParams:[],
    },
    computed: {

    },
    methods: {
        shopInfoData: function(){
            var _this = this;
            SupplierApi.SupplierViewShopInfo({userId:_this.userId},function(response){
                if(response.code ==0 ){
                    _this.isRequest = true;
                    _this.shopData = response.data.shop;
                }
            });
        },
        infoFata: function(){
            var _this = this;
            _this.previewThumb = _this.shopInfo.params.image;
        },
        changeTab: function(index){
            this.tabIndex = index;
        },
        homePageFn: function(){
            window.open('/supplier/index.html?id='+this.shopId);
        },
        toFixedFn: function(text){
            return Number(text).toFixed(2);
        },
        gernerateTitleId: function(index){
            return "title_" +index
        },
        setArray: function(arr){//回显处理字符串
            var _ARRAY = [];
            arr.split(',').forEach(function(item,index){
                var _OBJ = {name:item};
                _ARRAY.push(_OBJ)
            });
            return _ARRAY
        },
    },
    mounted: function () {
        var _this = this;
        if(globalUserData){
            _this.userId = globalUserData.userId;
            _this.shopId = globalUserData.shopId;
        }
        if( CAIMEI.Storage.getItem('adProductPeview')){
            _this.shopInfo =JSON.parse(CAIMEI.Storage.getItem('adProductPeview'));
            _this.infoFata();
            _this.shopInfoData();
            _this.previewBigimage = _this.shopInfo.params.image[0].image;
            _this.previewTags =_this.setArray(_this.shopInfo.tags);
            _this.previewParams =_this.shopInfo.params.param;
            console.log(_this.previewTags);
        }
        var magnifier = new mag('.preview-banner-big', '.preview-box','#CM____pic_thumb','.hover','.bigitem');
            magnifier.init();
    }
});
