79 lines
1.7 KiB
JavaScript
79 lines
1.7 KiB
JavaScript
var posterBehavior = require("../../../poster/poster.js");
|
|
var app = getApp();
|
|
|
|
Component({
|
|
/**
|
|
* 组件的属性列表
|
|
*/
|
|
behaviors: [posterBehavior],
|
|
properties: {
|
|
activityid: {
|
|
type: Number,
|
|
},
|
|
},
|
|
|
|
/**
|
|
* 组件的初始数据
|
|
*/
|
|
data: {},
|
|
ready() {
|
|
// this.getPosterPic();
|
|
},
|
|
|
|
/**
|
|
* 组件的方法列表
|
|
*/
|
|
methods: {
|
|
async getPosterPic() {
|
|
var urlStr = app.getNetAddresss(
|
|
"plugin.community-relay.frontend.activity.get-poster"
|
|
);
|
|
|
|
app._getNetWork({
|
|
showToastIn: false,
|
|
url: urlStr,
|
|
data: {
|
|
activity_id: this.data.activityid,
|
|
code_type: 2,
|
|
get_type: 1,
|
|
},
|
|
success: (resdata) => {
|
|
let res = resdata.data;
|
|
if (res.result != 1) {
|
|
wx.showToast({
|
|
title: res.msg,
|
|
});
|
|
return;
|
|
}
|
|
this.setData({
|
|
poster: res.data,
|
|
});
|
|
},
|
|
});
|
|
},
|
|
saveImg() {
|
|
console.log("执行", this.data.poster);
|
|
var imgSrc = this.data.poster;
|
|
var imgPath =
|
|
wx.env.USER_DATA_PATH + "/solitaire_qrcode" + "haibao" + ".png";
|
|
var imageData = imgSrc.replace(/^data:image\/\w+;base64,/, "");
|
|
var fs = wx.getFileSystemManager();
|
|
fs.writeFileSync(imgPath, imageData, "base64");
|
|
wx.saveImageToPhotosAlbum({
|
|
filePath: imgPath,
|
|
success: (data) => {
|
|
fs.unlinkSync(imgPath);
|
|
wx.showToast({
|
|
title: "保存成功",
|
|
icon: "none",
|
|
duration: 2000,
|
|
});
|
|
},
|
|
fail: function (err) {
|
|
console.log(err);
|
|
},
|
|
});
|
|
},
|
|
},
|
|
});
|