define(['zepto', 'medtap', 'mui', 'mui.picker'], function($, medtap, mui) {
  var index = {
    wechatId: medtap.getRequest('wechatId'),
    // 问卷id
    followUpId: medtap.getRequest('followUpId'),
    init: function(){
      // 点击开始填写
     $('.fill_write').on('tap',function(){
       medtap.pushWindow('pages/questionnaireWeight.html?followUpId='+index.followUpId)
     })
     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(){
      medtap.submitAjax({
				url: "https://testdevgw.medtap.cn/operation/followUp/followUpUser",
				type: 'post',
        async: false,
        contentType: 'application/json',
				data: {
          "followUpId":index.followUpId
				},
        success: function(res) {
          console.log(res)
          if(res.content.followUpUser.status=='1'){
            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()
})