From aacb4b111141c9b37397b528eae1668245ac93b2 Mon Sep 17 00:00:00 2001 From: litian <C21AF165> Date: 星期五, 22 三月 2024 11:16:41 +0800 Subject: [PATCH] 样书 --- packagePersonal/pages/userSetting/index.wxml | 18 + packagePersonal/pages/userSetting/index.wxss | 21 + assets/js/toolClass.js | 1 packagePersonal/pages/myCollection/index.js | 2 packageBookService/pages/bookServices/detail/index.wxml | 13 packageBookService/pages/bookServices/detail/index.wxss | 38 +++ packageDomain/pages/sampleBookList/applicationForm/index.js | 10 packageBookService/pages/bookServices/detail/index.js | 444 ++++++++++++++++++++++++++++++++++-- pages/personalCenter/components/user-center-card/index.wxml | 4 packageDomain/pages/sampleBookList/applicationForm/index.wxss | 5 pages/personalCenter/index.js | 13 packagePersonal/pages/userSetting/index.js | 125 +++++++++ 12 files changed, 626 insertions(+), 68 deletions(-) diff --git a/assets/js/toolClass.js b/assets/js/toolClass.js index c173046..ee88bba 100644 --- a/assets/js/toolClass.js +++ b/assets/js/toolClass.js @@ -163,6 +163,7 @@ }) ) } + res.forEach((item) => { const obj = { baseType: item.typeField.baseType, diff --git a/packageBookService/pages/bookServices/detail/index.js b/packageBookService/pages/bookServices/detail/index.js index 7addb7f..5211b66 100644 --- a/packageBookService/pages/bookServices/detail/index.js +++ b/packageBookService/pages/bookServices/detail/index.js @@ -16,6 +16,7 @@ name: '', }, bookDetail: {}, + bookItemDetail: {}, link: { jd: '', tamll: '', @@ -53,7 +54,19 @@ }, flag: true, applyResourceLoading: false, - noResources: false + noResources: false, + selectedIds: "",//鍟嗗搧鎴栧瓙鍟嗗搧閿�鍞柟寮� + bookBuy: false, //鍟嗗搧鎴栧瓙鍟嗗搧鏄惁璐拱 + expire: false,//鍟嗗搧鎴栧瓙鍟嗗搧閿�鍞柟寮忔槸鍚﹁繃鏈� + noFile: false, //鍟嗗搧鎴栧瓙鍟嗘湁鏃犵數瀛愪功鏂囦欢 + num: 0, //鏍蜂功鐢宠鍗曟暟閲� + alreadyPaperBookList: [], //宸茬敵璇风焊璐ㄦ牱涔� + alreadyElectronicBookList: [], //宸茬敵璇风數瀛愭牱涔� + paperBookList: [], //鏍蜂功鍗曠焊璐ㄤ功 + electronicBookList: [], //鏍蜂功鍗曠數瀛愪功 + paperBookCount: 0, //绾歌川涔﹀墿浣欐鏁� + ebookCount: 0, //鐢靛瓙涔﹀墿浣欐鏁� + userInfo: {}, }, @@ -81,6 +94,7 @@ name: options.name, }, }); + this.getBookInfo(options.id); this.getResourceClass() // 鑾峰彇璧勬簮鎵�灞炲垎绫� const token = wx.getStorageSync('jsek-token') @@ -89,6 +103,24 @@ this.getApplyInfo(options.id) this.getMockData() } + if (wx.getStorageSync(app.config.userInfoKey)) { + this.setData({ + userInfo: JSON.parse(wx.getStorageSync(app.config.userInfoKey)) + }) + } + if (wx.getStorageSync("paperBookList")) { + this.setData({ + paperBookList: wx.getStorageSync("paperBookList"), + }) + } + if (wx.getStorageSync("electronicBookList")) { + this.setData({ + electronicBookList: wx.getStorageSync("electronicBookList"), + }) + } + this.setData({ + num: this.data.paperBookList.length + this.data.electronicBookList.length + }) }, /** @@ -238,6 +270,7 @@ cmsDatas: res.datas.cmsDatas[0].datas, buyIdList: res.datas.purchasedSaleMethodIdList }); + this.getSubTtem(); // 鑾峰彇鍥句功鍒嗙被 const iconType = JSON.parse(res.datas.bookClassification)[0][0]; const classType = JSON.parse(res.datas.bookClassification)[0][1]; @@ -274,6 +307,76 @@ console.log('鍥句功淇℃伅', this.data.bookDetail); }); + }, + //璇锋眰瀛愬晢鍝佺殑鏂囦欢 + getSubTtem() { + const obj = { + path: '*', + queryType: 'SubProduct', + sort: { + type: 'Desc', + field: 'CreateDate' + }, + paging: { + start: 0, + size: 6 + }, + mainProductId: this.data.bookDetail.id, + fields: { + author: [], + bookshelf_pdf: [], + bookshelf_protectedEpub: [], + bookshelf_freeEpub: [], //epub璇曡鐧惧垎姣� + bookshelf_probationPage: [] //pdf璇曡椤垫暟 + } + } + app.MG.store.getProductList(obj).then((res) => { + if (res.datas && res.datas.length > 0) { + this.setData({ + bookItemDetail: res.datas[0], + selectedIds: res.datas[0].defaultSaleMethod.id, + bookBuy: res.datas[0].purchasedSaleMethodIdList.indexOf(res.datas[0].defaultSaleMethodId) > -1 + }); + console.log(this.data.bookItemDetail, 'bookItemData.value'); + let times = new Date(res.datas[0].defaultSaleMethod.endDate).getTime() + let startTime = new Date(res.datas[0].defaultSaleMethod.beginDate).getTime() + if (times < new Date().getTime() || new Date().getTime() < startTime) { + this.setData({ + expire: true + }); + } else { + this.setData({ + expire: false + }); + } + if (res.datas[0].bookshelf_pdf || res.datas[0].bookshelf_protectedEpub) { + this.setData({ + noFile: true + }); + } + } else { + if (this.data.bookDetail.pdf || this.data.bookDetail.protectedEpub) { + this.setData({ + noFile: true + }); + } + this.setData({ + selectedIds: this.data.bookDetail.defaultSaleMethodId, + bookBuy: this.data.bookDetail.purchasedSaleMethodIdList.indexOf(this.data.bookDetail.defaultSaleMethodId) > -1 + }); + let times = new Date(this.data.bookDetail.defaultSaleMethod.endDate).getTime() + let startTime = new Date(this.data.bookDetail.defaultSaleMethod.beginDate).getTime() + if (times < new Date().getTime() || new Date().getTime() < startTime) { + this.setData({ + expire: true + }); + } else { + this.setData({ + expire: false + }); + } + } + }) }, // 鑾峰彇鍥句功鍒嗙被 async getBookClass(iconType, classType) { @@ -567,7 +670,6 @@ // 鍥句功娣诲姞璐墿杞� async addBookShopcCar() { - const token = wx.getStorageSync('jsek-token') if (!token) { return wx.getUserProfile({ @@ -591,15 +693,14 @@ shoppingCartGetId.push(item.saleMethod.id) }) console.log(shoppingCartGetId, 'shoppingCartGetId'); - console.log(this.data.bookDetail.defaultSaleMethodId, 'this.data.bookDetail.defaultSaleMethodId'); - const determine = shoppingCartGetId.some((item) => item == this.data.bookDetail.defaultSaleMethodId) + console.log(this.data.selectedIds, '閿�鍞柟寮廼d'); + const determine = shoppingCartGetId.some((item) => item == this.data.selectedIds) console.log(determine); - if (!determine) { let query = { requests: [ { - saleMethodId: this.data.bookDetail.defaultSaleMethodId, + saleMethodId: this.data.selectedIds, storeEventId: null, agentCode: '鐢靛瓙涔�' } @@ -633,31 +734,38 @@ async buyBook() { - let bookOrdersId = '' - let query = { - remarks: '鐢靛瓙涔�', - requests: [ - { - saleMethodId: this.data.bookDetail.defaultSaleMethodId, - count: 1 - } - ] - } - // 鍙戣捣璁㈠崟鍒濆鍖栬姹傚苟绛夊緟缁撴灉 - const res = await app.MG.store.initOrder(query) - // 鑾峰彇璁㈠崟鍙峰苟璧嬪�肩粰 orderNumber.value - bookOrdersId = res.orderNumber - console.log(bookOrdersId); - // 妫�鏌ヨ鍗曞彿鏄惁瀛樺湪 - if (bookOrdersId) { - const url = '/pages/cart/paymentPage/index?orderNumber=' + bookOrdersId - wx.navigateTo({ - url - }) + if (!this.data.expire) { + let bookOrdersId = '' + let query = { + remarks: '鐢靛瓙涔�', + requests: [ + { + saleMethodId: this.data.bookItemDetail.defaultSaleMethodId ? this.data.bookItemDetail.defaultSaleMethodId : this.data.bookDetail.defaultSaleMethodId, + count: 1 + } + ] + } + // 鍙戣捣璁㈠崟鍒濆鍖栬姹傚苟绛夊緟缁撴灉 + const res = await app.MG.store.initOrder(query) + // 鑾峰彇璁㈠崟鍙峰苟璧嬪�肩粰 orderNumber.value + bookOrdersId = res.orderNumber + console.log(bookOrdersId); + // 妫�鏌ヨ鍗曞彿鏄惁瀛樺湪 + if (bookOrdersId) { + const url = '/pages/cart/paymentPage/index?orderNumber=' + bookOrdersId + wx.navigateTo({ + url + }) + } else { + console.log(222); + } } else { - console.log(222); + wx.showToast({ + title: "鍟嗗搧涓嶅湪鏈夋晥鏈�", + icon: 'none', + duration: 1000, + }) } - }, // 鑾峰彇鏁欏璧勬簮涓嬭浇鏄惁鐢宠閫氳繃 @@ -1227,10 +1335,7 @@ } else if (this.data.tabValue == 'jsek_cloudLearning') { const tree = this.selectComponent('#tree') - tree.onCloudShoppingCart() - - } else if (this.data.tabValue == 'questionBank') { this.buyMock() } else { @@ -1238,4 +1343,279 @@ } }, + //鏍蜂功鐢宠 + //鐢宠鐢靛瓙鏍蜂功 + appplyElectronicBook() { + console.log(this.data.bookDetail) + if (this.data.bookDetail.isApplyBook == 2 || this.data.bookDetail.isApplyBook == 4) { + let role = this.data.userInfo != null ? this.data.userInfo.role : null + if (role) { + if (role == 'Teacher') { + if (this.data.noFile) { + this.getSelectBookCount() + } else { + wx.showToast({ + title: "鏆傛棤鐢靛瓙涔︽枃浠�,璇疯仈绯荤鐞嗗憳!", + icon: 'none', + duration: 1000, + }) + } + } else { + wx.showModal({ + title: '灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�', //鎻愮ず鐨勬爣棰� + content: '璇峰厛杩涜鏁欏笀璁よ瘉锛�', //鎻愮ず鐨勫唴瀹� + success: function (res) { + if (res.confirm) { + wx.navigateTo({ + url: "/packageDomain/pages/teacherCertification/index", + }); + } else if (res.cancel) { + } + } + }) + } + } + } + }, + //鐢宠绾歌川鏍蜂功 + appplyPaperBook() { + if (this.data.bookDetail.isApplyBook == 3 || this.data.bookDetail.isApplyBook == 4) { + let role = this.data.userInfo != null ? this.data.userInfo.role : null + if (role) { + if (role == 'Teacher') { + this.getSelectPaperBookCount() + } else { + wx.showModal({ + title: '灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�', //鎻愮ず鐨勬爣棰� + content: '璇峰厛杩涜鏁欏笀璁よ瘉锛�', //鎻愮ず鐨勫唴瀹� + success: function (res) { + if (res.confirm) { + wx.navigateTo({ + url: "/packageDomain/pages/teacherCertification/index", + }); + } else if (res.cancel) { + } + } + }) + } + } + } + }, + //鑾峰彇褰撳墠宸茬敵璇锋鏁帮紙绾歌川锛� + getSelectPaperBookCount() { + app.MG.app + .getTicketResult({ + ticketRefCodeOrGuid: 'paperSampleBookapplyNum', + roleId: this.data.userInfo.roleId + }) + .then((res) => { + this.setData({ + paperBookCount: res.totalCount - res.usedCount + }) + this.getAlreadyBookList(this.data.bookDetail, 'pBook') + }) + }, + //鑾峰彇褰撳墠宸茬敵璇锋鏁帮紙鐢靛瓙锛� + getSelectBookCount() { + app.MG.app + .getTicketResult({ + ticketRefCodeOrGuid: 'electronicSampleBookapplyNum', + roleId: this.data.userInfo.roleId + }) + .then((res) => { + this.setData({ + ebookCount: res.totalCount - res.usedCount + }) + this.getAlreadyBookList(this.data.bookDetail, 'eBook') + }) + }, + //鑾峰彇宸茬敵璇风殑鏍蜂功鍒楄〃 + getAlreadyBookList(item, type) { + let topicIdOrRefCode = null + if (type == 'eBook') { + topicIdOrRefCode = 'applyBook' + } else { + topicIdOrRefCode = 'applyEntityBook' + } + const data = { + start: 0, + size: 9999, + topicIdOrRefCode, + appRefCode: app.config.appRefCode, + sort: { + type: 'Desc', + field: 'CreateDate' + } + } + app.MG.ugc.getTopicMessageList(data).then((res) => { + let itemAttr = null + let isHas = false + itemAttr = { + id: item.id, + title: item.name || '--', + icon: item.icon, + checked: false, + defaultSaleMethodId: item.defaultSaleMethodId, + md5: item.datas.Icon, + author: item.author || '--', + price: item.price || '--', + isbn: item.isbn || '--', + publicationDate: item.publicationDate + } + res.datas.map((item) => { + if (item.feedBack) { + item.feedBack = JSON.parse(item.feedBack) + if (item.feedBack.endDate) { + const currentDate = new Date() + let times = new Date(item.feedBack.endDate + ' 23:59:59').getTime() + if (times < currentDate.getTime()) { + item.isExpiry = true + } + } + } + if (item.content) { + item.content = JSON.parse(item.content) + item.content.map((e) => (item.productId = e.id)) + } + }) + let objVal = null + if (type != 'eBook') { + objVal = res.datas.find( + (i) => i.productId == item.id && i.state != 'Reject' && i.state == 'WaitAudit' + ) + } else { + objVal = res.datas.find((i) => i.productId == item.id && i.state != 'Reject') + } + if (objVal && !objVal.isExpiry && type == 'eBook') { + wx.showToast({ + title: "鎮ㄥ凡鐢宠璇ユ牱涔�", + icon: 'none', + duration: 1000, + }) + } else if (objVal && type != 'eBook') { + wx.showToast({ + title: "鎮ㄥ凡鐢宠璇ユ牱涔�", + icon: 'none', + duration: 1000, + }) + } else { + if (type == 'eBook') { + if (this.data.ebookCount > 0) { + const eBookData = this.data.electronicBookList + if (eBookData.length == 2) { + wx.showToast({ + title: "姣忔鏈�澶氬彧鍙敵璇�2鏈牱涔�", + icon: 'none', + duration: 1000, + }) + return false + } + if (eBookData.length > 0) { + for (let i = 0; i < eBookData.length; i++) { + if (eBookData[i].id == item.id) { + isHas = true + } + } + if (!isHas) { + wx.showToast({ + title: "娣诲姞鎴愬姛锛屽湪鏍蜂功鐢宠鍗曠瓑鎮ㄥ摝~", + icon: "none", + duration: 1000, + }) + this.setData({ + electronicBookList: [...this.data.electronicBookList, ...[itemAttr]], + num: this.data.electronicBookList.length + this.data.paperBookList.length + }) + wx.setStorageSync("electronicBookList", this.data.electronicBookList); + } else { + wx.showToast({ + title: "璇ヤ功宸插湪娓呭崟鍒楄〃涓�", + icon: "none", + duration: 1000, + }) + } + } else { + wx.showToast({ + title: "娣诲姞鎴愬姛锛屽湪鏍蜂功鐢宠鍗曠瓑鎮ㄥ摝~", + icon: "none", + duration: 1000, + }) + this.setData({ + electronicBookList: [itemAttr], + num: 1 + this.data.paperBookList.length + }) + wx.setStorageSync("electronicBookList", [itemAttr]); + } + } else { + wx.showToast({ + title: "鎮ㄧ殑鐢靛瓙鏍蜂功鐢宠娆℃暟宸茬敤灏斤紝鑻ヨ缁х画锛岃鑱旂郴绠$悊鍛橈紒", + icon: "none", + duration: 1000, + }) + } + } else { + if (this.data.paperBookCount > 0) { + const pBookData = this.data.paperBookList + if (pBookData.length == 2) { + wx.showToast({ + title: "姣忔鏈�澶氬彧鍙敵璇�2鏈牱涔�", + icon: 'none', + duration: 1000, + }) + return false + } + if (pBookData.length > 0) { + for (let i = 0; i < pBookData.length; i++) { + if (pBookData[i].id == item.id) { + isHas = true + } + } + if (!isHas) { + wx.showToast({ + title: "娣诲姞鎴愬姛锛屽湪鏍蜂功鐢宠鍗曠瓑鎮ㄥ摝~", + icon: 'none', + duration: 1000, + }) + this.setData({ + paperBookList: [...this.data.paperBookList, ...[itemAttr]], + num: this.data.paperBookList.lenght + this.data.electronicBookList.length + }) + wx.setStorageSync("paperBookList", this.data.paperBookList); + } else { + wx.showToast({ + title: "璇ヤ功宸插湪娓呭崟鍒楄〃涓�", + icon: "none", + duration: 1000, + }) + } + } else { + wx.showToast({ + title: "娣诲姞鎴愬姛锛屽湪鏍蜂功鐢宠鍗曠瓑鎮ㄥ摝~", + icon: 'none', + duration: 1000, + }) + this.setData({ + paperBookList: [itemAttr], + num: 1 + this.data.electronicBookList.length + }) + wx.setStorageSync("paperBookList", [itemAttr]); + } + } else { + wx.showToast({ + title: "鎮ㄧ殑绾歌川鏍蜂功鐢宠娆℃暟宸茬敤灏斤紝鑻ヨ缁х画锛岃鑱旂郴绠$悊鍛橈紒", + icon: 'none', + duration: 1000, + }) + } + } + } + }) + }, + //鍘绘牱涔︾敵璇峰崟 + goApply() { + wx.navigateTo({ + url: "/packageDomain/pages/sampleBookList/applicationForm/index", + }); + }, + }) diff --git a/packageBookService/pages/bookServices/detail/index.wxml b/packageBookService/pages/bookServices/detail/index.wxml index 0272a41..8296b05 100644 --- a/packageBookService/pages/bookServices/detail/index.wxml +++ b/packageBookService/pages/bookServices/detail/index.wxml @@ -137,13 +137,13 @@ </view> <!-- 璐拱鎸夐挳 --> <view class="box-bottom"> - <view class="bottom-btn"> + <view class="bottom-btn" bind:tap="appplyElectronicBook"> <view> <t-image src="/static/images/bookService/detail/ebook.png"></t-image> </view> <view class="btn-text">鐢靛瓙鏍蜂功鐢宠</view> </view> - <view class="bottom-btn"> + <view class="bottom-btn" bind:tap="appplyPaperBook"> <view> <t-image src="/static/images/bookService/detail/paper-book.png"></t-image> </view> @@ -156,4 +156,11 @@ <!-- 鎴戣寤鸿寮圭獥 --> <suggest class="suggest-component" id="suggest-component" bookIcon="{{bookDetail.icon}}" bookName="{{bookDetail.name}}"></suggest> <!-- 鏁欏璧勬簮涓嬭浇鎻愮ず寮圭獥 --> -<t-dialog class="teachDownloadDialog" visible="{{isShowTeachDownload}}" title="鎻愮ず" content="璇峰墠寰�PC绔笅杞�" confirm-btn="{{ confirmBtn }}" bind:confirm="closeTeachDownload" /> \ No newline at end of file +<t-dialog class="teachDownloadDialog" visible="{{isShowTeachDownload}}" title="鎻愮ず" content="璇峰墠寰�PC绔笅杞�" confirm-btn="{{ confirmBtn }}" bind:confirm="closeTeachDownload" /> + +<view class="applyBox" bindtap="goApply"> + <view class="box"> + <t-image src="/static/images/home/yangshuForm.png" mode="heightFix" class="img" /> + <view class="num" wx:if="{{num > 0}}">{{num}}</view> + </view> +</view> \ No newline at end of file diff --git a/packageBookService/pages/bookServices/detail/index.wxss b/packageBookService/pages/bookServices/detail/index.wxss index 8deaf31..0cf0628 100644 --- a/packageBookService/pages/bookServices/detail/index.wxss +++ b/packageBookService/pages/bookServices/detail/index.wxss @@ -227,7 +227,7 @@ } .box-bottom image { - width: 36rpx; + width: 38rpx; height: 44rpx; } @@ -300,4 +300,40 @@ .noData { height: 100%; +} + +.applyBox { + width: 184rpx; + height: 184rpx; + position: fixed; + bottom: 20%; + right: 0; +} + +.applyBox .box { + width: 184rpx; + height: 184rpx; + color: #fff; + position: relative; +} + +.applyBox .box .t-image { + width: 100%; + height: 100%; +} + +.num { + background-color: #FD3D16; + color: #fff; + border: 2rpx solid #FFFFFF; + font-size: 24rpx; + line-height: 30rpx; + font-weight: 400; + width: 48rpx; + height: 32rpx; + text-align: center; + border-radius: 9px; + position: absolute; + top: 30rpx; + left: 118rpx; } \ No newline at end of file diff --git a/packageDomain/pages/sampleBookList/applicationForm/index.js b/packageDomain/pages/sampleBookList/applicationForm/index.js index 92d0e54..e884a0f 100644 --- a/packageDomain/pages/sampleBookList/applicationForm/index.js +++ b/packageDomain/pages/sampleBookList/applicationForm/index.js @@ -9,6 +9,7 @@ workInfo: null, schoolName: "", courseName: "", + detailedAddress: "" }, contactInfo: { fullName: "", @@ -101,6 +102,7 @@ 'teacherInfo.workInfo': res[0].cmsTypeLinks[0].children, }) } + console.log(this.data.teacherInfo.workInfo, 333) }) }, //鑾峰彇褰撳墠宸茬敵璇锋鏁帮紙鐢靛瓙锛� @@ -177,12 +179,13 @@ }) return } + const mailAddress = JSON.stringify(that.data.contactInfo) that.setData({ - teacherInfo: { - detailedAddress: mailAddress, - } + 'teacherInfo.detailedAddress': mailAddress }) + console.log(that.data.teacherInfo.workInfo, 345) + data = { topicIdOrRefCode: 'applyEntityBook', name: that.data.userInfo.name || '', @@ -214,7 +217,6 @@ }) wx.setStorageSync("paperBookList", that.data.paperBookList); } - wx.showModal({ title: '鎻愮ず锛�', //鎻愮ず鐨勬爣棰� content: '鎮ㄧ殑鏍蜂功鐢宠宸叉彁浜わ紝绠$悊鍛樺鏍镐腑锛佺敵璇风姸鎬佸湪銆愪釜浜轰腑蹇冣�旀牱涔︾敵璇枫�戜腑鏌ヨ銆�', //鎻愮ず鐨勫唴瀹� diff --git a/packageDomain/pages/sampleBookList/applicationForm/index.wxss b/packageDomain/pages/sampleBookList/applicationForm/index.wxss index 877f863..894c094 100644 --- a/packageDomain/pages/sampleBookList/applicationForm/index.wxss +++ b/packageDomain/pages/sampleBookList/applicationForm/index.wxss @@ -6,6 +6,11 @@ width: 100%; } +.page-content { + padding-bottom: env(safe-area-inset-bottom); + +} + .t-tabs__track { display: none; diff --git a/packagePersonal/pages/myCollection/index.js b/packagePersonal/pages/myCollection/index.js index 1a6e3ff..fb1a765 100644 --- a/packagePersonal/pages/myCollection/index.js +++ b/packagePersonal/pages/myCollection/index.js @@ -167,7 +167,7 @@ icon: 'success', duration: 1000, }) - this.getDataList(false) + that.getDataList(false) }); } else if (res.cancel) { console.log('鐢ㄦ埛鐐瑰嚮浜嗗彇娑�') diff --git a/packagePersonal/pages/userSetting/index.js b/packagePersonal/pages/userSetting/index.js index 48c0a70..c732fd8 100644 --- a/packagePersonal/pages/userSetting/index.js +++ b/packagePersonal/pages/userSetting/index.js @@ -1,4 +1,6 @@ const app = getApp() +import tool from "../../../assets/js/toolClass.js"; +import FormData from '../../../utils/formdata/index.js'; Page({ /** @@ -10,6 +12,8 @@ userInfoBox: false, editType: '', userInfoForm: { + icon: '', + nickName: '', phone: '', email: '', captcha: '', @@ -49,6 +53,7 @@ // 鐢ㄦ埛淇℃伅浼樺厛绾э細鏁欏笀璁よ瘉 > 寰俊 > 瀛︾敓锛堟敞鍐屾椂榛樿锛� if (res) { let defaultUser = {}; + let nickNameData = res.infoList.find((item) => item.type == 'nickName') let teacherRole = res.roleLinks.find((item) => item.role.refCode == 'teacher') let teacherInfos = res.infoList.find((item) => item.type == 'teacherInfo') let secretData = res.secretList.find(i => i.type == 'LoginNameAndPassword') @@ -58,8 +63,8 @@ if (teacherRole && teacherInfos) { defaultUser = { ...teacherInfos, - fullName: teacherInfos.fullName, - icon: teacherInfos.icon, + nickName: nickNameData ? JSON.parse(nickNameData.data).nickName : teacherInfos.name, + icon: nickNameData ? JSON.parse(nickNameData.data).icon : WeChatInfo ? WeChatInfo.icon : '', userId: res.userId, role: 'Teacher', roleId: teacherRole.role.id, @@ -69,16 +74,16 @@ } else if (WeChatInfo) { defaultUser = { ...WeChatInfo, - fullName: WeChatInfo.name, - icon: WeChatInfo.icon, + nickName: nickNameData ? JSON.parse(nickNameData.data).nickName : WeChatInfo.name, + icon: JSON.parse(nickNameData.data).icon ? JSON.parse(nickNameData.data).icon : WeChatInfo.icon, userId: res.userId, phoneNumber: phoneInfo?.credential, Email: emailInfo?.credential } } else if (secretData) { defaultUser = { - fullName: secretData.credential, - icon: "", + nickName: nickNameData ? JSON.parse(nickNameData.data).nickName : secretData.credential, + icon: JSON.parse(nickNameData.data).icon ? JSON.parse(nickNameData.data).icon : '', userId: res.userId, phoneNumber: phoneInfo?.credential, Email: emailInfo?.credential @@ -99,7 +104,8 @@ userInfoBox: true, editType: info, "userInfoForm.captcha": "", - "userInfoForm.code": "" + "userInfoForm.code": "", + "userInfoForm.nickName": '' }); } this.getImgCapcha() @@ -110,7 +116,86 @@ countDown: 0, }); }, + editIconInfo(e) { + var that = this; + wx.chooseMedia({ + // count: 1, // 榛樿9 + sizeType: ['original', 'compressed'], // 鍙互鎸囧畾鏄師鍥捐繕鏄帇缂╁浘锛岄粯璁や簩鑰呴兘鏈� + sourceType: ['album', 'camera'], // 鍙互鎸囧畾鏉ユ簮鏄浉鍐岃繕鏄浉鏈猴紝榛樿浜岃�呴兘鏈� + success: function (res) { + // 杩斿洖閫夊畾鐓х墖鐨勬湰鍦版枃浠惰矾寰勫垪琛紝tempFilePath涔熷彲浠ヤ綔涓篿mg鏍囩鐨剆rc灞炴�ф樉绀哄浘鐗� + console.log(res.tempFiles[0]) + tool.getFileMd5(res.tempFiles[0]).then((e) => { + console.log(e, 4) + let formData = new FormData(); + formData.append('Md5', e); + formData.append('FileName', e); + 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) { + console.log(res) + if (res.statusCode == 200) { + resolve(res.data); + if (res.data) { + that.setData({ + 'userInfoForm.icon': app.config.requestCtx + `/file/GetPreViewImage?md5=` + e, + }); + let userTypeInfo = { + requests: [ + { + data: JSON.stringify({ nickName: that.data.userInfo.nickName, icon: that.data.userInfoForm.icon }), + name: '鐢ㄦ埛鏄电О澶村儚', + type: 'nickName' + } + ] + } + app.MG.identity.setAppUserInfo(userTypeInfo).then((res) => { + if (res) { + wx.showToast({ + title: "淇敼鎴愬姛", + icon: 'success', + duration: 1000, + }) + this.getUserInfo() + this.setData({ + userInfoBox: false, + }); + } + }) + } + } else { + reject('杩愯鏃堕敊璇�,璇风◢鍚庡啀璇�'); + } + } + }) + }) + }) + } + }); + }, + onNameInput(e) { + this.setData({ + "userInfoForm.nickName": e.detail.value, + }); + }, //杈撳叆鎵嬫満鍙� onPhoneInput(e) { console.log(e) @@ -247,7 +332,31 @@ }, confirmInfo() { - if (this.data.changeType == 'phone') { + if (this.data.editType == 'nickName') { + let userTypeInfo = { + requests: [ + { + data: JSON.stringify({ nickName: this.data.userInfoForm.nickName, icon: this.data.userInfo.icon }), + name: '鐢ㄦ埛鏄电О澶村儚', + type: 'nickName' + } + ] + } + app.MG.identity.setAppUserInfo(userTypeInfo).then((res) => { + if (res) { + wx.showToast({ + title: "淇敼鎴愬姛", + icon: 'success', + duration: 1000, + }) + this.getUserInfo() + this.setData({ + userInfoBox: false, + }); + } + }) + + } else if (this.data.editType == 'phone') { let query = { phoneNumber: this.data.userInfoForm.phone, phoneCaptcha: this.data.userInfoForm.code diff --git a/packagePersonal/pages/userSetting/index.wxml b/packagePersonal/pages/userSetting/index.wxml index 51c6a17..aaf6525 100644 --- a/packagePersonal/pages/userSetting/index.wxml +++ b/packagePersonal/pages/userSetting/index.wxml @@ -2,13 +2,15 @@ <view class="itemList"> <view class="label">澶村儚</view> <view class="contentImg"> - <t-avatar image="{{defaultAvatarUrl}}" class="user-center-card__header__avatar" /> + <t-avatar image="{{userInfo.icon}}" class="user-center-card__header__avatar" /> </view> - <t-icon name="chevron-right" size="40rpx" color="#C2C2C2" /> + <view class="iconEdit" data-info="{{'icon'}}" bindtap="editIconInfo"> + <t-icon name="chevron-right" size="40rpx" color="#C2C2C2" /> + </view> </view> <view class="itemList"> <view class="label">鐢ㄦ埛鍚�</view> - <view class="content">{{userInfo.fullName || '寰俊鐢ㄦ埛'}}</view> + <view class="content" data-info="{{'nickName'}}" bindtap="editUserInfo">{{userInfo.nickName || '寰俊鐢ㄦ埛'}}</view> <t-icon name="chevron-right" size="40rpx" color="#C2C2C2" /> </view> <view class="itemList"> @@ -24,6 +26,14 @@ <t-popup visible="{{userInfoBox}}" bind:visible-change="onVisibleChange" placement="bottom"> <view class="block"> <view class="body"> + <view class="from-item" wx:if="{{editType == 'nickName'}}"> + <view class="label"> 鏄电О锛� </view> + <view class="item-content"> + <view class="inputBox1"> + <t-input placeholder="杈撳叆鐢ㄦ埛鍚�" borderless value="{{userInfoForm.nickName}}" bindchange="onNameInput" /> + </view> + </view> + </view> <view class="from-item" wx:if="{{editType == 'phone'}}"> <view class="label"> 鎵嬫満鍙凤細 </view> <view class="item-content"> @@ -40,7 +50,7 @@ </view> </view> </view> - <view class="from-item"> + <view class="from-item" wx:if="{{editType !== 'nickName'}}"> <view class="label"> 鍥惧舰楠岃瘉鐮侊細 </view> <view class="item-content"> <view class="inputBox"> diff --git a/packagePersonal/pages/userSetting/index.wxss b/packagePersonal/pages/userSetting/index.wxss index be5d1e4..e5530ca 100644 --- a/packagePersonal/pages/userSetting/index.wxss +++ b/packagePersonal/pages/userSetting/index.wxss @@ -32,6 +32,10 @@ overflow: hidden; } +.iconEdit { + padding: 40rpx 0; +} + .content { flex: 1; color: #5C5C5C; @@ -59,10 +63,10 @@ } .block .body .from-item .label { - width: 170rpx; + width: 200rpx; height: 72rpx; line-height: 72rpx; - font-size: 28rpx; + font-size: 32rpx; } .block .body .from-item .item-content { @@ -72,14 +76,17 @@ } .inputBox1 { - width: 540rox; height: 72rpx; border: 2rpx solid #D9D9D9; flex: 1; } +.inputBox1 .t-input { + width: 440rpx !important; +} + .block .body .inputBox { - width: 280rpx; + width: 250rpx; height: 72rpx; border: 2rpx solid #D9D9D9; } @@ -90,17 +97,17 @@ .imgCode { height: 72rpx; - width: 200rpx; + width: 190rpx; } .code { - width: 200rpx; + width: 190rpx; height: 72rpx; margin-left: 20rpx; } .btn { - width: 200rpx; + width: 190rpx; height: 72rpx; padding: 0 10rpx !important; background: #ff6c00; diff --git a/pages/personalCenter/components/user-center-card/index.wxml b/pages/personalCenter/components/user-center-card/index.wxml index 60cff21..04cd0a2 100644 --- a/pages/personalCenter/components/user-center-card/index.wxml +++ b/pages/personalCenter/components/user-center-card/index.wxml @@ -17,7 +17,7 @@ <view class="user-center-card__header"> <t-avatar image="{{userInfo.icon || defaultAvatarUrl}}" class="user-center-card__header__avatar" /> <view> - <view class="user-center-card__header__name">{{userInfo.fullName || '寰俊鐢ㄦ埛'}}</view> + <view class="user-center-card__header__name">{{userInfo.nickName || '寰俊鐢ㄦ埛'}}</view> <view class="userTypeBox"> <text>{{userInfo.userType}}</text> <text class="edit" bindtap="editUserType">淇敼</text> @@ -36,7 +36,7 @@ <view class="user-center-card__header"> <t-avatar t-class="avatar" mode="aspectFill" class="user-center-card__header__avatar" image="{{userInfo.icon || defaultAvatarUrl}}" /> <view> - <view class="user-center-card__header__name">{{userInfo.fullName || '寰俊鐢ㄦ埛'}}</view> + <view class="user-center-card__header__name">{{userInfo.nickName || '寰俊鐢ㄦ埛'}}</view> <view class="userTypeBox"> <text>{{userInfo.userType}}</text> <text bindtap="editUserType">淇敼</text> diff --git a/pages/personalCenter/index.js b/pages/personalCenter/index.js index 7ece773..b7bd420 100644 --- a/pages/personalCenter/index.js +++ b/pages/personalCenter/index.js @@ -175,6 +175,7 @@ type = '-' } let defaultUser = {}; + let nickNameData = res.infoList.find((item) => item.type == 'nickName') let teacherRole = res.roleLinks.find((item) => item.role.refCode == 'teacher') let teacherInfos = res.infoList.find((item) => item.type == 'teacherInfo') let secretData = res.secretList.find(i => i.type == 'LoginNameAndPassword') @@ -182,8 +183,8 @@ if (teacherRole && teacherInfos) { defaultUser = { ...teacherInfos, - fullName: teacherInfos.fullName, - icon: teacherInfos.icon, + nickName: nickNameData ? JSON.parse(nickNameData.data).nickName : teacherInfos.name, + icon: nickNameData ? JSON.parse(nickNameData.data).icon : WeChatInfo ? WeChatInfo.icon : '', userId: res.userId, role: 'Teacher', roleId: teacherRole.role.id, @@ -196,8 +197,8 @@ } else if (WeChatInfo) { defaultUser = { ...WeChatInfo, - fullName: WeChatInfo.name, - icon: WeChatInfo.icon, + nickName: nickNameData ? JSON.parse(nickNameData.data).nickName : WeChatInfo.name, + icon: JSON.parse(nickNameData.data).icon ? JSON.parse(nickNameData.data).icon : WeChatInfo.icon, userId: res.userId, userType: type } @@ -206,8 +207,8 @@ }); } else if (secretData) { defaultUser = { - fullName: secretData.credential, - icon: "", + nickName: nickNameData ? JSON.parse(nickNameData.data).nickName : secretData.credential, + icon: JSON.parse(nickNameData.data).icon ? JSON.parse(nickNameData.data).icon : "", userId: res.userId, userType: type } -- Gitblit v1.9.1