Browse Source

讲义组件

谢杰标 2 years ago
parent
commit
632abe29aa

+ 40 - 0
components/course/handoutsBox.vue

@@ -0,0 +1,40 @@
+<template>
+  <view>
+    <view class="a" v-for="item in list" :key="item.fileId">
+      <handouts-tree :fileInfo="item"></handouts-tree>
+    </view>
+  </view>
+</template>
+
+<script>
+import handoutsTree from "@/components/course/handoutsTree.vue";
+export default {
+  name: "HandoutsBox",
+  props: {
+    list: {
+      type: Array,
+      default: () => {
+        return [];
+      },
+    },
+  },
+  data() {
+    return {};
+  },
+
+  mounted() {},
+
+  methods: {},
+  components: {
+    handoutsTree,
+  },
+};
+</script>
+
+<style lang="scss" scoped>
+.a{
+    border-radius: 20rpx;
+    background: #ffffff;
+    margin-bottom: 20rpx;
+}
+</style>

+ 142 - 0
components/course/handoutsTree.vue

@@ -0,0 +1,142 @@
+<template>
+  <view style="padding-left: 20rpx">
+    <view v-if="fileInfo.type == 2">
+      <view
+        @click="handelClick"
+        class="fl u-border-bottom"
+        style="height: 78rpx"
+      >
+        <u-icon name="arrow-down" color="#999" size="24" v-if="!down"></u-icon>
+        <u-icon name="arrow-right" color="#999" size="24" v-if="down"></u-icon>
+        <text class="menu_name u-line-1">{{ fileInfo.urlName }}</text>
+      </view>
+      <view v-show="!down">
+        <view v-for="item in fileInfo.children" :key="item.fileId">
+          <handouts-tree :fileInfo="item"></handouts-tree>
+        </view>
+      </view>
+    </view>
+    <view v-if="fileInfo.type == 1">
+      <view class="fl_c u-border-bottom level1">
+        <view class="title u-line-1">
+          {{ fileInfo.urlName }}
+        </view>
+        <view @click="openDocument(item)">
+          <image
+            v-if="!downLoading"
+            src="/pages3/static/imgs/downLoad.png"
+          ></image>
+          <image
+            v-else
+            src="/pages3/static/imgs/downLoading.png"
+            class="loading_down"
+          ></image>
+        </view>
+      </view>
+    </view>
+  </view>
+</template>
+
+<script>
+export default {
+  name: "handoutsTree",
+  props: {
+    fileInfo: {
+      type: Object,
+      default: () => {
+        return {};
+      },
+    },
+  },
+  data() {
+    return {
+      down: true,
+    };
+  },
+
+  mounted() {},
+
+  methods: {
+    handelClick() {
+      this.down = !this.down;
+    },
+    openDocument(item) {
+      let url = this.$method.splitImgHost(item.url);
+      // #ifdef H5
+      window.location.href = url;
+      // #endif
+      // #ifdef MP-WEIXIN
+      this.downLoading = true;
+      uni.downloadFile({
+        url: url,
+        success: (res) => {
+          var filePath = res.tempFilePath;
+          // h5不支持
+          uni.openDocument({
+            filePath: filePath,
+            fileType: "pdf",
+            showMenu: item.canDownload == 1 ? true : false,
+            success: (res) => {
+              this.downLoading = false;
+              uni.setStorageSync("current", this.current);
+            },
+            fail: (err) => {
+              this.downLoading = false;
+              uni.showToast({
+                icon: "none",
+                title: "文档地址错误",
+              });
+            },
+          });
+        },
+        fail: (err) => {
+          this.downLoading = false;
+          uni.showModal({
+            title: "提示",
+            content: "文档错误," + err.errMsg,
+            showCancel: false,
+          });
+        },
+      });
+      // #endif
+    },
+  },
+};
+</script>
+
+<style lang="scss" scoped>
+.menu_name {
+  flex: 1;
+  font-size: 26rpx;
+  font-weight: bold;
+  color: #333;
+  margin-left: 14rpx;
+}
+
+
+.level1 {
+  height: 78rpx;
+  padding-right: 20rpx;
+  .title {
+    flex: 1;
+    font-size: 26rpx;
+  }
+  .loading_down {
+    transform: rotate(360deg);
+    animation: rotation 3s linear infinite;
+  }
+  image {
+    width: 40rpx;
+    height: 40rpx;
+  }
+}
+
+@keyframes rotation {
+  from {
+    -webkit-transform: rotate(0deg);
+  }
+  to {
+    -webkit-transform: rotate(360deg);
+  }
+}
+</style>

+ 3 - 3
components/nav-bar/nav-logo.vue

@@ -1,5 +1,5 @@
 <template>
-  <div>
+  <view>
     <u-navbar
       :class="title ? 'navbarL' : 'navbarC'"
       :is-back="false"
@@ -21,11 +21,11 @@
         <!-- #endif -->
       </view>
     </u-navbar>
-  </div>
+  </view>
 </template>
 
 <script>
-import { mapGetters, mapActions } from "vuex";
+import { mapGetters } from "vuex";
 export default {
   name: "NavLogo",
   props: {

+ 73 - 0
pages3/polyv/detail.vue

@@ -269,6 +269,7 @@
             </view>
           </template>
           <view v-else style="text-align: center">暂无讲义</view>
+          <handouts-box :list="fileList"></handouts-box>
         </view>
         <!--笔记 -->
         <view v-show="current == 2">
@@ -792,6 +793,7 @@ import plv from "../static/polyv-sdk/index";
 import courseModule from "@/components/course/courseModule.vue";
 import courseChapter from "@/components/course/courseChapter.vue";
 import courseSection from "@/components/course/courseSection.vue";
+import handoutsBox from "@/components/course/handoutsBox.vue";
 import PopupPhoto from "@/components/popup/index.vue";
 import { mapGetters, mapMutations } from "vuex";
 var polyvPlayerContext = null;
@@ -801,6 +803,7 @@ export default {
     courseChapter,
     courseSection,
     PopupPhoto,
+    handoutsBox,
   },
   data() {
     return {
@@ -925,6 +928,76 @@ export default {
       pauseTimer: null,
       barTimer: null,
       isReach: false,
+      fileList: [
+        {
+          fileId: 501,
+          url: null,
+          urlName: "1微信图片2微信图片2微信图片2微信图片2微信图片2微信图片2微信图片2",
+          status: 1,
+          handoutsId: 1557,
+          sort: 1,
+          type: 2,
+          parentId: 0,
+          children: [
+            {
+              fileId: 502,
+              url: null,
+              urlName: "2",
+              status: 1,
+              handoutsId: 1557,
+              sort: 1,
+              type: 2,
+              parentId: 501,
+              children: [
+                {
+                  fileId: 504,
+                  url: "oss/images/certificate/20230411/1681201704754.jpg",
+                  urlName: "微信图片1微信图片2微信图片2微信图片2微信图片2微信图片2微信图片2微信图片2",
+                  status: 1,
+                  handoutsId: 1557,
+                  sort: 1,
+                  type: 1,
+                  parentId: 503,
+                  children: null,
+                },
+              ],
+            },
+            {
+              fileId: 506,
+              url: null,
+              urlName: "3",
+              status: 1,
+              handoutsId: 1557,
+              sort: 1,
+              type: 2,
+              parentId: 501,
+            },
+          ],
+        },
+        {
+          fileId: 502,
+          url: null,
+          urlName: "zhiyuan(修改终版-02)",
+          status: 1,
+          handoutsId: 1557,
+          sort: 1,
+          type: 2,
+          parentId: 0,
+          children: [
+            {
+              fileId: 504,
+              url: "oss/images/certificate/20230411/1681201704754.jpg",
+              urlName: "微信图片1.jpg",
+              status: 1,
+              handoutsId: 1557,
+              sort: 1,
+              type: 1,
+              parentId: 503,
+              children: null,
+            },
+          ],
+        },
+      ],
     };
   },
   computed: {