savefile.js 1.12 KB
// component/menu/addDelete.js
import util from '../../utils/util';
import App from '../../utils/api';

Component({
  /**
   * 组件的属性列表
   */
  properties: {
    filePath:String,
  },

  /**
   * 组件的初始数据
   */
  data: {

  },
  attached(){

  },
  ready () {

  },
  detached(){

  },
  /**
   * 组件的方法列表
   */
  methods: {
    saveFile(){
      let filePath=this.data.filePath
      console.log('saveFile.filePath',filePath)
      wx.saveImageToPhotosAlbum({
        filePath:filePath,
        complete:res=>{
          console.log(res,filePath)
        },
        success:res=>{
          util.toast('已保存到相册')
        },
        fail:(efail)=>{
          console.log('saveImageToPhotosAlbum.fail',efail)
          wx.showModal({
            title: '授权提示',
            content: '您拒绝了保存文件,请点击确定打开授权',
            confirmColor: '#199095',
            cancelColor: '#999',
            success: function (res) {
              if (res.confirm) {
                util.setting();
              }
            }
          })
        },
      })
    },
  }
})