const util = require("../../../utils/util");
const app = getApp();
Component({
  properties: {
    show: {
      type: Boolean,
      observer: function (newVal) {
        this.setData({ showCode: newVal });
        if (newVal) {
          this.getPopupContent()
        }
      }
    },
  },
  data: {
    height:'80%',
    showCode:false,
    headImg:'',
  },
  methods: {
    // 弹窗关闭
    closeCode(e){
      this.close(e.detail)
    },
    close(data){
      console.log(data)
      this.triggerEvent("close", {
        status:data,
        type:'subSuccess'
      });
    },
    // 获取弹窗内容
    getPopupContent(){
      var that = this;
      util.ajax({
        func: "article/wx_info",
        load: false
      }, function (res) {
        if (res.code == 0) {
          that.setData({
            headImg:res.data.wxlogo
          })
        } else {
          util.showTips(res.reason);
        }
      })
    },
    saveImage(e){
      // let self = this;
      // wx.downloadFile({
      //   url:e.currentTarget.dataset.img,
      //   success(res) {
      //     wx.saveImageToPhotosAlbum({
      //       filePath:res.tempFilePath,
      //       success:(res)=>{
      //         util.showTips('已保存至相册！')
      //         setTimeout(() => {
      //           self.close(false)
      //         }, 500);
      //       }
      //     })
      //   },
      //   fail(res){
      //     util.showTips('保存失败！')
      //   }
      // })
      this.close(false)
    }
  }
})