home.js 26.3 KB
   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
/*首页*/

// 网络请求工具类
var networkUtil = require('../../utils/network_util.js')
var api = require('../../utils/apiFile.js')
// 数字类数据处理
var numberUtil = require('../../utils/numberUtil.js')
var util = require('../../utils/util.js')
// 事件监听
var event = require('../../utils/event.js')
// 获取应用实例
var app = getApp()

//聊天控件
let WebIM = wx.WebIM = require("../../utils/WebIM.js").default;
let disp = require("../../utils/broadcast");

var timeCount = 60;
var timer;
var phone;
var name;
var days;
// 用户信息的缓存
var babyCache = ['']
// 文章的缓存
var artCache = ['']
var hospitalId;

Page({
/*---------属性变量--------*/
data: {
MsgCount:null,
isLogin: '',
item_big_height: 0,
item_small: 0,
// 首页类型 1登录 2用户首页 3欢迎页
pageType: 0,
unTotleReadCount:0,
time: '0s',
list: [],
userInfo: '',
inputFocus: {
nameInput: false,
phoneInput: false,
codeInput: false
},
babyIndex: 0,
babys: [],
tourist: true,
isShowLeft: false,
isShowRight: false,
vipList: [{
title: '高危指导',
icon: 'gaoweizhidao',
content: '医生依据新生儿娩出情况、新生儿患病情况及新生儿先天性疾病筛查结果辨识、诊断高危儿。针对医生的高危诊断,结合高危儿的月龄、生理因素、高危状态、检查结果、需监测指标等提供精准医疗服务。向早产儿、低出生体重儿、发育迟缓等特殊婴幼儿家长提供育儿帮助。'
},
{
title: '精准医疗服务',
icon: 'jingzunyiliao',
content: '依据新生儿特有的生理情况,结合其每天都会快速生长发育的特点,对可能遇到的生理病理问题,提供精确到天的健康教育。新生儿期过后,结合婴幼儿体格生长发育特点,针对不同月龄,进行喂养方式、营养补充、辅食添加、动作发育、习惯培养等宣教指导。'
},
{
title: '检查预约提醒',
icon: 'chakanyuyuetixing',
content: '每次检查后,医生会结合当前检查实际情况为儿童预约下次检查时间,届时提前通知家长带孩子进行相关检查。'
},
{
title: '随访提醒',
icon: 'suifangtixing',
content: '依据新生儿特有的生理情况,结合其每天都会快速生长发育的特点,对可能遇到的生理病理问题,提供精确到天的健康教育。新生儿期过后,结合婴幼儿体格生长发育特点,针对不同月龄,进行喂养方式、营养补充、辅食添加、动作发育、习惯培养等宣教指导。'
},
{
title: '查看检查记录',
icon: 'chakanjilv',
content: '医生依据新生儿娩出情况、新生儿患病情况及新生儿先天性疾病筛查结果辨识、诊断高危儿。针对医生的高危诊断,结合高危儿的月龄、生理因素、高危状态、检查结果、需监测指标等提供精准医疗服务。向早产儿、低出生体重儿、发育迟缓等特殊婴幼儿家长提供育儿帮助。'
},
{
title: '高危指导',
icon: 'gaoweizhidao',
content: '随时随地可查看因幼儿问诊检查、儿科检查、一般检查、辅助检查的各项指标,以及相关指标存在的异常情况。'
}
],
// 是否开通高危精准指导
riskGuide: false,
riskBase: false,
//是否开通疾病指导
riskDise:false,
hospitalId1:null,
userInfoDate:{},
erid:null
},
/*---------生命周期--------*/
onLoad: function(options) {
// console.log(app.globalData,'options1121');
this.getUserInfo(app.globalData.token)
hospitalId = options.hospitalId;
this.calculatePageSize()
this.setData({
hospitalId1:options.hospitalId
})
// 网络监听
this.networkStatusChange()
var that = this
disp.on("em.xmpp.unreadspot", function(){
that.getUnreaderMsgNum()
})
if (app.globalData.token == null || app.globalData.token == ''||wx.getStorageSync("access_token") == null||!wx.getStorageSync("access_token")) {
this.welcomePage()
} else {
this.homePage()
// 监听事件
event.on('likeChanged', this, function(data) {
if (data.categoryIndex == -1) {
var artList = this.data.crisisCategorie
artList[data.articleIdIndex].likeCount++
this.setData({
crisisCategorie: artList
});
} else {
var artList = this.data.articleList
artList[data.categoryIndex].article[data.articleIdIndex].likeCount++
this.setData({
articleList: artList
});
}
})
}

},
setNotification:function(){
const _that = this
networkUtil._get(api.getMsgList,{
page: 1,
limit: 20,
babyId:_that.data.erid,
},function (res) {
if (res.data.data.length > 0 ) {
wx.navigateTo({
url: '/packageA/pages/messageNotification/messageNotification',
})
} else {
wx.showModal({
title: '提示',
content: '当前没有医院活动通知',
showCancel: false,
})
}
}, function (res) {
networkUtil.showErrorToast(res.errormsg)
})


},
onShow: function() {
// 生命周期函数--监听页面显示
if (wx.getStorageSync("access_token") != null&&wx.getStorageSync("access_token")) {
// console.log(wx.getStorageSync("access_token"))
this.connectWebIM()

}
if (app.globalData.token.length > 0 && this.data.pageType != 2) {
this.getUserInfo()
this.homePage()
}
if (app.globalData.token.length > 0 && this.data.pageType == 2) {
this.getUserInfo()
}
if (!app.globalData.token && this.data.pageType != 1) {
this.welcomePage()
}
this.getUnreaderMsgNum()
},
onUnload: function() {
// 移除监听
event.remove('likeChanged', this);
},

getBabyMsgCountByIdNum:function(id){
const _that = this
networkUtil._get(api.getBabyMsgCountById,{
babyId:id
},function (res) {
// console.log(res.data.object,'res1111');
_that.setData({
MsgCount:res.data.object
})
wx.hideToast();
}, function (res) {
networkUtil.showErrorToast(res.errormsg)
})
},

/*---------交互--------*/
// 下拉刷新回调接口
onPullDownRefresh: function() {
if (app.globalData.token == null || app.globalData.token == '') {
wx.stopPullDownRefresh()
return
}
// 网络请求,重新请求一遍数据
this.homePage()
},
// 点击头像
tapAvatar: function() {
// var that = this
// wx.showActionSheet({
// itemList: ['退出当前用户'],
// success: function (res) {
// if (res.tapIndex == 0) {
// wx.setStorageSync('userToken', '')
// wx.setStorageSync('userId', '')
// getApp().globalData.token = ''
// getApp().globalData.userId = ''
// that.toLogin()
// }
// },
// fail: function (res) {
// console.log(res.errMsg)
// }
// })
wx.navigateTo({
url: '../Setting/Setting',
})
},
toHospital() {
if (this.data.userData.hospitalId && this.data.userData.hospitalId > 0) {
wx.navigateTo({
url: '../hospital_detail/hospital_detail?id=' + this.data.userData.hospitalId,
})
} else {
wx.navigateTo({
url: '../hospitalList/hospitalList',
})
}

},
toPreDoc () {
if (hospitalId!==null&&hospitalId!==undefined&&hospitalId!==""&&hospitalId===2100001605) {
wx.navigateTo({
url: '/packageA/pages/preDocumented/preDocumented?hospitalId=' + hospitalId
})
} else {
wx.navigateTo({
url: '/packageA/pages/preDocumented/preDocumented'
})
}

},
getNameFocus: function() {
var self = this
var inputFocus = {
nameInput: true,
phoneInput: false,
codeInput: false
}
self.setData({
inputFocus: inputFocus
})
},
getPhoneFocus: function() {
var self = this
var inputFocus = {
nameInput: false,
phoneInput: true,
codeInput: false
}
self.setData({
inputFocus: inputFocus
})
},
getCodeFocus: function() {
var self = this
var inputFocus = {
nameInput: false,
phoneInput: false,
codeInput: true
}
self.setData({
inputFocus: inputFocus
})
},
loseNameFocus: function() {
var self = this
var inputFocus = {
nameInput: false
}
self.setData({
inputFocus: inputFocus
})
},
losePhoneFocus: function() {
var self = this
var inputFocus = {
phoneInput: false,
}
self.setData({
inputFocus: inputFocus
})
},
loseCodeFocus: function() {
var self = this
var inputFocus = {
codeInput: false
}
self.setData({
inputFocus: inputFocus
})
},
// 跳转上一条
toBefore() {
var index = this.data.babyIndex
index--
// console.log('index', index)
var left = true
var right = true
if (index == 0) {
left = false
}
this.setData({
isShowLeft: left,
isShowRight: right,
babyIndex: index
})
this.changeBaby(index)
},
// 跳转下一条
toAfter() {
var index = this.data.babyIndex
index++
// console.log('index', index)
var left = true
var right = true
if (index == app.globalData.userId.length - 1) {
right = false
}
this.setData({
isShowLeft: left,
isShowRight: right,
babyIndex: index
})
this.changeBaby(index)
},
// 改变baby
changeBaby(index) {
this.setData({
babyIndex: index
})
getApp().globalData.currentId = getApp().globalData.userId[index]
if (babyCache.length > index) {
this.setUserInfo(babyCache[index])
this.setArtInfo(artCache[index])
this.getUserArchives();
} else {
this.getUserInfo()
}
},
/*---------自定义函数--------*/
homePage() {
var that = this
this.requestHomeInfo()
var that = this
var right = true
this.requestVipData()
if (app.globalData.userId.length == 1) {
right = false
}
that.setData({
pageType: 2,
babys: app.globalData.userId,
isShowRight: right
})
},
toLogin() {
var that = this

babyCache = ['']
artCache = ['']

that.setData({
pageType: 1
})
},
backHome () {
this.setData({
pageType: 3
})
},
welcomePage() {
var that = this
that.setData({
pageType: 3
})
},
toVipPage() {
wx.navigateTo({
url: '../vipService/vipService',
})
},
toRiskGuidePage() {
if (this.data.riskGuide) {
wx.navigateTo({
url: "../Guide/guide?category=精准指导",
// url: "../articleLists/articleLists?category=精准指导",
})
} else {
wx.showModal({
title: '温馨提示',
content: '您还没有开通该项服务哦',
confirmText: '立即开通',
success: function(res) {
if (res.confirm) {
wx.navigateTo({
url: '../vipService/vipService',
})
}
}
})
}
},
toInspection() {
if (this.data.riskBase) {
wx.navigateTo({
// url: '../Guide/guide',
url: "../inspect/inspectList?types=1",
})
} else {
wx.showModal({
title: '温馨提示',
content: '尚未开通儿保助理服务,无法享受会员服务',
confirmText: '立即开通',
success: function (res) {
if (res.confirm) {
wx.navigateTo({
url: '../vipService/vipService',
})
}
}
})
}
},
toDiseaseGuide(){
if (this.data.riskDise) {
wx.navigateTo({
// url: '../Guide/guide',
url: "../DiseaseGuide/DiseaseGuide",
})
} else {
wx.showModal({
title: '温馨提示',
content: '尚未开通儿保助理服务,无法享受会员服务',
confirmText: '立即开通',
success: function (res) {
// if (res.confirm) {
// wx.navigateTo({
// url: '../vipService/vipService',
// })
// }
}
})
}
},
requestVipData() {
var self = this
var param = {}
networkUtil._get(api.goods, param, function(res) {
// console.log(res)
res.data.data.map(function(item) {
if (item.id == 7) {
if (item.status == 1) {
self.setData({
// riskGuide: true,
})
}
}
})
}, function(res) {

})
},
calculatePageSize() {
var windowWidth = wx.getSystemInfoSync().windowWidth
// var smallWidth = ((windowWidth - 10) / 2 - 10)
this.setData({
// item_big_height: 'height:' + windowWidth / 4 + 'px',
item_small: 'width:' + windowWidth / 4 * 0.45 + 'px;height:' + windowWidth / 4 * 0.45 + 'px',
})
},
getAccessToken() {
// console.log('getAccessToken')
var that = this
var token = '';
var options = {
apiUrl: WebIM.config.apiURL,
user: wx.getStorageSync('hxName'),
pwd: wx.getStorageSync('hxPassWord'),
success: function (res) {
// console.log("conn success:", res);
wx.setStorageSync("access_token", res.data.access_token)
token = res.data.access_token
},
fail: function (e) {
console.log("fail:" + e);
},
autoReconnectNumMax: 30,
autoReconnectInterval: 1,
appKey: WebIM.config.appkey
}

WebIM.conn.open(options)
},
// 监听网络状态
networkStatusChange() {
var that = this
wx.onNetworkStatusChange(function(res) {
if (res.isConnected == true) {
that.connectWebIM()
}
})
},
connectWebIM() {
// console.log('开始连接')
//WebIM.conn.close()
var that = this
var options = {
apiUrl: WebIM.config.apiURL,
user: wx.getStorageSync('hxName'),
pwd: wx.getStorageSync('hxPassWord'),
accessToken: wx.getStorageSync('access_token'),
// grant_type: "password",

success: function (res) {
console.log("conn success:", res);
},
fail: function (e) {
console.log("fail:" + e);
},
autoReconnectNumMax: 30,
autoReconnectInterval: 1,
appKey: WebIM.config.appkey
}

WebIM.conn.open(options)
},
requestHomeInfo() {
// 需要先请求用户信息
this.getUserInfo()
},
// 获取用户信息
getUserInfo(userId) {
networkUtil.showLoading()
var self = this
var param = {
'token': app.globalData.token
}
if (getApp().globalData.tourist == true) {
param.type = 2
}
networkUtil._get(api.userInfo + app.globalData.currentId, param, function(res) {
// console.log('获取用户信息1212', res)
if (res.data.data.bzstatus==1){
self.data.riskBase=true;
}else{
self.data.riskBase=false;
}
if (res.data.data.status == 1){
self.data.riskGuide=true;
}else{
self.data.riskGuide = false;
}
self.getArticleInfo(res.data.data.days)
self.setUserInfo(res.data.data)
babyCache[self.data.babyIndex] = res.data.data
self.getUserArchives();
}, function(res) {

if (res.errorcode == 4002) {
wx.showModal({
title: '提示',
content: res.errormsg,
showCancel: false,
success: function(res) {
wx.setStorageSync('userToken', '')
wx.setStorageSync('userId', '')
getApp().globalData.token = ''
getApp().globalData.userId = ''
self.toLogin()
}
})
} else {
networkUtil.showErrorToast(res.errormsg)
}
})
},
//获取档案信息
getUserArchives(){
networkUtil.showLoading()
var self = this
var param = {
'pid': app.globalData.userInfo.pid,
'hospitalId':app.globalData.userInfo.hospitalId
}
networkUtil._post(api.getBabyBuildPidInfo,param,function(res){
wx.setStorageSync('erid',res.data.data.id)
self.getBabyMsgCountByIdNum(res.data.data.id)
// self.setNotification(res.data.data.id)
self.setData({
erid:res.data.data.id
})
app.globalData.encoded = res.data.data.encoded;
app.globalData.openDisease = res.data.data.openDisease;
if(res.data.data.openDisease == '2'){
self.setData({
riskDise:true
})
}else{
self.setData({
riskDise:false
})
}
self.setData({
"userData.encoded" : res.data.data.encoded,
"userData.openDisease" : res.data.data.openDisease
})
},function(res){
networkUtil.showErrorToast(res.errormsg)
},'application/json')
},
getArticleInfo(days) {
var self = this
// 文章列表
networkUtil._get(api.homeArtList, {
page: 0,
limit: 100,
days: days
}, function(res) {
// console.log('获取文章信息', res.data.list)
artCache[self.data.babyIndex] = res.data.list
self.setArtInfo(res.data.list)
}, function(res) {
wx.stopPullDownRefresh()
})
},
// 设置UI 用户信息
setUserInfo(data) {
var self = this
app.globalData.days = data.days
app.globalData.userInfo = data
self.setData({
userData: data,
userInfoDate:data,
tourist: getApp().globalData.tourist
})
},
// 设置UI 文章信息
setArtInfo(list) {
var self = this
app.globalData.artList = list
self.setData({
list: list
})
},
// 文章点赞
articleLike(e) {
// console.log(e)
var self = this
// 已经点赞
if (e.currentTarget.dataset.islike == 1) {
networkUtil.showErrorToast('您已经点过赞啦')
return;
}
networkUtil._post(api.articleLike, {
id: e.currentTarget.dataset.artid
}, function(res) {
var artList = self.data.list
artList[e.currentTarget.dataset.categaryindex].article[e.currentTarget.dataset.artindex].likeCount++
artList[e.currentTarget.dataset.categaryindex].article[e.currentTarget.dataset.artindex].isLike = 1
self.setData({
list: artList
});
}, function(res) {
console.log(res)
})
},
// 标签页面
clickLabel(e) {
// console.log(e)
wx.navigateTo({
url: '../articleLists/articleLists?category=' + e.currentTarget.dataset.categary,
})
},
/*---------------欢迎介绍页面---------------*/
toRegister() {
wx.navigateTo({
url: '../Register/Register',
})
},
toCheckInput() {
wx.navigateTo({
url: '../checkupAskInput/checkupAskInput',
})
},
toQuickArchives(){
wx.navigateTo({
url: '../quickArchives/quickArchives',
})
},
toIllnessArchives(){
wx.navigateTo({
url: '../illnessArchives/illnessArchives',
})
},
toQuickMeasurement(){
wx.navigateTo({
url: '../quickMeasurement/quickMeasurement',
})
},
// 获取验证码
getVerifyCode: function(e) {
// console.log("name:" + name)
// console.log("phone:" + phone)
// name = '小向阳'
// phone = '18202810912'
if (timeCount < 60) {
return
}
if (numberUtil.IsTelPhoneNumber(phone) && name.length > 0) {
var that = this
networkUtil._post(api.bindDoc, {
username: name,
phone: phone
}, function(res) {
console.log("getVerifyCode:", res)

}, function(res) {
timeCount = 60
clearTimeout(timer);
that.setData({
time: '0s'
})
// if (res.errorcode == 4003) {
// wx.showModal({
// title: '提示',
// content: '暂未查询到您宝宝的建档信息,是否立即使用游客身份注册?',
// success: function(res) {
// if (res.confirm) {
// wx.navigateTo({
// url: '../Register/Register?name=' + name + '&phone=' + phone,
// })
// } else if (res.cancel) {
// console.log('用户点击取消')
// }
// }
// })
// } else {
// networkUtil.showErrorToast(res.errormsg)
// }
networkUtil.showErrorToast(res.errormsg)
})
if (timeCount == 60) {
this.keepTime()
}
} else {
networkUtil.showErrorToast('请输入正确手机号码和姓名')
return
}
},
// 计时器
keepTime: function() {
var that = this
timeCount--
that.setData({
time: timeCount + 's'
})
if (timeCount == 0) {
timeCount = 60
clearTimeout(timer);
return
}
timer = setTimeout(function() {
that.keepTime()
}, 1000)
},
blurInput: function(e) {
phone = e.detail.value
// console.log(e)
},
blurNameInput: function(e) {
name = e.detail.value
// console.log(e)
},
// 提交表单
formSubmit: function(e) {

var self = this
if (e.detail.value.code == "") {
wx.showModal({
title: '提示',
content: '请输入验证码',
showCancel: false,
success: function(res) {}
})
return
}
networkUtil.showLoading()
var param = {
code: e.detail.value.code,
phone: phone
}
if (getApp().globalData.openInfo.mpid) {
param.gzopenid = getApp().globalData.openInfo.mpid
// console.log('绑定mpid', param)
}
if (getApp().globalData.openInfo.childCode) {
param.jscode = getApp().globalData.openInfo.childCode
// console.log('绑定code', param)
}
networkUtil._get(api.verifyCode, param, function(res) {
// console.log(res)
self.loginSuccess(res.data)
}, function(res) {
networkUtil.showErrorToast(res.errormsg)
})
},
loginSuccess(data) {
// 为3的时候就是没填写资料
wx.setStorageSync('hxName', data.hxName)
wx.setStorageSync('hxPassWord', data.hxPassWord)
this.getAccessToken();
if (data.status == 4) {
wx.navigateTo({
url: '../CompleteTouristInfo/CompleteTouristInfo?userId=' + data.id + '&token=' + data.token
})
return
}
// 游客用户
if (data.patientIds && data.patientIds.length == 0) {
data.patientIds = [data.id]
getApp().globalData.tourist = true
wx.setStorageSync('tourist', true)
} else {
getApp().globalData.tourist = false
wx.setStorageSync('tourist', false)
}
wx.setStorageSync('userToken', data.token)
wx.setStorageSync('userId', data.patientIds)
getApp().globalData.token = data.token
getApp().globalData.userId = data.patientIds
getApp().globalData.currentId = data.patientIds[0]
this.homePage()
wx.navigateBackMiniProgram({
extraData: {
res: '成功'
},
success(res) {
// 返回成功
}
})
},
goQRCode(){
wx.navigateTo({
url: '../../pages/QRCodePage/QRCodePage?encoded=' + this.data.userData.encoded,
})
},

//疾病护理咨询
expertConsultation(){
if(this.data.userData.disStatus == 0){
wx.navigateTo({
url: '../doctorLists/doctorLists',
})
}else if(this.data.userData.disStatus == 1){
var my = wx.getStorageSync('hxName')
var serviceId = this.data.userData.disData.serviceId;
var nameList = {
myName: my,
your: this.data.userData.disData.doctorHxName,
serviceId:serviceId,
memberId:this.data.userData.disData.memberId,
doctorId:this.data.userData.disData.doctorId
}
wx.setStorageSync('serviceId',serviceId)
// console.log(nameList)
wx.navigateTo({
url: '../consulting/consulting?username='+ JSON.stringify(nameList)
})
}
},
// 身长体重曲线
goGraph() {
networkUtil.showLoading()
var param = {
'pid': app.globalData.userInfo.pid,
'hospitalId':app.globalData.userInfo.hospitalId
}
networkUtil._post(api.getBabyBuildPidInfo,param,function(res){
// console.log(res,'res1212112');
if (res.data.data) {
wx.navigateTo({url: '/packageA/pages/graph/graph?id=' + res.data.data.id })
}
},function(res){
networkUtil.showErrorToast(res.errormsg)
},'application/json')
},
goEditAddress() {
networkUtil.showLoading()
var param = {
'pid': app.globalData.userInfo.pid,
'hospitalId':app.globalData.userInfo.hospitalId
}
networkUtil._post(api.getBabyBuildPidInfo,param,function(res){
if (res.data.data) {
wx.navigateTo({url: '/packageA/pages/editAddress/editAddress?id=' + res.data.data.id })
}
},function(res){
networkUtil.showErrorToast(res.errormsg)
},'application/json')
},
goArticle() {
wx.navigateTo({url: '/packageA/pages/articleList/articleList'})
},
//跳转服务名目通知
goServiceNotice(){
wx.navigateTo({url: '/packageA/pages/serviceNotice/serviceNotice'})
},
//专家咨询
consultation(){
if(this.data.riskGuide){
var my = wx.getStorageSync('hxName')
var nameList = {
myName: my,
your: this.data.userData.disData.doctorHxName,
memberId:this.data.userData.disData.memberId,
doctorId:this.data.userData.disData.doctorId
}
wx.navigateTo({
url: '../doctorLists/doctorLists?username='+ JSON.stringify(nameList),
})
}else{
wx.showModal({
title: '温馨提示',
content: '您还没有开通该项服务哦',
confirmText: '立即开通',
success: function(res) {
if (res.confirm) {
wx.navigateTo({
url: '../vipService/vipService',
})
}
}
})
}
},
// 获取未读总数
getUnreaderMsgNum(){
var that = this
var num = 0
var myName = wx.getStorageSync("hxName");
WebIM.conn.listRooms({
success: function(rooms){
// console.log(rooms)
rooms.map((item) => {
wx.getStorage({
key: item.roomId + myName,
success (res) {
var unreadMas =res.data
if(unreadMas){
num += unreadMas.length;
}
// console.log(num)
that.setData({unTotleReadCount:num})
}
})
})
},
error: function(){

}
})
}
})