<style scoped>  
.clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden}
.clearfix{overflow:hidden;_zoom:1;}
.text-gray{color:#717171;}
.text-orange{color:#eb7741;}
.text-danger{color:#c03546;}
.Key_CustomerView{background-color: #f3f6ff;padding:0 2%;}
.paddingVal{height:0.6rem;padding: 0;margin:0;background-color: #f3f6ff;}
.bottomItem{margin-bottom:0.6rem;background-color: #fff;border-radius: 0.4rem;display: flex;padding:1rem 2.4%;}
.bottomItem .imgTop{width:2.2rem;}
.bottomItem img{width:2.2rem;height:2.2rem;border-radius: 100%;}
.bottomItem .bottomInfo{flex:1;padding: 0 0.4rem;}
.bottomItem .bottomInfo h4{margin:0;word-wrap:break-word;word-break:break-all;}
.bottomItem .bottomInfo p{margin:0;margin-top:1rem;font-size: 0.7rem;color: #868689;}
.bottomItem .bottomTel{position:relative;}
.bottomItem .bottomTel span{margin-top: 0.9rem;border-radius: 1rem;padding: 0.2rem 0.4rem;display:block;background-color: #3b8afc;color:#fff;font-size: 0.7rem;}
.listPanel{background-color: #fff;padding: 0;border-radius: 0.4rem;margin-bottom: 0.6rem;}
.productWay {padding: 1.06rem 0.4rem;border-bottom: 1px solid #E9E9E9;display:flex;line-height: 1;}
.productWay:nth-last-of-type(1){border-bottom-width:0;}
.productWay .titleInfo{margin-right: 0.2rem}
.productWay .resultInfo{-webkit-box-flex: 1;flex: 1;text-align: right;}
.listPanelHeader{padding:0.8rem 3%;padding-bottom:0;text-indent:1.2rem;color:#3A8AFB;background: url(http://image.supercarrier8.com/h5_key/icon-billDetails.png) no-repeat 3% 0.8rem;background-size:1rem;background-color: #fff;font-weight: 700;}
.headerTime{padding: 0.8rem 0.4rem;line-height: 1;border-bottom:1px solid #E9E9E9;position: relative;}
.headerTime span{float: left;padding: 0.2rem 0.7rem;/*line-height:1;*/margin-right:0.2rem;border-radius:1rem;background-color: #f3f6ff;color:#868689;}
.headerTime span.selected{background-color: #b1d0fe;color:#599cfd;}
.headerTime .headerTimeRight {margin:0;float: right;padding-right: 1rem;background-image: url(https://release-sup8-images.oss-cn-shanghai.aliyuncs.com/h5_key/icon-customerdown.png);background-repeat: no-repeat;background-size: 0.6rem;background-position: 92% center;}
.headerTime .headerTimeSearch{position:absolute;top:0.5rem;right:0rem;background-position: 96% center;background-color: #fff;}
.headerTime .headerTimeSearch i{display: block;font-size: 0.7rem;font-style: normal;}
.mint-popup-bottom{width:100%;}
.picker-toolbar-title .btnHeader{display: flex;}
.picker-toolbar-title .btnHeader .button{width: 50%;text-align: center;}
.picker-toolbar-title .btnHeader button{flex: 1;}
.picker-toolbar-title .setDateHearder{display: flex;}
.picker-toolbar-title .setDateHearder div{flex: 1;text-align: left;padding: 0.4rem 0;margin-left: 2%;}
.picker-toolbar-title .setDateHearder div p{margin:0;}
.picker-toolbar-title .setDateHearder div p:nth-of-type(1){font-size: 0.76rem;color:#868689;}
.picker-toolbar-title .setDateHearder div p:nth-last-of-type(1){padding:0.8rem 0;font-weight: 600;}
.picker-toolbar-title .setDateHearder div p.selected{border-bottom: 2px solid #3b8afc;}
.buyList .buyListItem{border-bottom: 1px solid #E9E9E9;}
.buyList .productItem {font-size: 0.7rem;}
.buyList .buyListItem div{width:32.6%;float: left;text-align: center;padding: 0.8rem 0.36%;line-height: 1;}
.buyList .buyListItem div.productTime{width:24.6%;}
.buyList .buyListItem div.productName{width:40%;}
</style>
<style >
.picker-toolbar{height: auto;}
</style>
<template>     
  <div class="jfBaseSize Key_CustomerView" v-cloak v-bind:style="isShow.vh?'height:100vh':'height: 100%;'">
    <div class="paddingVal"></div>
    <div class='bottomItem'>
      <div class="imgTop">
        <img v-bind:src="model.HeadImage?model.HeadImage:'http://image.supercarrier8.com/h5_key/icon_headDefault.png'" alt="">
      </div>
      <div class="bottomInfo">
        <h4 v-html="model.NickName?model.NickName:'-'"></h4>
        <p>绑定时间:<span v-html="model.BindDateTime?model.BindDateTime:'-'"></span></p>
      </div>
      <div class="bottomTel" v-if="model.Mobile">
        <span v-on:click.stop="goTel(model.Mobile)">立即联系</span>
      </div>
    </div>
    <div class="listPanel">
      <div class="productWay">
        <div class="titleInfo">手机号:</div>
        <div class="resultInfo" v-html="model.Mobile?model.Mobile:'-'"></div>
      </div>
      <div class="productWay">
        <div class="titleInfo">扫码数量:</div>
        <div class="resultInfo" v-html="model.ScanCodeCount?model.ScanCodeCount:0"></div>
      </div>
      <div class="productWay">
        <div class="titleInfo">最后扫码时间:</div>
        <div class="resultInfo" v-html="model.LastScanCodeDateTime?model.LastScanCodeDateTime:'-'"></div>
      </div>
      <div class="productWay" v-if="model.CustomerStatus==1">
        <div class="titleInfo">保护关系剩余:</div>
        <div class="resultInfo" v-html="model.ProtectDateTimeVal"></div>
      </div>
      <div class="productWay" v-if="model.CustomerStatus==1">
        <div class="titleInfo">客户有效期:</div>
        <div class="resultInfo" v-html="model.ExpiryDateTimeVal"></div>
      </div>
      <div class="productWay" v-if="model.CustomerStatus==2">
        <div class="titleInfo">失效时间:</div>
        <div class="resultInfo" v-html="model.UnBindDateTime?model.UnBindDateTime:'-'"></div>
      </div>
      <div class="productWay" v-if="model.CustomerStatus==2">
        <div class="titleInfo">失效原因:</div>
        <div class="resultInfo" v-html="model.UnBindRemark?model.UnBindRemark:'客户有效期过期'"></div>
      </div>
    </div>
    <div class="listPanel" v-if="model.CustomerStatus!=2&&setResponse.BuyRecord==1">
      <div class="listPanelHeader">购买记录</div>
      <div class="headerTime clearfix">
        <span v-bind:class="searchRequest.dateType==0?'selected':''" v-on:click="changeTime(0)">全部</span>
        <span v-bind:class="searchRequest.dateType==1?'selected':''" v-on:click="changeTime(1)">今日</span>
        <span v-bind:class="searchRequest.dateType==2?'selected':''" v-on:click="changeTime(2)">昨日</span>
        <span v-bind:class="searchRequest.dateType==3?'selected':''" v-on:click="changeTime(3)">近7日</span>
        <span class="headerTimeRight" v-on:click="setDateTimeShow" v-if="!isShow.isDateSearch">自定义</span>
        <span class="headerTimeRight headerTimeSearch" v-on:click="setDateTimeShow" v-if="isShow.isDateSearch">
          <i v-html='dateTimeObj.dateTimeVal1'></i>
          <i v-html='dateTimeObj.dateTimeVal2'></i>
        </span>
      </div>
      <div class="buyList">
        <div class="buyListItem clearfix">
          <div class="productTime">时间</div>
          <div class="productName">产品名称</div>
          <div>获得奖励</div>
        </div>
        <div class="buyListItem productItem clearfix" v-for="(item,itemindex) in codeResult.Rows" v-bind:key="itemindex">
          <div class="productTime" v-html="item.ScanCodeDateTime?item.ScanCodeDateTime:'-'"></div>
          <div class="productName" v-html="item.ProductName?item.ProductName:'-'"></div>
          <div class="" v-html="item.RewardRecord?item.RewardRecord:'-'"></div>
        </div>
      </div>
    </div>
    <mt-popup v-model="isShow.isDateTimeShow" popup-transition="popup-fade" closeOnClickModal="true" position="bottom">
      <mt-picker :slots="dateTimeObj.slots1" ref="picker1" value-key="dateTimeStart" :show-toolbar="true" style="width:100%;" v-show="isShow.datetimed1" v-on:change="onDateChange1">
          <div class="picker-toolbar-title">
            <div class="btnHeader">
              <el-button type="text" name="button" class="button" v-on:click="setDateCancel">取消</el-button>
              <el-button type="text" name="button" class="button" v-on:click="setDateOk">确定</el-button>
            </div>
            <div class="setDateHearder">
              <div>
                <p>开始时间</p>
                <p class="selected" v-html='dateTimeObj.dateTimeVal1?dateTimeObj.dateTimeVal1:"请选择"'></p>
              </div>
              <div v-on:click="selectedDateTab(2)">
                <p>结束时间</p>
                <p v-html='dateTimeObj.dateTimeVal2?dateTimeObj.dateTimeVal2:"请选择"'></p>
              </div>
            </div>
          </div>
      </mt-picker>
      <mt-picker :slots="dateTimeObj.slots2" ref="picker2" value-key="dateTimeEnd" :show-toolbar="true" style="width:100%;" v-show="isShow.datetimed2" v-on:change="onDateChange2">
          <div class="picker-toolbar-title">
            <div class="btnHeader">
              <el-button type="text" name="button" class="button" v-on:click="setDateCancel">取消</el-button>
              <el-button type="text" name="button" class="button" v-on:click="setDateOk">确定</el-button>
            </div>
            <div class="setDateHearder">
              <div v-on:click="selectedDateTab(1)">
                <p>开始时间</p>
                <p v-html='dateTimeObj.dateTimeVal1?dateTimeObj.dateTimeVal1:"请选择"'></p>
              </div>
              <div>
                <p>结束时间</p>
                <p class="selected" v-html='dateTimeObj.dateTimeVal2?dateTimeObj.dateTimeVal2:"请选择"'></p>
              </div>
            </div>
          </div>
      </mt-picker>
    </mt-popup>
      <ReturnHome ref="returnhome"></ReturnHome>
  </div>
</template>
<script>
import Vue from 'vue';
import { Toast,DatetimePicker,Indicator,Picker,MessageBox } from 'mint-ui';
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
import channelHelper from "@/assets/js/channelHelper.js";
import { base64 } from "@/assets/js/cryptoHelper";
import { debug } from 'util';
import ReturnHome from "@/components/channel/temp001/ReturnHome";
import '@/assets/js/libs/js.cookie';
import utils from "@/assets/js/utils.js";
Vue.use(ElementUI);
export default {
  props: ["comp", "cfg", "selectedPage"],
  components: {
    ElementUI,ReturnHome
  },
  provide(){       
     return{           
        goPage:this.goPage       
     }   
  },
  data() {
    return {
      isShow:{
        vh:true,
        isDateTimeShow:false,
        datetimed1:false,
        datetimed2:false,
        isDateSearch:false,
        isDetails:false,
        isSetting:false,
      },
      searchRequest:{
        dateType:0,
        BeginTime:'',
        EndTime:'',
        Offset:0,
        Limit:100,
        EntranceId:this.sup8.context.entranceid,
        EnterpriseNo:this.sup8.context.enterpriseno,
        UserToken:channelHelper.GetUserToken(),
        LanguageType:"zh-cn",
        ID:'',
      },
      dateTimeObj:{
        slots1:[
          {
            flex: 1,
            values: [],
            className: 'slot1',
            textAlign: 'center',
            defaultIndex:1
          }, {
            flex: 1,
            values: [],
            className: 'slot2',
            textAlign: 'center',
            defaultIndex:1
          }, {
            flex: 1,
            values: [],
            className: 'slot3',
            textAlign: 'center',
            defaultIndex:1
          }
        ],
        slots2:[
          {
            flex: 1,
            values: [],
            className: 'slot1',
            textAlign: 'center',
            defaultIndex:1
          }, {
            flex: 1,
            values: [],
            className: 'slot2',
            textAlign: 'center',
            defaultIndex:1
          }, {
            flex: 1,
            values: [],
            className: 'slot3',
            textAlign: 'center',
            defaultIndex:1
          }
        ],
        dateTimeVal1:'',
        dateTimeVal2:'',
        dateTimeValOld1:[],
        dateTimeValOld2:[],
        isDateTime1:false,
        isDateTime2:false,
      },
      model:{
        ID:'',
      },
      setResponse:{},
      codeResult:{
        Rows: [],
        Total: 0
      }
    };
  },
  watch: {
      'isShow.isDetails': function (newV,oldV) {
        if (this.isShow.isDetails&&this.isShow.isSetting) {
          if(this.model.CustomerStatus!=2&&this.setResponse.BuyRecord==1){
            this.GetScanCodeList();
          }
        } 
      },
      'isShow.isSetting': function (newV,oldV) {
        if (this.isShow.isDetails&&this.isShow.isSetting) {
          if(this.model.CustomerStatus!=2&&this.setResponse.BuyRecord==1){
            this.GetScanCodeList();
          }
        } 
      }
  },
  methods: { 
    goPage(pagetype){
        this.$parent.changeSelectedPage(pagetype);
    },
    goTel(Mobile){
      if(Mobile){
        window.location.href = 'tel://'+Mobile;
      }
    },
    //配置获取
    GetCustomerSetting(){
      var that=this;
      var url = "/channel/GetCustomerSetting";
      var dataParams = that.searchRequest;
      Indicator.open();
      var cbSuccess = function(res){
        if (res.flag) {
          var data=res.data;
          that.$set(that,'setResponse',data);
          that.$set(that.isShow,'isSetting',true);
        }else
        { 
            Toast(res.msg);
        }
        Indicator.close();
      };
      var cbError = function(jqXHR, textStatus, errorThrown){
        Toast(jqXHR.responseText);
      };
      //请求后端
      channelHelper.CommonCallService(url,dataParams,cbSuccess,cbError,null,null);
    },
    //详情获取
    GetCustomerDataDetail(){
      var that=this;
      var url = "/channel/GetCustomerDataDetail";
      var dataParams = {
        ID:that.searchRequest.ID,
        EnterpriseNo:that.searchRequest.EnterpriseNo,
        UserToken:that.searchRequest.UserToken,
        LanguageType:that.searchRequest.LanguageType,
      };
      Indicator.open();
      var cbSuccess = function(res){
        if (res.flag) {
          var data=res.data;
          if(data.BindDateTime){
            data.BindDateTime=utils.formatDate("yyyy.MM.dd hh:mm",data.BindDateTime);
          }
          if(data.ProtectDateTime==-1){
            data['ProtectDateTimeVal']='长期';
          }else if(data.ProtectDateTime==0){
            data['ProtectDateTimeVal']='无';
          }else{
            data['ProtectDateTimeVal']=data.ProtectDateTime+'天';
          }
          if(data.ExpiryDateTime==-1){
            data['ExpiryDateTimeVal']='长期';
          }else{
            data['ExpiryDateTimeVal']=data.ExpiryDateTime+'天';
          }
          if(data.LastScanCodeDateTime){
            data.LastScanCodeDateTime=utils.formatDate("yyyy.MM.dd hh:mm",data.LastScanCodeDateTime);
          }
          if(data.UnBindDateTime){
            data.UnBindDateTime=utils.formatDate("yyyy.MM.dd hh:mm",data.UnBindDateTime);
          }
          if(data.UnBindRemark&&data.UnBindRemark==1){
            data.UnBindRemark="客户有效期过期";
          }else if(data.UnBindRemark&&data.UnBindRemark==2){
            data.UnBindRemark="客户与其他销售建立联系";
          }
          that.$set(that,'model',data);
          that.$set(that.isShow,'isDetails',true);
        }else
        { 
            Toast(res.msg);
        }
        Indicator.close();
      };
      var cbError = function(jqXHR, textStatus, errorThrown){
        Toast(jqXHR.responseText);
      };
      //请求后端
      channelHelper.CommonCallService(url,dataParams,cbSuccess,cbError,null,null);
    },
    //购买记录获取
    GetScanCodeList(){
      var that=this;
      var url = "/channel/GetScanCodeList";
      var dataParams = that.searchRequest;
      var dataParams = that.searchRequest;
      if(dataParams.BeginTime&&dataParams.BeginTime.length==10){
        dataParams.BeginTime=dataParams.BeginTime+' 00:00:00';
      }
      if(dataParams.EndTime&&dataParams.EndTime.length==10){
        dataParams.EndTime=dataParams.EndTime+' 23:59:59';
      }
      Indicator.open();
      var cbSuccess = function(res){
        if (res.flag) {
          var data=res.data;
          if(data&&data.Total){
            for(var i=0;i<data.Rows.length;i++){
              if(data.Rows[i].ScanCodeDateTime){
                data.Rows[i].ScanCodeDateTime=utils.formatDate("yyyy.MM.dd",data.Rows[i].ScanCodeDateTime);
              }
            }
            that.$set(that,'codeResult',data);
          }else{
            that.$set(that,'codeResult',{Rows:[],Total:0});
          }
        }else
        { 
          that.$set(that,'codeResult',{Rows:[],Total:0});
          Toast(res.msg);
        }
        Indicator.close();
      };
      var cbError = function(jqXHR, textStatus, errorThrown){
        Toast(jqXHR.responseText);
      };
      //请求后端
      channelHelper.CommonCallService(url,dataParams,cbSuccess,cbError,null,null);
    },
    //显示时间
    setDateTimeShow:function(){
      this.$set(this.isShow,'isDateTimeShow',true);
      this.$set(this.isShow,'datetimed1',true);
      this.$set(this.isShow,'datetimed2',false);
      this.$set(this.dateTimeObj,'dateTimeValOld1',[this.dateTimeObj.slots1[0].defaultIndex,this.dateTimeObj.slots1[1].defaultIndex,this.dateTimeObj.slots1[2].defaultIndex]);
      this.$set(this.dateTimeObj,'dateTimeValOld2',[this.dateTimeObj.slots2[0].defaultIndex,this.dateTimeObj.slots2[1].defaultIndex,this.dateTimeObj.slots2[2].defaultIndex]);
    },
    //时间切换 开始/结束 
    selectedDateTab:function(type){
      if(type==1){
        this.$set(this.isShow,'datetimed1',true);
        this.$set(this.isShow,'datetimed2',false);
      }else{
        this.$set(this.isShow,'datetimed1',false);
        this.$set(this.isShow,'datetimed2',true);
      }
    },
    //时间设置取消
    setDateCancel:function(){
      this.$set(this.isShow,'isDateTimeShow',false);
      this.$set(this.isShow,'datetimed1',false);
      this.$set(this.isShow,'datetimed2',false);
      this.$set(this.dateTimeObj.slots1[0],'defaultIndex',this.dateTimeObj.dateTimeValOld1[0]);
      this.$set(this.dateTimeObj.slots1[1],'defaultIndex',this.dateTimeObj.dateTimeValOld1[1]);
      this.$set(this.dateTimeObj.slots1[2],'defaultIndex',this.dateTimeObj.dateTimeValOld1[2]);
      this.$set(this.dateTimeObj.slots2[0],'defaultIndex',this.dateTimeObj.dateTimeValOld2[0]);
      this.$set(this.dateTimeObj.slots2[1],'defaultIndex',this.dateTimeObj.dateTimeValOld2[1]);
      this.$set(this.dateTimeObj.slots2[2],'defaultIndex',this.dateTimeObj.dateTimeValOld2[2]);
    },
    //时间设置确定
    setDateOk:function(){
      var that=this;
      var startdate=this.dateTimeObj.dateTimeVal1.replace(/\./g,"-");
      var enddate=this.dateTimeObj.dateTimeVal2.replace(/\./g,"-");
      if(Date.parse(startdate)<=Date.parse(enddate))
      { 
        that.$set(that.searchRequest,'dateType',4);
        that.$set(that.searchRequest,'BeginTime',startdate);
        that.$set(that.searchRequest,'EndTime',enddate);
        that.$set(that.isShow,'isDateSearch',true);
        this.$set(this.isShow,'isDateTimeShow',false);
        this.$set(this.isShow,'datetimed1',false);
        this.$set(this.isShow,'datetimed2',false);
        that.GetScanCodeList();
      }
      else
      {
        Toast("开始时间不能大于结束时间！");return false;
      }
    },
    //时间切换
    changeTime(type){
      var that=this;
      that.$set(that.isShow,'isDateSearch',false);
      var dataNow=new Date();
      var yearNow=dataNow.getFullYear();
      var nowMonth=dataNow.getMonth()+1;
      var nowDay=dataNow.getDate();
      var nowDateLast=new Date(yearNow, nowMonth, 0).getDate();
      if(type==0){
        that.$set(that.searchRequest,'BeginTime','');
        that.$set(that.searchRequest,'EndTime','');
      }else if(type==1){
        that.$set(that.searchRequest,'BeginTime',utils.formatDate("yyyy-MM-dd",dataNow)+' 00:00:00');
        that.$set(that.searchRequest,'EndTime',utils.formatDate("yyyy-MM-dd",dataNow)+' 23:59:59');
      }else if(type==2){
        dataNow.setTime(dataNow.getTime()-24*60*60*1000);
        var mm=(dataNow.getMonth()+1);
        var dateTime= dataNow.getFullYear()+"-" + (mm<10?('0'+mm):mm) + "-" + dataNow.getDate();
        that.$set(that.searchRequest,'BeginTime',dateTime+' 00:00:00');
        that.$set(that.searchRequest,'EndTime',dateTime+' 23:59:59');
      }else if(type==3){
        that.$set(that.searchRequest,'BeginTime',that.getDay(-6)+' 00:00:00');
        that.$set(that.searchRequest,'EndTime',that.getDay(0)+' 23:59:59');
      }
      that.$set(that.searchRequest,'dateType',type);
      that.GetScanCodeList();
    },
    onDateChange1:function(picker, values,column) {
      if(this.dateTimeObj.isDateTime1){
        values[0]=this.dateTimeObj.slots1[0].values[this.dateTimeObj.slots1[0].defaultIndex];
        values[1]=this.dateTimeObj.slots1[1].values[this.dateTimeObj.slots1[1].defaultIndex];
        values[2]=this.dateTimeObj.slots1[2].values[this.dateTimeObj.slots1[2].defaultIndex];
        this.$set(this.dateTimeObj,'isDateTime1',false);
      }else{
        this.$set(this.dateTimeObj.slots1[2],'defaultIndex',(parseInt(values[2])-1));
        this.$set(this.dateTimeObj.slots1[1],'defaultIndex',(parseInt(values[1])-1));
        for(var i=0;i<this.dateTimeObj.slots1[0].values.length;i++){
          if(this.dateTimeObj.slots1[0].values[i].toString()==values[0].toString()){
            this.$set(this.dateTimeObj.slots1[0],'defaultIndex',i);
          }
        }
      }
      var nowDateLast=new Date(values[0], values[1], 0).getDate();
      var arr=this.dateTimeObj.slots1[2].values;
      var vLen=arr.length;
      var index=Math.abs(nowDateLast-vLen);
      if(index!=0){
        if(vLen<nowDateLast){
          for(var i=1;i<=index;i++){
            arr.push(vLen+i);
          }
        }else if(vLen>nowDateLast){
          arr.splice(nowDateLast,index);
          if(parseInt(values[2])>nowDateLast){
            this.$set(this.dateTimeObj.slots1[2],'defaultIndex',(nowDateLast-1));
            this.$set(this.dateTimeObj.slots1[1],'defaultIndex',(parseInt(values[1])-1));
            for(var i=0;i<this.dateTimeObj.slots1[0].values.length;i++){
              if(this.dateTimeObj.slots1[0].values[i].toString()==values[0].toString()){
                this.$set(this.dateTimeObj.slots1[0],'defaultIndex',i);
              }
            }
            values[2]=nowDateLast;
            this.$set(this.dateTimeObj,'isDateTime1',true);
          }
        }
        this.$set(this.dateTimeObj.slots1[2],'values',arr);
      }
      this.$set(this.dateTimeObj,'dateTimeVal1',values[0]+'.'+values[1]+'.'+values[2]);
    },
    onDateChange2:function(picker, values,column) {
      if(this.dateTimeObj.isDateTime2){
        values[0]=this.dateTimeObj.slots2[0].values[this.dateTimeObj.slots2[0].defaultIndex];
        values[1]=this.dateTimeObj.slots2[1].values[this.dateTimeObj.slots2[1].defaultIndex];
        values[2]=this.dateTimeObj.slots2[2].values[this.dateTimeObj.slots2[2].defaultIndex];
        this.$set(this.dateTimeObj,'isDateTime2',false);
      }else{
        this.$set(this.dateTimeObj.slots2[2],'defaultIndex',(parseInt(values[2])-1));
        this.$set(this.dateTimeObj.slots2[1],'defaultIndex',(parseInt(values[1])-1));
        for(var i=0;i<this.dateTimeObj.slots2[0].values.length;i++){
          if(this.dateTimeObj.slots2[0].values[i].toString()==values[0].toString()){
            this.$set(this.dateTimeObj.slots2[0],'defaultIndex',i);
          }
        }
      }
      var nowDateLast=new Date(values[0], values[1], 0).getDate();
      var arr=this.dateTimeObj.slots2[2].values;
      var vLen=arr.length;
      var index=Math.abs(nowDateLast-vLen);
      if(index!=0){
        if(vLen<nowDateLast){
          for(var i=1;i<=index;i++){
            arr.push(vLen+i);
          }
        }else if(vLen>nowDateLast){
          arr.splice(nowDateLast,index);
          if(parseInt(values[2])>nowDateLast){
            this.$set(this.dateTimeObj.slots2[2],'defaultIndex',(nowDateLast-1));
            this.$set(this.dateTimeObj.slots2[1],'defaultIndex',(parseInt(values[1])-1));
            for(var i=0;i<this.dateTimeObj.slots2[0].values.length;i++){
              if(this.dateTimeObj.slots2[0].values[i].toString()==values[0].toString()){
                this.$set(this.dateTimeObj.slots2[0],'defaultIndex',i);
              }
            }
            values[2]=nowDateLast;
            this.$set(this.dateTimeObj,'isDateTime2',true);
          }
        }
        this.$set(this.dateTimeObj.slots2[2],'values',arr);
      }
      this.$set(this.dateTimeObj,'dateTimeVal2',values[0]+'.'+values[1]+'.'+values[2]);
    },
    getYearMM:function(){
      var dataNow=new Date();
      var yearNow=dataNow.getFullYear();
      var nowMonth=dataNow.getMonth()+1;
      var nowDay=dataNow.getDate();
      var yearArr=[yearNow];
      for(var i=1;i<=20;i++){
        yearArr.unshift((yearNow-i).toString());
      }
      this.$set(this.dateTimeObj.slots1[0],'values',yearArr);
      this.$set(this.dateTimeObj.slots2[0],'values',yearArr);
      this.$set(this.dateTimeObj.slots1[0],'defaultIndex',20);
      this.$set(this.dateTimeObj.slots2[0],'defaultIndex',20);
      var MM=[];
      for(var j=1;j<=12;j++){
        if(j<10){
          MM.push('0'+j);
        }else{
          MM.push(j.toString());
        }
      }
      this.$set(this.dateTimeObj.slots1[1],'values',MM);
      this.$set(this.dateTimeObj.slots2[1],'values',MM);
      this.$set(this.dateTimeObj.slots1[1],'defaultIndex',nowMonth-1);
      this.$set(this.dateTimeObj.slots2[1],'defaultIndex',nowMonth-1);
      var nowDateLast=new Date(yearNow, nowMonth, 0).getDate();
      var DD=[];
      for(var e=1;e<=nowDateLast;e++){
        if(e<10){
          DD.push('0'+e);
        }else{
          DD.push(e.toString());
        }
      }
      this.$set(this.dateTimeObj.slots1[2],'values',DD);
      this.$set(this.dateTimeObj.slots2[2],'values',DD);
      this.$set(this.dateTimeObj.slots1[2],'defaultIndex',nowDay-1);
      this.$set(this.dateTimeObj.slots2[2],'defaultIndex',nowDay-1);
      this.$set(this.dateTimeObj,'dateTimeVal1',yearArr[20]+'.'+MM[nowMonth-1]+'.'+DD[nowDay-1]);
      this.$set(this.dateTimeObj,'dateTimeVal2',yearArr[20]+'.'+MM[nowMonth-1]+'.'+DD[nowDay-1]);
    },
    getDay:function (day){
      var that=this;
      var today = new Date();
      var targetday_milliseconds=today.getTime() + 1000*60*60*24*day;
      today.setTime(targetday_milliseconds); //注意，这行是关键代码
      var tYear = today.getFullYear();
      var tMonth = today.getMonth();
      var tDate = today.getDate();
      tMonth = that.doHandleMonth(tMonth + 1);
      tDate = that.doHandleMonth(tDate);
      return tYear+"-"+tMonth+"-"+tDate;
    },
    doHandleMonth:function (month){
      var that=this;
      var m = month;
      if(month.toString().length == 1){
      m = "0" + month;
      }
      return m;
    },
    judgeLogin:function(){
      var eno = this.sup8.context.enterpriseno;
      if (!channelHelper.CheckLogin(this.$parent,eno,this.sup8.context.entranceid)) {
        this.$parent.changeSelectedPage('Key_Login');
        return false;
      }
    },
  },
  created: function() {
    var that=this;
    var isDesign = location.pathname.indexOf('design');
    if(isDesign!=-1)
    {
        return;
    }
    //判断是否登录
    that.judgeLogin();
    var ID=sessionStorage.getItem('Key_CustomerList_DetailID');
    that.GetCustomerSetting();
    that.getYearMM();
    if(ID){
      that.searchRequest.ID=ID;
      that.GetCustomerDataDetail();
    }
  },
  mounted: function() {
    var that =this;
    var isDesign = location.pathname.indexOf('design');
    if (!(isDesign>-1)) {
        that.$set(that.isShow,'vh',true);
    }else{
        that.$set(that.isShow,'vh',false);
    }
  }
};
</script>

