0
点赞
收藏
分享

微信扫一扫

微信小程序 下载视频 图片

一葉_code 2022-03-11 阅读 72

 // 保存图片

    saveImg() {

        wx.downloadFile({

            url: 'https://........',

            success: function (res) {

                console.log(res)

                wx.saveImageToPhotosAlbum({     //视频 替换 wx.saveVideoToPhotosAlbum

                    filePath: res.tempFilePath,

                    success: function (res) {

                        wx.showToast({

                            title: '保存成功!',

                            icon: 'none',

                            duration: 1500

                        })

                    },

                    fail: function (err) {

                        if (err.errMsg === "saveImageToPhotosAlbum:fail auth deny") {

                            wx.showModal({

                                title: '提示',

                                content: '请先开启“保存到相册”功能',

                                success(res) {

                                    if (res.confirm) {

                                        wx.openSetting();

                                    }

                                }

                            })

                        }

                    }

                })

            },

            fail: function (err) {

                wx.showToast({

                    title: '保存失败, 请重试!',

                    icon: 'none',

                    duration: 1500

                })

            }

        })

    },

举报

相关推荐

0 条评论