From 8e3ee81b6ed824866734b7034604121f370f4201 Mon Sep 17 00:00:00 2001
From: QYF-GitLab1 <1940665526@qq.com>
Date: 星期三, 09 七月 2025 17:55:14 +0800
Subject: [PATCH] 登录、购书码、申请阅读

---
 src/views/personalCenter/teacherCertificate.vue |  149 +++++++++++++++++++++++++++++--------------------
 1 files changed, 88 insertions(+), 61 deletions(-)

diff --git a/src/views/personalCenter/teacherCertificate.vue b/src/views/personalCenter/teacherCertificate.vue
index 6aaf3cd..268e79a 100644
--- a/src/views/personalCenter/teacherCertificate.vue
+++ b/src/views/personalCenter/teacherCertificate.vue
@@ -150,7 +150,7 @@
             label="鑱旂郴鐢佃瘽"
             :rules="[
               { required: true, message: '璇峰~鍐欐偍鐨勬墜鏈哄彿鐮侊紒' },
-              { pattern: /^1[3456789]\d{9}$/, message: '鎵嬫満鍙风爜鏍煎紡閿欒锛�' }
+              { pattern: /^1[3456789]\d{9}$/, message: '鎵嬫満鍙风爜鏍煎紡閿欒锛�' },
             ]"
             placeholder="璇疯緭鍏ユ偍鐨勮仈绯荤數璇�"
           />
@@ -216,7 +216,11 @@
           </div>
           <div
             v-if="!stateDisable"
-            style="background-color: rgb(240, 240, 240); padding-top: 25px; height: 175px"
+            style="
+              background-color: rgb(240, 240, 240);
+              padding-top: 25px;
+              height: 175px;
+            "
           >
             <van-checkbox
               v-model="approve.agree"
@@ -241,7 +245,7 @@
             </div>
           </div>
           <div v-if="stateDisable && approve.state != 'WaitAudit'">
-            <div style="margin:40px;">
+            <div style="margin: 40px">
               <van-button round block type="info" @click="stateDisable = false"
                 >淇� 鏀�</van-button
               >
@@ -294,7 +298,7 @@
       protocolTxt: "",
       refCode: "",
       headers: {
-        Authorization: ""
+        Authorization: "",
       },
       submitDisabled: true, // 鎻愪氦鎸夐挳,榛樿绂侀��
       showPicker: false,
@@ -337,7 +341,7 @@
         //鐩稿叧璇佷欢
         certificate: [],
         // 鏁欏笀鍚屾剰鍕鹃�夋
-        checked: false
+        checked: false,
       },
       isUpdate: false,
 
@@ -358,7 +362,7 @@
         // description: "", //涓汉绠�浠�
         relevantCertificates: [], //鐩稿叧璇佷欢
         state: "", //瀹℃牳鐘舵�侀粯璁ゅ緟瀹℃牳
-        agree: false
+        agree: false,
       },
       //picker閫夋嫨鍒楄〃
       colunmsJob: [
@@ -370,7 +374,7 @@
         "绯诲壇涓讳换",
         "涓撲笟璐熻矗浜�",
         "涓讳换",
-        "鍏朵粬"
+        "鍏朵粬",
       ],
       colunmsTitle: ["姝i珮绾�", "楂樼骇", "涓�绾�", "浜岀骇", "涓夌骇", "鏃�"],
       colunmsEdu: ["澶т笓", "鏈", "纭曞+", "鍗氬+"],
@@ -379,14 +383,14 @@
       fileList: [],
       isWaitAudit: false,
       userId: "",
-      isFree: false
+      isFree: false,
     };
   },
   watch: {
     "approve.agree": {
       handler(val) {
         this.submitDisabled = !val;
-      }
+      },
     },
     $route(to, from) {
       if (
@@ -395,7 +399,7 @@
       ) {
         this.getProtocol();
       }
-    }
+    },
   },
   created() {
     var that = this;
@@ -432,7 +436,7 @@
     finishAddress({ selectedOptions }) {
       this.showPicker3 = false;
       this.approve.region = selectedOptions
-        .map(option => option.text)
+        .map((option) => option.text)
         .join("/");
     },
     deleteFile(file) {
@@ -444,33 +448,39 @@
     },
     getUserRole() {
       let that = this;
-      that.MG.identity.getCurrentAppUser().then(res => {
+      that.MG.identity.getCurrentAppUser().then((res) => {
         that.userId = res.userId;
-        let teacherRole = res.roleLinks.find(item => item.role?.refCode == "teacher");
-        let teacherInfo = res.infoList.find(item => item.type == "teacherInfo") ?? {};
-        let wechatInfo = res.infoList.find(item => item.type == "WeChat") ?? {};
-        let studentInfo = res.infoList.find(item => item.type == "Default");
-        let phoneInfo = res.secretList.find(item => item.type == "MobilePhone");
+        let teacherRole = res.roleLinks.find(
+          (item) => item.role?.refCode == "teacher"
+        );
+        let teacherInfo =
+          res.infoList.find((item) => item.type == "teacherInfo") ?? {};
+        let wechatInfo =
+          res.infoList.find((item) => item.type == "WeChat") ?? {};
+        let studentInfo = res.infoList.find((item) => item.type == "Default");
+        let phoneInfo = res.secretList.find(
+          (item) => item.type == "MobilePhone"
+        );
         if (teacherRole && teacherInfo) {
           this.$store.dispatch("setUserInfo", {
             ...teacherInfo,
             phoneNumber: phoneInfo?.credential,
             icon: wechatInfo?.icon,
             role: "Teacher",
-            roleId: teacherRole.role.id
+            roleId: teacherRole.role.id,
           });
         } else if (wechatInfo) {
           this.$store.dispatch("setUserInfo", {
             ...wechatInfo,
             phoneNumber: phoneInfo?.credential,
-            role: "Student"
+            role: "Student",
           });
         } else if (studentInfo) {
           this.$store.dispatch("setUserInfo", {
             ...studentInfo,
             icon: wechatInfo?.icon,
             phoneNumber: phoneInfo?.credential,
-            role: "Student"
+            role: "Student",
           });
         }
       });
@@ -478,9 +488,9 @@
 
     getType() {
       const data = {
-        refCodes: ["tourism_teacherCertification"]
+        refCodes: ["tourism_teacherCertification"],
       };
-      this.MG.resource.getCmsTypeByRefCode(data).then(res => {
+      this.MG.resource.getCmsTypeByRefCode(data).then((res) => {
         this.newGetTeacherInfo();
         this.worksInfo = res[0].cmsTypeLinks[0].children;
       });
@@ -496,15 +506,15 @@
         appRefCode: "tourismWebsite",
         sort: {
           type: "Desc",
-          field: "CreateDate"
-        }
+          field: "CreateDate",
+        },
       };
-      that.MG.ugc.getTopicMessageList(data).then(res => {
+      that.MG.ugc.getTopicMessageList(data).then((res) => {
         try {
           if (res.datas.length > 0) {
             that.fileList = [];
             const resData = res.datas.find(
-              i => i.appUserCreator.userId == that.userId
+              (i) => i.appUserCreator.userId == that.userId
             );
             that.approve = that.tool.resultsBytool(
               that.worksInfo,
@@ -528,7 +538,7 @@
             }
             if (that.approve.relevantCertificates.length > 0) {
               if (typeof that.approve.relevantCertificates == "object") {
-                that.approve.relevantCertificates.forEach(ele => {
+                that.approve.relevantCertificates.forEach((ele) => {
                   let imgObj = {
                     md5: ele.file.md5,
                     url:
@@ -537,7 +547,7 @@
                       ele.file.md5,
                     linkType: "LinkFile",
                     linkProtectType: "Public",
-                    isImage: true
+                    isImage: true,
                   };
                   that.fileList.push(imgObj);
                 });
@@ -550,7 +560,7 @@
                   md5: that.approve.relevantCertificates,
                   linkType: "LinkFile",
                   linkProtectType: "Public",
-                  isImage: true
+                  isImage: true,
                 };
                 that.fileList.push(imgObj);
               }
@@ -570,13 +580,13 @@
         .getItem({
           path: "tourism_protocol",
           fields: {
-            tourism_content: []
-          }
+            tourism_content: [],
+          },
         })
-        .then(res => {
+        .then((res) => {
           try {
             const data = res.datas.find(
-              e => e.refCode == "tourism_teacherCertificationAgreement"
+              (e) => e.refCode == "tourism_teacherCertificationAgreement"
             );
             this.protocolTxt = data ? data.tourism_content : "鏆傛棤鍗忚";
           } catch (error) {
@@ -609,7 +619,7 @@
               this.worksInfo,
               this.approve,
               this.fileList
-            )
+            ),
           };
           let basicInfo = JSON.parse(JSON.stringify(this.approve));
           delete basicInfo.agree;
@@ -620,16 +630,24 @@
               {
                 data: JSON.stringify(basicInfo),
                 name: basicInfo.fullName,
-                type: "teacherInfo"
-              }
-            ]
+                type: "teacherInfo",
+              },
+            ],
           };
-          this.MG.identity.setAppUserInfo(userInfo).then(res => {
+          this.MG.identity.setAppUserInfo(userInfo).then((res) => {
             this.MG.ugc.newTopicMessage(data).then(() => {
-              console.log(res);
               this.subLoading = true;
+              const fromRouter = this.$route.query;
               if (res !== false) {
                 that.newGetTeacherInfo();
+              }
+              if (fromRouter.from && fromRouter.from == "bookDetail") {
+                this.$router.replace({
+                  name: "bookDetail",
+                  query: {
+                    id: this.$route.query.id,
+                  },
+                });
               }
             });
           });
@@ -665,8 +683,8 @@
         newDataRequests: fields.newData,
         updateDataRequests: fields.updateData,
         delDataRequest: {
-          ids: []
-        }
+          ids: [],
+        },
       };
       delete basicInfo.tourism_relevantCertificates;
       delete basicInfo.agree;
@@ -677,17 +695,26 @@
           {
             data: JSON.stringify(basicInfo),
             name: basicInfo.fullName,
-            type: "newTeacherInfo"
-          }
-        ]
+            type: "newTeacherInfo",
+          },
+        ],
       };
-      this.MG.identity.setAppUserInfo(userInfo).then(res => {
+      this.MG.identity.setAppUserInfo(userInfo).then((res) => {
         if (res) {
-          this.MG.ugc.updateTopicMessage(data).then(res => {
+          this.MG.ugc.updateTopicMessage(data).then((res) => {
             this.subLoading = false;
+            const fromRouter = this.$route.query;
             if (res !== false) {
               this.getUserRole();
               this.newGetTeacherInfo();
+            }
+            if (fromRouter.from && fromRouter.from == "bookDetail") {
+              this.$router.replace({
+                name: "bookDetail",
+                query: {
+                  id: this.$route.query.id,
+                },
+              });
             }
           });
         }
@@ -737,7 +764,7 @@
       let size = 1024;
       that.tool
         .getFileMd5(file.file, size * 1024)
-        .then(e => {
+        .then((e) => {
           const imgData = new FormData();
           that.fileMd5 = e;
           imgData.append("Md5", e);
@@ -746,14 +773,14 @@
           imgData.append("FileType", FileType);
           imgData.append("MetaData", null);
           imgData.append("file", file.file);
-          that.MG.file.upload(imgData).then(res => {
+          that.MG.file.upload(imgData).then((res) => {
             if (res) {
               this.fileList.push({
                 md5: e,
                 url: this.config.requestCtx + `/file/GetPreViewImage?md5=` + e,
                 linkType: "LinkFile",
                 linkProtectType: "Public",
-                isImage: true
+                isImage: true,
               });
               this.approve.relevantCertificates = this.fileList;
               // this.fileList = this.approve.relevantCertificates
@@ -761,7 +788,7 @@
             }
           });
         })
-        .catch(e => {
+        .catch((e) => {
           that.isLoding = false;
           console.error(e);
         });
@@ -802,12 +829,12 @@
       }
       this.MG.store
         .getProductTypeField({
-          refCodes: ["post"]
+          refCodes: ["post"],
         })
-        .then(res => {
+        .then((res) => {
           if (res && res[0].config) {
             let list = JSON.parse(res[0].config).option;
-            list.forEach(item => {
+            list.forEach((item) => {
               item.text = item.name;
             });
             this.colunmsJob = list;
@@ -822,12 +849,12 @@
       }
       this.MG.store
         .getProductTypeField({
-          refCodes: ["positionalTitle"]
+          refCodes: ["positionalTitle"],
         })
-        .then(res => {
+        .then((res) => {
           if (res && res[0].config) {
             let list = JSON.parse(res[0].config).option;
-            list.forEach(item => {
+            list.forEach((item) => {
               item.text = item.name;
             });
             this.colunmsTitle = list;
@@ -841,12 +868,12 @@
       }
       this.MG.store
         .getProductTypeField({
-          refCodes: ["education"]
+          refCodes: ["education"],
         })
-        .then(res => {
+        .then((res) => {
           if (res && res[0].config) {
             let list = JSON.parse(res[0].config).option;
-            list.forEach(item => {
+            list.forEach((item) => {
               item.text = item.name;
             });
             this.colunmsEdu = list;
@@ -877,8 +904,8 @@
     onConfirm2(value) {
       this.approve.education = value.text;
       this.showPicker2 = false;
-    }
-  }
+    },
+  },
 };
 </script>
 

--
Gitblit v1.9.1