From 4ef1826180997bac879913bf17867bd3e390c29d Mon Sep 17 00:00:00 2001 From: yiming <m13691596795@163.com> Date: 星期四, 28 三月 2024 09:24:46 +0800 Subject: [PATCH] 微信支付修改 --- packageBookService/pages/bookServices/detail/index.js | 239 ++++++++++++++++++++++++++++++++++++++--------------------- 1 files changed, 152 insertions(+), 87 deletions(-) diff --git a/packageBookService/pages/bookServices/detail/index.js b/packageBookService/pages/bookServices/detail/index.js index 711cb30..6eb4cc2 100644 --- a/packageBookService/pages/bookServices/detail/index.js +++ b/packageBookService/pages/bookServices/detail/index.js @@ -34,17 +34,20 @@ openTeachids: [], openLearnids: [], openTestids: [], - applyResourceState: false, // 鐢宠鏁欏璧勬簮鎸夐挳闃叉姈 + applyResourceState: false, // 鐢宠鏁欏璧勬簮鎸夐挳闃叉姈 resourceClassList: [], // 璧勬簮鎵�灞炲垎绫� - applyState: "", // 鏁欏璧勬簮鐢宠鐘舵�� - deadline: "", // 鏁欏璧勬簮鐢宠鏈夋晥鏃ユ湡 - rejectCause: "", // 涓嬭浇鎷掔粷鍘熷洜 + applyState: "", // 鏁欏璧勬簮鐢宠鐘舵�� + deadline: "", // 鏁欏璧勬簮鐢宠鏈夋晥鏃ユ湡 + rejectCause: "", // 涓嬭浇鎷掔粷鍘熷洜 buyIdList: [], shoppingCartGetId: [], // 宸茶喘涔癷d鍒楄〃 shoppingList: [], loading: false, - isShowTeachDownload: false, // 鎻愮ずPC涓嬭浇寮圭獥鐘舵�� - confirmBtn: { content: '鎴戠煡閬撲簡', variant: 'base' }, + isShowTeachDownload: false, // 鎻愮ずPC涓嬭浇寮圭獥鐘舵�� + confirmBtn: { + content: '鎴戠煡閬撲簡', + variant: 'base' + }, mockData: { id: 0, // 閿�鍞甶d price: 0, // 鍞环 @@ -55,9 +58,9 @@ }, flag: true, noResources: false, - selectedIds: "",//鍟嗗搧鎴栧瓙鍟嗗搧閿�鍞柟寮� + selectedIds: "", //鍟嗗搧鎴栧瓙鍟嗗搧閿�鍞柟寮� bookBuy: false, //鍟嗗搧鎴栧瓙鍟嗗搧鏄惁璐拱 - expire: false,//鍟嗗搧鎴栧瓙鍟嗗搧閿�鍞柟寮忔槸鍚﹁繃鏈� + expire: false, //鍟嗗搧鎴栧瓙鍟嗗搧閿�鍞柟寮忔槸鍚﹁繃鏈� noFile: false, //鍟嗗搧鎴栧瓙鍟嗘湁鏃犵數瀛愪功鏂囦欢 num: 0, //鏍蜂功鐢宠鍗曟暟閲� alreadyPaperBookList: [], //宸茬敵璇风焊璐ㄦ牱涔� @@ -72,10 +75,49 @@ fileType: "", md5: "", freePage: "" - }, //闃呰鍣ㄦ暟鎹� + }, //闃呰鍣ㄦ暟鎹� buyResourceData: { productLinkPath: '', refCode: '', + }, + briefIcon: { + name: "/static/images/bookService/detail/tushujianjie-g.png" + }, + briefIconClick: { + name: '/static/images/bookService/detail/tushujianjie-click.png' + }, + eBookIcon: { + name: '/static/images/bookService/detail/ebook-g.png' + }, + eBookClickIcon: { + name: '/static/images/bookService/detail/ebook-click.png' + }, + teachResourcesIcon: { + name: '/static/images/bookService/detail/jiaoxueziyuan.png' + }, + teachResourcesClickIcon: { + name: '/static/images/bookService/detail/jiaoxueziyuan-click.png' + }, + learnResourceIcon: { + name: '/static/images/bookService/detail/yunxuexi.png' + }, + learnResourceClickIcon: { + name: '/static/images/bookService/detail/yunxuexi-click.png' + }, + testResourceIocn: { + name: '/static/images/bookService/detail/test-icon-g.png' + }, + testResourceClickIocn: { + name: '/static/images/bookService/detail/test-click-icon.png' + }, + noteIcon: { + name: '/static/images/bookService/detail/biji-icon-g.png' + }, + noteClickIcon: { + name: '/static/images/bookService/detail/biji-click-icon.png' + }, + icon1: { + name: "/static/images/bookService/detail/dangdang.png" } }, @@ -118,6 +160,20 @@ userInfo: JSON.parse(wx.getStorageSync(app.config.userInfoKey)) }) } + + }, + + /** + * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚 + */ + onReady() { + + }, + + /** + * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず + */ + onShow() { if (wx.getStorageSync("paperBookList")) { this.setData({ paperBookList: wx.getStorageSync("paperBookList"), @@ -134,26 +190,14 @@ }, /** - * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚 - */ - onReady() { - - }, - - /** - * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず - */ - onShow() { }, - - /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌 */ - onHide() { }, + onHide() {}, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍗歌浇 */ - onUnload() { }, + onUnload() {}, /** * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔 @@ -176,7 +220,7 @@ /** * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜� */ - onShareAppMessage() { }, + onShareAppMessage() {}, // 鏍煎紡鍖栨棩鏈� formatDate(dateString) { if (!dateString) { @@ -402,7 +446,6 @@ }); } } - console.log(this.data.fileInfo, 456) this.setData({ selectedIds: this.data.bookDetail.defaultSaleMethodId, bookBuy: this.data.bookDetail.purchasedSaleMethodIdList.indexOf(this.data.bookDetail.defaultSaleMethodId) > -1 @@ -484,7 +527,9 @@ }, // 璺宠浆缃戝簵 goShop(e) { - const { link } = e.currentTarget.dataset; + const { + link + } = e.currentTarget.dataset; wx.navigateTo({ url: `/packageBookService/pages/bookServices/webpage/index?url=${link}`, }) @@ -503,9 +548,9 @@ 'buyResourceData.refCode': checkData.refCode }) } - if ((e.detail.value == 'jsek_teachingResources' && !this.data.teach.length) - || (e.detail.value == 'jsek_cloudLearning' && !this.data.learn.length) - || (e.detail.value == 'questionBank' && !this.data.test.length)) { + if ((e.detail.value == 'jsek_teachingResources' && !this.data.teach.length) || + (e.detail.value == 'jsek_cloudLearning' && !this.data.learn.length) || + (e.detail.value == 'questionBank' && !this.data.test.length)) { this.getResourceData(checkData) } } else { @@ -600,7 +645,7 @@ loading: false, openTeachids: result }) - console.log('鏁欏璧勬簮', this.data.teach); + console.log('鏁欏璧勬簮', this.data.teach, this.data.applyState); } else if (type.refCode == 'jsek_cloudLearning') { // res.datas.cmsDatas[0].datas.forEach(item => { // item.checked = false @@ -761,13 +806,11 @@ console.log(determine); if (!determine) { let query = { - requests: [ - { - saleMethodId: this.data.selectedIds, - storeEventId: null, - agentCode: '鐢靛瓙涔�' - } - ] + requests: [{ + saleMethodId: this.data.selectedIds, + storeEventId: null, + agentCode: '鐢靛瓙涔�' + }] } const addRes = app.MG.store.addShoppingCart(query) this.showSuccessToast() @@ -776,8 +819,8 @@ Toast({ context: this, selector: '#t-toast', - message: '宸叉坊鍔�', - theme: 'success', + message: '璇ヤ功宸插湪璐墿杞︼紝璇峰嬁閲嶅娣诲姞', + theme: 'warning', direction: 'column', }); } @@ -803,16 +846,15 @@ }, async buyBook() { + console.log(this.data.bookItemDetail.defaultSaleMethodId, 'this.data.bookItemDetail.defaultSaleMethodId'); 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 - } - ] + requests: [{ + saleMethodId: this.data.bookItemDetail.defaultSaleMethodId ? this.data.bookItemDetail.defaultSaleMethodId : this.data.bookDetail.defaultSaleMethodId, + count: 1 + }] } // 鍙戣捣璁㈠崟鍒濆鍖栬姹傚苟绛夊緟缁撴灉 const res = await app.MG.store.initOrder(query) @@ -936,14 +978,12 @@ cmsTypeRefCode: '', newDataListRequest: [], name: this.data.bookDetail.name, // name涓虹敵璇风殑涔︽湰鍚嶇О - content: JSON.stringify([ - { - name: this.data.bookDetail.name, - id: this.data.bookDetail.id, - // defaultSaleMethodId: bookData.value.defaultSaleMethodId, - icon: this.data.bookDetail.icon - } - ]) + content: JSON.stringify([{ + name: this.data.bookDetail.name, + id: this.data.bookDetail.id, + // defaultSaleMethodId: bookData.value.defaultSaleMethodId, + icon: this.data.bookDetail.icon + }]) } app.MG.ugc.newTopicMessage(query).then(async (res) => { if (res) { @@ -1294,9 +1334,9 @@ if (new RegExp('(' + k + ')').test(fmt)) { fmt = fmt.replace( RegExp.$1, - RegExp.$1.length == 1 - ? (o)[k] - : ('00' + (o)[k]).substr(('' + (o)[k]).length) + RegExp.$1.length == 1 ? + (o)[k] : + ('00' + (o)[k]).substr(('' + (o)[k]).length) ) } } @@ -1349,12 +1389,10 @@ try { let query = { remarks: '缁勫嵎', - requests: [ - { - saleMethodId: this.data.mockData.id, - count: 1 - } - ] + requests: [{ + saleMethodId: this.data.mockData.id, + count: 1 + }] } if (this.data.flag) { this.setData({ @@ -1369,7 +1407,9 @@ } else { // 0鍏冪洿鎺ラ鍙� // 纭璁㈠崟 - const confirmOrderRes = await app.MG.store.confirmOrder({ orderNum: res.orderNumber }) + const confirmOrderRes = await app.MG.store.confirmOrder({ + orderNum: res.orderNumber + }) if (confirmOrderRes) { wx.showToast({ icon: "success", @@ -1389,36 +1429,39 @@ recordBuyMock() { const num = this.data.mockData.mockList.length const id = tool.uuid(8) - const createDate = new Date().getTime() + const createDate = this.DateFormat(new Date().getTime(), 'yyyy-MM-dd') const mockList = this.data.mockData.mockList - mockList.push({ id, createDate, name: `绗�${num + 1}濂楄瘯鍗穈, state: '0' }) + mockList.push({ + id, + createDate, + name: `绗�${num + 1}濂楄瘯鍗穈, + state: '0' + }) this.setData({ 'mockData.mockList': mockList }) // 璁板綍璐拱鏃堕棿锛屽苟璁剧姸鎬乻tate涓�1锛岃〃绀哄垰璐拱瀹屾垚缁勫嵎 app.MG.identity.setUserKey({ - setKeyRequests: [ - { - domain: 'mockData', - key: this.data.bookDetail.id + '', - value: JSON.stringify(this.data.mockData.mockList) - } - ] + setKeyRequests: [{ + domain: 'mockData', + key: this.data.bookDetail.id + '', + value: JSON.stringify(this.data.mockData.mockList) + }] }) }, // 搴曢儴璐拱鎸夐挳 buyBtn() { - if (this.data.tabValue == 'brief') { + if (this.data.tabValue == 'brief' && !this.data.bookBuy) { this.buyBook() } - else if (this.data.tabValue == 'jsek_cloudLearning') { - const tree = this.selectComponent('#tree') - tree.onCloudShoppingCart() - } else if (this.data.tabValue == 'questionBank') { - this.buyMock() - } else { - console.log(this.data.tabValue); - } + // else if (this.data.tabValue == 'jsek_cloudLearning') { + // const tree = this.selectComponent('#tree') + // tree.onCloudShoppingCart() + // } else if (this.data.tabValue == 'questionBank') { + // this.buyMock() + // } else { + // console.log(this.data.tabValue); + // } }, goRead() { @@ -1463,8 +1506,7 @@ wx.navigateTo({ url: "/packageDomain/pages/teacherCertification/index", }); - } else if (res.cancel) { - } + } else if (res.cancel) {} } }) } @@ -1493,8 +1535,7 @@ wx.navigateTo({ url: "/packageDomain/pages/teacherCertification/index", }); - } else if (res.cancel) { - } + } else if (res.cancel) {} } }) } @@ -1723,5 +1764,29 @@ url: "/packageDomain/pages/sampleBookList/applicationForm/index", }); }, - -}) + handleTree() { + // const child = this.selectComponent('#teach-tree') + let tree + // let openIds = child.data.openIds + if (this.data.tabValue == 'jsek_teachingResources') { + tree = this.data.teach + } else { + tree = this.data.learn + } + for (let index = 0; index < tree.length; index++) { + const item = tree[index]; + if (item.children && item.children.length > 0) { + const num = this.data.openTeachids.findIndex(citem => item.id == citem) + if (num >= 0) { + item.open = true + } else { + item.open = false + } + this.handleTree(item.children) + } + } + this.setData({ + teach: tree + }) + }, +}) \ No newline at end of file -- Gitblit v1.9.1