Jelajahi Sumber

fix 修改结业证文字自适应高度和行距

tiedan 4 tahun lalu
induk
melakukan
510e91f479
2 mengubah file dengan 16 tambahan dan 6 penghapusan
  1. 5 2
      pages/myClass/myClass.js
  2. 11 4
      pages/myMission/myMission.js

+ 5 - 2
pages/myClass/myClass.js

@@ -196,6 +196,7 @@ Page({
         clasId: id
       },
       success: (res) => {
+        console.log(res)
         if (res.data.code == 0 && res.data.status == 1) {
           this.setData({
             istask3: true
@@ -968,12 +969,14 @@ Page({
         ctx.setFontSize(14); //字大小
         ctx.font = 'normal bold 14px sans-serif'
         ctx.setTextAlign('left'); //是否居中显示,参考点画布中线
-        let leftPositionAarr = [58, 30]
+        let leftPositionAarr = [59, 30]
         let graduationNum =res.data.data.graduationNum!=""? "编号:" + res.data.data.graduationNum:"";
         ctx.fillText(graduationNum, 130, 150);
+        let topPt=190-(strTar.length-4)*5;
+        let lineHeight=30-(strTar.length>4?strTar.length>6?10:(strTar.length-4)*5:0)
         for (let i = 0; i < strTar.length; i++) {
 
-          ctx.fillText(strTar[i], i == 0 ? leftPositionAarr[0] : leftPositionAarr[1], 190 + i * 30);
+          ctx.fillText(strTar[i], i == 0 ? leftPositionAarr[0] : leftPositionAarr[1], topPt + i * lineHeight);
         }
         ctx.draw();
         that.setData({

+ 11 - 4
pages/myMission/myMission.js

@@ -135,6 +135,7 @@ Page({
         clasId: id
       },
       success: (res) => {
+        console.log(res)
         if (res.data.code == 0 && res.data.status == 1) {
           this.setData({
             istask4: true
@@ -213,6 +214,7 @@ Page({
         sessionKey: sessionKey
       },
       success: (res) => {
+        console.log(res);
         if (res.data.code == 0) {
           this.setData({
             classInfo: res.data.data
@@ -301,6 +303,7 @@ Page({
   },
   // 获取我的课程表
   getMycourse(sessionKey) {
+    
     wx.request({
       url: app.globalData.publicUrl + '/wx/course/selectBySessionKey',
       method: "post",
@@ -308,6 +311,7 @@ Page({
         sessionKey: sessionKey
       },
       success: (res) => {
+        console.log(res,"我的课程")
         if (res.data.code == 0 && res.data.list.length !== 0) {
           this.setData({
             kcArr: res.data.list,
@@ -753,7 +757,7 @@ Page({
   //孙喆 2020-9-22 10:38最后更改
   lq() {
     var that = this;
-    if (!this.data.istask3) {
+    if (!this.data.istask4) {
       wx.showModal({
         showCancel: false,
         content: "您的期末考试还未完成哦!"
@@ -802,12 +806,15 @@ Page({
         ctx.setFontSize(14); //字大小
         ctx.font = 'normal bold 14px sans-serif'
         ctx.setTextAlign('left'); //是否居中显示,参考点画布中线
-        let leftPositionAarr = [58, 30]
-        let graduationNum = "编号:" + res.data.data.graduationNum;
+        let leftPositionAarr = [59, 30]
+        let graduationNum =res.data.data.graduationNum!=""? "编号:" + res.data.data.graduationNum:"";
         ctx.fillText(graduationNum, 130, 150);
+        
+        let topPt=190-(strTar.length-4)*5;
+        let lineHeight=30-(strTar.length>4?strTar.length>6?10:(strTar.length-4)*5:0)
         for (let i = 0; i < strTar.length; i++) {
 
-          ctx.fillText(strTar[i], i == 0 ? leftPositionAarr[0] : leftPositionAarr[1], 190 + i * 30);
+          ctx.fillText(strTar[i], i == 0 ? leftPositionAarr[0] : leftPositionAarr[1], topPt + i * lineHeight);
         }
         ctx.draw();