From 2abf00efb6d83426ad84342f17252a36aeb5a4e1 Mon Sep 17 00:00:00 2001
From: litian <C21AF165>
Date: 星期五, 27 九月 2024 16:09:29 +0800
Subject: [PATCH] rwd

---
 pages/retrievalPage/index.js |  465 +++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 302 insertions(+), 163 deletions(-)

diff --git a/pages/retrievalPage/index.js b/pages/retrievalPage/index.js
index 663142c..7c03f63 100644
--- a/pages/retrievalPage/index.js
+++ b/pages/retrievalPage/index.js
@@ -1,7 +1,9 @@
 // pages/retrievalPage/index.js
 import request from '../../assets/request/index'
 
-import { handleQueryResourceListData } from '../../assets/js/middleGround/tool'
+import {
+  handleQueryResourceListData
+} from '../../assets/js/middleGround/tool'
 const app = getApp()
 Page({
 
@@ -9,28 +11,69 @@
    * 椤甸潰鐨勫垵濮嬫暟鎹�
    */
   data: {
+    loading: true,
+    hidden: true,
+    input: '',
+    dialogKey: '',
+    showWithInput: false,
+    showTextAndTitleWithInput: false,
+    downloadLoadin: false,
     isMore: null,
-    tabPanelstyle: 'display:flex;justify-content:center;align-items:center;',
     navBarHeight: '',
     barHeight: '',
     searchVal: '',
-    bookData: [],   //鍥句功
+    bookData: [], //鍥句功
     bookTotal: 0,
-    courseData: [],  //璇剧▼
+    courseData: [], //璇剧▼
     courseTotal: 0,
-    digitalTextbooksData: [],  //鏁板瓧鏁欐潗
+    digitalTextbooksData: [], //鏁板瓧鏁欐潗
     digitalTextbooksTotal: 0,
     seminarData: [], //涓撻鐮旇
     seminarTotal: 0,
-    biblioClassificationData: [],//涔﹀睍
+    biblioClassificationData: [], //涔﹀睍
     biblioClassificationTotal: 0,
-    bookFairData: [],//涔︾洰
+    bookFairData: [], //涔︾洰
     bookFairTotal: 0,
     pageCount: {
       page: 1,
       total: 0,
     },
-    tabValue: ''
+    tabValue: '0',
+    tabPanelstyle: 'display:flex;justify-content:center;align-items:center;',
+    // tab閫夐」
+    tabList: [{
+        title: "鍥句功",
+        index: "0",
+        bookTotal: 0
+      },
+      {
+        title: "璇剧▼",
+        index: "1",
+        bookTotal: 0
+      },
+      {
+        title: "鏁板瓧鏁欐潗",
+        index: "2",
+        bookTotal: 0
+      }, {
+        title: "涓撻",
+        index: "3",
+        bookTotal: 0
+      },
+      {
+        title: "涔︾洰",
+        index: "4",
+        bookTotal: 0
+      },
+      {
+        title: "涔﹀睍",
+        index: "5",
+        bookTotal: 0
+      },
+    ],
+    tabsId: 0, //榛樿閫夊瀷涓鸿澶�
+    height: '',
+    inputStyle: 'border: 2rpx solid rgba(220,220,220,1);border-radius: 12rpx; padding: 0 0 0 16rpx;height:70rpx',
   },
 
   /**
@@ -45,19 +88,60 @@
       barHeight: systInfo.statusBarHeight,
       searchVal: options.searchVal
     })
-
-
     this.retrievalPageGet()
     this.bibliographyGet()
-    let event = {
+    let e = {
       detail: {
-
         value: "0"
       }
     }
-    this.onTabsChange(event)
+    this.onTabsChange(e)
+    // 妫�鏌ョ櫥褰曠姸鎬�
+    const token = wx.getStorageSync(app.config.tokenKey)
+    if (!token) {
+      loginInfo(app, (data) => {
+        if (data) {
+          this.getUserInfo()
+        }
+      })
+    } else {
+      this.getUserInfo()
+    }
+    var that = this;
+    // 鍔ㄦ�佽幏鍙栧睆骞曢珮搴�
+    wx.getSystemInfo({
+      success: (result) => {
+        that.setData({
+          height: result.windowHeight
+        });
+      },
+    })
   },
-
+  // 鑾峰彇鐧诲綍鐢ㄦ埛韬唤
+  getUserInfo() {
+    app.MG.identity.getCurrentAppUser().then(res => {
+      // 鐢ㄦ埛淇℃伅浼樺厛绾э細鏁欏笀璁よ瘉 > 寰俊 > 瀛︾敓锛堟敞鍐屾椂榛樿锛�
+      if (res) {
+        //鑾峰彇鐢ㄦ埛绫诲瀷
+        let teacherRole = res.roleLinks.find((item) => item.role.refCode == 'teacher')
+        let teacherInfos = res.infoList.find((item) => item.type == 'teacherInfo')
+        let eMailData = res.secretList.find(i => i.type == 'EMail')
+        if (eMailData) {
+          this.setData({
+            input: eMailData.credential
+          })
+        } else if (teacherRole && teacherInfos) {
+          this.setData({
+            input: JSON.parse(teacherInfos.data).email
+          })
+        } else {
+          this.setData({
+            input: ''
+          })
+        }
+      }
+    });
+  },
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚
    */
@@ -94,18 +178,10 @@
   },
 
   /**
-   * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁�
-   */
-  onReachBottom() {
-
-  },
-
-  /**
    * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜�
    */
-  onShareAppMessage() {
-
-  },
+  onShareAppMessage() {},
+  onShareTimeline() {},
   goBack() {
     wx.navigateBack();
   },
@@ -118,56 +194,22 @@
     this.bibliographyGet()
   },
 
-
   //鏍囩鐨勫垏鎹�
   onTabsChange(event) {
     const value = event.detail.value
-    // if (this.data.bookData <= 0 || this.data.courseData <= 0 || this.data.digitalTextbooksData <= 0 || this.data.seminarData <= 0 || this.data.biblioClassificationData <= 0 || this.data.bookFairData <= 0) {
-    //   this.setData({
-    //     isMore: true
-    //   })
-    // }
-    if (value === '0') {
-      this.setData({
-        tabValue: value,
-        isMore: false
-      })
+    this.setData({
+      tabValue: value,
+      isMore: false
+    })
 
-    } else if (value === '1') {
-      console.log(value, 'tab');
-      this.setData({
-        tabValue: value,
-        isMore: false
-      })
-    } else if (value === '2') {
-      this.setData({
-        tabValue: value,
-        isMore: false
-      })
-    } else if (value === '3') {
-      this.setData({
-        tabValue: value,
-        isMore: false
-      })
-    } else if (value === '4') {
-      this.setData({
-        tabValue: value,
-        isMore: false
-      })
-    } else if (value === '5') {
-      this.setData({
-        tabValue: value,
-        isMore: false
-      })
+    if (value === '4') {
+      this.bibliographyGet()
+    } else {
+      this.retrievalPageGet()
     }
-
   },
 
-
-
-
   retrievalPageGet() {
-
     let fields = {
       liveTime: [],
       lecturer: [],
@@ -186,7 +228,8 @@
         'Name*': this.data.searchVal.trim(),
         '||author*': this.data.searchVal.trim(),
         '||isbn*': this.data.searchVal.trim(),
-        '||seriesName*': this.data.searchVal.trim()
+        '||seriesName*': this.data.searchVal.trim(),
+        '||projectLeader*': this.data.searchVal.trim()
       }
 
     }
@@ -195,7 +238,7 @@
     let queryBook = {
       AccessControl: {
         Path: '*',
-        StoreRefCode: 'defaultGoodsStore27',
+        StoreRefCode: `defaultGoodsStore${app.config.appId}`,
         Type: '*',
         LinkType: ''
       },
@@ -203,11 +246,9 @@
         Start: 0,
         Size: this.data.pageCount.page * 9,
       },
-      SortQuery: [
-        {
-          LinkOrder: 'Desc'
-        }
-      ],
+      SortQuery: [{
+        LinkOrder: 'Desc'
+      }],
       CreateDate: [],
       Description: [],
       Name: [],
@@ -224,17 +265,15 @@
       ...searchObj,
       ...fields
     }
-
-
     let courseObj = {}
     if (this.data.searchVal) {
       courseObj = {
         'Name*': this.data.searchVal.trim(),
         '||author*': this.data.searchVal.trim(),
         '||isbn*': this.data.searchVal.trim(),
-        '||seriesName*': this.data.searchVal.trim()
+        '||seriesName*': this.data.searchVal.trim(),
+        '||projectLeader*': this.data.searchVal.trim()
       }
-
     }
     //璇剧▼
     let queryCourse = {
@@ -248,11 +287,9 @@
         Start: 0,
         Size: this.data.pageCount.page * 4
       },
-      SortQuery: [
-        {
-          LinkOrder: 'Desc'
-        }
-      ],
+      SortQuery: [{
+        LinkOrder: 'Desc'
+      }],
       CreateDate: [],
       Description: [],
       Name: [],
@@ -292,11 +329,9 @@
         Start: 0,
         Size: this.data.pageCount.page * 9,
       },
-      SortQuery: [
-        {
-          LinkOrder: 'Desc'
-        }
-      ],
+      SortQuery: [{
+        LinkOrder: 'Desc'
+      }],
       CreateDate: [],
       Description: [],
       Name: [],
@@ -313,8 +348,6 @@
       ...digitalTextbooksObj,
       ...fields
     }
-
-
     let seminarObj = {}
     if (this.data.searchVal) {
       seminarObj = {
@@ -337,11 +370,9 @@
         Start: 0,
         Size: this.data.pageCount.page * 6,
       },
-      SortQuery: [
-        {
-          LinkOrder: 'Desc'
-        }
-      ],
+      SortQuery: [{
+        LinkOrder: 'Desc'
+      }],
       CreateDate: [],
       Description: [],
       Name: [],
@@ -381,11 +412,9 @@
         Start: 0,
         Size: this.data.pageCount.page * 10
       },
-      SortQuery: [
-        {
-          LinkOrder: 'Desc'
-        }
-      ],
+      SortQuery: [{
+        LinkOrder: 'Desc'
+      }],
       CreateDate: [],
       Description: [],
       Name: [],
@@ -424,8 +453,6 @@
       method: 'post',
       data: body
     }).then((resp) => {
-      console.log(resp, 'resp');
-
       //鍥句功       0
       const data1 = resp[0]
       const datas1 = handleQueryResourceListData({
@@ -435,12 +462,8 @@
       this.setData({
         bookData: datas1,
         bookTotal: data1.totalCount,
-
+        [`tabList[${0}].bookTotal`]: data1.totalCount
       })
-
-
-
-
       //鏁板瓧璇剧▼    1
       const data2 = resp[1]
       const datas2 = handleQueryResourceListData({
@@ -449,11 +472,9 @@
       })
       this.setData({
         courseData: datas2,
-        courseTotal: data2.totalCount
+        courseTotal: data2.totalCount,
+        [`tabList[${1}].bookTotal`]: data2.totalCount
       })
-
-
-
       // 鏁板瓧鏁欐潗    2
       const data3 = resp[2]
       const datas3 = handleQueryResourceListData({
@@ -462,20 +483,19 @@
       })
       this.setData({
         digitalTextbooksData: datas3,
-        digitalTextbooksTotal: data3.totalCount
+        digitalTextbooksTotal: data3.totalCount,
+        [`tabList[${2}].bookTotal`]: data3.totalCount
       })
-
       // 涓撻鐮旇   3
-
       const data4 = resp[3]
       const datas4 = handleQueryResourceListData({
         datas: data4.datas,
         fields
       })
-
       this.setData({
         seminarData: datas4,
-        seminarTotal: data4.totalCount
+        seminarTotal: data4.totalCount,
+        [`tabList[${3}].bookTotal`]: data4.totalCount
       })
       // 涔﹀睍      4
       const data5 = resp[4]
@@ -483,24 +503,21 @@
         datas: data5.datas,
         fields
       })
-
       datas5.forEach((items) => {
         items.subtitleName = items.subtitle + items.name
       })
-      // console.log(datas5, 'sadasd');
       this.setData({
         biblioClassificationData: datas5,
-        biblioClassificationTotal: data5.totalCount
+        biblioClassificationTotal: data5.totalCount,
+        [`tabList[${5}].bookTotal`]: data5.totalCount
       })
-
-
-
-
+      this.setData({
+        loading: false,
+        hidden: false,
+        isMore: false
+      })
     })
     wx.stopPullDownRefresh()
-
-
-
   },
   bibliographyGet() {
     let bibliographyObj = {}
@@ -537,19 +554,17 @@
 
       this.setData({
         bookFairData: res.datas,
-        bookFairTotal: res.total
+        bookFairTotal: res.total,
+        [`tabList[${4}].bookTotal`]: res.total
       })
 
     })
     wx.stopPullDownRefresh()
   },
   downloadData(event) {
-    console.log(111);
     const item = event.currentTarget.dataset.item;
-    // console.log(item.datas.freeFile.Value);
     const URL = app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.datas.freeFile.Value
     item.determine = false
-    console.log(URL, 'URL');
     setTimeout(() => {
       if (URL) {
         item.determine = true
@@ -574,22 +589,49 @@
       }
     });
   },
+  openBookFair(event) {
+    const item = event.currentTarget.dataset.item
+    if (item.fileType == "pdf") {
+      wx.navigateTo({
+        url: "/packageBookService/pages/components/webView/index?md5=" +
+          item.freeFile +
+          "&fileName=" +
+          item.name +
+          "&fileType=" +
+          item.fileType + "&bookBuy=true"
+          // "&freePage=" +
+          // this.data.fileInfo.freePage +
+
+          +
+          "&bookId=" +
+          item.id,
+      });
+    } else {
+      Toast({
+        context: this,
+        selector: '#t-toast',
+        message: '姝や功涓嶈兘鏌ョ湅',
+        theme: 'warning',
+        direction: 'column',
+      });
+    }
+  },
   onSearchSubmit() {
-    console.log(this.data.searchVal);
+    this.setData({
+      loading: true,
+      hidden: true,
+    })
     this.retrievalPageGet()
     this.bibliographyGet()
   },
   onBook(e) {
-    console.log(e.currentTarget.dataset.item);
     const item = e.currentTarget.dataset.item
     wx.navigateTo({
       url: '/packageBookService/pages/bookServices/detail/index?id=' + item.id + '&name=' + item.name
     })
   },
   onBookExhibitionDetails(e) {
-    console.log(e.currentTarget.dataset.item);
     const item = e.currentTarget.dataset.item
-
     wx.navigateTo({
       url: '/pages/bookExhibitionDetails/index?id=' + item.id + '&bookName=' + item.name // 鍋囪璺宠浆鍒拌鎯呴〉闈紝骞朵紶閫掍簡id鍙傛暟
     });
@@ -599,12 +641,119 @@
   onPullDownRefresh() {
     console.log("涓嬫媺鍒锋柊...");
   },
-  /**
-     * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁�
-     */
-  onReachBottom(e) {
+
+  // 涓嬫媺鍑芥暟
+  onPullDownRefresh() {
+    if (this.data.tabValue == 4) {
+      this.setData({
+        bookFairData: [],
+        "pageCount.page": 1
+      })
+      this.bibliographyGet()
+    } else {
+      this.setData({
+        bookData: [],
+        courseData: [],
+        digitalTextbooksData: [],
+        seminarData: [],
+        biblioClassificationData: [],
+        "pageCount.page": 1
+      })
+      this.retrievalPageGet()
+    }
+  },
+
+  underConstruction(e) {
+    const {
+      book
+    } = e.currentTarget.dataset;
+    console.log(book);
+    wx.navigateTo({
+      url: '/pages/digitalCourses/digitalCoursesDetails/index?id=' + book.id + '&path=' + book.idPath,
+    });
+  },
+  goTextBookDetail(e) {
+    const {
+      item
+    } = e.currentTarget.dataset;
+    wx.navigateTo({
+      url: '/pages/digitalTextbooks/digitalTextbooksDetails/index?id=' + item.id,
+    });
+  },
+  goSubjectDetail(e) {
+    // return wx.showToast({
+    //   title: "寤鸿涓�",
+    //   icon: 'none',
+    //   duration: 1000
+    // })
+    const item = e.currentTarget.dataset.item
+    // 缃戦〉绫诲瀷璺宠浆鍒扮綉鍧�澶嶅埗椤碉紝鍥犱负url浼犲弬涓嶈兘浼� 甯﹀弬鏁扮殑缃戠粶鍦板潃锛屾墍浠ユ澶勮鎶婄綉缁滃湴鍧�閲岀殑浼犲弬鎽樺嚭鏉ワ紝鏀惧埌url閲�
+    let urlData = ''
+    const flags = item.jsek_link.indexOf("?")
+    if (flags > -1) {
+      urlData = item.jsek_link.slice(flags + 1, item.jsek_link.length)
+    }
+    let url = '/packageBookService/pages/bookServices/linkPage/index'
+    wx.navigateTo({
+      url: urlData ? url + `?path=${item.jsek_link.slice(0,flags)}` + '&' + urlData : url + `?path=${item.jsek_link}`
+    })
+
+  },
+  // 閭鐐瑰嚮
+  mailbox(e) {
+    const key = e.currentTarget.dataset.key;
+    const item = e.currentTarget.dataset.item;
+    this.setData({
+      [key]: true,
+      dialogKey: key,
+      Md5: item.datas.freeFile.FileList[0].Md5
+    });
+  },
+  //閭鐨勬牎楠�
+  onEmailInput(e) {
+    const isEmailValid = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/.test(e.detail.value);
+    this.setData({
+      emailError: !isEmailValid,
+      "input": e.detail.value,
+    });
+  },
+  //寮圭獥纭
+  onConfirm() {
+    if (!this.data.emailError && this.data.input) {
+      const {
+        dialogKey
+      } = this.data;
+      this.setData({
+        [dialogKey]: false
+      });
+      if (this.data.input) {
+        let query = {
+          eMail: this.data.input,
+          md5s: [this.data.Md5]
+        }
+        app.MG.file.sendFileWithEmail(query).then(res => {
+          console.log(res);
+        })
+      }
+    } else {
+      // 鏍¢獙涓嶉�氳繃锛岀粰鍑洪敊璇彁绀�
+      wx.showToast({
+        title: '閭鏍煎紡涓嶆纭�',
+        icon: 'none',
+      });
+    }
+  },
+  // 寮圭獥鍙栨秷
+  closeDialog() {
+    const {
+      dialogKey
+    } = this.data;
+    this.setData({
+      [dialogKey]: false
+    });
+  },
+  onScrollToLower() {
     if (this.data.tabValue == 0) {
-      console.log(0);
       if (this.data.bookData.length < this.data.bookTotal) {
         this.setData({
           isMore: true,
@@ -642,7 +791,6 @@
         }, 100)
 
       }
-      console.log(2);
     } else if (this.data.tabValue == 2) {
 
       if (this.data.digitalTextbooksData.length < this.data.digitalTextbooksTotal && this.data.digitalTextbooksData.length > 9) {
@@ -662,7 +810,6 @@
         }, 100)
 
       }
-      console.log(2);
     } else if (this.data.tabValue == 3) {
       if (this.data.seminarData.length < this.data.seminarTotal) {
         this.setData({
@@ -680,7 +827,6 @@
           })
         }, 100)
       }
-      console.log(3);
     } else if (this.data.tabValue == 4) {
       if (this.data.bookFairData.length < this.data.bookFairTotal) {
         this.setData({
@@ -698,7 +844,6 @@
           })
         }, 100)
       }
-      console.log(4);
     } else if (this.data.tabValue == 5) {
       if (this.data.biblioClassificationData.length < this.data.biblioClassificationTotal) {
         this.setData({
@@ -715,30 +860,24 @@
             isMore: false
           })
         }, 100)
-
       }
     }
-
-
-
   },
 
-  // 涓嬫媺鍑芥暟
-  onPullDownRefresh() {
-
-    if (this.data.tabValue == 4) {
-      this.setData({
-        "pageCount.page": 1
-      })
-      this.bibliographyGet()
-    } else {
-      this.setData({
-        "pageCount.page": 1
-      })
-      this.retrievalPageGet()
-    }
-
-
-
+  // 婊戝姩鏃惰Е鍙戠殑浜嬩欢
+  slideOn(e) {
+    // 鎷垮埌褰撳墠绱㈠紩骞跺姩鎬佹敼鍙�
+    this.setData({
+      tabsId: e.detail.current
+    })
   },
+
+  //鐐瑰嚮tab鏃惰Е鍙�
+  tabsOn(e) {
+    this.setData({
+      //鎷垮埌褰撳墠绱㈠紩骞跺姩鎬佹敼鍙�
+      tabsId: e.currentTarget.dataset.idx
+    })
+  },
+
 })
\ No newline at end of file

--
Gitblit v1.9.1