From 81c23f9c2f5bdfbe962d0b19a5a80ea7c12f043d Mon Sep 17 00:00:00 2001 From: litian <C21AF165> Date: 星期三, 10 七月 2024 17:39:02 +0800 Subject: [PATCH] 二维码 --- pages/digitalCourses/index.js | 98 +++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 86 insertions(+), 12 deletions(-) diff --git a/pages/digitalCourses/index.js b/pages/digitalCourses/index.js index aa22aa1..f4ea7cc 100644 --- a/pages/digitalCourses/index.js +++ b/pages/digitalCourses/index.js @@ -1,5 +1,10 @@ // pages/digitalCourses/index.js const app = getApp() +import { + setSessionGuid, + setNewView, + storage +} from "../../assets/js/userAction"; Page({ /** @@ -12,7 +17,9 @@ tabList: [], courseList: [], searchValue: '', - activeItem: null + activeItem: null, + loading: false, + shoppingCartGetId: [] }, /** @@ -28,6 +35,7 @@ navBarHeight: navBarHeight, }); this.getCourseTypeListList() + this.getShoppingCartList() }, /** @@ -79,7 +87,6 @@ }, onTabsChange(event) { - const value = event.detail.value this.getCourseList(this.data.tabList[value]) }, @@ -89,6 +96,10 @@ wx.navigateBack(); }, getCourseTypeListList() { + + this.setData({ + loading: true + }) const data = { path: '*', filterList: [{ @@ -113,11 +124,10 @@ this.setData({ tabList: newData, - activeItem: newData[0] + activeItem: newData[0], + loading: false }) this.getCourseList(newData[0]) - - }) }, @@ -174,7 +184,6 @@ } } app.MG.store.getProductList(obj).then((res) => { - console.log(res, '7895') res.datas.forEach(item => { item.price = item.price.toFixed(2) }) @@ -183,22 +192,87 @@ courseList: res.datas }) - console.log(this.data.courseList); - }) }, searchBook() { - console.log(this.data.searchValue); this.getCourseList(this.data.activeItem) }, courseDetail(e) { - console.log(e); const item = e.currentTarget.dataset.item - + setNewView('productId', item.id) + this.getCourseTypeListList() wx.navigateTo({ url: '/pages/digitalCourses/digitalCoursesDetails/index?id=' + item.id, }) - } + }, + getShoppingCartList() { + let query = { + start: 0, + size: 999, + filterList: [], + searchList: [] + } + app.MG.store.getShoppingCartProductList(query).then((res) => { + let idList = []; + res.datas.forEach((item) => { + idList.push(item.saleMethod.id) + }) + this.setData({ + shoppingCartGetId: idList + }) + }) + }, + addCart(e) { + const { + item + } = e.currentTarget.dataset; + wx.showToast({ + title: "寤鸿涓�", + icon: 'none', + duration: 1000 + }) + if (wx.getStorageSync(app.config.tokenKey)) { + let query = { + start: 0, + size: 999, + filterList: [], + searchList: [] + } + try { + if ( + this.data.shoppingCartGetId.includes( + item.defaultSaleMethodId + ) + ) { + wx.showToast({ + title: "璇ヤ功宸插湪璐墿杞︼紝璇峰嬁閲嶅娣诲姞绌�", + icon: 'none', + duration: 1000 + }) + } else { + let query = { + requests: [{ + saleMethodId: item.defaultSaleMethodId, + storeEventId: null, + agentCode: '鏁板瓧璇剧▼' + }] + } + const addRes = app.MG.store.addShoppingCart(query) + if (addRes) { + wx.showToast({ + title: "娣诲姞鎴愬姛", + icon: 'success', + duration: 1000 + }) + } + this.getShoppingCartList() + } + } catch (error) { + console.error('鍑洪敊浜嗭細', error) + } + } + + }, }) \ No newline at end of file -- Gitblit v1.9.1