Переглянути джерело

更改底部导航栏图片+学习页图片压缩

谢杰标 2 роки тому
батько
коміт
4d14037198

+ 71 - 178
common/compressPhoto.js

@@ -1,201 +1,94 @@
-//通过canvas将图片压缩至指定大小
+import methods from "@/common/methodTool";
+let num = 1;
+let _resolve;
+let _reject;
 
-//判断图片大小是否满足需求,limitSize的单位是kb
-function imageSizeIsLessLimitSize(
-  imagePath,
-  limitSize,
-  lessCallback,
-  moreCallback
-) {
-  //获取文件信息
-  wx.getFileSystemManager().getFileInfo({
-    filePath: imagePath,
-    success: (res) => {
-      console.log("压缩前图片大小", res, res.size / 1024, "kb");
-      if (res.size > limitSize) {
-        moreCallback();
-      } else {
-        lessCallback();
-      }
-    },
-  });
+function getBase64Size(base64) {
+  if (base64) {
+    base64 = base64.split(",")[1].split("=")[0];
+    var strLength = base64.length;
+    var fileLength = strLength - (strLength / 8) * 2;
+    return Math.floor(fileLength); // 向下取整
+  } else {
+    return null;
+  }
 }
-
-//将图片画在画布上并获取画好之后的图片的路径
-function getCanvasImage(canvasId, imagePath, imageW, imageH, getImgSuccess) {
-  //创建画布内容
-  const ctx = wx.createCanvasContext(canvasId);
-  //图片画上去,imageW和imageH是画上去的尺寸,图像和画布间隔都是0
-  ctx.drawImage(imagePath, 0, 0, imageW, imageH);
-  //这里一定要加定时器,给足够的时间去画(所以每次递归最少要耗时200ms,多次递归很耗时!)
-  ctx.draw(
-    false,
-    setTimeout(() => {
-      //把当前画布指定区域的内容导出生成指定大小的图片,并返回文件路径
-      wx.canvasToTempFilePath({
-        canvasId: canvasId,
-        x: 0,
-        y: 0,
-        width: imageW,
-        height: imageH,
-        quality: 1, // 取0-1,1最高质量
-        fileType: "jpg",
-        success: (res) => {
-          console.log(res, 989898);
-          //将取出的图片路径通过回调函数返回
-          getImgSuccess(res.tempFilePath);
-        },
-      });
-    }, 200)
-  );
+//获得图片大小
+function imageSizeIsLessLimitSize(imagePath, limitSize) {
+  return new Promise((resolve, reject) => {
+    wx.getFileSystemManager().getFileInfo({
+      filePath: imagePath,
+      success: (res) => {
+        resolve(res.size);
+      },
+    });
+  });
 }
 
 //主函数,默认限制大小2048kb即2mb,drawWidth是绘画区域的大小
 //初始值传入为画布自身的边长(我们这是一个正方形的画布)
-function getLessLimitSizeImage(
-  canvasId,
-  imagePath,
-  limitSize = 1024,
-  drawWidth,
-  callback
-) {
-  //判断图片尺寸是否满足要求
-  imageSizeIsLessLimitSize(
-    imagePath,
-    limitSize,
-    (lessRes) => {
-      //满足要求走callback,将压缩后的文件路径返回
-      console.log("满足要求走callback:", imagePath);
-      callback(imagePath);
-    },
-    (moreRes) => {
-      //不满足要求需要压缩的时候
-      wx.getImageInfo({
-        src: imagePath,
-        success: (imageInfo) => {
-          let maxSide = Math.max(imageInfo.width, imageInfo.height);
-          let windowW = drawWidth;
-          let scale = 1;
-          /*
-            这里的目的是当绘画区域缩小的比图片自身尺寸还要小的时候
-            取图片长宽的最大值,然后和当前绘画区域计算出需要放缩的比例
-            然后再画经过放缩后的尺寸,保证画出的一定是一个完整的图片。由于每次递归绘画区域都会缩小,
-            所以不用担心scale永远都是1绘画尺寸永远不变的情况,只要不满足压缩后体积的要求
-            就会缩小绘画区域,早晚会有绘画区域小于图片尺寸的情况发生
-            */
-          if (maxSide > windowW) {
-            scale = windowW / maxSide;
-          }
-          //trunc是去掉小数
-          let imageW = Math.trunc(imageInfo.width * scale);
-          let imageH = Math.trunc(imageInfo.height * scale);
-          // console.log('调用压缩',imageW,imageH);
-          //图片在规定绘画区域上画并获取新的图片的path
-          getCanvasImage(
-            canvasId,
-            imagePath,
-            imageW,
-            imageH,
-            (pressImgPath) => {
-              /*
-                再去检查是否满足要求,始终缩小绘画区域,让图片适配绘画区域
-                这里乘以0.95是必须的,如果不缩小绘画区域,会出现尺寸比绘画区域小,
-                而体积比要求压缩体积大的情况出现,就会无穷递归下去,因为scale的值永远是1
-                但0.95不是固定的,你可以根据需要自己改,0到1之间,越小则绘画区域缩小的越快
-                但不建议取得太小,绘画区域缩小的太快,压出来的将总是很糊的
-                */
-              getLessLimitSizeImage(
-                canvasId,
-                pressImgPath,
-                limitSize,
-                drawWidth * 0.95,
-                callback
-              );
-            }
-          );
-        },
-      });
-    }
-  );
-}
-function compressWx(url, quality, cb) {
-  //不满足要求需要压缩的时候
-  wx.getImageInfo({
-    src: url,
-    success: (imageInfo) => {
-      let maxSide = Math.max(imageInfo.width, imageInfo.height);
-      let windowW = drawWidth;
-      let scale = 1;
-      if (maxSide > windowW) {
-        scale = windowW / maxSide;
-      }
-      //trunc是去掉小数
-      let imageW = Math.trunc(imageInfo.width * scale);
-      let imageH = Math.trunc(imageInfo.height * scale);
-      //创建画布内容
-      const ctx = wx.createCanvasContext(canvasId);
-      //图片画上去,imageW和imageH是画上去的尺寸,图像和画布间隔都是0
-      ctx.drawImage(imagePath, 0, 0, imageW, imageH);
-      //这里一定要加定时器,给足够的时间去画(所以每次递归最少要耗时200ms,多次递归很耗时!)
-      ctx.draw(
-        false,
-        setTimeout(() => {
-          //把当前画布指定区域的内容导出生成指定大小的图片,并返回文件路径
-          wx.canvasToTempFilePath({
-            canvasId: canvasId,
-            x: 0,
-            y: 0,
-            width: imageW,
-            height: imageH,
-            quality: quality, // 取0-1,1最高质量
-            fileType: "jpg",
-            success: (res) => {
-              cb(res.tempFilePath);
-            },
-          });
-        }, 200)
-      );
+function getLessLimitSizeImage(imagePath, quality) {
+  uni.compressImage({
+    src: imagePath,
+    quality,
+    success: (res) => {
+      console.log(res.tempFilePath, res, "压缩后");
+      _resolve(res.tempFilePath);
     },
   });
 }
-function compressH5(url, quality, cb) {
+function compressH5(url, quality) {
   let image = new Image();
   image.onload = function () {
-    var h = this.height * (quality / 1); // 默认按比例压缩
-    var w = this.width * (quality / 1);
     var canvas = document.createElement("canvas");
+    canvas.width = image.width;
+    canvas.height = image.height;
     var ctx = canvas.getContext("2d");
-    var anw = document.createAttribute("width");
-    anw.nodeValue = w;
-    var anh = document.createAttribute("height");
-    anh.nodeValue = h;
-    canvas.setAttributeNode(anw);
-    canvas.setAttributeNode(anh);
-    ctx.drawImage(image, 0, 0, w, h); //压缩比例
+    ctx.drawImage(image, 0, 0, this.height, this.width); //压缩比例
     var base64 = canvas.toDataURL("image/jpeg", quality);
-    cb(base64);
+    _resolve(base64);
   };
   image.src = url;
   image.setAttribute("crossOrigin", "Anonymous");
   image.onerror = () => {
-    reject(new Error("urlToBase64 error"));
+    _reject(new Error("zip error"));
   };
 }
-function myCompressImage(url, limitSize = 2048, cb) {
-  limitSize = limitSize * 1024;
-  const size = url.size;
-  if (size < limitSize) {
-    return cb(url);
-  }
-  const quality = limitSize / size;
-  // #ifdef MP-WEIXIN
-  let canvasId = "zipCanvas";
-  let drawWidth = wx.getSystemInfoSync().windowWidth;
-  getLessLimitSizeImage(canvasId, url.path, limitSize, drawWidth, cb);
-  // #endif
-  // #ifdef H5
-  compressH5(url.path, quality, cb);
-  // #endif
+function myCompressImage(url, limitSize = 2048) {
+  return new Promise(async (resolve, reject) => {
+    _resolve = resolve;
+    _reject = resolve;
+    limitSize = limitSize * 1024;
+    // 获得size
+    if (typeof url == "string") {
+      // base64
+      if (methods.isBase64(url)) {
+        url = {
+          path: url,
+          size: getBase64Size(url),
+        };
+      }
+      // #ifdef MP-WEIXIN
+      url = {
+        path: url,
+        size: await imageSizeIsLessLimitSize(url),
+      };
+      // #endif
+    }
+    const size = url.size;
+    console.log(size, "压缩前");
+    if (size < limitSize) {
+      return _resolve(url);
+    }
+    num++;
+    const quality = limitSize / size;
+    // #ifdef MP-WEIXIN
+    getLessLimitSizeImage(url.path, quality);
+    // #endif
+    // #ifdef H5
+    compressH5(url.path, quality);
+    // #endif
+  });
 }
 
 export default myCompressImage;

+ 4 - 1
components/course/handoutsTree.vue

@@ -84,8 +84,11 @@ export default {
       let url = this.$method.splitImgHost(this.fileInfo.url);
       // #ifdef H5
       uni.navigateTo({
-        url: `/pages/webview/sdlink?url=http://192.168.1.57:8080/?src=${url}`,
+        url: `/pages/webview/sdlink?url=https://preview.xyyxt.net?src=${url}`,
       });
+      // uni.navigateTo({
+      //   url: `/pages/webview/sdlink?url=http://192.168.1.57:8080/?src=${url}`,
+      // });
       // #endif
       // #ifdef MP-WEIXIN
       this.downLoading = true;

+ 13 - 23
components/tabbar/index.vue

@@ -5,16 +5,9 @@
     :list="list"
     @change="change"
   ></u-tabbar>
-  <!-- <tabbar
-    v-model="current"
-    :before-switch="beforeSwitch"
-    :list="list"
-    @change="change"
-  ></tabbar> -->
 </template>
-
 <script>
-import tabbar from "./tabbar.vue";
+import config from "@/common/config";
 export default {
   name: "myTabbar",
   options: { styleIsolation: "shared" },
@@ -23,38 +16,38 @@ export default {
       list: [
         {
           pagePath: "/pages/index/index",
-          iconPath: "/../../static/nav1.png",
-          selectedIconPath: "/../../static/nav1_on.png",
+          iconPath: config.BASE_IMG_URL + "web/icon/nav1.png",
+          selectedIconPath: config.BASE_IMG_URL + "web/icon/nav1_on.png",
           text: "首页",
         },
         {
           pagePath: "/pages/course/index",
-          iconPath: "/../../static/nav2.png",
-          selectedIconPath: "/../../static/nav2_on.png",
+          iconPath: config.BASE_IMG_URL + "/web/icon/nav2.png",
+          selectedIconPath: config.BASE_IMG_URL + "/web/icon/nav2_on.png",
           text: "选课",
         },
         {
           pagePath: "/pages/learn/index",
-          iconPath: "/../../static/nav6.png",
-          selectedIconPath: "/../../static/nav6_on.png",
+          iconPath: config.BASE_IMG_URL + "/web/icon/nav6.png",
+          selectedIconPath: config.BASE_IMG_URL + "/web/icon/nav6_on.png",
           text: "学习",
         },
         {
           pagePath: "/pages/questionBank/index",
-          iconPath: "/../../static/nav3.png",
-          selectedIconPath: "/../../static/nav3_on.png",
+          iconPath: config.BASE_IMG_URL + "/web/icon/nav3.png",
+          selectedIconPath: config.BASE_IMG_URL + "/web/icon/nav3_on.png",
           text: "题库",
         },
         {
           pagePath: "/pages/information/index",
-          iconPath: "/../../static/nav4.png",
-          selectedIconPath: "/../../static/nav4_on.png",
+          iconPath: config.BASE_IMG_URL + "/web/icon/nav4.png",
+          selectedIconPath: config.BASE_IMG_URL + "/web/icon/nav4_on.png",
           text: "资料",
         },
         {
           pagePath: "/pages/wd/index",
-          iconPath: "/../../static/nav5.png",
-          selectedIconPath: "/../../static/nav5_on.png",
+          iconPath: config.BASE_IMG_URL + "/web/icon/nav5.png",
+          selectedIconPath: config.BASE_IMG_URL + "/web/icon/nav5_on.png",
           text: "我的",
         },
       ],
@@ -80,9 +73,6 @@ export default {
       });
     },
   },
-  components: {
-    tabbar,
-  },
 };
 </script>
 

+ 0 - 375
components/tabbar/tabbar.vue

@@ -1,375 +0,0 @@
-<template>
-  <view v-if="show" class="u-tabbar" @touchmove.stop.prevent="() => {}">
-    <view
-      class="u-tabbar__content safe-area-inset-bottom"
-      :style="{
-        height: $u.addUnit(height),
-        backgroundColor: bgColor,
-      }"
-      :class="{
-        'u-border-top': borderTop,
-      }"
-    >
-      <view
-        class="u-tabbar__content__item"
-        v-for="(item, index) in list"
-        :key="index"
-        :class="{
-          'u-tabbar__content__circle': midButton && item.midButton,
-        }"
-        @tap.stop="clickHandler(index)"
-        :style="{
-          backgroundColor: bgColor,
-        }"
-      >
-        <view
-          :class="[
-            midButton && item.midButton
-              ? 'u-tabbar__content__circle__button'
-              : 'u-tabbar__content__item__button',
-          ]"
-        >
-          <u-icon
-            :size="midButton && item.midButton ? midButtonSize : iconSize"
-            :name="elIconPath(index)"
-            img-mode="scaleToFill"
-            :color="elColor(index)"
-            :custom-prefix="item.customIcon ? 'custom-icon' : 'uicon'"
-          ></u-icon>
-          <u-badge
-            :count="item.count"
-            :is-dot="item.isDot"
-            v-if="item.count"
-            :offset="[-2, getOffsetRight(item.count, item.isDot)]"
-          ></u-badge>
-        </view>
-        <view
-          class="u-tabbar__content__item__text"
-          :style="{
-            color: elColor(index),
-          }"
-        >
-          <text class="u-line-1">{{ item.text }}</text>
-        </view>
-      </view>
-      <view
-        v-if="midButton"
-        class="u-tabbar__content__circle__border"
-        :class="{
-          'u-border': borderTop,
-        }"
-        :style="{
-          backgroundColor: bgColor,
-          left: midButtonLeft,
-        }"
-      >
-      </view>
-    </view>
-    <!-- 这里加上一个48rpx的高度,是为了增高有凸起按钮时的防塌陷高度(也即按钮凸出来部分的高度) -->
-    <view
-      class="u-fixed-placeholder safe-area-inset-bottom"
-      :style="{
-        height: `calc(${$u.addUnit(height)} + ${midButton ? 48 : 0}rpx)`,
-      }"
-    ></view>
-  </view>
-</template>
-
-<script>
-export default {
-  props: {
-    // 显示与否
-    show: {
-      type: Boolean,
-      default: true,
-    },
-    // 通过v-model绑定current值
-    value: {
-      type: [String, Number],
-      default: 0,
-    },
-    // 整个tabbar的背景颜色
-    bgColor: {
-      type: String,
-      default: "#ffffff",
-    },
-    // tabbar的高度,默认50px,单位任意,如果为数值,则为rpx单位
-    height: {
-      type: [String, Number],
-      default: "50px",
-    },
-    // 非凸起图标的大小,单位任意,数值默认rpx
-    iconSize: {
-      type: [String, Number],
-      default: 40,
-    },
-    // 凸起的图标的大小,单位任意,数值默认rpx
-    midButtonSize: {
-      type: [String, Number],
-      default: 90,
-    },
-    // 激活时的演示,包括字体图标,提示文字等的演示
-    activeColor: {
-      type: String,
-      default: "#303133",
-    },
-    // 未激活时的颜色
-    inactiveColor: {
-      type: String,
-      default: "#606266",
-    },
-    // 是否显示中部的凸起按钮
-    midButton: {
-      type: Boolean,
-      default: false,
-    },
-    // 配置参数
-    list: {
-      type: Array,
-      default() {
-        return [];
-      },
-    },
-    // 切换前的回调
-    beforeSwitch: {
-      type: Function,
-      default: null,
-    },
-    // 是否显示顶部的横线
-    borderTop: {
-      type: Boolean,
-      default: true,
-    },
-    // 是否隐藏原生tabbar
-    hideTabBar: {
-      type: Boolean,
-      default: true,
-    },
-  },
-  data() {
-    return {
-      // 由于安卓太菜了,通过css居中凸起按钮的外层元素有误差,故通过js计算将其居中
-      midButtonLeft: "50%",
-      pageUrl: "", // 当前页面URL
-    };
-  },
-  created() {
-    // 是否隐藏原生tabbar
-    if (this.hideTabBar) uni.hideTabBar();
-    // 获取引入了u-tabbar页面的路由地址,该地址没有路径前面的"/"
-    let pages = getCurrentPages();
-    // 页面栈中的最后一个即为项为当前页面,route属性为页面路径
-    this.pageUrl = pages[pages.length - 1].route;
-  },
-  computed: {
-    elIconPath() {
-      return (index) => {
-        return "photo";
-        // 历遍u-tabbar的每一项item时,判断是否传入了pagePath参数,如果传入了
-        // 和data中的pageUrl参数对比,如果相等,即可判断当前的item对应当前的tabbar页面,设置高亮图标
-        // 采用这个方法,可以无需使用v-model绑定的value值
-        let pagePath = this.list[index].pagePath;
-        // 如果定义了pagePath属性,意味着使用系统自带tabbar方案,否则使用一个页面用几个组件模拟tabbar页面的方案
-        // 这两个方案对处理tabbar item的激活与否方式不一样
-        if (pagePath) {
-          if (pagePath == this.pageUrl || pagePath == "/" + this.pageUrl) {
-            return this.list[index].selectedIconPath;
-          } else {
-            return this.list[index].iconPath;
-          }
-        } else {
-          // 普通方案中,索引等于v-model值时,即为激活项
-          return index == this.value
-            ? this.list[index].selectedIconPath
-            : this.list[index].iconPath;
-        }
-      };
-    },
-    elColor() {
-      return (index) => {
-        // 判断方法同理于elIconPath
-        let pagePath = this.list[index].pagePath;
-        if (pagePath) {
-          if (pagePath == this.pageUrl || pagePath == "/" + this.pageUrl)
-            return this.activeColor;
-          else return this.inactiveColor;
-        } else {
-          return index == this.value ? this.activeColor : this.inactiveColor;
-        }
-      };
-    },
-  },
-  mounted() {
-    this.midButton && this.getMidButtonLeft();
-  },
-  methods: {
-    clickTip(val) {
-      console.log(val);
-    },
-    async clickHandler(index) {
-      console.log(index, 789);
-      if (this.beforeSwitch && typeof this.beforeSwitch === "function") {
-        // 执行回调,同时传入索引当作参数
-        // 在微信,支付宝等环境(H5正常),会导致父组件定义的customBack()函数体中的this变成子组件的this
-        // 通过bind()方法,绑定父组件的this,让this.customBack()的this为父组件的上下文
-        let beforeSwitch = this.beforeSwitch.bind(this.$u.$parent.call(this))(
-          index
-        );
-        console.log(beforeSwitch, "beforeSwitch");
-        // 判断是否返回了promise
-        if (!!beforeSwitch && typeof beforeSwitch.then === "function") {
-          await beforeSwitch
-            .then((res) => {
-              // promise返回成功,
-              this.switchTab(index);
-            })
-            .catch((err) => {});
-        } else if (beforeSwitch === true) {
-          // 如果返回true
-          this.switchTab(index);
-        }
-      } else {
-        this.switchTab(index);
-      }
-    },
-    // 切换tab
-    switchTab(index) {
-      console.log(this.list[index].pagePath, "pagePath");
-      // 发出事件和修改v-model绑定的值
-      this.$emit("change", index);
-      // 如果有配置pagePath属性,使用uni.switchTab进行跳转
-      if (this.list[index].pagePath) {
-        console.log("跳转")
-        uni.switchTab({
-          url: this.list[index].pagePath,
-        });
-      } else {
-        // 如果配置了papgePath属性,将不会双向绑定v-model传入的value值
-        // 因为这个模式下,不再需要v-model绑定的value值了,而是通过getCurrentPages()适配
-        this.$emit("input", index);
-      }
-    },
-    // 计算角标的right值
-    getOffsetRight(count, isDot) {
-      // 点类型,count大于9(两位数),分别设置不同的right值,避免位置太挤
-      if (isDot) {
-        return -20;
-      } else if (count > 9) {
-        return -40;
-      } else {
-        return -30;
-      }
-    },
-    // 获取凸起按钮外层元素的left值,让其水平居中
-    getMidButtonLeft() {
-      let windowWidth = this.$u.sys().windowWidth;
-      // 由于安卓中css计算left: 50%的结果不准确,故用js计算
-      this.midButtonLeft = windowWidth / 2 + "px";
-    },
-  },
-};
-</script>
-
-<style scoped lang="scss">
-@mixin vue-flex($direction: row) {
-  /* #ifndef APP-NVUE */
-  display: flex;
-  flex-direction: $direction;
-  /* #endif */
-}
-.u-fixed-placeholder {
-  /* #ifndef APP-NVUE */
-  box-sizing: content-box;
-  /* #endif */
-}
-
-.u-tabbar {
-  &__content {
-    @include vue-flex;
-    align-items: center;
-    position: relative;
-    position: fixed;
-    bottom: 0;
-    left: 0;
-    width: 100%;
-    z-index: 1998;
-    /* #ifndef APP-NVUE */
-    box-sizing: content-box;
-    /* #endif */
-
-    &__circle__border {
-      border-radius: 100%;
-      width: 110rpx;
-      height: 110rpx;
-      top: -48rpx;
-      position: absolute;
-      z-index: 4;
-      background-color: #ffffff;
-      // 由于安卓的无能,导致只有3个tabbar item时,此css计算方式有误差
-      // 故使用js计算的形式来定位,此处不注释,是因为js计算有延后,避免出现位置闪动
-      left: 50%;
-      transform: translateX(-50%);
-
-      &:after {
-        border-radius: 100px;
-      }
-    }
-
-    &__item {
-      flex: 1;
-      justify-content: center;
-      height: 100%;
-      padding: 12rpx 0;
-      @include vue-flex;
-      flex-direction: column;
-      align-items: center;
-      position: relative;
-
-      &__button {
-        position: absolute;
-        top: 14rpx;
-        left: 50%;
-        transform: translateX(-50%);
-      }
-
-      &__text {
-        color: $u-content-color;
-        font-size: 26rpx;
-        line-height: 28rpx;
-        position: absolute;
-        bottom: 14rpx;
-        left: 50%;
-        transform: translateX(-50%);
-        width: 100%;
-        text-align: center;
-      }
-    }
-
-    &__circle {
-      position: relative;
-      @include vue-flex;
-      flex-direction: column;
-      justify-content: space-between;
-      z-index: 10;
-      /* #ifndef APP-NVUE */
-      height: calc(100% - 1px);
-      /* #endif */
-
-      &__button {
-        width: 90rpx;
-        height: 90rpx;
-        border-radius: 100%;
-        @include vue-flex;
-        justify-content: center;
-        align-items: center;
-        position: absolute;
-        background-color: #ffffff;
-        top: -40rpx;
-        left: 50%;
-        z-index: 6;
-        transform: translateX(-50%);
-      }
-    }
-  }
-}
-</style>

+ 16 - 61
pages3/polyv/detail.vue

@@ -799,6 +799,7 @@ 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 myCompressImage from "@/common/compressPhoto.js";
 import { mapGetters, mapMutations } from "vuex";
 var polyvPlayerContext = null;
 export default {
@@ -2960,7 +2961,6 @@ export default {
           filePath = new File([url], "a.jpg", {
             type: "image/jpg",
           });
-
           uni.uploadFile({
             url: ossToken.host,
             name: "file",
@@ -2980,7 +2980,7 @@ export default {
             success: (result) => {
               this.$u.toast("上传成功");
               self.ossAvatarUrl = ossToken.dir;
-              resolve();
+              resolve(ossToken.dir);
             },
             fail: (error) => {
               uni.showToast({
@@ -3014,7 +3014,7 @@ export default {
               // if (result.statusCode === 200) {
               this.$u.toast("上传成功");
               self.ossAvatarUrl = ossToken.dir;
-              resolve();
+              resolve(ossToken.dir);
             },
             fail: (error) => {
               uni.showToast({
@@ -3032,55 +3032,9 @@ export default {
     imageInfos() {
       var self = this;
       return new Promise(async (resolve, reject) => {
-        // #ifdef MP-WEIXIN
-        uni.getImageInfo({
-          src: self.avatarUrl,
-          success: async (res) => {
-            let canvasWidth = res.width; //图片原始长宽
-            let canvasHeight = res.height;
-            if (canvasWidth > 2000 || canvasHeight > 2000) {
-              // h5不支持
-              uni.compressImage({
-                src: self.avatarUrl,
-                quality: 75,
-                width: "35%",
-                height: "35%",
-                success: async (rest) => {
-                  const waitUpload = await self.uploadFile(
-                    rest.tempFilePath,
-                    0
-                  );
-                  resolve(waitUpload);
-                },
-              });
-            } else if (canvasWidth > 1000 || canvasHeight > 1000) {
-              uni.compressImage({
-                src: self.avatarUrl,
-                quality: 75,
-                width: "50%",
-                height: "50%",
-                success: async (rest) => {
-                  const waitUpload = await self.uploadFile(
-                    rest.tempFilePath,
-                    0
-                  );
-                  resolve(waitUpload);
-                },
-              });
-            } else {
-              const waitUpload = await self.uploadFile(self.avatarUrl, 0);
-              resolve(waitUpload);
-            }
-          },
-          fail: (err) => {
-            this.$u.toast("图片上传失败");
-          },
-        });
-        // #endif
-        // #ifdef H5
-        const waitUpload = await this.uploadFile(this.faceUrl, 0);
+        let resPath = await myCompressImage(this.avatarUrl || this.faceUrl, 50);
+        const waitUpload = await self.uploadFile(resPath, 0);
         resolve(waitUpload);
-        // #endif
       });
     },
     timeEvent() {
@@ -3097,7 +3051,10 @@ export default {
         let photoTime = 0; //获取拍照秒数
         for (let i = 0; i < this.photoList.length; i++) {
           photoTime = Number(this.photoList[i]); //获取拍照秒数
-          if (this.erJianErZao && !this.photoHistoryList.length || photoTime < this.playTime && photoTime > this.playTime - 8) {
+          if (
+            (this.erJianErZao && !this.photoHistoryList.length) ||
+            (photoTime < this.playTime && photoTime > this.playTime - 8)
+          ) {
             //3秒区间内才触发拍照,避免拉动滚动条
             if (this.photoHistoryList.indexOf(i) < 0) {
               //不存在拍照历史,没有重修过,没有学过,则拍照
@@ -3117,7 +3074,7 @@ export default {
                 uni.getStorageSync(`tabkePhotoShow${this.goodsId}`) ==
                 this.goodsId
               ) {
-                return this.openPhoto()
+                return this.openPhoto();
               } else {
                 this.popupPhotoShow = true;
                 uni.setStorageSync(
@@ -3166,9 +3123,9 @@ export default {
       polyvPlayerContext = this.selectComponent("#playerVideo");
       if (newstate.detail.newstate == "playing") {
         console.log("播放");
-        if(this.noticeShow){
+        if (this.noticeShow) {
           polyvPlayerContext.pause();
-          return
+          return;
         }
         if (this.needSeek) {
           // var polyvPlayerContext = this.selectComponent("#playerVideo");
@@ -3446,12 +3403,10 @@ export default {
         return;
       }
       this.uploadLock = true;
-
       let compareFaceData = await this.faceRecognition();
-      console.log(compareFaceData, "compareFaceData");
       this.compareFaceData = compareFaceData;
       if (compareFaceData >= 80) {
-        const waitYS = await this.imageInfos();
+        await this.imageInfos();
         this.postCoursePhotoRecord()
           .then(async (res) => {
             this.photoHistoryList.push(this.photoIndex);
@@ -3921,9 +3876,9 @@ export default {
         polyvPlayerContext.on("s2j_onVideoPlay", () => {
           // 视频初次播放或由暂停恢复播放时触发
           console.log("视频初次播放或由暂停恢复播放时触发");
-          if(this.noticeShow){
-            polyvPlayerContext.j2s_pauseVideo(); 
-            return
+          if (this.noticeShow) {
+            polyvPlayerContext.j2s_pauseVideo();
+            return;
           }
           if (this.needSeek) {
             if (this.recordObj.videoCurrentTime) {

BIN
static/nav1.png


BIN
static/nav1_on.png


BIN
static/nav2.png


BIN
static/nav2_on.png


BIN
static/nav3.png


BIN
static/nav3_on.png


BIN
static/nav4.png


BIN
static/nav4_on.png


BIN
static/nav5.png


BIN
static/nav5_on.png


BIN
static/nav6.png


BIN
static/nav6_on.png