123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344 |
- var d1 = dialog({contentType:'load', skin:'bk-popup'});
- var d = dialog({contentType:'load', skin:'bk-popup', content:'提交签约信息,请稍后...'});
- var Request = new Object();
- Request = GetRequest();
- var doctor = Request["doctor"];
- var doctorName = Request["doctorName"];
- var hospitalName = Request["hospitalName"];
- var idcard = Request["idcard"];
- var code = Request["code"];
- var level =Request["level"];
- var is_renew = window.localStorage.getItem("is_renew");
- if(code){
- closeWindow();
- }
- // 从医生主页传递的签约邀请code
- var signInvitationCode = Request["inviCode"];
- var patientCode = Request["patientCode"];
- if(!patientCode || patientCode=="undefined") {
- patientCode = "";
- }
- $(function(){
- if(level==2){
- $(".bottom-title").html(decodeURI(doctorName)+"医生为全科医生,与其签约后,"+decodeURI(doctorName)+"医生将为您选择一个健管师,共同为您提供各项健康服务");
- }else{
- $(".bottom-title").html(decodeURI(doctorName)+"医生为健管师,与其签约后,"+decodeURI(doctorName)+"医生将为您选择一个全科医生,共同为您提供各项健康服务");
- }
- if (decodeURI(doctorName)) {
- document.getElementById("doctorName").innerText = decodeURI(doctorName);
- }
- if (decodeURI(hospitalName)) {
- document.getElementById("hospitalName").innerText = decodeURI(hospitalName);
- }
- if(signInvitationCode&&signInvitationCode!="undefined") {
- $('#name_label').text('代理家人');
- $(".div-family-remark").show();
- }
- query();
- $("#idcard").on("blur", function() {
- var value = $(this).val();
- validateIdcard(value);
- });
- })
- //查询用户信息
- function query() {
- d1.show();
- var data={};
- if(signInvitationCode&&signInvitationCode!="undefined") {
- sendPost('patient/getPatientByInviLogCode', {invilogCode: signInvitationCode}, 'json', 'post', queryFailed, querySuccess);
- } else {
- sendPost('patient/baseinfo', data, 'json', 'post', queryFailed, querySuccess);
- }
-
- }
- function queryFailed(res) {
- d1.close();
- if (res && res.msg) {
- dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg}).show();
- } else {
- dialog({contentType:'tipsbox', skin:'bk-popup' , content:'用户信息获取失败'}).show();
- }
- }
- function querySuccess(res) {
- if (res.status == 200) {
- var data = res.data;
- var name = data.name;
- var mobile = data.mobile;
- var idcard = data.idcard;
- var idcardAll = data.idcardAll;
- var ssc = data.ssc;
- var medicareNumber = data.medicareNumber;
- if(!name) name = "";
- if(!mobile) mobile = "";
- if(!ssc) ssc = "";
- if(!idcard) idcard = "";
- document.getElementById("name").value = name;
- document.getElementById("mobile").value = mobile;
- document.getElementById("ssc").value = ssc;
- document.getElementById("idcard").value = idcard;
- document.getElementById("medicareNumber").value = medicareNumber || "";
- $('#committee').text(data.countryName);
- $('#committee').attr('data-code',data.countryCode);
- $(".userName").html(name);
- $('#idcard').attr('data-idcard',idcardAll);
- if(!ssc || ssc ==""){
- dialog({
- content: '对不起,未办理医保卡或在2016年6月之后办理医保卡的居民暂不能进行签约。请保证在您的帐户中(我的资料)正确录入您的医保卡号,然后再重试!',
- cancelValue: '我知道了',
- cancel: function () {
- wx.closeWindow();
- }
- }).showModal();
- }
-
- //选择居委会
- selectCommittee()
-
- //如果是改签,获取改签原因列表
- if(parseInt(is_renew) == 1){
- var url = "/patient/sign/getRenewChangeReason";
- sendPost(url, {}, 'json', 'get', queryFailed, function(res1){
- if(res1.status == 200){
- $("#renewReason").show();
- initSelectData(res1);
- d1.close();
- }else{
- queryFailed(res1);
- }
- });
- }else{
- d1.close();
- }
- } else {
- queryFailed(res);
- }
- }
- //填充下拉框数据
- function initSelectData(res){
- var arr_key = [],
- arr_value = [];
- for(i=0; i<res.data.length; i++){
- var item = res.data[i];
- arr_key.push(item.code);
- arr_value.push(item.value);
- }
- // console.log(arr_key);
- // console.log(arr_value);
- $('#reason').mobiscroll({
- theme: 'ios',
- lang: 'zh',
- customWheels: true,
- wheels: [
- [{
- keys: arr_key,
- values: arr_value
- }]
- ],
- onSelect: function(valueText, inst) {
- var dd = eval("[" + valueText + "]");
- $('#reason').val(dd[0].values);
- $('#reason').attr("data-code",dd[0].keys);
- }
- });
- }
- //验证信息
- function validate(data) {
- if (data.name == "") {
- dialog({contentType:'tipsbox', skin:'bk-popup' , content:'请输入您的姓名'}).show();
- return false;
- }
- if (data.ssc == "") {
- dialog({contentType:'tipsbox', skin:'bk-popup' , content:'医保卡号信息未完善!'}).show();
- return false;
- }
- if (data.countryCode == "") {
- dialog({contentType:'tipsbox', skin:'bk-popup' , content:'请选择所属居委会'}).show();
- return false;
- }
- if(data.medicareNumber == "") {
- dialog({contentType:'tipsbox', skin:'bk-popup' , content:'请输入医疗保险号'}).show();
- return false;
- }
- // if (data.idcard != "" && !isIdcard(data.idcard)) {
- // dialog({contentType:'tipsbox', skin:'bk-popup' , content:'身份证号格式不正确'}).show();
- // return false;
- // }
- // if (data.mobile != "" && !isphone(data.mobile)) {
- // dialog({contentType:'tipsbox', skin:'bk-popup' , content:'手机号格式不正确'}).show();
- // return false;
- // }
-
- //增加改签原因的判断
- if(parseInt(is_renew) == 1){
- var reason = $("#reason").attr("data-code");
-
- if(!reason){
- dialog({contentType:'tipsbox', skin:'bk-popup' , content:'请选择改签原因!'}).show();
- return false;
- }
- }
- return true;
- }
- function validateIdcard(v){
- if ( v == "" ||( v != "" && !isIdcard(v))) {
- dialog({contentType:'tipsbox', skin:'bk-popup' , content:'身份证号格式不正确'}).show();
- return false;
- }
- }
- function validatePhone(v){
- if(v != "" && !isphone(v)){
- dialog({contentType:'tipsbox', skin:'bk-popup' , content:'手机号格式不正确'}).show();
- document.getElementById("mobile").focus();
- return false;
- }
- return true;
- }
- function validateSsc(v){
- if(!isSsc(v)){
- dialog({contentType:'tipsbox', skin:'bk-popup' , content:'医保卡号格式不正确'}).show();
- document.getElementById("ssc").focus();
- return false;
- }
- return true;
- }
- //提交签约
- function submitSign(){
- var data = {};
- data.name = $("#name").val();
- data.ssc = $("#ssc").val();
- data.medicareNumber = $("#medicareNumber").val();
- data.mobile = $("#mobile").val();
- //data.idcard = $("#idcard").val();
- data.idcard = $('#idcard').attr('data-idcard');
- data.countryCode = $("#committee").attr('data-code');
- //判断是否是续签变更医生的情况
- if(validate(data)){
- d.showModal();
- if(parseInt(is_renew)){
- var url = "/patient/family_contract/signRenew",
- params = {
- doctor: doctor || "",
- patient: patientCode,
- reason: $("#reason").attr("data-code"),
- countryCode:$("#committee").attr('data-code'),
- medicareNumber: $("#medicareNumber").val()
- };
- sendPost(url, params, "json", "post", operateFailed, operateSuccesss2);
- return;
- }
- data.doctor = doctor;
- data.doctorType = level;
- data.patient = patientCode;
- // 存入缓存。以便建档成功时提交签约信息
- window.localStorage.removeItem("jiandangCase1")
- window.localStorage.removeItem("jiandangCase2")
- if(window.localStorage.getItem('is_signData')) {
- window.localStorage.removeItem('is_signData');
- }
- data.jwCountryCode = $("#committee").attr('data-jwcode');
- data.countryName = $('#committee').text().trim();
- data.signInvitationCode = signInvitationCode;
- var dataStr = JSON.stringify(data);
- window.localStorage.setItem('is_signData', dataStr);
- sendPost("patient/family_contract/sign", data, "json", "post", operateFailed, operateSuccesss);
- }
- }
- //失败
- function operateFailed(res) {
- d.close();
- if (res && res.msg) {
- dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg}).show();
- if(res.status == -2) {// 跳转自助建档
- window.location.href = "../../jdqy/html/zizhujiandang.html";
- } else {
- window.localStorage.removeItem('is_signData');
- }
- } else {
- window.localStorage.removeItem('is_signData');
- dialog({contentType:'tipsbox', skin:'bk-popup' , content:'提交失败'}).show();
- }
- return;
- }
- function operateSuccesss(res) {
- if (res.status == 200) {
- window.localStorage.removeItem('is_signData');
- d.close();
- if(signInvitationCode&&signInvitationCode!="undefined") {
- dialog({
- content: '签约申请已提交,请耐心等待,<br/>医生通过后即可为您的家人提供家庭医生服务',
- okValue:'我知道了',
- ok: function() {
- wx.closeWindow();
- }
- }).showModal();
- }else{
- window.location.href = "../../ssgg/html/doctor-homepage-new.html?waitSign=1&state=" + doctor;
- }
- // window.location.href = "doctor-home-page.html?doctor=" + doctor;
- } else {
- //非200则为失败
- operateFailed(res);
- }
- }
- //续签申请成功后页面跳转
- function operateSuccesss2(res) {
- if (res.status == 200) {
- d.close();
- dialog({
- content: '续签申请已提交,请耐心等待,<br/>医生通过后即可为您的家人提供家庭医生服务',
- okValue:'我知道了',
- ok: function() {
- window.location.replace("../../qygl/html/signing_management.html");
- }
- }).showModal();
- } else {
- //非200则为失败
- operateFailed(res);
- }
- }
- function closeWindow() {
- var Request = new Object();
- Request = GetRequest();
- var code = Request["code"];
- //从后台那边获取签名等信息
- var params = {};
- params.pageUrl = window.location.href;
- $.ajax(server + "weixin/getSign", {
- data: params,
- dataType: "json",
- type: "post",
- success: function(res) {
- if(res.status == 200) {
- var t = res.data.timestamp;
- var noncestr = res.data.noncestr;
- var signature = res.data.signature;
- wx.config({
- //debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
- appId: appId, // 必填,公众号的唯一标识
- timestamp: t, // 必填,生成签名的时间戳
- nonceStr: noncestr, // 必填,生成签名的随机串
- signature: signature, // 必填,签名,见附录1
- jsApiList: [
- 'closeWindow'
- ] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
- });
- }
- }
- });
- }
|