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
define(['zepto', 'medtap', 'mui', 'mui.picker'], function($, medtap, mui) {
var questionnaireWeight = {
// 获取问卷id
followUpId: medtap.getRequest('followUpId'),
// 获取parentId
parentId: medtap.getRequest('parentId')||'',
// 修改人员id
adminId: medtap.getRequest('adminId')||'',
height:'',
weight:'',
init:function(){
// 点击下一题
$('.next').on('tap',function(){
questionnaireWeight.weight = $.trim($('#weight').val())
if(questionnaireWeight.weight.lenght>5||questionnaireWeight.weight==''){
medtap.winPop('请输入您的实际体重(数字)!')
return
}
questionnaireWeight.height = $.trim($('#height').val())
if(questionnaireWeight.height.lenght>5||questionnaireWeight.height=='' ){
medtap.winPop('请输入您的实际身高(数字)!')
return
}
questionnaireWeight.getNextQuestion()
})
},
// 获取问题答案
getQuestionAnswer: function(){
var crm = questionnaireWeight.adminId==''? '':'/crm'
medtap.submitAjax({
url: 'https://testdevgw.medtap.cn/operation/followUp'+crm+'/getAnswer',
type: 'post',
async: false,
contentType: 'application/json',
data: {
"followUpId": questionnaireWeight.followUpId,
"questionId":'1',
},
success: function(res) {
console.log(res)
if(!res.success) return medtap.winPop('获取数据失败')
if(!res.content.followAnswer.answer) {
return
}
$('#weight').val(res.content.followAnswer.answer.weight||'')
$('#height').val(res.content.followAnswer.answer.height||'')
}
})
},
// 下一题
getNextQuestion:function(){
var crm = questionnaireWeight.adminId==''? '':'/crm'
medtap.submitAjax({
url: 'https://testdevgw.medtap.cn/operation/followUp'+crm+'/nextQuestion',
type: 'post',
async: false,
contentType: 'application/json',
data: {
"parentId":questionnaireWeight.parentId,
"questionId":'1',
"answer":{"weight":questionnaireWeight.weight,"height":questionnaireWeight.height},
"questionNo":1,
"followUpId": questionnaireWeight.followUpId
},
success: function(res) {
console.log(res)
// 获取下一题的id和序号通过url传递
var parentId = res.content.nextQuestion.parentId||''
var questionId = res.content.nextQuestion.questionId||''
var questionNo = res.content.nextQuestion.questionNo||''
medtap.pushWindow('furtherConsultation.html?followUpId='+questionnaireWeight.followUpId + '&questionId='+questionId + '&questionNo='+questionNo+'&parentId='+parentId+'&adminId='+questionnaireWeight.adminId);
}
})
}
}
questionnaireWeight.init()
questionnaireWeight.getQuestionAnswer()
})