99 lines
3.3 KiB
JavaScript
99 lines
3.3 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const gen_Apis = require("../../gen/Apis.js");
|
|
const BILL_poster_model = require("./model.js");
|
|
const common_libraries_apiLoading = require("../../common/libraries/apiLoading.js");
|
|
const getQrCode = (data, fun) => {
|
|
common_libraries_apiLoading.getApiLoading(gen_Apis.Apis.HouseOrder.HouseOrders.GetPayQrCode, {
|
|
id: data == null ? void 0 : data.order_id
|
|
}).then((res) => {
|
|
var _a;
|
|
const fs = common_vendor.index.getFileSystemManager();
|
|
var times = new Date().getTime();
|
|
var codeimg = common_vendor.wx$1.env.USER_DATA_PATH + "/" + times + ".png";
|
|
fs.writeFile({
|
|
filePath: codeimg,
|
|
data: (_a = res == null ? void 0 : res.data) == null ? void 0 : _a.qr_code.slice(22),
|
|
encoding: "base64",
|
|
success: () => {
|
|
return fun == null ? void 0 : fun(codeimg);
|
|
}
|
|
});
|
|
});
|
|
};
|
|
const method = {
|
|
//method
|
|
getHouseDetail(id) {
|
|
},
|
|
updateCoverInfo() {
|
|
this.setCanvas(BILL_poster_model.useModel.houseDetail.value);
|
|
},
|
|
setCanvas(data) {
|
|
const context = common_vendor.index.createCanvasContext("firstCanvas");
|
|
getQrCode(data, (url) => {
|
|
common_vendor.index.downloadFile({
|
|
url: "https://jyw-dev-1322946948.cos.ap-guangzhou.myqcloud.com/uploads/cs-test/01K2GQ7CEB6DJ9BN8HMRV8SSWE.png",
|
|
success(res) {
|
|
context.drawImage(res.tempFilePath, 0, 0, 345, 504);
|
|
context.font = "bold 18px Arial";
|
|
context.setTextAlign("center");
|
|
context.fillText((data == null ? void 0 : data.name) || "-", 345 / 2, 45);
|
|
context.font = "bold 16px Arial";
|
|
context.fillStyle = "#DF3600";
|
|
context.fillText(`缴费金额:¥${data == null ? void 0 : data.amount}元`, 345 / 2, 78);
|
|
context.font = "14px Arial";
|
|
context.fillStyle = "#333";
|
|
context.fillText("请使用微信扫码支付", 345 / 2, 450);
|
|
context.font = "12px Arial";
|
|
context.fillStyle = "#666";
|
|
context.fillText(`生成时间:${data == null ? void 0 : data.time}`, 345 / 2, 475);
|
|
context.drawImage(url, 72.5, 150, 200, 200);
|
|
context.restore();
|
|
context.draw();
|
|
}
|
|
});
|
|
console.log(url, "二维码路径");
|
|
});
|
|
},
|
|
onDownloadPosters() {
|
|
common_vendor.index.showLoading({
|
|
title: "正在保存中..."
|
|
});
|
|
common_vendor.index.canvasToTempFilePath({
|
|
x: 0,
|
|
y: 0,
|
|
width: 345,
|
|
height: 504,
|
|
destWidth: 345 * 4,
|
|
destHeight: 504 * 4,
|
|
canvasId: "firstCanvas",
|
|
success: function(res) {
|
|
common_vendor.index.hideLoading();
|
|
common_vendor.index.saveImageToPhotosAlbum({
|
|
filePath: res.tempFilePath,
|
|
success: function() {
|
|
console.log("save success");
|
|
common_vendor.index.hideLoading();
|
|
},
|
|
fail() {
|
|
common_vendor.index.hideLoading();
|
|
}
|
|
});
|
|
console.log(res.tempFilePath);
|
|
},
|
|
fail() {
|
|
common_vendor.index.hideLoading();
|
|
}
|
|
});
|
|
},
|
|
initActualImages: async (id) => {
|
|
},
|
|
choiceImgPopControl() {
|
|
var _a;
|
|
this.initActualImages((_a = BILL_poster_model.useModel.houseDetail.value) == null ? void 0 : _a.id);
|
|
},
|
|
copyLink() {
|
|
}
|
|
};
|
|
exports.method = method;
|