小程序_操作图片(上传预览及保存)

图片长按保存

图片长按保存(多张图片循环渲染后预览、保存、识别带参数二维码)

1
2
3
4
// .wxml
<view wx:for="{{imgalist}}" wx:for-item="image" class="previewimg">
<image src="{{image}}" data-src="{{image}}" bindtap="previewImage"></image>
</view>
1
2
3
4
5
6
7
8
9
10
11
12
// .js
Page({
data: {
imgalist: ['http://sz800800.cn/video/test.png', 'http://sz800800.cn/video/test.png'],
},
previewImage: function (e) {
wx.previewImage({
current: this.data.imgalist, // 当前显示图片的http链接
urls: this.data.imgalist // 需要预览的图片http链接列表
})
},
})

实现图片点开长按保存到相册

单张图片预览、保存、识别带参数二维码(目前实测无效果)

1
2
3
4
5
<!-- .wxml-->  
<text class='search_no'>点击可保存及分享二维码</text>
<view class='view_img' >
<image class='img' bindtap="previewImage" src='{{scene}}'></image>
</view>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// .js  
var app = getApp();
Page({
data: {
scene: ''
},
onLoad: function (options) {
var that = this
var scene_img = '' //这里添加图片的地址
that.setData({
scene: scene_img
})
},
previewImage: function (e) {
wx.previewImage({
urls: this.data.scene.split(',')
// 需要预览的图片http链接 使用split把字符串转数组。不然会报错
})
}
})