// pages/newAddPage/letterCommitment/index.js
const app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        safetyQualityRich:'<p style="line-height: 1.5;"><br></p><h4 style="text-align: center; line-height: 1.5;"></h4><h4 style="text-align: center; line-height: 1.5;">安全质量承诺书</h4><p style="line-height: 1.5;"> </p><p style="text-indent: 2em; line-height: 1.5;">为了个人的安全健康,为了家庭的幸福美满,为了企业的稳定发展,本人在工作中,自愿签订并遵守以下承诺:</p><p style="text-indent: 2em; line-height: 1.5;"><br></p><p style="text-indent: 2em; line-height: 1.5;">忠诚企业、恪尽职守、珍爱生命、铸造精品!</p><p style="text-indent: 2em; line-height: 1.5;"><br></p><p style="text-indent: 2em; line-height: 1.5;">我坚决做到:遵守规章制度、遵守操作规程、遵守劳动纪律,不出事故、不出次品、不留隐患!我将以实际行动,确保企业生产安全、产品优质!”</p><p style="text-indent: 2em; line-height: 1.5;"><br></p><p style="text-indent: 2em; line-height: 1.5;">对于以上承诺,本人自觉遵守,如有违反,本人愿承担责任。 </p><p style="text-indent: 2em; line-height: 1.5;"><br></p><p style="text-indent: 2em; line-height: 1.5;">本承诺书自签字日起生效。 </p><p style="text-indent: 36pt; line-height: 1.5;"><br></p><p style="line-height: 1.5;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;承诺人(签字):</p><p style="line-height: 1.5;"><br></p><p style="line-height: 1.5;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;岗 位(工种):</p><p style="line-height: 1.5;"><br></p><p style="line-height: 1.5;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;日 &nbsp;期: &nbsp; &nbsp;年 &nbsp; &nbsp;月 &nbsp; &nbsp;日 </p><p><br></p>',
        healthRich:'<p style="line-height: 1.5;"><br></p><h4 style="text-align: center; line-height: 1.5;">健康承诺书</h4><p style="line-height: 1.5;"> </p><p style="text-indent: 2em; line-height: 1.5;">本人:<u> &nbsp; &nbsp; &nbsp; &nbsp;</u>,性别:<u> &nbsp; &nbsp;</u>,年龄: <u> &nbsp; &nbsp;</u>岁、身份证号码:<u> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </u>,从事岗位:<u> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </u>,无 □ / 有 □ 高血压、心脏病等基础身体健康问题;无 □ / 有 □ 严重呼吸系统疾病、严重心脑血管疾病、肝肾疾病、恶性肿瘤以及药物无法有效控制的高血压和糖尿病等基础性病症状征兆,能够胜任本岗位相应工作,我向公司承诺以上所述信息无隐瞒、无虚报,如有隐瞒造成所有后果由本人承担,于项目无关。</p><p style="line-height: 1.5;"> </p><p style="line-height: 1.5;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;承诺人(按手印):</p><p style="line-height: 1.5;"><br></p><p style="line-height: 1.5;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;承诺日期: &nbsp; &nbsp;年 &nbsp; 月 &nbsp; 日</p><p style="line-height: 1.5;"><br></p><p style="line-height: 1.5;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;日 &nbsp;期: &nbsp; &nbsp;年 &nbsp; &nbsp;月 &nbsp; &nbsp;日 </p><p><br></p>',
        workerRich:'<p style="text-indent: 2em; line-height: 1.5;"><br></p><h1 style="text-indent: 2em; text-align: center; line-height: 1.5;"></h1><h4 style="text-align: center; line-height: 1.5;">作业工人安全生产责任书</h4><p style="line-height: 1.5;"><br></p><p style="text-indent: 2em; line-height: 1.5;">(一)作业工人对自己施工中的安全负责。</p><p style="text-indent: 2em; line-height: 1.5;"><br></p><p style="text-indent: 2em; line-height: 1.5;">(二)作业工人应严格执行劳动纪律和现场安全生产管理制度,严格执行安全操作规程和安全技术交底,做到“四不伤害”即:我不伤害自己,我不伤害别人,我不被别人伤害。</p><p style="text-indent: 2em; line-height: 1.5;"><br></p><p style="text-indent: 2em; line-height: 1.5;">(三)拒绝强令冒险作业。发现隐患及防护设施缺陷应及时向安全管理人员报告。</p><p style="text-indent: 2em; line-height: 1.5;"><br></p><p style="text-indent: 2em; line-height: 1.5;">(四)正确使用和穿戴安全防护用品,自觉维护现场安全防护设施,未经批准不得随意移动拆除防护设施。</p><p style="text-indent: 2em; line-height: 1.5;"><br></p><p style="text-indent: 2em; line-height: 1.5;">(五)发生事故应及时报告现场管理人员,并在项目负责人的指挥下积极配合施救。</p><p style="text-indent: 2em; line-height: 1.5;"><br></p><p style="text-indent: 2em; line-height: 1.5;">(六)严格遵守本单位的安全生产规章制度和操作规程,服从管理,正确佩戴和使用劳动防护用品。</p><p style="text-indent: 2em; line-height: 1.5;"><br></p><p style="text-indent: 2em; line-height: 1.5;">(七)接受安全生产教育和培训,掌握本职工作所需的安全生产知识,提高安全生产技能,增强事故预防和应急处理能力。从业人员发现事故隐患或者其他不安全因素,应当立即向现场安全生产管理人员或者本单位负责人报告;接到报告的人员应当及时予以处理。</p><p style="text-indent: 2em; line-height: 1.5;"><br></p><p style="line-height: 1.5;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;承诺人(按手印):</p><p style="line-height: 1.5;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </p><p style="line-height: 1.5;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;承诺日期: &nbsp; &nbsp;年 &nbsp; 月 &nbsp; 日</p><p><br></p>',
        protectiveEquipmentRich:'<p style="text-align: center; line-height: 1.5;"><br></p><h4 style="text-align: center; line-height: 1.5;"><strong>安全防护用品使用图解</strong></h4><h3 style="text-align: center; line-height: 1.5;"> </h3><p style="text-align: center; line-height: 1.5;">进入施工现场必须根据要求按照下图要求佩戴好相应安全防护用品。</p><p style="text-indent: 2em; text-align: center; line-height: 1.5;"><br></p><p style="text-align: center; line-height: 1.5;"><br></p><p style="text-align: center; line-height: 1.5;"><img src="http://fileimg.makalu.cc/WEB_33F25A7600DB4909A0B9B6098CB19054.png" style="width:90%;"/></p><p style="text-align: center; line-height: 1.5;"><br></p><p style="text-align: center; line-height: 1.5;">本人已经掌握安全防护用品佩戴方法,并严格遵守!</p><p style="text-align: center; line-height: 1.5;"><br></p><p style="text-align: left; line-height: 1.5;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;签字:</p><p style="text-align: left; line-height: 1.5;"><br></p><p style="text-align: left; line-height: 1.5;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;日期: &nbsp; &nbsp; &nbsp; 年 &nbsp; &nbsp; 月 &nbsp; &nbsp; &nbsp;日 &nbsp; &nbsp; &nbsp; </p><p style="text-align: left; line-height: 1.5;"> &nbsp; &nbsp; &nbsp; &nbsp; </p>',
        workerPostRich:'<p style="text-indent: 2em; text-align: left; line-height: 1.5;"><br></p><p style="text-align: center; line-height: 1.5;"><strong>作业人员岗位告知书</strong></p><p style="text-indent: 2em; text-align: left; line-height: 1.5;"> </p><p style="text-indent: 2em; text-align: left; line-height: 1.5;"> &nbsp;你将从事的普工作业,存在着车辆伤害、机械伤害、坠落、物体打击、触电等岗位危险,予以告知。你在作业时务必遵守相关的规章制度、专项工程安全施工方案、安全技术措施,并熟记作业要点及其特性,掌握好相应的安全防范技能;进入作业场所后,要进行重新检查,发现异常情况和不安全因素必须及时采取有效措施排除;要正确使用和佩戴劳动保护用品,在做好自我防范的同时,还要认真贯彻联保互保。同时对以下针对性措施必须经常对照执行:</p><p style="text-indent: 2em; text-align: left; line-height: 1.5;"><br></p><p style="text-indent: 2em; line-height: 1.5;">1、在道路上工作时,密切注意来往车辆,做到“一看二停三通过”,不抢一分一秒,保证自己不被车辆伤害。</p><p style="text-indent: 2em; line-height: 1.5;"><br></p><p style="text-indent: 2em; line-height: 1.5;">2、从事开挖作业时,先观察好周边情况和环境,在最坏的情况能够不伤及自身和他人的情况下再作业。</p><p style="text-indent: 2em; line-height: 1.5;"><br></p><p style="text-indent: 2em; line-height: 1.5;">3、从事搬运石块等工作时,要严格注意身边的人,在呼喊并应答、引起对方注意并退让到安全地带后才可以工作。同时,要积极注意自身安全,不搬运过重的石块,经常检查铁锹、榔头、扁担等工具,一有损坏,立即更换或修复。</p><p style="text-indent: 2em; line-height: 1.5;"><br></p><p style="text-indent: 2em; line-height: 1.5;">4、在电力线底下、光缆附近施工时,必须严格按照安全技术交底,时刻提高警惕,保护好电力电线、国防光缆。</p><p style="text-indent: 2em; line-height: 1.5;"><br></p><p style="text-indent: 2em; line-height: 1.5;">5、严禁在河流、池塘等地游泳、洗澡,由此引发的后果由你承担。</p><p style="text-indent: 2em; line-height: 1.5;"><br></p><p style="text-indent: 2em; line-height: 1.5;">6、做好防火、防盗工作,保护好自己的财物。</p><p style="text-indent: 2em; line-height: 1.5;"><br></p><p style="text-indent: 2em; line-height: 1.5;">7、工作时必须佩戴好劳动防护用品,带好安全帽并系好下额带。</p><p style="text-indent: 2em; line-height: 1.5;"><br></p><p style="text-indent: 2em; line-height: 1.5;">8、密切注意工程施工机械,在挖掘机、压路机、推土机等机械附近施工时,必须面向机械并及时避让,确保安全。严禁在压路机等机械下休息,严禁在施工现场打闹、追逐。</p><p style="text-indent: 2em; line-height: 1.5;"><br></p><p style="text-indent: 2em; line-height: 1.5;">9、工作时听从班组长统一指挥,严格遵守劳动纪律、三级安全教育及安全交底内容。</p><p style="text-indent: 2em; line-height: 1.5;"><br></p><p style="line-height: 1.5;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;被告知者签字(指印):</p><p style="line-height: 1.5;"><br></p><p style="line-height: 1.5;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 日期: &nbsp; &nbsp; &nbsp;年 &nbsp; &nbsp; &nbsp;月 &nbsp; &nbsp; &nbsp;日</p><p style="text-indent: 2em; text-align: left; line-height: 1.5;"> &nbsp; &nbsp; &nbsp; &nbsp; </p>',
        show:true,
        radio1:'',
        radio2:'',
        signImgUrl:'',
        token: '',
    },

    onChange1(event) {
        this.setData({
            radio1: event.detail,
        });
    },

    onChange2(event) {
        this.setData({
            radio2: event.detail,
        });
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
      this.getQiniupToken();
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    },

    /**
     * 获取七牛云token
     */
    getQiniupToken() {
      var that = this
      wx.request({
        url: app.globalData.szhUrl+'/mkl/api/getToken',
        method:"GET",
        success:function(res){
          that.setData({
            token: res.data,
          });
        }
      })
    },

    /**
     * 确认签名
     */
    sign(e){
        let tempFilePath = e.detail
        //上传签名图片
        this.uploadToQiniu(tempFilePath)
    },

    /**
     * 重置
     */
    reset(){
        this.setData({
          radio1:'',
          radio2:''
        })
    },

    /**
     * 提交签名信息并生成承诺书
     */
    submit(){
      var that = this
      if(this.data.radio1 == ''){
        app.toast("请选择是否有高血压、心脏病等基础身体健康问题");
        return;
      }
      if(this.data.radio2 == ''){
        app.toast("请选择是否有严重呼吸系统疾病、严重心脑血管疾病、肝肾疾病、恶性肿瘤以及药物无法有效控制的高血压和糖尿病等基础性病症状征兆");
        return;
      }
      if(this.data.signImgUrl == ''){
        app.toast("请点击签名!");
        return;
      }

      wx.showLoading({
        title: '正在提交。。。',
        mask: true,
      })

      wx.request({
        header: {
            'content-type': 'application/x-www-form-urlencoded'
        },
        url:app.globalData.szhUrl+'/mkl/api/generateSafetyLetterOfCommitment',
        data:{
          "openId": wx.getStorageSync('userOpenId'),
          "idCardNo": wx.getStorageSync('idCardNo'),
          "radio1":this.data.radio1,
          "radio2":this.data.radio2,
          "signImgUrl":this.data.signImgUrl,
        },
        method:"POST",
        success:function(res){
            if(res.data.code == '200'){
              that.setData({
                show:false
              })
              wx.hideLoading({});
              app.toast("温馨提醒:你的个人信息和培训考试结果已成功提交至项目审核,审核通过后可通过人脸识别闸机进场。");
              return;
            }else{
              app.toast(res.data.msg);
              return;
            }
        }
    })
	},
	
	/**
   * 上传图片
   */
  uploadToQiniu(url) { //图片直接上传到七牛云,获取七牛云链接
    var that = this;
    wx.uploadFile({
      url: 'https://upload.qiniup.com',
      name: 'file',
      filePath: url,
      header: {
        "Content-Type": "multipart/form-data"
      },
      formData: {
        token: that.data.token,
      },
      success: function (res) {
        let data = JSON.parse(res.data);
        that.setData({
          signImgUrl: 'https://fileimg.makalu.cc/' + data.key
        })
      },
      fail: function (res) {
        console.log(res)
      }
    });
  },
})