From 81c23f9c2f5bdfbe962d0b19a5a80ea7c12f043d Mon Sep 17 00:00:00 2001 From: litian <C21AF165> Date: 星期三, 10 七月 2024 17:39:02 +0800 Subject: [PATCH] 二维码 --- pages/bibliographyList/index.js | 931 ++++++++++++++++++++++++++++++--------------------------- 1 files changed, 486 insertions(+), 445 deletions(-) diff --git a/pages/bibliographyList/index.js b/pages/bibliographyList/index.js index 9043fb8..f1bca7e 100644 --- a/pages/bibliographyList/index.js +++ b/pages/bibliographyList/index.js @@ -1,471 +1,512 @@ // pages/bibliographyList/index.js import Toast from 'tdesign-miniprogram/toast/index'; const app = getApp() -const config = - Page({ +import { + loginInfo +} from '../../assets/js/login'; +Page({ - /** - * 椤甸潰鐨勫垵濮嬫暟鎹� - */ - data: { - hiddenmodalput: false, - name: "", - phoneNum: '', - input: '', - dialogKey: '', - showWithInput: false, - showTextAndTitleWithInput: false, - downloadLoadin: false, + /** + * 椤甸潰鐨勫垵濮嬫暟鎹� + */ + data: { + personalDataEmail: '', + hiddenmodalput: false, + name: "", + phoneNum: '', + input: '', + dialogKey: '', + showWithInput: false, + showTextAndTitleWithInput: false, + downloadLoadin: false, + isMore: null, + higherList: [], + vocationalList: [], + teacherList: [], + higherTotal: 0, + vocationalTotal: 0, + teacherTotal: 0, + value: '', + BarHeight: '', + navBarHeight: '', + start: 1, + tabValue: '', + keyword: '', + Md5: '', + emailError: false, + loading: true, //寮�鍚鏋跺睆鍔犺浇 + hidden: true, //鏄惁灞曠ず鍐呭 + height: '', + dialogBox: false, + inputStyle: 'border: 2rpx solid rgba(220,220,220,1);border-radius: 12rpx; padding: 0 0 0 16rpx;height:70rpx', + }, + + /** + * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇 + */ + onLoad(options) { + this.higherGet() + this.vocationalGet() + this.teacherGet() + const systInfo = wx.getSystemInfoSync(); + const menu = wx.getMenuButtonBoundingClientRect(); // 鑳跺泭淇℃伅 + const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 瀵艰埅鏍忛珮搴� + this.setData({ + navBarHeight: navBarHeight, + barHeight: systInfo.statusBarHeight, + }) + let event = { + detail: { + value: "0" + } + } + this.onTabsChange(event) + var that = this; + // 鍔ㄦ�佽幏鍙栧睆骞曢珮搴� + wx.getSystemInfo({ + success: (result) => { + that.setData({ + height: result.windowHeight + }); + }, + }) + }, + + /** + * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚 + */ + onReady() { + + }, + + /** + * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず + */ + onShow() { + // console.log(this.data.value); + // 妫�鏌ョ櫥褰曠姸鎬� + const token = wx.getStorageSync(app.config.tokenKey) + if (!token) { + loginInfo(app, (data) => { + if (data) { + this.getUserInfo() + } + }) + } else { + this.getUserInfo() + } + }, + + /** + * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌 + */ + onHide() { + + }, + + /** + * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍗歌浇 + */ + onUnload() { + + }, + + /** + * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔 + */ + onPullDownRefresh() { + + }, + + /** + * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁� + */ + onReachBottom() { + + }, + + /** + * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜� + */ + onShareAppMessage() { + + }, + // 鑾峰彇鐧诲綍鐢ㄦ埛韬唤 + 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: '' + }) + } + } + }); + }, + + onTabsChange(event) { + const value = event.detail.value + this.setData({ isMore: null, - higherList: [], - vocationalList: [], - teacherList: [], - higherTotal: 0, - vocationalTotal: 0, - teacherTotal: 0, - value: '', - BarHeight: '', - navBarHeight: '', - start: 1, - tabValue: '', - keyword: '', - Md5: '', - emailError: false, - loading: true, //寮�鍚鏋跺睆鍔犺浇 - hidden: true, //鏄惁灞曠ず鍐呭 - height: '', - dialogBox: false, - inputStyle: 'border: 2rpx solid rgba(220,220,220,1);border-radius: 12rpx; padding: 0 0 0 16rpx;height:70rpx', - }, - - /** - * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇 - */ - onLoad(options) { + tabValue: value, + }) + if (value == '0') { this.higherGet() + } else if (value == '1') { this.vocationalGet() + } else if (value == '2') { this.teacherGet() - const systInfo = wx.getSystemInfoSync(); - const menu = wx.getMenuButtonBoundingClientRect(); // 鑳跺泭淇℃伅 - const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 瀵艰埅鏍忛珮搴� - this.setData({ - navBarHeight: navBarHeight, - barHeight: systInfo.statusBarHeight, + } + }, + //楂樼瓑鏁欒偛 + higherGet(keyword) { + let searchObj = { + 'Name*': keyword, + '||author*': keyword, + '||isbn*': keyword + } + app.MG.resource.getItem({ + path: 'jsek_biblioClassification\\jsek_bCHigherEducation', + queryType: '*', + paging: { + start: '0', + size: this.data.start * 9 + }, + coverSize: { + width: 260 + }, + fields: { + jsek_link: [], + subtitle: [], + content: [], + fileType: [], + jsek_resource: [], + freeFile: [], + ...searchObj, + }, + SysType: 'CmsItem' + }).then(res => { + res.datas.forEach(item => { + item.determine = true }) - let event = { - detail: { - value: "0" - } + this.setData({ + higherList: res.datas, + higherTotal: res.total + }) + this.setData({ + loading: false, //寮�鍚鏋跺睆鍔犺浇 + hidden: false, //鏄惁灞曠ず鍐呭 + }) + if (res.datas.length < 7 && res.datas.length > 0) { + this.setData({ + isMore: false + }) } - this.onTabsChange(event) - var that = this; - // 鍔ㄦ�佽幏鍙栧睆骞曢珮搴� - wx.getSystemInfo({ - success: (result) => { - that.setData({ - height: result.windowHeight - }); - }, + }) + wx.stopPullDownRefresh() + }, + + //鏁欏笀鏁欒偛 + vocationalGet(keyword) { + let searchObj = { + 'Name*': keyword, + '||author*': keyword, + '||isbn*': keyword + } + app.MG.resource.getItem({ + path: 'jsek_biblioClassification\\jsek_bCVocationalEducation', + queryType: '*', + paging: { + start: '0', + size: this.data.start * 9 + }, + coverSize: { + width: 260 + }, + fields: { + jsek_link: [], + content: [], + subtitle: [], + fileType: [], + jsek_resource: [], + freeFile: [], + ...searchObj + }, + SysType: 'CmsItem' + }).then(res => { + console.log(res); + res.datas.forEach(item => { + item.determine = true }) - }, - - /** - * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚 - */ - onReady() { - - }, - - /** - * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず - */ - onShow() { - // console.log(this.data.value); - - }, - - /** - * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌 - */ - onHide() { - - }, - - /** - * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍗歌浇 - */ - onUnload() { - - }, - - /** - * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔 - */ - onPullDownRefresh() { - - }, - - /** - * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁� - */ - onReachBottom() { - - }, - - /** - * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜� - */ - onShareAppMessage() { - - }, - onTabsChange(event) { - const value = event.detail.value this.setData({ - isMore: null, - tabValue: value, + vocationalList: res.datas, + vocationalTotal: res.total }) - if (value == '0') { + if (res.datas.length < 7 && this.datas.length > 0) { + this.setData({ + isMore: false + }) + } + }) + wx.stopPullDownRefresh() + }, + // 鑱屼笟鏁欒偛 + teacherGet(keyword) { + let searchObj = { + 'Name*': keyword, + '||author*': keyword, + '||isbn*': keyword + } + app.MG.resource.getItem({ + path: 'jsek_biblioClassification\\jsek_bCTeacherEducation', + queryType: '*', + paging: { + start: '0', + size: this.data.start * 9 + }, + coverSize: { + width: 260 + }, + fields: { + jsek_link: [], + content: [], + subtitle: [], + fileType: [], + jsek_resource: [], + freeFile: [], + bookshelf_freeEpub: [], //epub璇曡鐧惧垎姣� + bookshelf_probationPage: [], //pdf璇曡椤垫暟 + ...searchObj + }, + SysType: 'CmsItem' + }).then(res => { + res.datas.forEach(item => { + item.determine = true + }) + this.setData({ + teacherList: res.datas, + teacherTotal: res.total + }) + if (res.datas.length < 7 && this.datas.length > 0) { + this.setData({ + isMore: false + }) + } + }) + wx.stopPullDownRefresh() + }, + // downloadData(event) { + // this.setData({ + // downloadLoadin: true + // }) + // 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 + // } + // }, 600) + // wx.downloadFile({ + // url: URL, + // success: function (res) { + // const filePath = res.tempFilePath; + // wx.openDocument({ + // filePath: filePath, + // success: function (res) { + // console.log('鎵撳紑鏂囨。鎴愬姛'); + // }, + // fail: function (res) { + // console.log('鎵撳紑鏂囨。澶辫触', res); + // } + // }); + // }, + // fail: function (res) { + // console.log('涓嬭浇鏂囦欢澶辫触', res); + // } + // }); + // setTimeout(() => { + // this.setData({ + // downloadLoadin: false + // }); + // }, 2000); + // }, + downloadData(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: function (e) { + const keyword = e.detail.value; + // 澶勭悊鎼滅储閫昏緫锛屼緥濡傚彂閫佹悳绱㈣姹傜瓑 + console.log('鎼滅储鍏抽敭璇嶏細', keyword); + this.higherGet(keyword) + this.vocationalGet(keyword) + this.teacherGet(keyword) + }, + goBack() { + wx.navigateBack(); + }, + onReachBottom(e) { + if (this.data.tabValue == 0) { + if (this.data.higherList.length < this.data.higherTotal) { + this.setData({ + isMore: true, + start: this.data.start + 1 + }) this.higherGet() - } else if (value == '1') { - this.vocationalGet() - } else if (value == '2') { - this.teacherGet() - } - }, - //楂樼瓑鏁欒偛 - higherGet(keyword) { - let searchObj = { - 'Name*': keyword, - '||author*': keyword, - '||isbn*': keyword - } - app.MG.resource.getItem({ - path: 'jsek_biblioClassification\\jsek_bCHigherEducation', - queryType: '*', - paging: { - start: '0', - size: this.data.start * 9 - }, - coverSize: { - width: 260 - }, - fields: { - jsek_link: [], - content: [], - subtitle: [], - fileType: [], - jsek_resource: [], - freeFile: [], - ...searchObj, - }, - SysType: 'CmsItem' - }).then(res => { - res.datas.forEach(item => { - item.determine = true - }) - this.setData({ - higherList: res.datas, - higherTotal: res.total - }) - this.setData({ - loading: false, //寮�鍚鏋跺睆鍔犺浇 - hidden: false, //鏄惁灞曠ず鍐呭 - }) - if (res.datas.length < 7 && res.datas.length > 0) { - this.setData({ - isMore: false - }) - } - }) - wx.stopPullDownRefresh() - }, - - //鏁欏笀鏁欒偛 - vocationalGet(keyword) { - let searchObj = { - 'Name*': keyword, - '||author*': keyword, - '||isbn*': keyword - } - app.MG.resource.getItem({ - path: 'jsek_biblioClassification\\jsek_bCVocationalEducation', - queryType: '*', - paging: { - start: '0', - size: this.data.start * 9 - }, - coverSize: { - width: 260 - }, - fields: { - jsek_link: [], - content: [], - subtitle: [], - fileType: [], - jsek_resource: [], - freeFile: [], - ...searchObj - }, - SysType: 'CmsItem' - }).then(res => { - console.log(res); - res.datas.forEach(item => { - item.determine = true - }) - this.setData({ - vocationalList: res.datas, - vocationalTotal: res.total - }) - if (res.datas.length < 7 && this.datas.length > 0) { - this.setData({ - isMore: false - }) - } - }) - wx.stopPullDownRefresh() - }, - // 鑱屼笟鏁欒偛 - teacherGet(keyword) { - let searchObj = { - 'Name*': keyword, - '||author*': keyword, - '||isbn*': keyword - } - app.MG.resource.getItem({ - path: 'jsek_biblioClassification\\jsek_bCTeacherEducation', - queryType: '*', - paging: { - start: '0', - size: this.data.start * 9 - }, - coverSize: { - width: 260 - }, - fields: { - jsek_link: [], - content: [], - subtitle: [], - fileType: [], - jsek_resource: [], - freeFile: [], - bookshelf_freeEpub: [], //epub璇曡鐧惧垎姣� - bookshelf_probationPage: [], //pdf璇曡椤垫暟 - ...searchObj - }, - SysType: 'CmsItem' - }).then(res => { - res.datas.forEach(item => { - item.determine = true - }) - this.setData({ - teacherList: res.datas, - teacherTotal: res.total - }) - if (res.datas.length < 7 && this.datas.length > 0) { - this.setData({ - isMore: false - }) - } - }) - wx.stopPullDownRefresh() - }, - // downloadData(event) { - // this.setData({ - // downloadLoadin: true - // }) - // 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 - // } - // }, 600) - // wx.downloadFile({ - // url: URL, - // success: function (res) { - // const filePath = res.tempFilePath; - // wx.openDocument({ - // filePath: filePath, - // success: function (res) { - // console.log('鎵撳紑鏂囨。鎴愬姛'); - // }, - // fail: function (res) { - // console.log('鎵撳紑鏂囨。澶辫触', res); - // } - // }); - // }, - // fail: function (res) { - // console.log('涓嬭浇鏂囦欢澶辫触', res); - // } - // }); - // setTimeout(() => { - // this.setData({ - // downloadLoadin: false - // }); - // }, 2000); - // }, - downloadData(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', - }); + this.setData({ + isMore: true, + }) + setTimeout(() => { + this.setData({ + isMore: false + }) + }, 100) } - }, - onSearchSubmit: function (e) { - const keyword = e.detail.value; - // 澶勭悊鎼滅储閫昏緫锛屼緥濡傚彂閫佹悳绱㈣姹傜瓑 - console.log('鎼滅储鍏抽敭璇嶏細', keyword); - this.higherGet(keyword) - this.vocationalGet(keyword) - this.teacherGet(keyword) - }, - goBack() { - wx.navigateBack(); - }, - onReachBottom(e) { - if (this.data.tabValue == 0) { - if (this.data.higherList.length < this.data.higherTotal) { + } else if (this.data.tabValue == 2) { + if (this.data.teacherList.length < this.data.teacherTotal) { + this.setData({ + isMore: true, + start: this.data.start + 1 + }) + this.teacherGet() + } else { + this.setData({ + isMore: true, + }) + setTimeout(() => { this.setData({ - isMore: true, - start: this.data.start + 1 + isMore: false }) - this.higherGet() - } else { - this.setData({ - isMore: true, - }) - setTimeout(() => { - this.setData({ - isMore: false - }) - }, 100) - } - } else if (this.data.tabValue == 2) { - if (this.data.teacherList.length < this.data.teacherTotal) { - this.setData({ - isMore: true, - start: this.data.start + 1 - }) - this.teacherGet() - } else { - this.setData({ - isMore: true, - }) - setTimeout(() => { - this.setData({ - isMore: false - }) - }, 100) - } - } else if (this.data.tabValue == 1) { - console.log(this.data.vocationalList.length); - console.log(this.data.vocationalTotal); - if (this.data.vocationalList.length < this.data.vocationalTotal) { - this.setData({ - isMore: true, - start: this.data.start + 1 - }) - this.vocationalGet() - } else { - this.setData({ - isMore: true, - }) - setTimeout(() => { - this.setData({ - isMore: false - }) - }, 100) - } + }, 100) } - }, + } else if (this.data.tabValue == 1) { + console.log(this.data.vocationalList.length); + console.log(this.data.vocationalTotal); + if (this.data.vocationalList.length < this.data.vocationalTotal) { + this.setData({ + isMore: true, + start: this.data.start + 1 + }) + this.vocationalGet() + } else { + this.setData({ + isMore: true, + }) + setTimeout(() => { + this.setData({ + isMore: false + }) + }, 100) + } + } + }, - onPullDownRefresh() { - let keyword = this.data.value - this.setData({ - start: 1, - }) - this.higherGet(keyword) - this.vocationalGet(keyword) - this.teacherGet(keyword) - }, - // 閭鐐瑰嚮 - mailbox(e) { - const key = e.currentTarget.dataset.key; - const item = e.currentTarget.dataset.item; - this.setData({ - Md5: item.datas.freeFile.FileList[0].Md5, - dialogBox: true - }) - // wx.scanCode({ - // success: res => { - // console.log(res); - // } - // }) - }, - // 寮圭獥鍙栨秷 - closeDialog() { + onPullDownRefresh() { + let keyword = this.data.value + this.setData({ + start: 1, + }) + this.higherGet(keyword) + this.vocationalGet(keyword) + this.teacherGet(keyword) + }, + // 閭鐐瑰嚮 + mailbox(e) { + const key = e.currentTarget.dataset.key; + const item = e.currentTarget.dataset.item; + this.setData({ + Md5: item.datas.freeFile.FileList[0].Md5, + dialogBox: true + }) + // wx.scanCode({ + // success: res => { + // console.log(res); + // } + // }) + }, + // 寮圭獥鍙栨秷 + closeDialog() { + this.setData({ + dialogBox: false, + // input: '' + }) + }, + //鎻愪氦 + confirmM(e) { + wx.showLoading({ + title: '鍙戦�佷腑...', + }) + const isEmailValid = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/.test(this.data.input); + if (isEmailValid && this.data.input) { this.setData({ dialogBox: false }) - }, - //鎻愪氦 - confirmM(e) { - wx.showLoading({ - title: '鍙戦�佷腑...', - }) - const isEmailValid = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/.test(this.data.input); - if (isEmailValid && this.data.input) { - this.setData({ - dialogBox: false - }) - let query = { - eMail: this.data.input, - md5s: [this.data.Md5] - } - app.MG.file.sendFileWithEmail(query).then(res => { - wx.hideLoading() - if (res) { - wx.showToast({ - icon: 'success', - title: '閭欢宸插彂閫�', - }) - } - }) - } else { - // 鏍¢獙涓嶉�氳繃锛岀粰鍑洪敊璇彁绀� - wx.showToast({ - title: '閭鏍煎紡涓嶆纭�', - icon: 'none', - }); + let query = { + eMail: this.data.input, + md5s: [this.data.Md5] } - }, - inputChange(e) { - this.setData({ - input: e.detail.value + app.MG.file.sendFileWithEmail(query).then(res => { + wx.hideLoading() + if (res) { + wx.showToast({ + icon: 'success', + title: '閭欢宸插彂閫�', + }) + } }) + } else { + // 鏍¢獙涓嶉�氳繃锛岀粰鍑洪敊璇彁绀� + wx.showToast({ + title: '閭鏍煎紡涓嶆纭�', + icon: 'none', + }); } - }) \ No newline at end of file + }, + inputChange(e) { + this.setData({ + input: e.detail.value + }) + }, + +}) \ No newline at end of file -- Gitblit v1.9.1