|
@@ -22,7 +22,8 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
-import { bannerGetQrcode } from "@/api/report";
|
|
|
|
|
|
+import { bannerGetQrcode, bannerDownload } from "@/api/report";
|
|
|
|
+import { h5BaseUrl } from "@/utils/config";
|
|
export default {
|
|
export default {
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
@@ -40,8 +41,6 @@ export default {
|
|
this.title = op.title;
|
|
this.title = op.title;
|
|
this.bannerId = op.id;
|
|
this.bannerId = op.id;
|
|
this.enable = op.enable;
|
|
this.enable = op.enable;
|
|
- console.log(this.imgBg, this.title);
|
|
|
|
-
|
|
|
|
this.enable == 1 && this.getQrcCode();
|
|
this.enable == 1 && this.getQrcCode();
|
|
uni.setNavigationBarTitle({
|
|
uni.setNavigationBarTitle({
|
|
title: this.title,
|
|
title: this.title,
|
|
@@ -64,114 +63,95 @@ export default {
|
|
};
|
|
};
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
- // 背景图的canvas
|
|
|
|
- renderCanvas() {
|
|
|
|
- const SystemInfo = uni.getSystemInfoSync();
|
|
|
|
- wx.getImageInfo({
|
|
|
|
- src: this.imgBg,
|
|
|
|
- success: (res) => {
|
|
|
|
- const temPath = res.path;
|
|
|
|
- this.canvasW = SystemInfo.windowWidth * 2;
|
|
|
|
- this.canvasH = res.height / (res.width / this.canvasW);
|
|
|
|
- this.drawImg(temPath);
|
|
|
|
- },
|
|
|
|
- fail(err) {
|
|
|
|
- reject(err);
|
|
|
|
- },
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- // 二维码的canvas
|
|
|
|
- drawImg(path) {
|
|
|
|
- let ctx = uni.createCanvasContext("canvasDom", this);
|
|
|
|
- ctx.drawImage(path, 0, 0, this.canvasW, this.canvasH);
|
|
|
|
- if (this.$store.state.user.userInfo.is_bind === 0) {
|
|
|
|
- ctx.draw();
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
|
|
+ // 保存二维码到本地
|
|
|
|
+ async canvasGet() {
|
|
|
|
|
|
- wx.getImageInfo({
|
|
|
|
- src: this.qrcodeImg,
|
|
|
|
- success: (res) => {
|
|
|
|
- ctx.drawImage(
|
|
|
|
- res.path,
|
|
|
|
- this.canvasW * 0.5 - res.width / 2,
|
|
|
|
- this.canvasH - 430,
|
|
|
|
- res.width,
|
|
|
|
- res.height
|
|
|
|
- );
|
|
|
|
- ctx.draw();
|
|
|
|
- },
|
|
|
|
- fail(err) {
|
|
|
|
- reject(err);
|
|
|
|
- },
|
|
|
|
|
|
+ const token = this.$store.state.user.token;
|
|
|
|
+ let userId = this.$store.state.report.inviteShareCode || this.userInfo.user_id;
|
|
|
|
+ let url = `${h5BaseUrl}/hzyb/surveyDetail?token=${token}&userId=${userId}&bannerId=${this.bannerId}&remark=${this.title}#wechat_redirect`;
|
|
|
|
+ const res = await bannerDownload({
|
|
|
|
+ banner_url: url,
|
|
|
|
+ banner_id: +this.bannerId,
|
|
|
|
+ user_id: +this.userId,
|
|
});
|
|
});
|
|
- },
|
|
|
|
-
|
|
|
|
- // 保存二维码到本地
|
|
|
|
- canvasGet() {
|
|
|
|
- uni.canvasToTempFilePath({
|
|
|
|
- canvasId: "canvasDom",
|
|
|
|
- success: (res) => {
|
|
|
|
- wx.saveImageToPhotosAlbum({
|
|
|
|
- filePath: res.tempFilePath,
|
|
|
|
- success: function (data) {
|
|
|
|
- uni.showToast({
|
|
|
|
- title: "保存成功",
|
|
|
|
- duration: 2000,
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- fail: function (err) {
|
|
|
|
- if (
|
|
|
|
- err.errMsg === "saveImageToPhotosAlbum:fail:auth denied" ||
|
|
|
|
- err.errMsg === "saveImageToPhotosAlbum:fail auth deny" ||
|
|
|
|
- err.errMsg ===
|
|
|
|
- "saveImageToPhotosAlbum:fail authorize no response"
|
|
|
|
- ) {
|
|
|
|
- // 这边微信做过调整,必须要在按钮中触发,因此需要在弹框回调中进行调用
|
|
|
|
- wx.showModal({
|
|
|
|
- title: "提示",
|
|
|
|
- content: "需要您授权保存相册",
|
|
|
|
- showCancel: false,
|
|
|
|
- success: (modalSuccess) => {
|
|
|
|
- wx.openSetting({
|
|
|
|
- success(settingdata) {
|
|
|
|
- if (settingdata.authSetting["scope.writePhotosAlbum"]) {
|
|
|
|
- wx.showModal({
|
|
|
|
- title: "提示",
|
|
|
|
- content: "获取权限成功,再次点击图片即可保存",
|
|
|
|
- showCancel: false,
|
|
|
|
- });
|
|
|
|
- } else {
|
|
|
|
- wx.showModal({
|
|
|
|
- title: "提示",
|
|
|
|
- content: "获取权限失败,将无法保存到相册哦~",
|
|
|
|
- showCancel: false,
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- fail(failData) {
|
|
|
|
- // console.log("failData", failData);
|
|
|
|
- },
|
|
|
|
- complete(finishData) {
|
|
|
|
- // console.log("finishData", finishData);
|
|
|
|
- },
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
|
|
+ if (res.code === 200) {
|
|
|
|
+ wx.getImageInfo({
|
|
|
|
+ src: res.data,
|
|
|
|
+ success: (res) => {
|
|
|
|
+ wx.saveImageToPhotosAlbum({
|
|
|
|
+ filePath: res.path,
|
|
|
|
+ success: function (data) {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: "保存成功",
|
|
|
|
+ duration: 2000,
|
|
});
|
|
});
|
|
- }
|
|
|
|
- },
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- fail: () => {
|
|
|
|
- // console.log("下载失败");
|
|
|
|
- },
|
|
|
|
- });
|
|
|
|
|
|
+ },
|
|
|
|
+ fail: function (err) {
|
|
|
|
+ if (
|
|
|
|
+ err.errMsg === "saveImageToPhotosAlbum:fail:auth denied" ||
|
|
|
|
+ err.errMsg === "saveImageToPhotosAlbum:fail auth deny" ||
|
|
|
|
+ err.errMsg ===
|
|
|
|
+ "saveImageToPhotosAlbum:fail authorize no response"
|
|
|
|
+ ) {
|
|
|
|
+ // 这边微信做过调整,必须要在按钮中触发,因此需要在弹框回调中进行调用
|
|
|
|
+ wx.showModal({
|
|
|
|
+ title: "提示",
|
|
|
|
+ content: "需要您授权保存相册",
|
|
|
|
+ showCancel: false,
|
|
|
|
+ success: (modalSuccess) => {
|
|
|
|
+ wx.openSetting({
|
|
|
|
+ success(settingdata) {
|
|
|
|
+ if (
|
|
|
|
+ settingdata.authSetting["scope.writePhotosAlbum"]
|
|
|
|
+ ) {
|
|
|
|
+ wx.showModal({
|
|
|
|
+ title: "提示",
|
|
|
|
+ content: "获取权限成功,再次点击图片即可保存",
|
|
|
|
+ showCancel: false,
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ wx.showModal({
|
|
|
|
+ title: "提示",
|
|
|
|
+ content: "获取权限失败,将无法保存到相册哦~",
|
|
|
|
+ showCancel: false,
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ fail(failData) {
|
|
|
|
+ // console.log("failData", failData);
|
|
|
|
+ },
|
|
|
|
+ complete(finishData) {
|
|
|
|
+ // console.log("finishData", finishData);
|
|
|
|
+ },
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: "保存失败",
|
|
|
|
+ duration: 2000,
|
|
|
|
+ icon: "error",
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ fail(err) {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: "保存失败",
|
|
|
|
+ duration: 2000,
|
|
|
|
+ icon: "error",
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ });
|
|
|
|
+ }
|
|
},
|
|
},
|
|
|
|
|
|
// 获取code 二维码
|
|
// 获取code 二维码
|
|
async getQrcCode() {
|
|
async getQrcCode() {
|
|
const res = await bannerGetQrcode({
|
|
const res = await bannerGetQrcode({
|
|
- UserId: this.$store.state.report.inviteShareCode || this.userInfo.user_id,
|
|
|
|
|
|
+ UserId:
|
|
|
|
+ this.$store.state.report.inviteShareCode || this.userInfo.user_id,
|
|
BannerId: this.bannerId,
|
|
BannerId: this.bannerId,
|
|
Remark: this.title,
|
|
Remark: this.title,
|
|
});
|
|
});
|
|
@@ -180,9 +160,6 @@ export default {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
},
|
|
},
|
|
- onShow() {
|
|
|
|
- this.enable == 1 && this.renderCanvas();
|
|
|
|
- },
|
|
|
|
};
|
|
};
|
|
</script>
|
|
</script>
|
|
<style>
|
|
<style>
|