const util = require("../../utils/util");
Component({
  properties: {
    showType:{
      type:Boolean,
      value:false,
      observer:function(newVal){
        this.setData({showType:newVal})
      }
    },
    aid:{
      type:String,
      observer:function(newVal){
        this.setData({aid:newVal})
        this.getGoodstext();
        this.getGoodsList();
      }
    },
  },
  data: {
    dataList:{},
    content:{},
    aid:'',
    showType:false,
  },
  methods: {
    getGoodstext(){
      let that=this;
      util.getGoodstext(this.data.aid).then(res=>{
        let data=res;
        data.provide = data.provide.replace(/section/g, "div");
        data.provide = data.provide.replace(/<img/g, "<img style='max-width:100%'");
        
        data.userProvided = data.userProvided.replace(/section/g, "div");
        data.userProvided = data.userProvided.replace(/<img/g, "<img style='max-width:100%'");
        that.setData({content:data})
      })
    },
    getGoodsList(){
      let that=this;
      util.getGoodsList(this.data.aid).then(res=>{
        res.forEach(el => {
          el.logo=el.logo.replace('@!logo','')
        });
        that.setData({dataList:res})
      })
    }
  }
})
