|
@@ -107,6 +107,11 @@
|
|
|
import htzImageUpload from '@/components/htz-image-upload/htz-image-upload.vue';
|
|
|
import getPolicyEncode from '@/components/obs/getPolicy.js';
|
|
|
import getSignature from '@/components/obs/GetSignature.js';
|
|
|
+ import {
|
|
|
+ saveImageToPhotosAlbum,
|
|
|
+ showToast,
|
|
|
+ downloadFile
|
|
|
+ } from '@/uni_modules/sakura-canvas/js_sdk/util'
|
|
|
export default {
|
|
|
components: {
|
|
|
mvBar,
|
|
@@ -361,29 +366,69 @@
|
|
|
},
|
|
|
// 保存图片
|
|
|
async saveImage() {
|
|
|
- // showToast('保存成功')
|
|
|
- wx.downloadFile({
|
|
|
- url: 'https://horastar.obs.cn-east-3.myhuaweicloud.com/talent/lQLPDhrXwll1_NcjI7AD0T3viYtxQwGOvh1SwG0A_35_35u',
|
|
|
- success: function(res) {
|
|
|
- wx.saveImageToPhotosAlbum({
|
|
|
- filePath: res.tempFilePath,
|
|
|
- success: function(data) {
|
|
|
- wx.showToast({
|
|
|
- title: "保存成功",
|
|
|
- icon: "success",
|
|
|
- duration: 2000
|
|
|
- })
|
|
|
- },
|
|
|
- fail: function(err) {
|
|
|
- console.log(err);
|
|
|
- },
|
|
|
- complete(res) {
|
|
|
- console.log(res);
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
+ console.log("进入保存方法");
|
|
|
+
|
|
|
+ // 将base64数据部分提取出来
|
|
|
+ const base64 = this.qrcodeURL.replace(/^data:image\/\w+;base64,/, "");
|
|
|
+
|
|
|
+ // 将base64字符串转换为ArrayBuffer
|
|
|
+ const buffer = wx.base64ToArrayBuffer(base64);
|
|
|
+
|
|
|
+ // 使用文件系统管理器将ArrayBuffer写入文件
|
|
|
+ wx.getFileSystemManager().writeFile({
|
|
|
+ filePath: `${wx.env.USER_DATA_PATH}/qrcode.png`,
|
|
|
+ data: buffer,
|
|
|
+ encoding: 'binary',
|
|
|
+ success: res => {
|
|
|
+ // 文件写入成功后,保存图片到相册
|
|
|
+ wx.saveImageToPhotosAlbum({
|
|
|
+ filePath: `${wx.env.USER_DATA_PATH}/qrcode.png`,
|
|
|
+ success: function(data) {
|
|
|
+ wx.showToast({
|
|
|
+ title: "保存成功",
|
|
|
+ icon: "success",
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+ },
|
|
|
+ fail: function(err) {
|
|
|
+ console.log(err);
|
|
|
+ },
|
|
|
+ complete: function(res) {
|
|
|
+ console.log(res);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ fail: err => {
|
|
|
+ console.log(err);
|
|
|
+ }
|
|
|
+ });
|
|
|
},
|
|
|
+
|
|
|
+ // async saveImage() {
|
|
|
+ // console.log("into save")
|
|
|
+ // // showToast('保存成功')
|
|
|
+ // wx.downloadFile({
|
|
|
+ // url: this.qrcodeURL,
|
|
|
+ // success: function(res) {
|
|
|
+ // wx.saveImageToPhotosAlbum({
|
|
|
+ // filePath: res.tempFilePath,
|
|
|
+ // success: function(data) {
|
|
|
+ // wx.showToast({
|
|
|
+ // title: "保存成功",
|
|
|
+ // icon: "success",
|
|
|
+ // duration: 2000
|
|
|
+ // })
|
|
|
+ // },
|
|
|
+ // fail: function(err) {
|
|
|
+ // console.log(err);
|
|
|
+ // },
|
|
|
+ // complete(res) {
|
|
|
+ // console.log(res);
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // },
|
|
|
closepop() {
|
|
|
this.$refs.popup4.close()
|
|
|
},
|