define(['zepto', 'medtap', 'mui', 'mui.picker'], function($, medtap, mui) {
  var index = {
    wechatId: medtap.getRequest('wechatId'),
    // 问卷id
    followUpId: medtap.getRequest('followUpId'),
    		// 修改人员id
		adminId: medtap.getRequest('adminId')||'',
    init: function(){
      // 点击开始填写
     $('.fill_write').on('tap',function(){
       medtap.pushWindow('pages/questionnaireWeight.html?followUpId='+index.followUpId+'&adminId='+index.adminId)
     })
     index.getMyquestionnaire();
    },
    //换取微信token
    getUserToken: function() {
      localStorage.wxLungToken = '';
      medtap.loading(1);
      medtap.submitAjax({
        url: 'https://testdevgw.medtap.cn/user/auth/token',
        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(){
     var crm = index.adminId==''? '':'/crm'
      medtap.submitAjax({
				url: 'https://testdevgw.medtap.cn/operation/followUp'+ crm +'/followUpUser',
				type: 'post',
        async: false,
        contentType: 'application/json',
				data: {
          "followUpId":index.followUpId
				},
        success: function(res) {
          console.log(res)
          // if(res.content.followUpUser.status=='1' && index.adminId==''){
          //   medtap.pushWindow('pages/questionnaireDetails.html?followUpId='+index.followUpId)
          // }
          index.followUpId =res.content.followUpUser.id
          var mm = res.content.followUpUser.answerTime
          $('.mouth_title span').text(mm.split("-")[1])
        }
      })
    }
  }
  index.init()
})