| | |
| | | courseList: [], |
| | | searchValue: '', |
| | | activeItem: null, |
| | | loading: false |
| | | loading: false, |
| | | shoppingCartGetId: [] |
| | | }, |
| | | |
| | | /** |
| | |
| | | navBarHeight: navBarHeight, |
| | | }); |
| | | this.getCourseTypeListList() |
| | | this.getShoppingCartList() |
| | | }, |
| | | |
| | | /** |
| | |
| | | loading: false |
| | | }) |
| | | this.getCourseList(newData[0]) |
| | | |
| | | |
| | | }) |
| | | }, |
| | | |
| | |
| | | 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) |
| | | } |
| | | } |
| | | |
| | | }, |
| | | |
| | | }) |