From 485fcbbc57cbf7495286359250135c482ec1360a Mon Sep 17 00:00:00 2001
From: litian <C21AF165>
Date: 星期五, 30 八月 2024 09:50:00 +0800
Subject: [PATCH] xz

---
 pages/digitalTextbooks/digitalTextbooksDetails/index.js |  157 ++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 121 insertions(+), 36 deletions(-)

diff --git a/pages/digitalTextbooks/digitalTextbooksDetails/index.js b/pages/digitalTextbooks/digitalTextbooksDetails/index.js
index 2f5b7dc..523ca07 100644
--- a/pages/digitalTextbooks/digitalTextbooksDetails/index.js
+++ b/pages/digitalTextbooks/digitalTextbooksDetails/index.js
@@ -7,6 +7,8 @@
 import {
   worksDataBytool
 } from "../../../assets/js/toolClass.js";
+import SparkMD5 from 'spark-md5'
+import FormData from '../../../utils/formdata/index.js';
 const app = getApp()
 Page({
 
@@ -53,7 +55,7 @@
     testResourceClickIocn: {
       name: "/static/images/digitalTextbooks/link-t-click@3x.png",
     },
-
+    showIndex1: '',
     catalogue: {
       name: "/static/images/digitalTextbooks/mulu-t@3x.png",
     },
@@ -61,13 +63,22 @@
       name: "/static/images/digitalTextbooks/mulu-t-click@3x.png",
     },
     userInfo: {
-      fullName: '' //鍚嶇О
+      fullName: '', //鍚嶇О
+      userPicture: '' //鐢宠璇佷功鐢ㄦ埛鍥剧墖
     },
+    pictureMd5: '',
     worksInfo: [],
     isCertificate: {},
     isLearn: false,
     isTest: false,
-    publishingUnit: ''
+    publishingUnit: '',
+    cbzsImg: '', //鍑虹増璇佷功base64
+    rzzsImg: '', //璁よ瘉璇佷功base64
+    visible: false,
+    showIndex: false,
+    closeBtn: false,
+    deleteBtn: false,
+    images: [],
   },
 
   /**
@@ -665,15 +676,13 @@
   suggestBtn() {
     // 妫�鏌ョ櫥褰曠姸鎬�
     const token = wx.getStorageSync(app.config.tokenKey);
-
     console.log(465);
-
-    const child = this.selectComponent("#suggest-component");
-    // if (token)
-    //   // child.showDialog();
-    //   this.setData({
-    //     showIndex: '1'
-    //   })
+    const child = this.selectComponent("#suggest-component1");
+    if (token)
+      // child.showDialog();
+      this.setData({
+        showIndex1: '1'
+      })
   },
 
   //鐢宠璇佷功
@@ -711,30 +720,30 @@
   },
 
   onCertificate() {
-    if (!this.data.isBuy) {
-      wx.showToast({
-        title: "璇峰厛璐拱锛屼綋楠屽畬鏁存湇鍔�",
-        icon: "none",
-        duration: 1000,
-      });
-      return false
-    }
-    if (!this.data.isLearn) {
-      wx.showToast({
-        title: "鎮ㄧ殑瀛︿範浠诲姟杩樻湭瀹屾垚锛屾殏涓嶈兘鐢宠璇佷功锛屽姞娌瑰摝锛�",
-        icon: "none",
-        duration: 1000,
-      });
-      return false
-    }
-    if (this.data.isCertificate && this.data.isCertificate.state == 'WaitAudit') {
-      wx.showToast({
-        title: "鎮ㄧ敵璇风殑璇佷功姝e湪瀹℃牳涓�",
-        icon: "none",
-        duration: 1000,
-      });
-      return false
-    }
+    // if (!this.data.isBuy) {
+    //   wx.showToast({
+    //     title: "璇峰厛璐拱锛屼綋楠屽畬鏁存湇鍔�",
+    //     icon: "none",
+    //     duration: 1000,
+    //   });
+    //   return false
+    // }
+    // if (!this.data.isLearn) {
+    //   wx.showToast({
+    //     title: "鎮ㄧ殑瀛︿範浠诲姟杩樻湭瀹屾垚锛屾殏涓嶈兘鐢宠璇佷功锛屽姞娌瑰摝锛�",
+    //     icon: "none",
+    //     duration: 1000,
+    //   });
+    //   return false
+    // }
+    // if (this.data.isCertificate && this.data.isCertificate.state == 'WaitAudit') {
+    //   wx.showToast({
+    //     title: "鎮ㄧ敵璇风殑璇佷功姝e湪瀹℃牳涓�",
+    //     icon: "none",
+    //     duration: 1000,
+    //   });
+    //   return false
+    // }
 
     var page = getCurrentPages().pop(); // 鑾峰彇褰撳墠椤甸潰瀹炰緥
     page.setData({
@@ -759,13 +768,89 @@
       "userInfo.fullName": e.detail.value,
     });
   },
+  uploadPicture() {
+    var that = this;
+    wx.chooseMedia({
+      count: 1, // 榛樿9
+      sizeType: ['original', 'compressed'], // 鍙互鎸囧畾鏄師鍥捐繕鏄帇缂╁浘锛岄粯璁や簩鑰呴兘鏈�
+      sourceType: ['album', 'camera'], // 鍙互鎸囧畾鏉ユ簮鏄浉鍐岃繕鏄浉鏈猴紝榛樿浜岃�呴兘鏈�
+      success: function (res) {
+        wx.getFileSystemManager().readFile({
+          filePath: res.tempFiles[0].tempFilePath, //閫夋嫨鍥剧墖杩斿洖鐨勭浉瀵硅矾寰�
+          // encoding: 'binary', //缂栫爜鏍煎紡
+          success: ress => {
+            //鎴愬姛鐨勫洖璋�
+            let spark = new SparkMD5.ArrayBuffer();
+            spark.append(ress.data);
+            let md5 = spark.end(false);
+            let formData = new FormData();
+            formData.append('Md5', md5);
+            formData.append('FileName', md5);
+            formData.append('FileType', res.tempFiles[0].fileType);
+            formData.appendFile("file", res.tempFiles[0].tempFilePath);
+            const data = formData.getData();
+            let _token = wx.getStorageSync(app.config.tokenKey);
+            let header = {};
+            if (_token == null) {
+              header["Authorization"] = `Basic ${Base64.encode(website.clientId + ":" + website.clientSecret)}`;
+            } else {
+              header["Authorization"] = `Bearer ` + _token;
+            }
+            new Promise((resolve, reject) => {
+              wx.request({
+                url: app.config.requestCtx + '/file/api/ApiUpload',
+                method: 'POST',
+                header: {
+                  'content-type': data.contentType,
+                  ...header
+                },
+                data: data.buffer,
+                success(res) {
+                  if (res.statusCode == 200) {
+                    resolve(res.data);
+                    if (res.data) {
+                      that.setData({
+                        'userInfo.userPicture': app.config.requestCtx + `/file/GetPreViewImage?md5=` + md5,
+                        pictureMd5: md5
+                      });
+                    }
+                  } else {
+                    reject('杩愯鏃堕敊璇�,璇风◢鍚庡啀璇�');
+                  }
+                }
+              })
+            })
+          }
+        })
+      }
+    });
+  },
+
   confirmM() {
     if (this.data.userInfo.fullName) {
+      if (this.data.pictureMd5 == '') {
+        wx.showToast({
+          title: "璇蜂笂浼犵収鐗�",
+          icon: "none",
+          duration: 1000,
+        });
+        return false
+      }
       let data = {}
+      let bookInfo = {
+        bookId: this.data.digitalsData.id,
+        icon: this.data.digitalsData.icon,
+        name: this.data.digitalsData.name,
+        author: this.data.digitalsData.author,
+        ISBN: this.data.digitalsData.isbn,
+        publicationDate: this.data.digitalsData.publicationDate,
+        userPicture: this.data.pictureMd5,
+        certificate: this.data.rzzsImg
+      }
       data = {
         topicIdOrRefCode: 'applyTextbookCertificate',
         name: this.data.userInfo.fullName,
-        content: JSON.stringify(this.data.digitalsData),
+        content: JSON.stringify(bookInfo),
         state: 'WaitAudit',
         cmsTypeRefCode: 'jsek_textbookCertificate',
         type: 'applyTextbook',

--
Gitblit v1.9.1