Prechádzať zdrojové kódy

feature:修改结业证编号

tiedan 4 rokov pred
rodič
commit
f949606e45
3 zmenil súbory, kde vykonal 232 pridanie a 70 odobranie
  1. 123 39
      pages/myClass/myClass.js
  2. 107 30
      pages/myMission/myMission.js
  3. 2 1
      utils/util.js

+ 123 - 39
pages/myClass/myClass.js

@@ -21,7 +21,8 @@ Page({
     istask3: false, //期末考试是否完成
     istask4: false, //综合反馈是否完成
     currentId: null,
-    currentName: ""
+    currentName: "",
+    tva: 32,
   },
   // 查询我是否认证
   isRz(sessionKey) {
@@ -45,11 +46,13 @@ Page({
       }
     })
   },
+  // 取消认证
   escRz() {
     wx.switchTab({
       url: '/pages/index/index',
     })
   },
+  // 确认认证
   goRz() {
     wx.navigateTo({
       url: '/pages/Identity/Identity',
@@ -843,7 +846,75 @@ Page({
     })
   },
   // 领取结业证
+  // lq() {
+  //   if (!this.data.istask3) {
+  //     wx.showModal({
+  //       showCancel: false,
+  //       content: "您的期末考试还未完成哦!"
+  //     })
+  //     return false
+  //   }
+  //   wx.showLoading({
+  //     mask: true,
+  //     title: '加载中',
+  //   })
+  //   this.setData({
+  //     myCanvasId: this.data.myCanvasId + 1
+  //   })
+  //   let str = this.data.studentName + "同志:"
+  //   let str1 = "于" + this.data.classInfo.beginDate + "至" + this.data.classInfo.endDate + "参加学习" + this.data.classInfo.clasName + "完成规定培训内容。准予结业,特发此证。"
+  //   let strArr1 = [];
+  //   // let a = str1.slice(0, 22);
+  //   // let b = str1.slice(22, 36);
+  //   // let c = str1.slice(36, 50);
+  //   // let d = str1.slice(50, 67);
+  //   // strArr1.push(a, b, c, d);
+  //   // const ctx = wx.createCanvasContext(this.data.myCanvasId);
+  //   // ctx.drawImage(this.data.byzsbj, 0, 0, 300, 415); //里面的参数无非就是图片放置的位置即图片的横纵坐标,图片的宽高
+  //   // ctx.setFillStyle("#000");
+  //   // ctx.setFontSize(15); //字大小
+  //   // ctx.font = 'normal bold 15px sans-serif'
+  //   // ctx.setTextAlign('left'); //是否居中显示,参考点画布中线
+  //   let a = str1.slice(0, 22);
+  //   let b = str1.slice(22, 37);
+  //   let c = str1.slice(37, 52);
+  //   let d = str1.slice(52, 67);
+  //   strArr1.push(a, b, c, d);
+  //   const ctx = wx.createCanvasContext(this.data.myCanvasId);
+  //   ctx.drawImage(this.data.byzsbj, 0, 0, 300, 415); //里面的参数无非就是图片放置的位置即图片的横纵坐标,图片的宽高
+  //   ctx.setFillStyle("#000");
+  //   ctx.setFontSize(15); //字大小
+  //   ctx.font = 'normal bold 15px sans-serif'
+  //   ctx.setTextAlign('left'); //是否居中显示,参考点画布中线
+  //   let leftPositionAarr = [60, 30, 30, 30]
+  //   ctx.fillText(str, 30, 160);
+  //   for (let i = 0; i < strArr1.length; i++) {
+  //     ctx.fillText(strArr1[i], leftPositionAarr[i], 190 + i * 30);
+  //   }
+  //   ctx.draw();
+  //   wx.hideLoading();
+  //   this.setData({
+  //     showzs: true
+  //   });
+  //   wx.request({
+  //     url: app.globalData.publicUrl + '/wx/student/wxGraduation',
+  //     method: "post",
+  //     data: {
+  //       sessionKey: this.data.sessionKey
+  //     },
+  //     success: (res) => {
+  //       console.log(res.data, "领取结业证提交")
+  //     }
+  //   })
+  // },
+
+
+
+
+
+  //孙喆 2020-9-22 10:38最后更改
   lq() {
+    var that = this;
     if (!this.data.istask3) {
       wx.showModal({
         showCancel: false,
@@ -855,44 +926,6 @@ Page({
       mask: true,
       title: '加载中',
     })
-    this.setData({
-      myCanvasId: this.data.myCanvasId + 1
-    })
-    let str = this.data.studentName + "同志:"
-    let str1 = "于" + this.data.classInfo.beginDate + "至" + this.data.classInfo.endDate + "参加学习" + this.data.classInfo.clasName + "完成规定培训内容。准予结业,特发此证。"
-    let strArr1 = [];
-    // let a = str1.slice(0, 22);
-    // let b = str1.slice(22, 36);
-    // let c = str1.slice(36, 50);
-    // let d = str1.slice(50, 67);
-    // strArr1.push(a, b, c, d);
-    // const ctx = wx.createCanvasContext(this.data.myCanvasId);
-    // ctx.drawImage(this.data.byzsbj, 0, 0, 300, 415); //里面的参数无非就是图片放置的位置即图片的横纵坐标,图片的宽高
-    // ctx.setFillStyle("#000");
-    // ctx.setFontSize(15); //字大小
-    // ctx.font = 'normal bold 15px sans-serif'
-    // ctx.setTextAlign('left'); //是否居中显示,参考点画布中线
-    let a = str1.slice(0, 22);
-    let b = str1.slice(22, 37);
-    let c = str1.slice(37, 52);
-    let d = str1.slice(52, 67);
-    strArr1.push(a, b, c, d);
-    const ctx = wx.createCanvasContext(this.data.myCanvasId);
-    ctx.drawImage(this.data.byzsbj, 0, 0, 300, 415); //里面的参数无非就是图片放置的位置即图片的横纵坐标,图片的宽高
-    ctx.setFillStyle("#000");
-    ctx.setFontSize(15); //字大小
-    ctx.font = 'normal bold 15px sans-serif'
-    ctx.setTextAlign('left'); //是否居中显示,参考点画布中线
-    let leftPositionAarr = [60, 30, 30, 30]
-    ctx.fillText(str, 30, 160);
-    for (let i = 0; i < strArr1.length; i++) {
-      ctx.fillText(strArr1[i], leftPositionAarr[i], 190 + i * 30);
-    }
-    ctx.draw();
-    wx.hideLoading();
-    this.setData({
-      showzs: true
-    });
     wx.request({
       url: app.globalData.publicUrl + '/wx/student/wxGraduation',
       method: "post",
@@ -900,10 +933,61 @@ Page({
         sessionKey: this.data.sessionKey
       },
       success: (res) => {
+        console.log(res);
         console.log(res.data, "领取结业证提交")
+        wx.hideLoading();
+        that.setData({
+          myCanvasId: that.data.myCanvasId + 1
+        })
+        let str = that.data.studentName + " 同志于" + that.data.classInfo.beginDate + "至" + that.data.classInfo.endDate + "参加" + that.data.classInfo.clasName + ",完成规定培训内容,准予结业,特发此证。"
+        //汉字占两格,英文数字占一格
+        let re = /^[\u4e00-\u9fa5]$/;
+        let stra = str.split("");
+        let tva = 30;  //阈值
+        let strTar = [];
+        let num = 0;
+        let st = "";
+        for (let i = 0; i < str.length; i++) {
+          let s = stra.shift()
+          st = st + s;
+          num += re.test(s) ? 2 : 1;
+          tva = strTar.length < 1 ? that.data.tva - 4 : that.data.tva;
+          if (num >= tva || i == str.length - 1) {
+            strTar.push(st);
+            num = 0;
+            st = "";
+          }
+        }
+        const ctx = wx.createCanvasContext(that.data.myCanvasId);
+        ctx.drawImage(that.data.byzsbj, 0, 0, 300, 415); //里面的参数无非就是图片放置的位置即图片的横纵坐标,图片的宽高
+        ctx.setFillStyle("#000");
+        ctx.setFontSize(14); //字大小
+        ctx.font = 'normal bold 14px sans-serif'
+        ctx.setTextAlign('left'); //是否居中显示,参考点画布中线
+        let leftPositionAarr = [60, 30]
+        let graduationNum = "编号:" + res.data.data.graduationNum;
+        ctx.fillText(graduationNum, 130, 150);
+        for (let i = 0; i < strTar.length; i++) {
+
+          ctx.fillText(strTar[i], i == 0 ? leftPositionAarr[0] : leftPositionAarr[1], 190 + i * 30);
+        }
+        ctx.draw();
+        that.setData({
+          showzs: true
+        });
+      },
+      fail: () => {
+        wx.hideLoading();
+        wx.showModal({
+          showCancel: false,
+          content: "网络错误,请稍后再试"
+        })
       }
     })
   },
+
+
+
   // 存储结业证
   saveZs() {
     wx.canvasToTempFilePath({ //把当前画布指定区域的内容导出生成指定大小的图片

+ 107 - 30
pages/myMission/myMission.js

@@ -20,7 +20,8 @@ Page({
     myCanvasId: 0, //画布的id 再次绘制不成功的原因是id不能一致  所以id为变量++
     IngCourseArr: [], //如果有正在进行的课就存一下
     currentId: null,
-    currentName: ""
+    currentName: "",
+    tva:32,
   },
   // 检查第一个任务 班级二维码是否点击 && 检查第二个任务 学员登记表  &&   第六个任务 领取结业证
   checkTaskList(sessionKey) {
@@ -697,11 +698,65 @@ Page({
     })
   },
   // 领取结业证
+  // lq() {
+  //   if (!this.data.istask4) {
+  //     wx.showModal({
+  //       showCancel: false,
+  //       content: "请先去期末考试再来领取结业证吧!"
+  //     })
+  //     return false
+  //   }
+  //   wx.showLoading({
+  //     mask: true,
+  //     title: '加载中',
+  //   })
+  //   this.setData({
+  //     myCanvasId: this.data.myCanvasId + 1
+  //   })
+  //   let str = this.data.studentName + "同志:"
+  //   let str1 = "于" + this.data.classInfo.beginDate + "至" + this.data.classInfo.endDate + "参加学习" + this.data.classInfo.clasName + "完成规定培训内容。准予结业,特发此证。"
+  //   let strArr1 = [];
+  //   let a = str1.slice(0, 22);
+  //   let b = str1.slice(22, 37);
+  //   let c = str1.slice(37, 52);
+  //   let d = str1.slice(52, 67);
+  //   strArr1.push(a, b, c, d);
+  //   const ctx = wx.createCanvasContext(this.data.myCanvasId);
+  //   ctx.drawImage(this.data.byzsbj, 0, 0, 300, 415); //里面的参数无非就是图片放置的位置即图片的横纵坐标,图片的宽高
+  //   ctx.setFillStyle("#000");
+  //   ctx.setFontSize(15); //字大小
+  //   ctx.font = 'normal bold 15px sans-serif'
+  //   ctx.setTextAlign('left'); //是否居中显示,参考点画布中线
+  //   let leftPositionAarr = [60, 30, 30, 30]
+  //   ctx.fillText(str, 30, 160);
+  //   for (let i = 0; i < strArr1.length; i++) {
+  //     ctx.fillText(strArr1[i], leftPositionAarr[i], 190 + i * 30);
+  //   }
+  //   ctx.draw();
+  //   wx.hideLoading();
+  //   this.setData({
+  //     showzs: true
+  //   });
+  //   wx.request({
+  //     url: app.globalData.publicUrl + '/wx/student/wxGraduation',
+  //     method: "post",
+  //     data: {
+  //       sessionKey: this.data.sessionKey
+  //     },
+  //     success: (res) => {
+  //       console.log(res.data, "领取结业证提交")
+  //     }
+  //   })
+  // },
+
+
+  //孙喆 2020-9-22 10:38最后更改
   lq() {
-    if (!this.data.istask4) {
+    var that = this;
+    if (!this.data.istask3) {
       wx.showModal({
         showCancel: false,
-        content: "请先去期末考试再来领取结业证吧!"
+        content: "您的期末考试还未完成哦!"
       })
       return false
     }
@@ -709,33 +764,6 @@ Page({
       mask: true,
       title: '加载中',
     })
-    this.setData({
-      myCanvasId: this.data.myCanvasId + 1
-    })
-    let str = this.data.studentName + "同志:"
-    let str1 = "于" + this.data.classInfo.beginDate + "至" + this.data.classInfo.endDate + "参加学习" + this.data.classInfo.clasName + "完成规定培训内容。准予结业,特发此证。"
-    let strArr1 = [];
-    let a = str1.slice(0, 22);
-    let b = str1.slice(22, 37);
-    let c = str1.slice(37, 52);
-    let d = str1.slice(52, 67);
-    strArr1.push(a, b, c, d);
-    const ctx = wx.createCanvasContext(this.data.myCanvasId);
-    ctx.drawImage(this.data.byzsbj, 0, 0, 300, 415); //里面的参数无非就是图片放置的位置即图片的横纵坐标,图片的宽高
-    ctx.setFillStyle("#000");
-    ctx.setFontSize(15); //字大小
-    ctx.font = 'normal bold 15px sans-serif'
-    ctx.setTextAlign('left'); //是否居中显示,参考点画布中线
-    let leftPositionAarr = [60, 30, 30, 30]
-    ctx.fillText(str, 30, 160);
-    for (let i = 0; i < strArr1.length; i++) {
-      ctx.fillText(strArr1[i], leftPositionAarr[i], 190 + i * 30);
-    }
-    ctx.draw();
-    wx.hideLoading();
-    this.setData({
-      showzs: true
-    });
     wx.request({
       url: app.globalData.publicUrl + '/wx/student/wxGraduation',
       method: "post",
@@ -743,7 +771,56 @@ Page({
         sessionKey: this.data.sessionKey
       },
       success: (res) => {
+        console.log(res);
         console.log(res.data, "领取结业证提交")
+        wx.hideLoading();
+        that.setData({
+          myCanvasId: that.data.myCanvasId + 1
+        })
+        let str = that.data.studentName + " 同志于" + that.data.classInfo.beginDate + "至" + that.data.classInfo.endDate + "参加" + that.data.classInfo.clasName + ",完成规定培训内容,准予结业,特发此证。"
+        //汉字占两格,英文数字占一格
+        let re = /^[\u4e00-\u9fa5]$/;
+        let stra = str.split("");
+        let tva = 30;  //阈值
+        let strTar = [];
+        let num = 0;
+        let st = "";
+        for (let i = 0; i < str.length; i++) {
+          let s = stra.shift()
+          st = st + s;
+          num += re.test(s) ? 2 : 1;
+          tva = strTar.length < 1 ? that.data.tva - 4 : that.data.tva;
+          if (num >= tva || i == str.length - 1) {
+            strTar.push(st);
+            num = 0;
+            st = "";
+          }
+        }
+        const ctx = wx.createCanvasContext(that.data.myCanvasId);
+        ctx.drawImage(that.data.byzsbj, 0, 0, 300, 415); //里面的参数无非就是图片放置的位置即图片的横纵坐标,图片的宽高
+        ctx.setFillStyle("#000");
+        ctx.setFontSize(14); //字大小
+        ctx.font = 'normal bold 14px sans-serif'
+        ctx.setTextAlign('left'); //是否居中显示,参考点画布中线
+        let leftPositionAarr = [60, 30]
+        let graduationNum = "编号:" + res.data.data.graduationNum;
+        ctx.fillText(graduationNum, 130, 150);
+        for (let i = 0; i < strTar.length; i++) {
+
+          ctx.fillText(strTar[i], i == 0 ? leftPositionAarr[0] : leftPositionAarr[1], 190 + i * 30);
+        }
+        ctx.draw();
+
+        that.setData({
+          showzs: true
+        });
+      },
+      fail: () => {
+        wx.hideLoading();
+        wx.showModal({
+          showCancel: false,
+          content: "网络错误,请稍后再试"
+        })
       }
     })
   },

+ 2 - 1
utils/util.js

@@ -3,7 +3,8 @@
   // publicUrl: 'https://sqpx.jiaxintech.com'//正式地址
   // publicUrl:'http://10.16.10.139'//ly
   // publicUrl:'http://10.16.4.19:80'//hyb
-  //  publicUrl:'http://10.16.4.26:80'//zxq
+  // publicUrl:'http://10.16.4.26:80'//zxq
+  // publicUrl:'http://10.20.1.207:80'//dailin
 };
 const formatTime = date => {
   const year = date.getFullYear()