app 图片下载

develop
jscyl13849007907 12 months ago
parent ad8bc7ea7a
commit 6107ca5c53

@ -38,6 +38,42 @@ Component({
this.setData({ this.setData({
showModal: false showModal: false
}) })
} },
saveImage: function (e) {
console.log('saveImage', e.currentTarget.dataset.src);
const imageUrl = e.currentTarget.dataset.src;
// 给出确认弹窗
wx.downloadFile({
url: imageUrl,
success: res => {
if (res.statusCode === 200) {
wx.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success: () => {
wx.showToast({
title: '保存成功',
icon: 'success'
});
},
fail: err => {
console.error('保存失败', err);
wx.showToast({
title: '保存失败',
icon: 'none'
});
}
});
}
},
fail: err => {
console.error('下载失败', err);
wx.showToast({
title: '下载失败',
icon: 'none'
});
}
});
},
} }
}) })

@ -16,7 +16,13 @@
</view> </view>
<view class hover-class="none" hover-stop-propagation="false">加载中...</view> <view class hover-class="none" hover-stop-propagation="false">加载中...</view>
</view> </view>
<!-- #if MP -->
<image src="{{serviceInfo.qrCode}}" bindload="imageLoad" show-menu-by-longpress="{{true}}" style="width: 184px;height: 184px;"></image> <image src="{{serviceInfo.qrCode}}" bindload="imageLoad" show-menu-by-longpress="{{true}}" style="width: 184px;height: 184px;"></image>
<!-- #elif IOS -->
<image src="{{serviceInfo.qrCode}}" data-src="{{serviceInfo.qrCode}}" bindload="imageLoad" bindlongpress="saveImage" show-menu-by-longpress="{{false}}" style="width: 184px;height: 184px;"></image>
<!-- #elif ANDROID -->
<image src="{{serviceInfo.qrCode}}" data-src="{{serviceInfo.qrCode}}" bindload="imageLoad" bindlongpress="saveImage" show-menu-by-longpress="{{false}}" style="width: 184px;height: 184px;"></image>
<!-- #endif -->
<!-- <view class="f14 c9">人才经纪人</view> --> <!-- <view class="f14 c9">人才经纪人</view> -->
<!-- <view class="mt20 f22 c3">{{pmdUserInfo.tel}}</view> --> <!-- <view class="mt20 f22 c3">{{pmdUserInfo.tel}}</view> -->
<view class="f14 c3 mt6">长按识别二维码</view> <view class="f14 c3 mt6">长按识别二维码</view>

@ -44,7 +44,7 @@
"tabIndent": "insertSpaces", "tabIndent": "insertSpaces",
"tabSize": 2 "tabSize": 2
}, },
"appid": "wxe431e0b3abd9ae0b", "appid": "wxb0dea4d11428c6a5",
"packOptions": { "packOptions": {
"ignore": [], "ignore": [],
"include": [] "include": []

Loading…
Cancel
Save