index.js 1.97 KB
Newer Older
1 2 3
define(['zepto', 'medtap', 'mui', 'mui.picker'], function($, medtap, mui) {
  var index = {
    wechatId: medtap.getRequest('wechatId'),
zujiaozhang committed
4 5
    // 问卷id
    followUpId: medtap.getRequest('followUpId'),
6 7
    		// 修改人员id
		adminId: medtap.getRequest('adminId')||'',
8 9
    init: function(){
      // 点击开始填写
zujiaozhang committed
10
     $('.fill_write').on('tap',function(){
11
       medtap.pushWindow('pages/questionnaireWeight.html?followUpId='+index.followUpId+'&adminId='+index.adminId)
12
     })
zujiaozhang committed
13
     index.getMyquestionnaire();
14 15 16 17 18 19
    },
    //换取微信token
    getUserToken: function() {
      localStorage.wxLungToken = '';
      medtap.loading(1);
      medtap.submitAjax({
zujiaozhang committed
20
        url: 'https://testdevgw.medtap.cn/user/auth/token',
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
        type: 'POST',
        async: false,
        contentType: 'application/json',
        data: {
          wechatId: index.wechatId
        },
        success: function(res) {
          medtap.loading(0);
          if (res.success == true) {
            var token = res.content.token;
            localStorage.setItem('wxLungToken', token);
          } else {
          }
        },
        error: function(res) {
          console.log(res.resultDesc);
        }
      });
    },
    // 获取问卷
    getMyquestionnaire: function(){
42
     var crm = index.adminId==''? '':'/crm'
43
      medtap.submitAjax({
zujiaozhang committed
44
				url: 'https://testdevgw.medtap.cn/operation/followUp'+ crm +'/followUpUser',
45 46
				type: 'post',
        async: false,
47
        contentType: 'application/json',
48
				data: {
zujiaozhang committed
49 50
          "followUpId":index.followUpId,
          "adminId":index.adminId
51 52
				},
        success: function(res) {
53 54 55
          if(res.content.followUpUser.status=='1' && index.adminId==''){
            medtap.pushWindow('pages/questionnaireDetails.html?followUpId='+index.followUpId)
          }
zujiaozhang committed
56 57 58
          index.followUpId =res.content.followUpUser.id
          var mm = res.content.followUpUser.answerTime
          $('.mouth_title span').text(mm.split("-")[1])
59 60 61 62 63 64
        }
      })
    }
  }
  index.init()
})