| | |
| | | // pages/digitalCourses/index.js |
| | | import { |
| | | loginInfo |
| | | } from '../../assets/js/login'; |
| | | const app = getApp() |
| | | import { |
| | | setSessionGuid, |
| | |
| | | active: 0, |
| | | activeItem: null, |
| | | loading: false, |
| | | contentLoading: false, |
| | | noData: false, |
| | | shoppingCartGetId: [], |
| | | sorter: { |
| | | value: "*", |
| | |
| | | ], |
| | | }, |
| | | sortActive: '', |
| | | otherType: null |
| | | }, |
| | | |
| | | /** |
| | |
| | | }); |
| | | } |
| | | this.getCourseTypeListList() |
| | | this.getShoppingCartList() |
| | | const token = wx.getStorageSync(app.config.tokenKey) |
| | | if (token) this.getShoppingCartList() |
| | | }, |
| | | |
| | | /** |
| | |
| | | }, |
| | | onTabsChange(event) { |
| | | const value = event.detail.value |
| | | this.setData({ |
| | | contentLoading: true |
| | | }) |
| | | this.getCourseList(this.data.tabList[value]) |
| | | }, |
| | | |
| | |
| | | }, |
| | | getCourseTypeListList() { |
| | | this.setData({ |
| | | loading: true |
| | | loading: true, |
| | | }) |
| | | const data = { |
| | | path: '*', |
| | |
| | | } |
| | | } |
| | | app.MG.store.getStoreChannelList(data).then((res) => { |
| | | // 去除数组最后一个元素 |
| | | // 找出其他分类的path,用于排除其他分类里的数据 |
| | | this.data.otherType = res.datas.find(item => item.refCode == "jsek_dCOther") |
| | | res.datas = res.datas.filter(item => item.state == 'Normal') |
| | | const newData = res.datas.slice(0, res.datas.length - 1) |
| | | newData.unshift({ |
| | | name: "全部", |
| | |
| | | }, |
| | | |
| | | getCourseList(item) { |
| | | this.setData({ |
| | | noData: false, |
| | | }) |
| | | let searchObj = {} |
| | | let sort = {} |
| | | // // 搜索框 |
| | | if (this.data.searchValue) { |
| | | searchObj = { |
| | | 'Name*': this.data.searchValue.trim(), |
| | | '||isbn*': searchInputValue.value.trim(), |
| | | '||courseLeader*': searchInputValue.value.trim() |
| | | '||isbn*': this.data.searchValue.trim(), |
| | | '||courseLeader*': this.data.searchValue.trim() |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | app.MG.store.getProductList(obj).then((res) => { |
| | | if (!res.datas.length) { |
| | | return this.setData({ |
| | | noData: true, |
| | | courseList: [], |
| | | contentLoading: false |
| | | }) |
| | | } |
| | | res.datas.forEach(item => { |
| | | item.price = item.price.toFixed(2) |
| | | item.productLinkInfo = JSON.parse(item.productLinkInfo) |
| | | }) |
| | | // 排除其他分类里的数据 |
| | | this.setData({ |
| | | courseList: res.datas.filter(item => item.productLinkInfo[0].LinkPath != this.data.otherType.pathList[0] + '\\' + this.data.otherType.id) |
| | | courseList: res.datas, |
| | | contentLoading: false, |
| | | }) |
| | | }) |
| | | }, |
| | |
| | | this.setData({ |
| | | "sortActive": e.detail.value, |
| | | }); |
| | | console.log(e) |
| | | this.getCourseList(this.data.activeItem); |
| | | }, |
| | | courseDetail(e) { |
| | |
| | | setNewView('productId', item.id) |
| | | this.getCourseTypeListList() |
| | | wx.navigateTo({ |
| | | url: '/pages/digitalCourses/digitalCoursesDetails/index?id=' + item.id + '&path=' + item.idPath, |
| | | url: '/pages/digitalCourses/digitalCoursesDetails/index?id=' + item.id + '&path=' + item.idPath |
| | | }) |
| | | |
| | | }, |
| | |
| | | }) |
| | | }, |
| | | 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) { |
| | | const addFun = () => { |
| | | 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: 'success', |
| | | 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() |
| | | } |
| | | this.getShoppingCartList() |
| | | } catch (error) { |
| | | console.error('出错了:', error) |
| | | } |
| | | } catch (error) { |
| | | console.error('出错了:', error) |
| | | } |
| | | } |
| | | |
| | | const token = wx.getStorageSync(app.config.tokenKey) |
| | | if (token) { |
| | | addFun() |
| | | } else { |
| | | loginInfo(app, (data) => { |
| | | if (data) { |
| | | this.getShoppingCartList() |
| | | } |
| | | }) |
| | | } |
| | | }, |
| | | |
| | | }) |