博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
微信小程序保存图片功能实现
阅读量:6950 次
发布时间:2019-06-27

本文共 1691 字,大约阅读时间需要 5 分钟。

小程序保存图片功能实现

wxml:

wxss:

.previewImage{
position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: #000;}

 

 

js:

previewImg:function(){        this.setData({            previewImage:"block"        });    },    saveImg:function(){        longTouch = true;        this.setData({            saveImage:false        })    },    closePrev:function(){        if(longTouch){            longTouch = false;        }else{            this.setData({                previewImage:"none"            });        }    },    actionSheetChange:function(){        this.setData({            saveImage:!this.data.saveImage        })    },    downloadFile:function(e){        var imgUrl = e.currentTarget.dataset.imageHref;        var that = this;        wx.downloadFile({              url: imgUrl,              type: 'image',              success:function(res){                  var tempFilePath = res.tempFilePath;                console.log(tempFilePath);                wx.saveFile({                      tempFilePath:tempFilePath,                      success:function(res){                        var savedFilePath = res.savedFilePath;                        console.log(savedFilePath);                        that.setData({                            saveImage:true                        });                      },                      fail:function(res){                          console.log(res);                      }                });              },              fail:function(res){                  console.log(res);              }        });    }

 

转载地址:http://mqkil.baihongyu.com/

你可能感兴趣的文章
使用Symantec Backup Exec 对Exchange 2010 进行备份还原和灾难恢复系列之三
查看>>
Java词汇表(五)S——T
查看>>
Java词汇表(四)P——R
查看>>
连接查询,子查询,联合查询
查看>>
php性能分析工具xhprof
查看>>
Codevs 1503 愚蠢的宠物 解题报告
查看>>
python中matplotlib绘制图形
查看>>
Java IO流详解
查看>>
POJ 2886 线段树 反素数
查看>>
我的友情链接
查看>>
weblogic 配置mysql数据源Cannot load driver class: com.mysql.jdbc.Driver的问题
查看>>
RIP
查看>>
微软近期Open的职位
查看>>
ElasticSearch-倒排索引
查看>>
python隐含的特性
查看>>
爬虫笔记(十一)——认识cookie
查看>>
python内置模块——time
查看>>
uva 10280(欧拉函数)
查看>>
面试 : C语言 功底 被 鄙视了
查看>>
MySQL优化—工欲善其事,必先利其器(2)
查看>>