微信公众号开发

微信小程序 下载视频 图片

本文主要是介绍微信小程序 下载视频 图片,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

 // 保存图片

    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

                })

            }

        })

    },

这篇关于微信小程序 下载视频 图片的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!