<template>
  <div>
    <!--个人身份空间组件2开始-->
    <div class="identity_person_pc_2"><!--使用此组件，请复制此div-->
      <!--弹出-->
      <upload v-show="bool==true" ref="upload" :isUpload="oolean" :type="type" :wksId="wksId"></upload>
      <div class="container">
        <div class="row">
          <div class="col-lg-3 col-md-4 col-sm-5 col-xs-12">
            <div class="lndx-center-left">
                            <span class="sp1">
                                <a href="javascript:;" @click="sitemenunav=3;sitemenu=8">
                                    <img v-if="userinfo.photo" :src="userinfo.photo" alt="">
                                    <img v-if="!userinfo.photo" src="../../theme-chalk/src/images/headphoto.png" alt="">
                                </a>
                            </span>
              <span class="sp2">{{userinfo.custName}}</span>
              <span class="sp3">手机号：{{userinfo.phone?hidephone(userinfo.phone):'暂无手机'}}</span>
              <div class="lndx-left-menu">
                <span @click="sitemenunav==0?sitemenunav='20':sitemenunav='0'" :class="sitemenunav==0?'first-nav on':'first-nav'"><i class="el-icon-notebook-2"></i><span>我的学习</span></span>
                <ul class="ul1" v-if="sitemenunav==0">
                  <li :class="sitemenu==0 || sitemenu==11?'active':''" @click="sitemenu=11"><a href="javascript:;">资源学习</a></li>
                  <li :class="sitemenu==1?'active':''" @click="sitemenu=1"><a href="javascript:;">课程学习</a></li>
                  <li :class="sitemenu==2?'active':''" @click="sitemenu=2"><a href="javascript:;">我的班级</a></li>
                  <!--<li :class="sitemenu==3?'active':''" @click="sitemenu=3"><a href="javascript:;">我的证书</a></li>-->
                  <li :class="sitemenu==4?'active':''" @click="sitemenu=4"><a href="javascript:;">我的收藏</a></li>
                </ul>
                <span @click="sitemenunav==1?sitemenunav='20':sitemenunav='1'" :class="sitemenunav==1?'first-nav on':'first-nav'"><i class="el-icon-magic-stick"></i><span>我的展示</span></span>
                <ul class="ul1" v-if="sitemenunav==1">
                  <li :class="sitemenu==5?'active':''" @click="sitemenu=5"><a href="javascript:;">我的活动</a></li>
                  <li :class="sitemenu==6?'active':''" @click="sitemenu=6"><a href="javascript:;">我的作品</a></li>
                  <li :class="sitemenu==10?'active':''" @click="sitemenu=10"><a href="javascript:;">我的直播</a></li>
                </ul>
                <span @click="sitemenunav==2?sitemenunav='20':sitemenunav='2'" :class="sitemenunav==2?'first-nav on':'first-nav'"><i class="el-icon-pie-chart"></i><span>我的数据</span></span>
                <ul class="ul1" v-if="sitemenunav==2">
                  <li :class="sitemenu==7?'active':''" @click="sitemenu=7"><a href="javascript:;">我的订单</a></li>
                </ul>
                <span @click="sitemenunav==3?sitemenunav='20':sitemenunav='3'" :class="sitemenunav==3?'first-nav on':'first-nav'"><i class="el-icon-wallet"></i><span>我的资料</span></span>
                <ul class="ul1" v-if="sitemenunav==3">
                  <li :class="sitemenu==8?'active':''"  @click="sitemenu=8"><a href="javascript:;">修改资料</a></li>
                  <!--<li :class="sitemenu==9?'active':''"  @click="sitemenu=9"><a href="javascript:;">修改密码</a></li>-->
                </ul>
              </div>
            </div>
          </div>
          <div class="col-lg-9 col-md-8 col-sm-7 col-xs-12">
            <div class="lndx-center-right">
              <div v-if="sitemenu==0" class="right-tongji clearfix">
                <span><i>{{schcount.signedCsNum?schcount.signedCsNum:'0'}}</i>门<br>已学课程</span>
                <span><i>{{schcount.activityNum?schcount.activityNum:'0'}}</i>个<br>已参加活动</span>
                <span><i>{{schcount.classNum?schcount.classNum:'0'}}</i>个<br>已报班级</span>
                <span><i>{{schcount.finishedStudyLength?schcount.finishedStudyLength:'0'}}</i>学时<br>已获学时</span>
              </div>
              <div v-if="sitemenu==0 || sitemenu==11" class="right-title"><span></span>资源学习</div>
              <div v-if="sitemenu==0 || sitemenu==11" class="zyxx-table">
                <table>
                  <tr>
                    <th>资源名称</th>
                    <th>学习时长</th>
                    <th>上次学习时间</th>
                    <th>是否完成</th>
                    <th>操作</th>
                  </tr>
                  <tr v-for="(item, index) in resourcelist" :key="index">
                    <td class="td1">{{item.resName}}</td>
                    <td>{{getNowTime(item.studyTime?item.studyTime:'0')}}</td>
                    <td>{{item.updateDate}}</td>
                    <td class="redtxt" v-if="item.studyFinished=='0'">未完成</td>
                    <td class="bluetxt" v-if="item.studyFinished=='1'">已完成</td>
                    <td class="td2">
                      <a v-if="item.studyFinished=='0'" href="JavaScript:;" @click="lookresource(item.resId)">继续学习</a>
                      <a v-if="item.studyFinished=='1'" href="javascript:;" @click="lookresource(item.resId)">复习</a>
                    </td>
                  </tr>
                </table>
                <div class="search-result-page">
                  <div class="tp-page">
                    <el-pagination
                            background
                            layout="total, sizes, prev, pager, next, jumper"
                            :page-sizes="[10, 15, 20, 25]"
                            @current-change="resourceChange"
                            @prev-click="resourceprevClick"
                            @next-click="resourcenextClick"
                            @size-change="resourcesizeChange"
                            :total="resourcenum">
                    </el-pagination>
                  </div>
                </div>
              </div>
              <div v-if="sitemenu==1" class="right-title"><span></span>最近学习课程</div>
              <div v-if="sitemenu==1" class="zyxx-table">
                <table>
                  <tr>
                    <th>课程名称</th>
                    <th>学习时长</th>
                    <th>进度</th>
                    <th>上次学习时间</th>
                    <th>是否完成</th>
                    <th>操作</th>
                  </tr>
                  <tr v-for="(item,index) in courselist" :key="index">
                    <td class="td1">{{item.csName}}</td>
                    <td>{{getNowTime(item.lcsStudyTime?item.lcsStudyTime:'0')}}</td>
                    <td>{{parseInt(item.lcsProcess)}}%</td>
                    <td>{{item.updateDate}}</td>
                    <td v-if="item.lcsStudyFinished!=='1'">未完成</td>
                    <td v-if="item.lcsStudyFinished=='1'">已完成</td>
                    <td class="td2">
                      <a href="javascript:;" v-if="item.lcsStudyFinished!=='1'" @click="lookcourse(item.csId)">继续学习</a>
                      <a href="javascript:;" v-if="item.lcsStudyFinished=='1'" @click="lookcourse(item.csId)">复习</a>
                    </td>
                  </tr>
                </table>
                <div class="search-result-page">
                  <div class="tp-page">
                    <el-pagination
                            background
                            layout="total, sizes, prev, pager, next, jumper"
                            :page-sizes="[10, 15, 20, 25]"
                            @current-change="courseChange"
                            @prev-click="courseprevClick"
                            @next-click="coursenextClick"
                            @size-change="coursesizeChange"
                            :total="coursenum">
                    </el-pagination>
                  </div>
                </div>
              </div>
              <div v-if="sitemenu==2" class="right-title"><span></span>我的班级</div>
              <div v-if="sitemenu==2" class="zyxx-table">
                <table>
                  <tr>
                    <th>班级名称</th>
                    <th>培训时间</th>
                    <th>开始时间</th>
                    <th>结束时间</th>
                    <th>操作</th>
                  </tr>
                  <tr v-for="(item,index) in classlist" :key="index">
                    <td class="td1">{{item.czName}}</td>
                    <td>{{item.singupDate}}</td>
                    <td>{{item.czStartDate}}</td>
                    <td>{{item.czEndDate}}</td>
                    <td class="td2">
                      <a href="javascript:;" @click="lookclass(item.czId)">查看班级</a>
                    </td>
                  </tr>
                </table>
                <div class="search-result-page">
                  <div class="tp-page">
                    <el-pagination
                            background
                            layout="total, sizes, prev, pager, next, jumper"
                            :page-sizes="[10, 15, 20, 25]"
                            @current-change="classChange"
                            @prev-click="classprevClick"
                            @next-click="classnextClick"
                            @size-change="classsizeChange"
                            :total="classnum">
                    </el-pagination>
                  </div>
                </div>
              </div>
              <div v-if="sitemenu==3" class="right-title"><span></span>已获得证书</div>
              <div v-if="sitemenu==3">
                <table class="percenter-right-dongtai-table">
                  <tr v-for="(item, index) in certlist" :key="index">
                    <td class="td3">({{item.ucCertNo}}){{item.ucCertName}}</td>
                    <td class="td1">{{item.ucGenTime}}</td>
                    <td class="td1"><a target="_blank"
                                       :href="'/cert-service/cert/CtUserCert/downloadUserCert?ucId=' + item.ucId">下载</a>
                    </td>
                  </tr>
                  <!--<tr>-->
                  <!--<td class="td3">【金属非金属矿山培训】安全生产法规与安全生产管理证书</td>-->
                  <!--<td class="td1">2020-07-01 14:30:20</td>-->
                  <!--<td class="td1"><a href="">下载</a></td>-->
                  <!--</tr>-->
                </table>
                <div class="search-result-page">
                  <div class="tp-page">
                    <el-pagination
                            background
                            layout="total, sizes, prev, pager, next, jumper"
                            :page-sizes="[10, 15, 20, 25]"
                            @current-change="certChange"
                            @prev-click="certprevClick"
                            @next-click="certnextClick"
                            @size-change="certsizeChange"
                            :total="certnum">
                    </el-pagination>
                  </div>
                </div>
              </div>
              <div v-if="sitemenu==4" class="right-title"><span></span>我的收藏</div>
              <div v-if="sitemenu==4" class="zyxx-table">
                <table>
                  <tr>
                    <th>名称</th>
                    <th>类型</th>
                    <th>收藏时间</th>
                    <th>操作</th>
                  </tr>
                  <tr v-for="(item,index) in collectlist" :key="index">
                    <td class="td1">{{item.tag}}</td>
                    <td>
                      <text v-if="item.type=='course'">课程</text>
                      <text v-if="item.type=='resource'">资源</text>
                      <text v-if="item.type=='experience'">经验</text>
                      <text v-if="item.type=='group'">小组</text>
                      <text v-if="item.type=='class'">班级</text>
                      <text v-if="item.type=='cert'">证书</text>
                      <text v-if="item.type=='news'">资讯</text>
                    </td>
                    <td>{{item.createDate}}</td>
                    <td class="td2">
                      <!--<a href="javascript:;" @click="lookcollect(item.objId)">查看详情</a>-->
                      <a href="javascript:;" @click="delcollect(item.cltId,item.objId,item.type)">删除</a>
                    </td>
                  </tr>
                </table>
                <div class="search-result-page">
                  <div class="tp-page">
                    <el-pagination
                            background
                            layout="total, sizes, prev, pager, next, jumper"
                            :page-sizes="[10, 15, 20, 25]"
                            @current-change="collectChange"
                            @prev-click="collectprevClick"
                            @next-click="collectnextClick"
                            @size-change="collectsizeChange"
                            :total="collectnum">
                    </el-pagination>
                  </div>
                </div>
              </div>
              <div v-if="sitemenu==5" class="right-title"><span></span>参加的活动</div>
              <div v-if="sitemenu==5" class="zyxx-table">
                <table>
                  <tr>
                    <th>活动名称</th>
                    <th>开始时间</th>
                    <th>结束时间</th>
                    <th>参加人数</th>
                    <th>操作</th>
                  </tr>
                  <tr v-for="(item,index) in actlist" :key="index">
                    <td class="td1">{{item.actTitle}}</td>
                    <td>{{item.actStartDate}}</td>
                    <td>{{item.actEndDate}}</td>
                    <td>{{item.actSignupNum}}</td>
                    <td class="td2">
                      <a href="javascript:;" @click="lookact(item.actId)">查看活动</a>
                    </td>
                  </tr>
                </table>
                <div class="search-result-page">
                  <div class="tp-page">
                    <el-pagination
                            background
                            layout="total, sizes, prev, pager, next, jumper"
                            :page-sizes="[10, 15, 20, 25]"
                            @current-change="actChange"
                            @prev-click="actprevClick"
                            @next-click="actnextClick"
                            @size-change="actsizeChange"
                            :total="actnum">
                    </el-pagination>
                  </div>
                </div>
              </div>
              <div v-if="sitemenu==6" class="right-title"><span></span>活动作品</div>
              <div v-if="sitemenu==6" class="zyxx-table">
                <table>
                  <tr>
                    <th>作品名称</th>
                    <th>编号</th>
                    <th>上传时间</th>
                    <th>状态</th>
                    <th>投票数</th>
                    <th>审核意见</th>
                    <th>操作</th>
                  </tr>
                  <tr v-for="(item,index) in worklist" :key="index">
                    <td class="td1">{{item.wksName}}</td>
                    <td>{{item.wksCode}}</td>
                    <td>{{item.updateDate}}</td>
                    <td>
                      {{item.wksStatus=='2'?'审核通过':item.wksStatus=='3'?'审核未通过':item.wksStatus=='0'?'未提交':'待审核'}}
                    </td>
                    <td>{{item.wksVoteNum}}</td>
                    <td>{{item.adContent}}</td>
                    <td class="td2">
                      <a href="javascript:;" v-if="item.wksStatus=='0'" @click="auditwork(item.wksId)">提交作品<br /></a>
                      <a href="javascript:;" @click="lookwork(item.wksId)">查看</a>
                    </td>
                  </tr>
                </table>
                <div class="search-result-page">
                  <div class="tp-page">
                    <el-pagination
                            background
                            layout="total, sizes, prev, pager, next, jumper"
                            :page-sizes="[10, 15, 20, 25]"
                            @current-change="workChange"
                            @prev-click="workprevClick"
                            @next-click="worknextClick"
                            @size-change="worksizeChange"
                            :total="worknum">
                    </el-pagination>
                  </div>
                </div>
              </div>
              <div v-if="sitemenu==7" class="right-title"><span></span>我的订单</div>
              <div v-if="sitemenu==7" class="zyxx-table">
                <table>
                  <tr>
                    <th>订单号</th>
                    <th>订单名称</th>
                    <th>金额（元）</th>
                    <th>下单时间</th>
                    <th>状态</th>
                    <th>操作</th>
                  </tr>
                  <tr v-for="(item,index) in orderlist" :key="index">
                    <td>{{item.sn}}</td>
                    <td>{{item.name}}</td>
                    <td>{{item.realPrice}}</td>
                    <td>{{item.createDate}}</td>
                    <td v-if="item.status==1">待付款</td>
                    <td v-if="item.status==2">已过期</td>
                    <td v-if="item.status==3">已完成</td>
                    <td v-if="item.status==4">已退单</td>
                    <td class="td2">
                      <a v-if="item.status==1" href="javascript:;" @click="payorder(item.orderId,item.orderType)">继续支付<br></a>
                      <a v-if="item.status==1" href="javascript:;" @click="delorder(item.orderId)">取消订单</a>
                    </td>
                  </tr>
                </table>
                <div class="search-result-page">
                  <div class="tp-page">
                    <el-pagination
                            background
                            layout="total, sizes, prev, pager, next, jumper"
                            :page-sizes="[10, 15, 20, 25]"
                            @current-change="orderChange"
                            @prev-click="orderprevClick"
                            @next-click="ordernextClick"
                            @size-change="ordersizeChange"
                            :total="ordernum">
                    </el-pagination>
                  </div>
                </div>
              </div>
              <div v-if="sitemenu==8" class="right-title"><span></span>资料信息</div>
              <div v-if="sitemenu==8" class="zyxx-table">
                <el-form :model="userData" :rules="rules" ref="userData" label-width="100px"
                         class="userData-info">
                  <el-form-item label="姓名" prop="custName">
                    <el-input v-model="userData.custName"></el-input>
                  </el-form-item>
                  <!--<el-form-item label="活动区域" prop="region">-->
                  <!--<el-select v-model="userData.region" placeholder="请选择活动区域">-->
                  <!--<el-option label="区域一" value="shanghai"></el-option>-->
                  <!--<el-option label="区域二" value="beijing"></el-option>-->
                  <!--</el-select>-->
                  <!--</el-form-item>-->
                  <el-form-item label="性别" prop="resource">
                    <el-radio-group v-model="userData.sex">
                      <el-radio label="1">男</el-radio>
                      <el-radio label="2">女</el-radio>
                    </el-radio-group>
                  </el-form-item>
                  <el-form-item label="身份证" prop="idcarNo">
                    <el-input v-model="userData.idcarNo"></el-input>
                  </el-form-item>
                  <el-form-item label="手机号" prop="phone">
                    <el-input v-model.number="userData.phone"></el-input>
                  </el-form-item>
                  <el-form-item label="地址" prop="adress">
                    <el-input v-model="userData.adress"></el-input>
                  </el-form-item>
                  <el-form-item label="单位" prop="office">
                    <el-input v-model="userData.office"></el-input>
                  </el-form-item>
                  <el-form-item label="头像" prop="imageUrl">
                    <el-upload
                            class="avatar-uploader"
                            :action="uploadurl"
                            :show-file-list="false"
                            :on-success="handleAvatarSuccess"
                            :before-upload="beforeAvatarUpload">
                      <img v-if="imageUrl" :src="imageUrl" class="avatar">
                      <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                    </el-upload>
                  </el-form-item>
                  <el-form-item>
                    <el-button type="primary" @click="usersave('userData')">确认并保存
                    </el-button>
                    <!--<el-button @click="resetForm('userData')">重置</el-button>-->
                  </el-form-item>
                </el-form>
              </div>
              <div v-if="sitemenu==10" class="right-title"><span></span>我的直播</div>
              <div v-if="sitemenu==10" class="zyxx-table">
                <table>
                  <tr>
                    <th>直播名称</th>
                    <th>直播时间</th>
                    <th>操作</th>
                  </tr>
                  <tr v-for="(item,index) in livelist" :key="index">
                    <td class="td1">{{item.lylName}}</td>
                    <td>{{item.lylStartDate}}</td>
                    <td class="td2">
                      <a href="javascript:;" @click="looklive(item.lylId)">查看</a>
                    </td>
                  </tr>
                </table>
                <div class="search-result-page">
                  <div class="tp-page">
                    <el-pagination
                            background
                            layout="total, sizes, prev, pager, next, jumper"
                            :page-sizes="[10, 15, 20, 25]"
                            @current-change="liveChange"
                            @prev-click="liveprevClick"
                            @next-click="livenextClick"
                            @size-change="livesizeChange"
                            :total="livenum">
                    </el-pagination>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <!--<script>-->
      <!--jQuery(".lndx-left-menu").slide({titCell:".first-nav", targetCell:"ul",defaultIndex:0,effect:"slideDown",delayTime:300,trigger:"click"});-->
      <!--</script>-->
    </div>
    <!--个人身份空间组件2结束-->
  </div>
</template>

<script>
    import formMixin from '../../../src/mixins/formMixin';
    import lenye_base from 'lenye_base';
    // import echarts from 'echarts';
    import msg from '../../message';
    import upload from '../../active-updata-pc/src/main'
export default {
  name: 'ElIdentityPersonPc2',
  mixins: [formMixin],
  components:{
    upload
  },
    data() {
        let idCardValidity = (rule, code, callback) => {
            var city = {
                11: '北京',
                12: '天津',
                13: '河北',
                14: '山西',
                15: '内蒙古',
                21: '辽宁',
                22: '吉林',
                23: '黑龙江 ',
                31: '上海',
                32: '江苏',
                33: '浙江',
                34: '安徽',
                35: '福建',
                36: '江西',
                37: '山东',
                41: '河南',
                42: '湖北 ',
                43: '湖南',
                44: '广东',
                45: '广西',
                46: '海南',
                50: '重庆',
                51: '四川',
                52: '贵州',
                53: '云南',
                54: '西藏 ',
                61: '陕西',
                62: '甘肃',
                63: '青海',
                64: '宁夏',
                65: '新疆',
                71: '台湾',
                81: '香港',
                82: '澳门',
                91: '国外 '
            };
            var tip = '';
            var pass = true;

            if (!code || !/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(code)) {
                tip = '身份证号格式错误';
                pass = false;
            } else if (!city[code.substr(0, 2)]) {
                tip = '地址编码错误';
                pass = false;
            } else {
                // 18位身份证需要验证最后一位校验位
                if (code.length === 18) {
                    // code = code.split('');
                    // ∑(ai×Wi)(mod 11)
                    // 加权因子
                    // var factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
                    // // 校验位
                    // var parity = [1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2];
                    // var sum = 0;
                    // var ai = 0;
                    // var wi = 0;
                    // for (var i = 0; i < 17; i++) {
                    //     ai = code[i];
                    //     wi = factor[i];
                    //     sum += ai * wi;
                    // }
                    // var last = parity[sum % 11];
                    // if (parity[sum % 11] !== code[17]) {
                    //     tip = '校验位错误';
                    //     pass = false;
                    // }
                }
            }
            if (!pass) {
                callback(new Error(tip));
            } else {
                callback();
            }
            // if (!pass) alert(tip)
            // return pass
        };
        return {
            courselist: [],
            coursenum: 0,
            courserows: 10,
            coursepage: 1,
            classlist: [],
            classnum: 0,
            classrows: 10,
            classpage: 1,
            certlist: [],
            certnum: 0,
            certrows: 10,
            certpage: 1,
            collectlist: [],
            collectnum: 0,
            collectrows: 10,
            collectpage: 1,
            actlist: [],
            actnum: 0,
            actrows: 10,
            actpage: 1,
            worklist: [],
            worknum: 0,
            workrows: 10,
            workpage: 1,
            orderlist: [],
            ordernum: 0,
            orderrows: 10,
            orderpage: 1,
            livelist: [],
            livenum: 0,
            liverows: 10,
            livepage: 1,
            resourcelist: [],
            resourcenum: 0,
            resourcerows: 10,
            resourcepage: 1,
            //    站点数据
            siteData: '',
            //    用户数据
            userData: '',
            userinfo: {
                'photo': '',
                'idcarNo': '',
                'phone': '',
                'custName': ''
            },
            coursecount: [],
            schcount: [],
            sitemenu: 0, //侧边选中
            sitemenunav: 20, //侧边选中
            //信息提交
            custName: '',
            imageUrl: '',
            imageUrlid: '',
            uploadurl: '',
            rules: {
                custName: [
                    {required: true, message: '请输入姓名', trigger: 'blur'},
                    {min: 0, max: 18, message: '长度在 0 到 18 个字符', trigger: 'blur'}
                ],
                idcarNo: [
                    {required: false, message: '请输入证件号', trigger: 'blur'},
                    {
                        pattern: /(^\d{8}(0\d|10|11|12)([0-2]\d|30|31)\d{3}$)|(^\d{6}(18|19|20)\d{2}(0\d|10|11|12)([0-2]\d|30|31)\d{3}(\d|X|x)$)/,
                        message: '请输入正确的证件号',
                        trigger: 'blur'
                    },
                    {validator: idCardValidity, trigger: 'blur'}
                ],
                phone: [
                    {required: true, message: '请输入手机号', trigger: 'blur'},
                    {
                        pattern: /^((0\d{2,3}-\d{7,8})|(1[358497]\d{9}))$/,
                        message: '请输入合法手机号',
                        trigger: 'blur'
                    }
                ]
            },
          type:'',
          wksId:'',
          oolean:true,
          bool:false
        };
    },
    created() {
        this.siteData = lenye_base.site_data.getsiteData();
        console.log('站点', this.siteData);
        this.userData = lenye_base.user_data.getuserData();
        console.log('个人信息', this.userData);
    },
    mounted() {
        console.log('站点数据', this.siteData);
        this.uploadurl = lenye_base.base_data.getapiUrl() + lenye_base.api_url.file.upload;
        this.getuserdetail(1);
        this.getData();
        this.getuserresource();
    },
    watch: {
        'sitemenu'(newvalue) {
            if (newvalue === 1) {
                this.getusercourse();
            } else if (newvalue === 2) {
                this.getuserclass();
            } else if (newvalue === 11) {
                this.getuserresource();
            } else if (newvalue === 3) {
                this.getusercert();
            } else if (newvalue === 4) {
                this.getusercollect();
            } else if (newvalue === 5) {
                this.getuseract();
            } else if (newvalue === 6) {
                this.getuserwork();
            } else if (newvalue === 7) {
                this.getuserorder();
            } else if (newvalue === 8) {
                this.getuserdetail();
            } else if (newvalue === 9) {
                // this.getuserdetail();
            } else if (newvalue === 10) {
                this.getuserlive();
            } else if (newvalue === 11) {
                this.getuserresource();
            }
        }
    },
    methods: {
        hidephone(value){
          return value.replace(value.substr(3, 4),"****")
        },
        // 时间格式转换
        getNowTime(value){
            var secondTime = parseInt(value); // 秒
            var minuteTime = 0 // 分
            var hourTime = 0 // 小时
            var dayTime = 0 // 天
            var result = ''
            if (value < 60) {
                result = secondTime + '秒'
            } else {
                if (secondTime >= 60) { // 如果秒数大于60，将秒数转换成整数
                    // 获取分钟，除以60取整数，得到整数分钟
                    minuteTime = parseInt(secondTime / 60)
                    // 获取秒数，秒数取佘，得到整数秒数
                    secondTime = parseInt(secondTime % 60)
                    // 如果分钟大于60，将分钟转换成小时
                    if (minuteTime >= 60) {
                        // 获取小时，获取分钟除以60，得到整数小时
                        hourTime = parseInt(minuteTime / 60)
                        // 获取小时后取佘的分，获取分钟除以60取佘的分
                        minuteTime = parseInt(minuteTime % 60)
                        if (hourTime >= 24) {
                            // 获取天数， 获取小时除以24，得到整数天
                            dayTime = parseInt(hourTime / 24)
                            // 获取小时后取余小时，获取分钟除以24取余的分；
                            hourTime = parseInt(hourTime % 24)
                        }
                    }
                }
                if (secondTime > 0) {
                    secondTime = parseInt(secondTime) >= 10 ? secondTime : secondTime
                    result = '' + secondTime + '秒'
                }
                if (minuteTime > 0) {
                    minuteTime = parseInt(minuteTime) >= 10 ? minuteTime : minuteTime;
                    result = '' + minuteTime + '分钟' + result
                }
                if (hourTime > 0) {
                    result = '' + parseInt(hourTime) + '小时' + result
                }
                if (dayTime > 0) {
                    result = '' + parseInt(dayTime) + '天' + result
                }
            }
            return result
        },
        goCourseDetails(csId,bsId) {
            if (csId) {
                let token = '';
                if (lenye_base.user_data.getuserData()) {
                    token = lenye_base.user_data.getuserData().token;
                }
                // window.open(csId + '&token=' + token);

                lenye_base.httpPost(lenye_base.base_data.getapiUrl() + '/base-service/api2/thirdBusinessMng/queryById.do', lenye_base.base_data.getformatting({
                    bsId: bsId
                }), function(res) {
                    if (res.success == '1') {
                        var url = res.data.callbaclUrl02;
                        if (url) {
                            window.open(url.replace('{courseId}', csId).replace('{token}', token));
                        } else {
                            msg.error('无学习地址');
                        }
                    } else {
                        msg.error(res.message);
                    }
                });
            } else {
                msg.warning('暂无课程链接');
            }
        },
        toPay(orderId, bsId) {
            if (orderId) {
                let token = '';
                if (lenye_base.user_data.getuserData()) {
                    token = lenye_base.user_data.getuserData().token;
                }
                lenye_base.httpPost(lenye_base.base_data.getapiUrl() + '/base-service/api2/thirdBusinessMng/queryById.do', lenye_base.base_data.getformatting({
                    bsId: bsId
                }), function(res) {
                    if (res.success == '1') {
                        var url = res.data.callbaclUrl01;
                        if (url) {
                            this.isPay(orderId);
                            window.open(url.replace('{orderId}', orderId).replace('{token}', token));
                        } else {
                            msg.error('无支付地址');
                        }
                    } else {
                        msg.error(res.message);
                    }
                });
            } else {
                msg.warning('暂无支付地址');
            }
        },
        isPay(orderIds) {
            var hasPay = setInterval(() => {
                if (this.sitemenu === 4) {
                    lenye_base.httpPost(lenye_base.base_data.getapiUrl() + '/orderform-service/api2/ordOrderform/queryMultiOrderStatus.do', lenye_base.base_data.getformatting({
                        orderIds: orderIds
                    }), function (res) {
                        if (res.success == '1') {
                            if (res.data.status === '0') {
                                this.getuserorder();
                                msg.success("支付完成！");
                                clearInterval(hasPay);
                            }
                        } else {
                            msg.error(res.message);
                        }
                    });
                }
            }, 3000);
        },
        // 详情
        goDetails(articleId) {
            window.open(`/infodetail?id=${articleId}`);
        },
        looklive(id) {
            window.open(`/livestudio?id=${id}`);
        },
        lookact(id) {
            window.open(`/activedetail?id=${id}`);
        },
        lookclass(id) {
            window.open(`/classregdetail?id=${id}`);
        },
        lookcourse(id) {
            window.open(`/courseplay?id=${id}`);
        },
        lookresource(id) {
            window.open(`/resourcedetail?id=${id}`);
        },
        payorder(id,type) {
            window.open(`/projectorderpay?type=${type}&fp=${type}&id=${id}&orderId=${id}`);
        },
        //    获取统计列表
        getData() {
            const that = this;
            // lenye_base.httpPost(lenye_base.base_data.getapiUrl() + '/course-service/api2/crsCustLearnCourse/queryBsNumByCustId.do', lenye_base.base_data.getformatting({
            //     studyUserId: this.userData.custId
            // }), function(e) {
            //     console.log('课程统计', e);
            //     that.coursecount = e.data;
            // });
            lenye_base.httpPost(lenye_base.base_data.getapiUrl() + '/schoolclass-service/api2/proStudentTeachcontent/studentCsAndTcCount.do', lenye_base.base_data.getformatting({
                custId: this.userData.custId
            }), function(e) {
                console.log('计划统计', e);
                that.schcount = e.data;
            });
        },
        //    获取资源列表
        getuserresource() {
            const that = this;
            lenye_base.httpPost(lenye_base.base_data.getapiUrl() + lenye_base.api_url.resource.queryResourcePageById, lenye_base.base_data.getformatting({
                resinfo:'1',
                orderType: '1',
                page: this.resourcepage,
                rows: this.resourcerows
            }), function(e) {
                console.log('我的资源', e);
                that.resourcelist = e.data;
                that.resourcenum = e.totalCount;
            });
        },
        // 翻页：当前页数的显示条数改变触发
        resourcesizeChange(rows) {
            console.log(rows);
            this.resourcerows = rows;
            this.getuserresource();
        },
        // 翻页：选中当前页
        resourceChange(page) {
            console.log(page);
            this.resourcepage = page;
            this.getuserresource();
        },
        // 翻页：上一页
        resourceprevClick(page) {
            console.log(page);
            this.resourcepage = page;
            this.getuserresource();
        },
        // 翻页：下一页
        resourcenextClick(page) {
            console.log(page);
            this.resourcepage = page;
            this.getuserresource();
        },
        //    获取课程列表
        getusercourse() {
            const that = this;
            lenye_base.httpPost(lenye_base.base_data.getapiUrl() + '/course-service/api2/crsCustLearnCourse/queryUserCoursePageById.do', lenye_base.base_data.getformatting({
                orderType: 1,
                courseinfo: 1,
                page: this.coursepage,
                rows: this.courserows
            }), function(e) {
                console.log('我的课程', e);
                that.courselist = e.data;
                that.coursenum = e.totalCount;
            });
        },
        // 翻页：当前页数的显示条数改变触发
        coursesizeChange(rows) {
            console.log(rows);
            this.courserows = rows;
            this.getusercourse();
        },
        // 翻页：选中当前页
        courseChange(page) {
            console.log(page);
            this.coursepage = page;
            this.getusercourse();
        },
        // 翻页：上一页
        courseprevClick(page) {
            console.log(page);
            this.coursepage = page;
            this.getusercourse();
        },
        // 翻页：下一页
        coursenextClick(page) {
            console.log(page);
            this.coursepage = page;
            this.getusercourse();
        },
        //    获取班级列表
        getuserclass() {
            const that = this;
            lenye_base.httpPost(lenye_base.base_data.getapiUrl() + lenye_base.api_url.schoolclass.queryUserClazzPageById, lenye_base.base_data.getformatting({
                czCerted: '0',
                page: this.classpage,
                rows: this.classrows
            }), function(e) {
                console.log('我的班级', e);
                that.classlist = e.data;
                that.classnum = e.totalCount;
            });
        },
        // 翻页：当前页数的显示条数改变触发
        classsizeChange(rows) {
            console.log(rows);
            this.classrows = rows;
            this.getuserclass();
        },
        // 翻页：选中当前页
        classChange(page) {
            console.log(page);
            this.classpage = page;
            this.getuserclass();
        },
        // 翻页：上一页
        classprevClick(page) {
            console.log(page);
            this.classpage = page;
            this.getuserclass();
        },
        // 翻页：下一页
        classnextClick(page) {
            console.log(page);
            this.classpage = page;
            this.getuserclass();
        },
        //    获取证书列表
        getusercert() {
            const that = this;
            lenye_base.httpPost(lenye_base.base_data.getapiUrl() + lenye_base.api_url.cert.certList, lenye_base.base_data.getformatting({
                ucUserId: this.userData.custId,
                page: 1,
                rows: 10
            }), function(e) {
                console.log('我的证书', e);
                that.certlist = e.data;
                that.certnum = e.totalCount;
            });
        },
        // 翻页：当前页数的显示条数改变触发
        certsizeChange(rows) {
            console.log(rows);
            this.certrows = rows;
            this.getusercert();
        },
        // 翻页：选中当前页
        certChange(page) {
            console.log(page);
            this.certpage = page;
            this.getusercert();
        },
        // 翻页：上一页
        certprevClick(page) {
            console.log(page);
            this.certpage = page;
            this.getusercert();
        },
        // 翻页：下一页
        certnextClick(page) {
            console.log(page);
            this.certpage = page;
            this.getusercert();
        },
        //    获取收藏列表
        getusercollect() {
            const that = this;
            lenye_base.httpPost(lenye_base.base_data.getapiUrl() + '/interact-service/api2/itaCollection/queryPage.do', lenye_base.base_data.getformatting({
                ucUserId: this.userData.custId,
                page: this.collectpage,
                rows: this.collectrows
            }), function(e) {
                console.log('我的收藏', e);
                that.collectlist = e.data;
                that.collectnum = e.totalCount;
            });
        },
        // 翻页：当前页数的显示条数改变触发
        collectsizeChange(rows) {
            console.log(rows);
            this.collectrows = rows;
            this.getusercollect();
        },
        // 翻页：选中当前页
        collectChange(page) {
            console.log(page);
            this.collectpage = page;
            this.getusercollect();
        },
        // 翻页：上一页
        collectprevClick(page) {
            console.log(page);
            this.collectpage = page;
            this.getusercollect();
        },
        // 翻页：下一页
        collectnextClick(page) {
            console.log(page);
            this.collectpage = page;
            this.getusercollect();
        },
        //    获取活动列表
        getuseract() {
            const that = this;
            lenye_base.httpPost(lenye_base.base_data.getapiUrl() + '/activity-service/api2/actActivity/myQueryPage.do', lenye_base.base_data.getformatting({
                custId: this.userData.custId,
                page: this.actpage,
                rows: this.actrows
            }), function(e) {
                console.log('我的活动', e);
                that.actlist = e.data;
                that.actnum = e.totalCount;
            });
        },
        // 翻页：当前页数的显示条数改变触发
        actsizeChange(rows) {
            console.log(rows);
            this.actrows = rows;
            this.getuseract();
        },
        // 翻页：选中当前页
        actChange(page) {
            console.log(page);
            this.actpage = page;
            this.getuseract();
        },
        // 翻页：上一页
        actprevClick(page) {
            console.log(page);
            this.actpage = page;
            this.getuseract();
        },
        // 翻页：下一页
        actnextClick(page) {
            console.log(page);
            this.actpage = page;
            this.getuseract();
        },
        //    获取作品列表
        getuserwork() {
            const that = this;
            lenye_base.httpPost(lenye_base.base_data.getapiUrl() + '/activity-service/api2/actActivityWorks/queryPage.do', lenye_base.base_data.getformatting({
                page: this.workpage,
                rows: this.workrows
            }), function(e) {
                console.log('我的作品', e);
                that.worklist = e.data;
                that.worknum = e.totalCount;
            });
        },
        // 翻页：当前页数的显示条数改变触发
        worksizeChange(rows) {
            console.log(rows);
            this.workrows = rows;
            this.getuserwork();
        },
        // 翻页：选中当前页
        workChange(page) {
            console.log(page);
            this.workpage = page;
            this.getuserwork();
        },
        // 翻页：上一页
        workprevClick(page) {
            console.log(page);
            this.workpage = page;
            this.getuserwork();
        },
        // 翻页：下一页
        worknextClick(page) {
            console.log(page);
            this.workpage = page;
            this.getuserwork();
        },
        //    获取订单列表
        getuserorder() {
            const that = this;
            lenye_base.httpPost(lenye_base.base_data.getapiUrl() + '/orderform-service/api2/ordOrderform/queryManagePageByCurId.do', lenye_base.base_data.getformatting({
                page: this.orderpage,
                rows: this.orderrows
            }), function(e) {
                console.log('我的订单', e);
                that.orderlist = e.data;
                that.ordernum = e.totalCount;
            });
        },
        // 翻页：当前页数的显示条数改变触发
        ordersizeChange(rows) {
            console.log(rows);
            this.orderrows = rows;
            this.getuserorder();
        },
        // 翻页：选中当前页
        orderChange(page) {
            console.log(page);
            this.orderpage = page;
            this.getuserorder();
        },
        // 翻页：上一页
        orderprevClick(page) {
            console.log(page);
            this.orderpage = page;
            this.getuserorder();
        },
        // 翻页：下一页
        ordernextClick(page) {
            console.log(page);
            this.orderpage = page;
            this.getuserorder();
        },
        //    获取个人信息详情
        getuserdetail(type) {
            const that = this;
            lenye_base.httpPost(lenye_base.base_data.getapiUrl() + lenye_base.api_url.base.detail, lenye_base.base_data.getformatting({
                pt4dict: ''
            }), function(e) {
                if (e.success === '1') {
                    console.log('我的信息', e);
                    that.userData = e.data;
                    if (type === 1) {
                        that.userinfo.custName = e.data.custName;
                        that.userinfo.phone = e.data.phone;
                        that.userinfo.photo = e.data.photo;
                        that.userinfo.idcarNo = e.data.idcarNo;
                    }
                    that.imageUrl = e.data.photo;
                } else {
                    that.$message({
                        showClose: true,
                        message: e.message,
                        type: 'warning'
                    });
                }
                ;
            });
        },
        //    获取直播列表
        getuserlive() {
            const that = this;
            lenye_base.httpPost(lenye_base.base_data.getapiUrl() + lenye_base.api_url.live.lylLivequeryUserLivePage, lenye_base.base_data.getformatting({
                custId: this.userData.custId,
                page: this.livepage,
                rows: this.liverows
            }), function(e) {
                console.log('我的直播', e);
                that.livelist = e.data;
                that.livenum = e.totalCount;
            });
        },
        // 翻页：当前页数的显示条数改变触发
        livesizeChange(rows) {
            console.log(rows);
            this.liverows = rows;
            this.getuserlive();
        },
        // 翻页：选中当前页
        liveChange(page) {
            console.log(page);
            this.livepage = page;
            this.getuserlive();
        },
        // 翻页：上一页
        liveprevClick(page) {
            console.log(page);
            this.livepage = page;
            this.getuserlive();
        },
        // 翻页：下一页
        livenextClick(page) {
            console.log(page);
            this.livepage = page;
            this.getuserlive();
        },
        usersave() {
            const that = this;
            lenye_base.httpPost(lenye_base.base_data.getapiUrl() + '/base-service/api/cust/userSelf/save.do', lenye_base.base_data.getformatting({
                custId: that.userData.custId,
                custName: that.userData.custName,
                phone: that.userData.phone,
                idcarNo: that.userData.idcarNo,
                adress: that.userData.adress,
                office: that.userData.office,
                photo: that.imageUrlid,
                sex: that.userData.sex
            }), function(e) {
                console.log('我的信息', e);
                if (e.success === '1') {
                    that.$message({
                        showClose: true,
                        message: '保存成功',
                        type: 'success'
                    });
                    window.location.reload();
                } else {
                    that.$message({
                        showClose: true,
                        message: e.message,
                        type: 'warning'
                    });
                }
                ;
            });
        },
        handleAvatarSuccess(res, file) {
            console.log(res);
            console.log(file);
            // this.imageUrl = URL.createObjectURL(file.raw);
            this.imageUrl = res.data.fileUrl;
            this.imageUrlid = res.data.fileId;
        },
        beforeAvatarUpload(file) {
            console.log(file);
            const isJPG = file.type === 'image/jpeg' || 'image/png';
            const isLt2M = file.size / 1024 / 1024 < 2;

            if (!isJPG) {
                this.$message.error('上传头像图片只能是 JPG 格式!');
            }
            if (!isLt2M) {
                this.$message.error('上传头像图片大小不能超过 2MB!');
            }
            return isJPG && isLt2M;
        },
        delcollect(cltId,objId,type) {
            const that = this;
            lenye_base.httpPost(lenye_base.base_data.getapiUrl() + '/interact-service/api2/itaCollection/deleteFromList.do', lenye_base.base_data.getformatting({
                cltId: cltId,
                objId: objId,
                type: type,
            }), function(e) {
                if (e.success === '1') {
                    that.$message({
                        showClose: true,
                        message: '取消收藏成功',
                        type: 'success'
                    });
                    window.location.reload();
                } else {
                    that.$message({
                        showClose: true,
                        message: e.message,
                        type: 'warning'
                    });
                }
            });
        },
        delorder(orderId) {
            const that = this;
            lenye_base.httpPost(lenye_base.base_data.getapiUrl() + '/orderform-service/api2/ordOrderform/fqOrder.do', lenye_base.base_data.getformatting({
                orderId: orderId
            }), function(e) {
                if (e.data.status === '1') {
                    that.$message({
                        showClose: true,
                        message: '取消成功',
                        type: 'success'
                    });
                    window.location.reload();
                } else {
                    that.$message({
                        showClose: true,
                        message: e.data.msg,
                        type: 'warning'
                    });
                }
            });
            this.getuserorder();
        },
      lookwork(id){
        this.wksId = id
        this.bool = !this.$refs.upload.close(1);
        console.log(111)
        this.type='pro'
        this.oolean=false
        this.$refs.upload.detail(id);
      },
      auditwork(id){
          const that = this;
          lenye_base.httpPost(lenye_base.base_data.getapiUrl() + '/activity-service/api2/actActivityWorks/subAudit.do', lenye_base.base_data.getformatting({
              wksId: id,
              wksStatus: '1'
          }), function(e) {
              if (e.data.status === '1') {
                  that.$message({
                      showClose: true,
                      message: '已提交审核',
                      type: 'success'
                  });
                  window.location.reload();
              } else {
                  that.$message({
                      showClose: true,
                      message: e.data.msg,
                      type: 'warning'
                  });
              }
          });
          this.getuserorder();
      },
    }
};
</script>
