Browse Source

fix: 二维码预览wenti

huangziyang 1 day ago
parent
commit
cb63a33c54

+ 12 - 0
components/ShareTemplate/ShareTemplate.vue

@@ -36,6 +36,18 @@ onMounted(() => {
   }).then((res) => {
     if (res.data.image) {
       let url = res.data.image;
+      if (url.startsWith("data:")) {
+        var imgPath =
+          uni.env.USER_DATA_PATH +
+          "/e-invoice" +
+          Date.parse(new Date()) +
+          ".jpg";
+        var imageData = url.replace(/^data:image\/\w+;base64,/, "");
+        var fs = uni.getFileSystemManager();
+        fs.writeFileSync(imgPath, imageData, "base64");
+        fs.close();
+        url = imgPath;
+      }
       qrCode.value = url;
     }
   });

+ 17 - 4
components/ShareTemplate/ShareTemplateExam.vue

@@ -5,7 +5,7 @@ import lPainterImage from "@/uni_modules/lime-painter/components/l-painter-image
 import lPainterText from "@/uni_modules/lime-painter/components/l-painter-text/l-painter-text.vue";
 import { ref, onMounted } from "vue";
 import { request } from "../../utils/request";
-import { getRoute, objToUrlParams } from "../../utils/router";
+import { getRoute } from "../../utils/router";
 
 const painter = ref(null);
 const prosp = defineProps({
@@ -35,6 +35,18 @@ onMounted(() => {
   }).then((res) => {
     if (res.data.image) {
       let url = res.data.image;
+      if (url.startsWith("data:")) {
+        var imgPath =
+          uni.env.USER_DATA_PATH +
+          "/e-invoice" +
+          Date.parse(new Date()) +
+          ".jpg";
+        var imageData = url.replace(/^data:image\/\w+;base64,/, "");
+        var fs = uni.getFileSystemManager();
+        fs.writeFileSync(imgPath, imageData, "base64");
+        fs.close();
+        url = imgPath;
+      }
       qrCode.value = url;
     }
   });
@@ -84,10 +96,11 @@ const onSaveImage = () => {
             :text="correct.rate.toFixed(1) + '%'"
             css="position: absolute;top: 550rpx;left: 100rpx;color: #e7a552;font-size: 30rpx; z-index: 2;"
           />
-          <l-painter-view
-            css="background: red; width: 146rpx; height: 146rpx;position: absolute;bottom: 18rpx;left: 18rpx;"
+          <l-painter-image
+            :src="qrCode"
+            css="width: 146rpx; height: 146rpx;position: absolute;bottom: 18rpx;left: 18rpx;"
           >
-          </l-painter-view>
+          </l-painter-image>
         </l-painter-view>
       </l-painter>
     </view>

+ 6 - 6
pages.json

@@ -205,12 +205,12 @@
         "selectedIconPath": "static/icons/home_select.png",
         "text": "首页"
       },
-      // {
-      //   "pagePath": "pages/learn/index",
-      //   "iconPath": "static/icons/learn.png",
-      //   "selectedIconPath": "static/icons/learn_select.png",
-      //   "text": "学习本"
-      // },
+      {
+        "pagePath": "pages/learn/index",
+        "iconPath": "static/icons/learn.png",
+        "selectedIconPath": "static/icons/learn_select.png",
+        "text": "学习本"
+      },
       {
         "pagePath": "pages/challenge/index",
         "iconPath": "static/icons/challenge.png",

+ 1 - 1
pages/challenge/index.vue

@@ -70,7 +70,7 @@ const toAdd = async () => {
 <style lang="scss" scoped>
 .bg {
   width: 100%;
-  height: 1734rpx;
+  height: 1824rpx;
   background: url("https://openwork-oss.oss-cn-shenzhen.aliyuncs.com/uploads/question/2025/06/Mta1ISg62sk0DW7GfkD2qGxwa0uQ2p4NH4gUC5op.png");
   background-size: cover;
   padding: 32rpx;

+ 1 - 1
pages/real/exam.vue

@@ -23,7 +23,7 @@ const correct = ref({
 const useTime = ref(null);
 
 const showReport = ref(false);
-const showShare = ref(false);
+const showShare = ref(true);
 const isEnd = ref(false);
 const submitter = ref({
   closeText: "直接退出",

+ 1 - 1
pages/regulations/practice.vue

@@ -22,7 +22,7 @@ const correct = ref({
 });
 
 const showReport = ref(false);
-const showShare = ref(false);
+const showShare = ref(true);
 const submitter = ref({
   closeText: "直接退出",
   context: "您本次答题还未提交, 确定要退出答题吗?",