123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- var qs = parseQueryString(window.location.href),user_id,userInfoData;
- // var request = 'http://182.92.118.1:5090';
- var request = '',signatureUrl='';
- $().ready(function(){
- if(qs.user_id){
- user_id = qs.user_id;
- }
- if(qs.tpl_id){
- tpl_id = qs.tpl_id;
- }
- // if(!getCookie('user_id') || getCookie('user_id') != user_id){
- // window.location.href="index.html"
- // }
-
- // userInfo();//用户信息
- })
- function userInfo () {
- //用户信息
- $(".loading").show();
- $.ajax({
- type: 'get',
- url: request + '/userInfo',
- data:{
- 'user_id':user_id
- },
- success: function (res) {
- $(".loading").hide();
- console.log(res)
- if(res.status == 200){
- userInfoData = res.data;
- var party_B_html = '<p>甲方(姓名):' + res.data.name + '</p><p>地址:' + res.data.address + '</p><p>身份证号:' + res.data.id_card_num + '</p><p>快手ID:' + res.data.platform_account + '</p><p>移动电话:' + res.data.mobile + '</p>';
- var detailTimeHtml = '<div class="">甲方:' + res.data.name + '</div><div>签字:' + res.data.name + '</div><div></div>日期:' + format() + '</div>';
- $('.party_B').html(party_B_html)
- $('#nail').html(detailTimeHtml)
- $(".detailTime .time").html('日期:' + format())
- }else{
- showMsg(res.msg)
- }
- },
- fail: function () {
- showMsg('网络错误,请稍后再试~')
- $(".loading").hide();
- }
- })
- }
- function format(){
- //shijianchuo是整数,否则要parseInt转换
- var time = new Date();
- var y = time.getFullYear();
- var m = time.getMonth() + 1;
- var d = time.getDate();
- var h = time.getHours();
- var mm = time.getMinutes();
- var s = time.getSeconds();
- return y + '年' + m + '月' + d + '日';
- }
- function signingEvent() {
- //阅读并签约
- console.log('签约')
- $(".loading").show();
- $.ajax({
- type: 'get',
- url: request + '/contract',
- data:{
- 'user_id':user_id,
- 'tpl_id':tpl_id,
- 'signPic':signatureUrl
- },
- success: function (res) {
- $(".loading").hide();
- console.log(res)
- if(res.status == 200 || res.status == 201){
- if(res.status == 201){
- showMsg(res.msg);//已经签约过
- }
- // contract_view(res.order_id)
- // window.open(res.view_url)
- window.location.href = decodeURIComponent(res.view_url)
- // window.location.href="lookPdf.html?contract_url=" + res.view_url + '&user_id=' + user_id
- // window.location.href=decodeURIComponent();
- }else{
- showMsg(res.msg)
- }
- },
- fail: function () {
- showMsg('网络错误,请稍后再试~')
- $(".loading").hide();
- }
- })
- }
- //获取地址栏参数
- function parseQueryString(url) {
- var urlObj = {};
- var reg = /([^?=&]+)=([^?=&]+)/g;
- url.replace(reg, function($0, $1, $2) {
- urlObj[$1] = decodeURIComponent($2);
- })
- return urlObj;
- }
- // 展示错误提示信息
- function showMsg(msg) {
- var msgBox = document.getElementsByClassName('alert-info')[0];
- msgBox.getElementsByTagName("p")[0].innerHTML=msg;
- msgBox.style.display="block";
- setTimeout(function() {
- msgBox.style.display="none";
- }, 2000);
- }
- //取Cookie的值
- function getCookie(name) {
- var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
- if (arr = document.cookie.match(reg)){
- return arr[2];
- }else{
- return false
- }
- }
- //写入到Cookie
- //name:cookie名称 value:cookie值
- function setCookie(name,value){
- var exp = new Date();
- exp.setTime(exp.getTime() + 12 * 60 * 60000);//过期时间 12小时
- // exp.setTime(exp.getTime() + 60 * 10000);//过期时间 10分钟
- document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
- }
- function goSignature () {//去签名
- $(".signatureDiv").show();
- $('.js-signature').jqSignature();
-
- $('.js-signature').on('jq.signature.changed', function() {
- $('#saveBtn').attr('disabled', false);
- });
-
- document.getElementsByClassName("js-signature")[0].addEventListener('touchstart', startEventHandler, {passive: false});
- function startEventHandler(event) {
- event.preventDefault();
- }
- }
- function clearCanvas() {
- // $('#signature').html('<p><em>Your signature will appear here when you click "Save Signature"</em></p>');
- $('.js-signature').jqSignature('clearCanvas');
- $('#saveBtn').attr('disabled', true);
- }
- function saveSignature() {
- $('#signature').empty();
- var dataUrl = $('.js-signature').jqSignature('getDataURL');
- signatureUrl = dataUrl
- var img = $('<img>').attr('src', dataUrl);
- // $('#signature').append($('<p>').text("Here's your signature:"));
- $('#signature').append(img);
- $(".signatureDiv").hide();
- $(".contract_button2").show();
- $(".contract_button1").hide();
- }
|