no message

cyl/master-im
jscyl13849007907 5 months ago
parent ebd02b4201
commit 33d2bb39e1

@ -540,6 +540,7 @@
</scroll-view>
</div>
</u-popup>
<canvas type="2d" style="position: absolute; left: -2000px; width: 425px; height: 350px; background: #fff" id="canvasId" ref="canvasId"></canvas>
</div>
</template>
@ -552,7 +553,27 @@ export default {
},
onShareAppMessage() {
this.attention = false;
return this.G.shareFun("/root/detail/job?id=" + this.jobDetail.id, "", this.jobDetail.jobName + " " + this.jobDetail.priceStr + " " + "好厂好工作 火热招聘中");
// return this.G.shareFun("/root/detail/job?id=" + this.jobDetail.id,
// "", this.jobDetail.jobName + " " + this.jobDetail.priceStr + " " + " ");
let that = this;
let path;
if (this.isMember) {
path = `/root/detail/job?id=${that.jobDetail.id}&from=home&userId=${that.userInfo.user.id}`;
} else {
path = `/root/detail/job?id=${that.jobDetail.id}&from=home`;
}
return {
promise: new Promise((resolve, reject) => {
that.getWXCanvas("", "setShare").then((res) => {
wx.hideLoading();
resolve({
title: " ",
imageUrl: res.tempFilePath,
path,
});
});
}),
};
},
mounted() {
var obj = dateTimePicker.dateTimePicker(this.startYear, this.endYear, this.currentTime);
@ -1274,6 +1295,143 @@ export default {
);
})
},
//
getWXCanvas(sharelImg, type) {
const that = this;
return new Promise((resolve) => {
var mycenter = 0; //
var myheight = 0; //
const query = uni.createSelectorQuery().in(this);
query
.select("#canvasId")
.fields({
node: true,
size: true,
})
.exec((res) => {
console.log("uni 获取节点信息:", res);
const canvas = res[0].node;
const ctx = canvas.getContext("2d");
that.setShareCover(ctx, canvas, mycenter).then((canvas) => {
uni.canvasToTempFilePath({
canvas: canvas,
success(res) {
resolve(res);
},
fail(res) {
uni.hideLoading();
uni.showToast({
title: res.errMsg,
icon: "error",
});
},
});
});
});
});
},
/**
* 生成分享小程序的封面
*/
setShareCover(ctx, canvas, mycenter) {
let that = this;
canvas.width = 750;
canvas.height = 600;
mycenter = canvas.width / 2;
let labelLeft = 0;
let baseLeft, logoSize, titleFontSize, mainFontSize, line1, line2, line3, line4, line5, line6, line7, line8;
baseLeft = 24; // 线
logoSize = 132; // logo
mainFontSize = 36; //
titleFontSize = 56; //
line1 = 68; //
line2 = 90;
line3 = 200;
line4 = 280;
line5 = 350;
line6 = 380;
line7 = 460;
//
console.log("that.jobDetail", that.jobDetail);
that.G.roundRect1(ctx, 0, 0, 750, 600, 0, "#fff");
return new Promise(function (imgres) {
//
that.G.fillTextLineBreak(ctx, that.jobDetail.jobName, baseLeft, line2, 800, 20, "#000", titleFontSize, "500", "left");
//
that.G.fillTextLineBreak(ctx, that.jobDetail.monthPay, 750 - ctx.measureText(that.jobDetail.monthPay).width + 20, line3 + 6, 400, 20, "#ff4400", titleFontSize, "400");
//
that.G.fillTextLineBreak(ctx, that.G.getSalaryClassifyValue(that.jobDetail.salaryClassify, that.jobDetail.salaryClassifyValue), baseLeft, line3, 400, 40, "#ff4400", titleFontSize + 6, "600", "left");
if (that.jobDetail.jobRequestLabelNames.length > 0) {
that.jobDetail.jobRequestLabelNames.forEach((item1, index) => {
if (index <= 3) {
that.G.fillTextLineBreak(ctx, item1, baseLeft + labelLeft + 80, line4 + 4, 400, 40, "#666", mainFontSize); //
// that.G.roundRect1(ctx, baseLeft + labelLeft, line4 - 38, ctx.measureText(item1).width + 24, 56, 8, "#00000012");
labelLeft += ctx.measureText(item1).width + 32;
if (index == 3) {
labelLeft = 0;
}
} else if (index > 3 && index <= 6) {
// that.G.roundRect1(ctx, baseLeft + labelLeft, line5 - 38, ctx.measureText(item1).width + 24, 56, 8, "#00000012");
that.G.fillTextLineBreak(ctx, item1, baseLeft + labelLeft + 80, line5 + 4, 400, 40, "#666", mainFontSize); //
labelLeft += ctx.measureText(item1).width + 32;
}
});
} else if (that.jobDetail.jobSpecialLabelNames.length > 0) {
that.jobDetail.jobSpecialLabelNames.forEach((item1, index) => {
if (index <= 3) {
that.G.fillTextLineBreak(ctx, item1, baseLeft + labelLeft + 80, line4 + 4, 400, 40, "#666", mainFontSize); //
// that.G.roundRect1(ctx, baseLeft + labelLeft, line4 - 38, ctx.measureText(item1).width + 24, 56, 8, "#00000012");
labelLeft += ctx.measureText(item1).width + 32;
if (index == 3) {
labelLeft = 0;
}
} else if (index > 3 && index <= 6) {
// that.G.roundRect1(ctx, baseLeft + labelLeft, line5 - 38, ctx.measureText(item1).width + 24, 56, 8, "#00000012");
that.G.fillTextLineBreak(ctx, item1, baseLeft + labelLeft + 80, line5 + 4, 400, 40, "#666", mainFontSize); //
labelLeft += ctx.measureText(item1).width + 32;
}
});
}
//
that.G.roundRect1(ctx, mycenter - 712 / 2, line6, 712, 60, 4, "#fff6e8"); //
//
//
that.G.roundRect1(ctx, mycenter - 712 / 2, line7, 712, 100, 4, "#3b80fa"); //
//
that.G.fillTextLineBreak(ctx, "立即咨询", mycenter - 24 - ctx.measureText("立即咨询").width / 2 + 100, line7 + 65, 300, 120, "#fff", titleFontSize, "500"); //
// logo
uni.downloadFile({
url: "https://matripe-cms.oss-cn-beijing.aliyuncs.com/pugongying/goxj2-qpwbo.png",
success(res) {
console.log("duihao", res);
const img1 = canvas.createImage();
img1.src = res.tempFilePath;
console.log("img info img", img1);
img1.onload = (info) => {
console.log("img info", info);
let safeMarkPosition = 44;
//
["安全保障", "工资保障", "补贴保障"].forEach((item1, index) => {
//
that.G.fillTextLineBreak(ctx, item1, baseLeft + safeMarkPosition + 70, line6 + 40, 100, 32, "#fca025");
that.G.roundRect(ctx, img1, baseLeft + safeMarkPosition - 36, line6 + 12, 32, 32, 12);
safeMarkPosition += 130 + ctx.measureText(item1).width;
});
setTimeout(() => {
imgres(canvas);
}, 200);
};
},
fail(err) {
console.log("downloadFile err", err);
},
});
}).catch((err) => {
console.log("all err", err);
});
},
},
};
</script>

Loading…
Cancel
Save