| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842 | <template>  <div class="container GCLS-BOOK-Container" v-if="showContent">    <template v-if="!isPhone">      <div v-if="!type" class="header-box">        <Header />        <Nav nav-value="书籍预览" />      </div>      <div v-else class="header-box">        <div class="bookname">          <i            style="cursor: pointer; margin-right: 5px"            class="el-icon-arrow-left"            @click="back"          ></i>          {{ name }}        </div>      </div>    </template>    <div      class="content"      id="content-scroll"      :class="[type ? 'content-top' : '', isPhone ? 'content-phone' : '']"    >      <div        id="content-tree"        :class="[          fullTree ? 'content-tree-full' : 'content-tree',          isPhone ? 'content-tree-phone' : '',          showMenu ? '' : 'content-tree-unfold',        ]"        :style="{ background: isPhone && showMenu ? themeColorPhone : '' }"      >        <template v-if="isPhone">          <div            class="toggle-box"            :class="[showMenu ? 'toggle-box-fold' : '']"            @click="toggleMenu"          >            <i              :class="[showMenu ? 'el-icon-s-fold' : 'el-icon-s-unfold']"              v-if="showMenu"              style="padding: 10px"            ></i>            <img src="../assets/menu-phone.png" v-else style="width: 20px" />          </div>        </template>        <TreeView          ref="treeView"          :book-id="bookId"          :change-id="changeId"          :changeTreeData="changeTreeData"          :currentTreeID="chapterId"          v-show="(isPhone && showMenu) || !isPhone"        />        <div class="moveBtn-nnpe" v-move></div>      </div>      <i class="el-icon-close close-phone" v-if="isPhone" @click="back"></i>      <div        id="data-screen"        :class="[          'inner',          fullscreen ? 'inner-full' : '',          isPhone ? 'inner-phone' : '',        ]"        :style="{ background: isPhone ? themeColorPhone : '' }"        v-loading="loading"      >        <el-image          :src="pictureUrl"          fit="scale-down"          class="img_url"          v-if="!chapterId && pictureUrl"        >          <div slot="placeholder" class="image-slot">            <img src="../assets/common/icon-imgloading.png" />          </div>        </el-image>        <!-- 显示答案按钮 -->        <!-- <a v-if="chapterId" :class="['answerShow',isAnswerShow?'answerShowTrue':'']" @click="handleAnswerShow">显示答案</a> -->        <!-- <a class="edit-btn" @click="handleEdit">编辑</a> -->        <div v-if="chapterId" class="title-box">          <img            v-if="!treeFlag"            src="../assets/common/icon-view-back.png"            @click="treeShow"          />          <img            v-if="!treeFlag"            src="../assets/common/icon-treelist.png"            @click="chooseCourseware"          />          <!-- <h2 class="title">{{ chapterName }}</h2> -->          <!-- <el-switch            v-if="!treeFlag"            v-model="switchvalue"            active-color="#FF9900"            active-text            inactive-text="生词模式"          /> -->        </div>        <template v-if="category == 'OC' || !category">          <Preview            v-if="chapterId && context"            ref="previewAnswer"            :context="context"            :bookAnswerContent="bookAnswerContent"            bookclientwidth="900"            :TaskModel="TaskModel"            @handleBookUserAnswer="handleBookUserAnswer"          />        </template>        <template v-if="category == 'NPC'">          <Booknpc            v-if="chapterId && context"            ref="previewAnswerNPC"            :context="context"            :currentTreeID="chapterId"            :FatherTreeData="FatherTreeData"            :change-id="changeId"            :themeColor="themeColor"            :isShowTitle="true"            :TaskModel="TaskModel"            :isShowSave="false"            @finishTaskMaterial="finishTaskMaterial"            :bookAnswerContent="bookAnswerContent"            :isAnswerItemShow="isAnswerItemShow"            @changeThemeColorPhone="changeThemeColorPhone"          />        </template>        <template v-if="category == 'NNPE'">          <Booknnpe            v-if="chapterId && context"            ref="previewAnswerNNPE"            :context="context"            :currentTreeID="chapterId"            :FatherTreeData="FatherTreeData"            :change-id="changeId"            :themeColor="themeColor"            :isShowTitle="true"            :isAnswerItemShow="true"            :TaskModel="TaskModel"            :isShowSave="true"            @finishTaskMaterial="finishTaskMaterial"            :bookAnswerContent="bookAnswerContent"          />        </template>        <template v-if="category == 'RLC'">          <Bookrlc            v-if="chapterId && context"            ref="previewAnswerRLC"            :context="context"            :currentTreeID="chapterId"            :FatherTreeData="FatherTreeData"            :change-id="changeId"            :themeColor="themeColor"            :isShowTitle="true"            :bookFontSize="bookFontSize"            :isAnswerItemShow="isAnswerItemShow"            :TaskModel="TaskModel"            :isShowSave="false"            @finishTaskMaterial="finishTaskMaterial"            :bookAnswerContent="bookAnswerContent"          />        </template>        <template v-if="category == 'NEW'">          <BookNew            v-if="chapterId && context"            ref="book"            :context="context"            :currentTreeID="chapterId"          />        </template>      </div>    </div>    <!-- <Preview :context="context" :queIndex="queIndex" /> -->    <a      v-if="chapterId && treeFlag && !isPhone"      class="screen-full"      @click="fullScreen()"    />  </div></template><script>import Header from "@/components/inputModules/common/Header";import Nav from "@/components/inputModules/common/Nav";import TreeView from "@/components/inputModules/common/TreeView";import { getContent, getLogin } from "@/api/ajax";import Cookies from "js-cookie";// import Preview from '@/componentsAnswer/PreviewAnswer.vue'import Preview from "@/components/Preview";import { getToken } from "../utils/auth";export default {  name: "CourseView",  directives: {    move(el, bindings) {      el.onmousedown = function (e) {        var init = e.clientX;        var parent = document.getElementById("content-tree");        var initWidth = parent.offsetWidth;        document.onmousemove = function (e) {          var end = e.clientX;          var newWidth = end - init + initWidth;          if (newWidth >= 340 && newWidth <= 680)            parent.style.width = newWidth + "px";        };        document.onmouseup = function () {          document.onmousemove = document.onmouseup = null;        };      };    },  },  components: {    Header,    Nav,    TreeView,    Preview,  },  data() {    return {      bookId: "",      chapterId: "",      chapterName: "",      fullscreen: false, // 控制全屏      fullTree: false, // 全屏模式下树是否显示      context: null,      question: null, // 选择的模板题型      queIndex: "",      treeFlag: true, // tree是否显示      switchvalue: true, // 生词模式      isAnswerShow: false, // 是否显示答案      bookAnswerContent: "",      TaskModel: "",      category: "",      FatherTreeData: null,      themeColor: "",      type: "",      name: "",      loading: false,      bookFontSize: "",      showContent: false,      bookName: [        {          name: "新实用汉语课本1",          id: "002-20211006-10-NHVOMDLDRY",        },        {          name: "发展汉语初级综合(Ⅰ)",          id: "002-20211007-06-4DGL2ZRIB5",        },        {          name: "HSK标准教程1",          id: "002-20211007-14-UNYIWU8EKW",        },        {          name: "新实用汉语",          id: "003-20210908-10-1ZWNGSASZL",        },        {          name: "新航标职业英语 综合英语(基础级)学生用书1(修订版)",          id: "002-20211029-14-9VGMXLV2NU",        },        {          name: "新航标职业英语 综合英语(提高级)学生用书1 (第3版)",          id: "002-20211011-10-GOLXUZST4G",        },        {          name: "新航标英语 汽车英语",          id: "002-20211222-15-O7WVMR4XHK",        },        {          name: "新航标职业英语 英语视听说教程(入门级)1",          id: "001-20211222-15-LXK64LQZST",        },        {          name: "新航标职业英语 综合英语(提高级)学生用书2(第3版)",          id: "001-20220118-14-EZVO52PYXF",        },        {          name: "新航标职业英语 综合英语(基础级)学生用书2(修订版)",          id: "002-20220208-09-FDKUJJSLI8",        },        {          name: "轻松学中文. 课本 .第1册",          id: "002-20220312-11-HK93JKDAGR",        },        {          name: "轻松学中文. 课本. 第2册",          id: "001-20220312-11-WU8XCRQMDB",        },        {          name: "轻松学中文 . 练习册 . 第1册",          id: "001-20220429-18-ZDIKBFQ9DP",        },        {          name: "轻松学中文 . 练习册 . 第 2 册",          id: "002-20220429-18-KIOM0VEXLY",        },      ],      isAnswerItemShow: false,      pictureUrl: "",      isPhone: false, // 是否是移动端打开      showMenu: false, //是否展开菜单      themeColorPhone: "", // 移动端护眼色    };  },  created() {    console.log("2024-04-23");    const regExp = /Android|webOS|iPhone|BlackBerry|IEMobile|Opera Mini/i;    this.isPhone = regExp.test(navigator.userAgent) && window.innerWidth < 860;    this.showMenu = !(      regExp.test(navigator.userAgent) && window.innerWidth < 860    );    const _this = this;    if (      _this.$route.query.encryption &&      _this.$route.query.encryption != "undefined" &&      _this.$route.query.type    ) {      if (        _this.$route.query.encryption.substring(          _this.$route.query.encryption.length - 8        ) *          1 <        20240712      ) {        _this.$message({          message: "链接已停用",          type: "warning",        });        return false;      }      getLogin("login_control-CheckValidDateEncryptionString", {        encryption_string: _this.$route.query.encryption,      })        .then((res) => {          if (res.is_check_pass == "true") {            _this.bookId = this.$route.query.bookId;            _this.type = this.$route.query.type;            const MethodName = "book-book_manager-GetBook";            const data = {              id: _this.bookId,            };            getContent(MethodName, data).then((res) => {              this.showContent = true;              _this.name = res.name;            });          } else {            _this.$message({              message: "链接已失效",              type: "warning",            });          }        })        .catch(() => {          _this.$message({            message: "链接已失效",            type: "warning",          });        });    } else if (_this.$route.query.showCourse) {      _this.bookId = this.$route.query.bookId;      this.showContent = true;    } else if (_this.$route.query.fromPage === "OBOC") {      _this.bookId = this.$route.query.bookId;      const MethodName = "book-book_manager-GetBook";      const data = {        id: _this.$route.query.bookId,      };      getContent(MethodName, data).then((res) => {        this.showContent = true;        _this.name = res.name;      });    } else {      _this.$message({        message: "链接已失效",        type: "warning",      });    }    let userInfor = JSON.parse(getToken());    if (      userInfor &&      (userInfor.user_type == "TEACHER" || userInfor.user_type == "INNER")    ) {      _this.isAnswerItemShow = true;    } else {      _this.isAnswerItemShow = false;    }    this.themeColorPhone = localStorage.getItem("themeColorPhone")      ? localStorage.getItem("themeColorPhone")      : "";  },  mounted() {},  methods: {    toggleMenu() {      this.showMenu = !this.showMenu;    },    back() {      this.$router.go(-1);    },    changeTreeData(val) {      const _this = this;      if (_this.$route.query.nodeId) {        _this.changeId(_this.$route.query.nodeId, "");      } else {        this.FatherTreeData = JSON.parse(JSON.stringify(val));        let nodes = this.FatherTreeData;        for (let i = 0; i < nodes.length; i++) {          if (nodes[i].is_courseware == "true") {            _this.changeId(nodes[i].id, "");            return false;          } else {            if (nodes[i].children) {              let nodesC = nodes[i].children;              for (let j = 0; j < nodesC.length; j++) {                if (nodesC[j].is_courseware == "true") {                  _this.changeId(nodesC[j].id, "");                  return false;                } else {                  if (nodesC[j].children) {                    let nodesCs = nodesC[j].children;                    for (let l = 0; j < nodesCs.length; l++) {                      if (nodesCs[l].is_courseware == "true") {                        _this.changeId(nodesCs[l].id, "");                        return false;                      }                    }                  }                }              }            }          }        }      }    },    changeId(id, name) {      const _this = this;      _this.chapterId = id;      _this.chapterName = name;      _this.isAnswerShow = false;      _this.onGetData();      if (!_this.treeFlag) {        _this.fullTree = false;        document.getElementById("content-tree").style.display = "none";      }      if (document.getElementById("content-scroll")) {        document.getElementById("content-scroll").scrollTop = 0;      }      if (_this.isPhone) {        _this.showMenu = false;        document.getElementsByClassName("content-tree-phone")[0].scrollTop = 0;      }    },    // 点击全屏展示 隐藏tree    fullScreen() {      this.treeFlag = false;      this.fullscreen = true;      document.getElementById("content-tree").style.display = "none";    },    treeShow() {      this.treeFlag = true;      this.fullTree = false;      this.fullscreen = false;      document.getElementById("content-tree").style.display = "block";    },    // 获取预览数据    onGetData() {      this.loading = true;      const _this = this;      const MethodName = "book-courseware_manager-GetCoursewareContent_View";      const data = {        id: _this.chapterId,      };      getContent(MethodName, data).then((res) => {        this.category = res.category;        this.themeColor = res.book_theme_color;        this.bookFontSize = res.book_font_size;        if (res.content) {          const _this = this;          if (!this.category || this.category == "OC") {            _this.context = {              id: _this.chapterId,              ui_type: JSON.parse(res.content).question                ? JSON.parse(res.content).question.ui_type                : "",              sort_number: 1,              content: JSON.parse(res.content),            };          } else {            _this.context = JSON.parse(res.content);          }        } else {          const _this = this;          _this.context = null;        }        this.loading = false;      });    },    // 跳转编辑页面    handleEdit() {      const index = this.$refs.treeView.handleParentIndex().split("###");      if (index.length > 1) {        Cookies.set("bookIndex", index[0]);        Cookies.set("bookLevel", index[1]);        Cookies.set("bookNodename", index[2]);      }      this.$router.push("/input?bookId=" + this.bookId);    },    // 显示或隐藏答案    handleAnswerShow() {      this.isAnswerShow = !this.isAnswerShow;      this.$refs.previewAnswer.bookAnswerShow(this.isAnswerShow);    },    // 得到用户答题答案    handleBookUserAnswer(data) {      console.log(data);    },    // 悬浮树隐藏显示    chooseCourseware() {      this.fullTree = !this.fullTree;      if (this.fullTree) {        document.getElementById("content-tree").style.display = "block";      } else {        document.getElementById("content-tree").style.display = "none";      }    },    finishTaskMaterial(data, duration) {      console.log("保存答案:");      console.log(data);      console.log(duration);    },    changeThemeColorPhone(color) {      this.themeColorPhone = color;    },  },};</script><style lang="scss" scoped>.header-box {  position: fixed;  width: 100%;  top: 0;  left: 0;  z-index: 999;}.container {  width: 100%;  height: auto;  .bookname {    width: 100%;    height: 60px;    display: flex;    align-items: center;    box-sizing: border-box;    padding: 0 46px;    background: #f3f7fa;    position: relative;    z-index: 999;  }  .content {    width: 100%;    display: flex;    justify-content: flex-start;    align-items: flex-start;    height: 100vh;    overflow: auto;    padding-top: 124px;    &-top {      padding-top: 60px;      .title-box {        top: 66px !important;      }      .content-tree-full {        top: 100px !important;      }    }    &-phone {      padding-top: 0;    }    &-tree {      width: 340px;      height: 85vh;      overflow: auto;      padding: 20px 0px;      border-right: 1px solid #d9d9d9;      background: #fff;      position: fixed;      left: 0;      z-index: 2;      &-phone {        width: 50%;        height: 100%;        padding-top: 50px;        z-index: 4;        overflow-x: hidden;      }      &-unfold {        width: 40px;        height: 40px;        border: none;        overflow: hidden;        background: none;        > div {          text-align: left !important;        }      }    }    .content-tree-full {      position: fixed !important;      top: 170px;      left: 152px;      max-height: 588px;      overflow: auto;      z-index: 1000;      background: #fff;      box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.25);      border-radius: 4px;    }    #content-tree {      //   position: relative;    }    .moveBtn-nnpe {      position: absolute;      height: 100%;      width: 10px;      right: 0;      top: 0;      cursor: col-resize;    }    .inner {      // border-left: 1px solid #d9d9d9;      width: 1000px;      margin: 0 auto;      flex: 1;      margin-left: 340px;      box-sizing: border-box;      padding: 20px;      position: relative;      background: #fff;      &.inner-full {        margin-left: 0;      }      &-phone {        margin-left: 0;        padding: 0;        width: 100%;      }      .title-box {        display: flex;        align-items: center;        margin-bottom: 12px;        padding-right: 160px;        position: fixed;        top: 76px;        left: 230px;        z-index: 999;        > img {          width: 40px;          margin-right: 16px;          cursor: pointer;        }      }      .title {        font-size: 24px;        margin-bottom: 20px;        line-height: 40px;        margin: 0;      }      .has-module {        display: flex;        justify-content: flex-start;        align-items: flex-start;        &-tree {          width: 340px;          height: 100%;          overflow: auto;          padding: 20px 0px;          border-right: 1px solid #d9d9d9;        }        .inner {          // border-left: 1px solid #d9d9d9;          width: 1000px;          flex: 1;          margin: 0 auto;          box-sizing: border-box;          padding: 20px;          position: relative;          background: #fff;          .title-box {            display: flex;            align-items: center;            margin-bottom: 12px;            padding-right: 160px;            position: relative;            > img {              width: 40px;              margin-right: 16px;              cursor: pointer;            }          }          .title {            font-size: 24px;            margin-bottom: 20px;            line-height: 40px;            margin: 0;          }          .has-module {            display: flex;            justify-content: flex-start;            align-items: flex-start;          }          .edit-btn {            display: inline-block;            font-size: 14px;            background: #ff9900;            float: right;            line-height: 36px;            color: #fff;            width: 60px;            text-align: center;            border-radius: 4px;          }        }      }    }    .nav-list {      width: 200px;      height: 40px;      background: rgba(49, 212, 134, 0.2);      border-radius: 240px;      display: flex;      justify-content: flex-start;      align-items: center;      padding: 0;      margin: 0;      margin-bottom: 10px;      list-style: none;      > li {        height: 40px;        width: 100px;        text-align: center;        font-style: normal;        font-weight: bold;        font-size: 14px;        line-height: 40px;        color: #19b068;        cursor: pointer;        &.active {          background: #19b068;          border-radius: 240px;          color: #ffffff;        }      }    }  }  .answerShow {    position: absolute;    right: 20px;    top: 20px;    width: 112px;    height: 40px;    background: #ffffff url("../assets/common/icon-eye-close.png") 16px center      no-repeat;    background-size: 16px;    border: 1px solid rgba(44, 44, 44, 0.15);    box-sizing: border-box;    border-radius: 4px;    font-size: 14px;    line-height: 150%;    color: #000000;    padding: 9px 16px 9px 36px;    cursor: pointer;    z-index: 2;    &.answerShowTrue {      background: #f5f5f5 url("../assets/common/icon-eye-open.png") 16px center        no-repeat;      background-size: 16px;    }  }  .close-phone {    position: fixed;    top: 10px;    right: 0;    z-index: 1;    font-size: 20px;    color: #fff;    cursor: pointer;    padding: 10px;  }}.img_url {  width: 1000px;  height: 700px;}.toggle-box {  position: fixed;  top: 15px;  left: 0;  z-index: 5;  text-align: right;  color: black;  padding: 10px;  width: 40px;  &-fold {    width: 50%;  }}</style><style lang="scss">.GCLS-BOOK-Container {  .screen-full {    position: fixed;    right: 30px;    bottom: 30px;    width: 48px;    height: 48px;    background: rgba(0, 0, 0, 0.4) url("../assets/common/icon-screenFull.png")      center no-repeat;    background-size: 32px;  }}.title-box {  .el-switch {    position: absolute;    top: 0;    right: 0px;    border: 1px solid rgba(44, 44, 44, 0.15);    border-radius: 40px;    height: 40px;    padding: 6px 6px 6px 16px;  }  .el-switch__label.is-active {    color: #000000;    font-size: 16px;  }}</style>
 |