index.vue 26.9 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668
<template>
    <view class="study">
        <u-navbar :is-back="false" background="{background: transparent}" :border-bottom="false" :is-fixed="false">
            <text class="title-view">学习</text>
        </u-navbar>
        <image :src="bannerImage" mode="" class="banner"></image>
        <view>
            <u-tabs-swiper bg-color="#F4F5F7" inactive-color="#999999" font-size="28" ref="uTabs" :list="tabs"
                :current="current" @change="tabsChange" :is-scroll="false" swiperWidth="750"></u-tabs-swiper>
        </view>
        <swiper :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish"
            style="height: 755rpx;">
            <swiper-item class="swiper-item">
                <scroll-view scroll-y style="height:796rpx;width:100%;" @scrolltolower="onreachBottom">
                    <view class="standard" @click="goToPrint">
                        <text>充电桩交付规范</text>
                        <text>></text>
                    </view>
                </scroll-view>
            </swiper-item>
            <swiper-item class="swiper-item">
                <scroll-view scroll-y style="height:100%;width:100%;" @scrolltolower="onreachBottom">
                    <view v-for="item in list" :key="item.id" class="notice" @click="bbb(item)">
                        <view class="n-head">
{{item.title}}
                        </view>
                        <view class="news" v-html="item.body">
                            <u-parse :html="item.body"></u-parse>
                        </view>
                        <u-line color="#F4F5F7" class="content-line"/>
                    </view>
                    <view v-shou="isLoadMore">
                        <u-loadmore :status="loadStatus" />
                    </view>
                </scroll-view>
            </swiper-item>
            <swiper-item class="swiper-item">
                <scroll-view scroll-y style="height:100%;width:100%;">
                    <view class="lean">
                        <view class="top">
                            <view class="title u-margin-top-10 u-margin-bottom-30">通用课程</view>
                            <view class="currency-class">
                                <view class="class1" @click=ccc(courselist[0].id)>
                                    <image class="img" :src="courselist[0].pic" mode=""></image>
                                    <view class="right">
                                        <view class="u-font-32 font-bold">
                                            {{ courselist[0].title }}
                                        </view>
                                        <view class="u-font-24">
                                            {{ courselist[0].desc }}
                                        </view>
                                        <view class="line-percent">
                                            <u-line-progress active-color="#2979ff" :percent="courselist[0].percent"
                                                :show-percent="false">
                                            </u-line-progress>
                                            <text class="font-default-color"
                                                :class="{'font-active-color':courselist[0].percent}"
                                                v-text="courselist[0].status"></text>
                                        </view>
                                    </view>
                                </view>
                                <view class="class1 u-margin-top-40" @click=ccc(courselist[1].id)>
                                    <image class="img" :src="courselist[1].pic" mode=""></image>
                                    <view class="right">
                                        <view class="u-font-32 font-bold">
                                            {{ courselist[1].title }}
                                        </view>
                                        <view class="u-font-24">
                                            {{ courselist[1].desc }}
                                        </view>
                                        <view class="line-percent">
                                            <u-line-progress active-color="#2979ff" :percent="courselist[1].percent"
                                                :show-percent="false">
                                            </u-line-progress>
                                            <text class="font-default-color"
                                                :class="{'font-active-color':courselist[1].percent}"
                                                v-text="courselist[1].status"></text>
                                        </view>
                                    </view>
                                </view>
                            </view>
                            <view class="title u-margin-top-50 u-margin-bottom-30">技能课程</view>
                            <view class="currency-class">
                                <view class="class1" @click=ccc(courselist[2].id)>
                                    <image class="img" :src="courselist[2].pic" mode=""></image>
                                    <view class="right">
                                        <view class="u-font-32 font-bold">
                                            {{ courselist[2].title }}
                                        </view>
                                        <view class="u-font-24">
                                            {{ courselist[2].desc }}
                                        </view>
                                        <view class="line-percent" style="display:flex;justify-content: space-between;">
                                            <u-line-progress active-color="#2979ff" :percent="courselist[2].percent"
                                                :show-percent="false">
                                            </u-line-progress>
                                            <text class="font-default-color"
                                                :class="{'font-active-color':courselist[2].percent}"
                                                v-text="courselist[2].status"></text>
                                        </view>
                                    </view>
                                </view>
                            </view>
                        </view>
                    </view>
                </scroll-view>
            </swiper-item>
            <swiper-item>
                <scroll-view scroll-y style="height:100%;width:100%;" @scrolltolower="onreachBottom">
                    <view class="lean">
                        <view class="top">
                            <view class="title u-margin-top-10 u-margin-bottom-30">通用认证</view>
                            <view class="currency-class">
                                <view class="class1" @click="aaa(0)">
                                    <image class="img" :src="examList[0].pic" mode=""></image>
                                    <view class="right">
                                        <view class="u-font-32 font-bold">
                                            {{ examList[0].title }}
                                        </view>
                                        <view class="u-font-24">
                                            {{ examList[0].desc }}
                                        </view>
                                        <view class="u-font-24" style="display:flex;justify-content: space-between;">
                                            <text class="font-color-999999">{{ examList[0].condition }}</text>
                                            <text class="font-default-exam-color"
                                                :class="{'font-active-color':examList[0].isComplete}">
                                                {{ examList[0].status }}
                                            </text>
                                        </view>
                                    </view>
                                </view>
                                <view class="class1 u-margin-top-40" @click="aaa(1)">
                                    <image class="img" :src="examList[1].pic" mode=""></image>
                                    <view class="right">
                                        <view class="u-font-32 font-bold">
                                            {{examList[1].title}}
                                        </view>
                                        <view class="u-font-24">
                                            {{ examList[1].desc }}
                                        </view>
                                        <view class="u-font-24" style="display:flex;justify-content: space-between;">
                                            <text class="font-color-999999">{{ examList[1].condition }}</text>
                                            <text class="font-default-exam-color"
                                                :class="{'font-active-color':examList[1].isComplete}">
                                                {{ examList[1].status }}</text>
                                        </view>
                                    </view>
                                </view>
                            </view>
                            <view class="title u-margin-top-50 u-margin-bottom-30">技能认证</view>
                            <view class="currency-class">
                                <view class="class1" @click="aaa(2)">
                                    <image class="img" :src="examList[2].pic" mode=""></image>
                                    <view class="right">
                                        <view class="u-font-32 font-bold">
                                            {{ examList[2].title }}
                                        </view>
                                        <view class="u-font-24">
                                            {{ examList[2].desc }}
                                        </view>
                                        <view class="u-font-24" style="display:flex;justify-content: space-between;">
                                            <text class="font-color-999999">{{ examList[2].condition }}</text>
                                            <text class="font-default-exam-color"
                                                :class="{'font-active-color':examList[2].isComplete}">
                                                {{ examList[2].status }}</text>
                                        </view>
                                    </view>
                                </view>
                            </view>
                        </view>
                    </view>
                </scroll-view>
            </swiper-item>
        </swiper>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                msg: "赣南吴彦祖",
                tabs: [{
                        name: "交付规范",
                    },
                    {
                        name: "培训通知",
                    },
                    {
                        name: "在线学习",
                    },
                    {
                        name: "考核认证",
                    },
                ],
                current: 0,
                swiperCurrent: 0,
                params: {
                    start: 0,
                },
                list: [],
                courselist: [{
                        title: '服务规范',
                        desc: '为用户提供更好服务,自己赚更多钱',
                        percent: 0,
                        status: '',
                        pic: process.uniEnv.qn_base_url + "guifan1@3x.png",
                        id: 173
                    },
                    {
                        title: '接单操作',
                        desc: '快速学习,使用APP 接单、抢单',
                        percent: 0,
                        status: '',
                        pic: process.uniEnv.qn_base_url + "guifan2@3x.png",
                        id: 173
                    },
                    {
                        title: '从0-1学习充电桩安装服务',
                        desc: '让你全面了解充电桩市场及服务规范',
                        percent: 0,
                        status: '',
                        pic: process.uniEnv.qn_base_url + "kecehng1@3x.png",
                        id: 173
                    }
                ],
                examList: [{
                        title: '服务规范',
                        desc: '通过本认证,是接单的必要条件',
                        condition: '随机20题,及格20题',
                        status: '',
                        pic: process.uniEnv.qn_base_url + "guifan1@3x.png",
                        id: 2,
                        examId: '',
                        examStatus: '',
                        isComplete: false
                    },
                    {
                        title: '接单操作',
                        desc: '快速认证,是否具备接单操作能力',
                        condition: '随机20题,及格16题',
                        status: '',
                        pic: process.uniEnv.qn_base_url + "guifan2@3x.png",
                        id: 2,
                        examId: '',
                        examStatus: '',
                        isComplete: false
                    },
                    {
                        title: '从0-1学习充电桩安装服务',
                        desc: '通过本认证后,可接充电桩业务单',
                        condition: '随机30题,及格25题',
                        status: '',
                        pic: process.uniEnv.qn_base_url + "kecehng1@3x.png",
                        id: 2,
                        examId: '',
                        examStatus: '',
                        isComplete: false
                    }
                ],
                loadStatus: "loading", //加载样式:loadMore-加载前样式,loading-加载加载中样式,nomore-没有数据样式
                isLoadMore: false, //是否加载中
                course_id: "course_id_=173",
                exam: null,
            };
        },
        onLoad() {
            // this.getList();
            // this.getCourseList();
            // this.getUserExamInfo();
        },
        computed: {
            bannerImage() {
                return process.uniEnv.qn_base_url + "banner-xx@3x.png";
            },
        },
        methods: {
            getList() {
                this.$u.api
                    .getTrainingNoticeList(this.params)
                    .then((res) => {
                        if (res.code == 200) {
                            if (res.data) {
                                this.list = this.list.concat(res.data);
                                if (res.data.length < 5) {
                                    //判断接口返回数据量小于请求数据量,则表示此为最后一页
                                    this.isLoadMore = true;
                                    this.loadStatus = "nomore";
                                } else {
                                    this.isLoadMore = false;
                                }
                            } else {
                                this.isLoadMore = true;
                                this.loadStatus = "nomore";
                            }
                        } else {
                            //接口请求失败的处理
                            uni.showToast({
                                title: res.message,
                                icon: "none",
                            });
                            this.isLoadMore = false;
                            if (this.params.start > 0) {
                                this.page -= 5;
                            }
                        }
                    })
                    .catch((err) => {
                        uni.showToast({
                            title: err,
                            icon: "none",
                        });
                        this.isLoadMore = false;
                        if (this.params.start > 0) {
                            this.page -= 5;
                        }
                    });
            },
            getTypeName(percent) {
                if (percent == 0) {
                    return '未开始';
                } else if (percent == '100') {
                    return '已完成';
                } else {
                    return '继续';
                }
            },
            //在线学习通用课程信息
            getCourseList() {
                let courseLength = this.courselist.length;
                for (let i = 0; i < courseLength; i++) {
                    let param = {
                        course_id: this.courselist[i].id
                    };
                    this.$u.api
                        .CourseList(param)
                        .then((res) => {
                            if (res.code == 200) {
                                if (res.data) {
                                    res.data.learnedInfo.learnPercent *= 100;
                                    this.courselist[i].status = this.getTypeName(res.data.learnedInfo.learnPercent);
                                    this.courselist[i].percent = res.data.learnedInfo.learnPercent;
                                }
                            }
                        })
                        .catch((err) => {
                            uni.showToast({
                                title: err,
                                icon: "none",
                            });
                        });
                }
            },
            //tabs通知swiper切换
            tabsChange(index) {
                this.swiperCurrent = index;
                switch (index) {
                    case 1:
                        this.params.start = 0;
                        this.list = [];
                        this.getList();
                        break;
                    case 2:
                        this.getCourseList();
                        console.log('重新加载学习进度');
                        break;
                    case 3:
                        this.getUserExamInfo();
                        break;
                }
            },
            //swiper-item左右移动,通知tabs的滑块跟随移动
            transition(e) {
                let dx = e.detail.dx;
                this.$refs.uTabs.setDx(dx);
            },
            animationfinish(e) {
                let current = e.detail.current;
                this.$refs.uTabs.setFinishCurrent(current);
                this.swiperCurrent = current;
                this.current = current;
            },
            //跳转到assessment页面
            aaa(index) {
                var examInfo = this.examList[index];
                if (examInfo.examStatus == 0) {
                    console.log("这是申请的考试id", examInfo.examId);

                    wx.navigateTo({
                        url: "./answer?userExamId=" + examInfo.examId,
                    });
                } else if (examInfo.examStatus == 1) {
                    wx.navigateTo({
                        url: "./result?userExamId=" + examInfo.examId,
                    });
                } else if (examInfo.examStatus == 2) {
                    wx.navigateTo({
                        url: "./assessment",
                    });
                }
            },
            //跳转到课程介绍
            ccc(id) {
                uni.navigateTo({
                    url: "./curriculum?course_id=" + id,
                });
            },
            //跳转到
            bbb(e) {
                var news = {
                    body: e.body,
                    id: e.id,
                    level: e.level,
                    title: e.title,
                };
                // console.log(news)

                uni.navigateTo({
                    url: "./news-details",
                });
                setTimeout(() => {
                    uni.$emit("news", news), console.log("发送数据");
                }, 500);

                console.log("跳转结束11111111");
            },
            //scroll-view到底部加载更多
            onreachBottom() {
                console.log("上拉触底函数");
                //上拉触底函数
                if (!this.isLoadMore) {
                    this.isLoadMore = true;
                    this.params.start += 5;
                    if (this.loadStatus !== "nomore") {
                        this.getList();
                    }
                }
            },
            //跳转到拍照小程序首页
            goToPrint() {
                console.log("111111");
                uni.navigateToMiniProgram({
                    appId: "wxd1d6eede324b0465",
                    success(res) {
                        //打开成功
                        console.log("success", res);
                    },
                    fail(err) {
                        console.log("err", err);
                    },
                });
            },
            //考核认证,通用认证,考试通过or未通过查询接口请求
            getUserExamInfo() {
                uni.showLoading({
                    title: "请稍候",
                });

                let that = this;
                let token = that.vuex_token;
                let length = this.examList.length;
                for (let i = 0; i < length; i++) {
                    let examId = this.examList[i].id;
                    this.$u.api
                        .getExamResult(examId)
                        .then((res) => {
                            if (res.code == 200) {
                                this.examList[i].examId = res.data.id;
                                let examResult = res.data.examLevelResult;
                                this.examList[i].status = examResult != '' ? examResult : '未通过';
                                // examStatus 用户考试状态 0考试中 1考试完成 2未参与
                                that.exam = res.data;
                                console.log(that.exam);
                                if (res.data.examStatus == 2) {
                                    console.log("examStatus " + i + " 2");
                                    that.applyExam();
                                    return;
                                }
                                if (res.data.examStatus == 1) {
                                    console.log("examStatus " + i + " 1");
                                    that.examList[i].isComplete = true;
                                    that.examScore = res.data.examScore;
                                    that.postResult();
                                    return;
                                }
                                if (res.data.examStatus == 0) {
                                    console.log("examStatus " + i + " 0");
                                    that.userExamId = res.data.id;
                                    // that.getNext();
                                }
                            } else {
                                console.log('getUserExamInfo 200 err');
                                uni.showToast({
                                    icon: "none",
                                    title: '获取考试信息失败',
                                });
                            }
                        })
                        .catch((err) => {
                            console.log('getUserExamInfo err' + err);
                            uni.hideLoading();
                            uni.showToast({
                                icon: "none",
                                title: "获取考试信息失败",
                            });
                        });

                }
            }
        },
    };
</script>

<style>
    .study {
        height: 100vh;
        background-color: #f4f5f7;
        padding: 0rpx 30rpx 0 30rpx;
    }

    .title-view {
        color: #333333;
        font-weight: bold;
        font-size: 40rpx;
    }

    .banner {
        width: 690rpx;
        height: 240rpx;
        margin-top: 10rpx;
    }

    /* //交付规范 */
    .standard {
        width: 656rpx;
        display: flex;
        justify-content: space-between;
        border-bottom: 1rpx solid #82848a;
        padding: 0 34rpx;
        margin: 72rpx auto;
    }

    /* //培训通知 */
    .notice {
        /* border: #808080 solid 2rpx; */
        width: 100%;
        height: 400rpx;
        margin-top: 36rpx;
        overflow: hidden;
        background-color: #ffffff;
        border-radius: 12rpx;
    }

    .n-head {
        text-align: left;
       /* margin: 30rpx 30rpx 0 30rpx;
     */   margin-left: 30rpx;
    }

    .news {
        height: 168rpx;
        overflow: hidden;
        /* margin: 30rpx 30rpx 0 30rpx; */
    }

    /* //在线学习 */
    .currency-class {
        width: 100%;
        /* height: 340rpx; */
        background: #ffffff;
        padding: 30rpx;
        /* margin-bottom: 11px; */
        border-radius: 12rpx;
    }

    .title {
        font-size: 32rpx;
        font-weight: bold;
        font-family: PingFang-SC-Bold, PingFang-SC;
    }

    .class1 {
        display: -webkit-box;
        display: -webkit-flex;
        display: flex;
        -webkit-box-pack: justify;
        -webkit-justify-content: space-between;
        justify-content: space-between;
    }

    .img {
        width: 160rpx;
        height: 120rpx;
        /* display: block; */
        /* margin-right: 0rpx; */
    }

    .right {
        width: 434rpx;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }

    .intro {
        color: #9999a6;
    }

    .tab {
        background: #fff;
        height: 82rpx;
        margin: 0 0;
    }

    .text {
        margin: 0 40rpx;
        line-height: 82rpx;
        color: #667eb5;
    }

    .content {
        margin: 5px 0;
        height: 485rpx;
        background: #fff;
    }

    swiper {
        height: 691rpx;
    }

    .line-percent {
        display: flex;
        justify-content: space-between;
        line-height: 24rpx;
        font-size: 24rpx;
        color: #999999;
    }

    .u-progress {
        width: 280rpx !important;
        height: 12rpx !important;
        background-color: #ececec;
    }

    .font-bold {
        font-weight: bold;
    }

    .font-default-color {
        color: #999999;
    }
    
    .font-default-exam-color {
        color: #FA5A49;
    }

    .font-active-color {
        color: #2272FF;
    }
    
    .font-color-999999 {
        color: #99999;
    }
    
    .content-line {
        margin-top: 30rpx;
    }
</style>