123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- var d = dialog({contentType:'load', skin:'bk-popup'});
- var pagetype = 46;
- var Request = GetRequest();
- var $body = $('.my-main');
- var route = Request['route'];//来源路径
- var code;
- //定义弹窗
- function toast(msg){
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:msg}).show()
- }
- //请求失败
- function queryFailed(){
- d.close()
- toast('请求失败')
- }
- $(function(){
- checkUserAgent();
- //从后台那边获取签名等信息
- 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
- })
- }
- }
- })
-
- getImmuneMembers();
- newBind();
- })
- function getImmuneMembers(){
- var data = {};
- sendPost("patient/family/members", data, "json", "get", queryListFailed, queryAppoListSuccesss);
- }
- function queryAppoListSuccesss(res){
- if (res.status == 200) {
- code = "";
- if(res.data.immunemembers.length==0){
- location.replace("ertongbangding.html");
-
- }else{
- showMember(res);
- }
- }else{
- //非200则为失败
- queryListFailed(res);
- }
- }
- function queryListFailed(res) {
- if (res && res.msg) {
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
- } else {
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载家庭成员失败'}).show();
- }
- }
- function showMember(res){
- var html='',
- data=res.data.immunemembers;
- for(var i=0;i<data.length;i++){
- //"relation": 1//---1父亲 2母亲 3老公 4老婆 5儿子 6女儿 7其他
- if(data[i].relation==5){
- data[i].familyRelationName = '儿子'
- }else if(data[i].relation==6){
- data[i].familyRelationName = '女儿'
- }else{
- data[i].familyRelationName = '其他'
- }
- html = html + '<div class="mui-control-item" data-code="'+data[i].code+'" data-name="'+data[i].name+'" style="display: inline-block;margin-right: 15px;-webkit-user-select: none;vertical-align: middle;text-align: center;">\
- <img style="width: 40px;height: 40px;border-radius: 50%;overflow: hidden;border:solid 1px #dcdcdc;" src="../images/youer_moren_img.png"/>\
- <div class="name" style="font-size: 12px;color: #333;line-height: 20px;">'+data[i].name+'('+data[i].familyRelationName+')</div></div>'
- }
- html = html + '<div id="xinzeng_btn" style="display: inline-block;margin-right: 15px;-webkit-user-select: none;vertical-align: middle;text-align: center;">\
- <img style="width: 40px;height: 40px;border-radius: 50%;overflow: hidden;border:solid 1px #dcdcdc;" src="../images/xinzengguanlian_btn.png"/>\
- <div class="name" style="font-size: 12px;color: #333;line-height: 20px;">新增关联</div></div>'
-
- html = '<div class="mui-scroll-wrapper family-member" style="position: absolute;z-index: 999;top: 0;bottom: 0;left: 0;overflow: hidden;width: 100%;height: 90px;background-color:#f3f3f3;padding-left: 15px;padding-top: 7px;border-bottom:solid 1px #dcdcdc;box-sizing: border-box;">\
- <div class="mui-scroll" style="position: absolute;width: auto;z-index: 99;white-space: nowrap;-webkit-transform: translateZ(0);transform: translateZ(0);">'+html+'</div></div>';
- $('#memberContainer').append(html);
- setTimeout(function(){
- addEvent();
- },200)
- initData();
- }
- function active(one){
- one.find('img').css({width: '55px',height: '55px'});
- one.find('.name').css({'font-size': '14px','line-height':'23px'});
- }
- function addEvent(){
- mui('.family-member').scroll({
- scrollY: false, //是否竖向滚动
- scrollX: true, //是否横向滚动
- });
- $('#memberContainer').on('tap','.mui-control-item',function(){
- var $this = $(this),
- $code = $this.data('code');
- code = $code;
- $('.mui-control-item').find('img').css({width: '40px',height: '40px'});
- $('.mui-control-item').find('.name').css({'font-size': '12px','line-height':'20px'});
- active($this);
- initData();
- })
- }
- function initData(){
- d.show();
- var params = {};
- if(code == ""){
- var $ul = $('#memberContainer').find('.mui-control-item');
- code = $ul.eq(0).data('code')
- if(code){
- active($ul.eq(0));
- }
- }
- if(code){
- $('.my-section').css('top','90px');
- // $(".my-section").show();
- // $('.div-no-info').css('padding-top','150px');
- // $(".div-no-info").hide();
- params.code = code;
- getImmChildInfo(params);
- }else{
- $('.my-section').css('top','0px');
- d.close();
- // $(".my-section").hide();
- // $(".div-no-info").show();
- }
- }
- //根据新生儿编码获取新生儿基础信息
- function getImmChildInfo(params){
- d.close();
- sendPost('/patient/family/getImmChildInfo',params,'json','get', queryFailed,function(res){
- if(res.status == 200){
- var html = template('patient_tmpl', res.data)
- $('#patientInfo').html(html)
-
- if(res.data.sex==2){
- // nextWork()
- bindEvent()
- }else{
- d.close()
- dialog({
- content: '<div><div class="c-f16 c-333 c-t-left mb10">当前未关联在免疫计划内居民,是否添加条形码关联?</div></div>',
- okValue: '是',
- ok: function() {
- location.href="ertongbangding.html"
- },
- cancelValue: '否',
- cancel: function () {
- wx.closeWindow();
- }
- }).showModal()
- }
- }else{
- d.close()
- toast('获取信息失败')
- }
- })
- }
- function bindEvent(){
- //头部展示
- showActive(route)
- mui('.my-nav').scroll({
- scrollY: false, //是否竖向滚动
- scrollX: true, //是否横向滚动
- })
- //切换类型
- $('.j-change').on('tap',function(){
- var $this = $(this)
- if(!$this.hasClass('active')){
- $this.addClass('active').siblings().removeClass('active')
- }
- })
- //跳转疫苗详情
- $('.my-line').on('tap',function(){
- location.href="yimiaoxiangqing.html"
- })
- }
- function newBind(){
- //新增关联
- $('body').on('tap','#xinzeng_btn',function(){
- location.href="ertongbangding.html"
- })
- $('body').on('tap','.idClick',function(){
- var $this = $(this);
- var $editbarcode = $this.attr('data-code');
- location.href="edit-idcard-ssc.html?barcode="+$editbarcode;
- })
- $('body').on('tap','.sscClick',function(){
- var $this = $(this);
- var $editbarcode = $this.attr('data-code');
- location.href="edit-idcard-ssc.html?barcode="+$editbarcode;
- })
- }
- //优先展示
- function showActive(route){
- var $list = $('.j-change');
- if(route){
- for(var i=0;i<$list.length;i++){
- if($list.eq(i).attr('data-id') == route){
- $list.eq(i).addClass('active')
- return
- }
- }
- }else{
- $list.eq(0).addClass('active')
- }
- }
- template.helper("setPhoto", function(p) {
- return getImgUrl(p);
- });
- template.helper("setAge", function(p) {
- // 获得今天的时间
- var date = new Date();
- // alert(birthday);
- var startDate = new Date(p);
- var newDate = date.getTime() - startDate.getTime();
- // 向下取整 例如 10岁 20天 会计算成 10岁
- // 如果要向上取整 计算成11岁,把floor替换成 ceil
- var age = Math.ceil(newDate / 1000 / 60 / 60 / 24 /365);
- if (isNaN(age)){
- age = "";
- }
- return age;
- });
|