| | |
| | | import { |
| | | fetchHome |
| | | } from '../../services/home/home'; |
| | | import moment from 'moment' |
| | | import { |
| | | loginInfo |
| | | } from '../../assets/js/login'; |
| | |
| | | } |
| | | }) |
| | | } |
| | | |
| | | }, |
| | | onReachBottom() {}, |
| | | onPullDownRefresh() { |
| | |
| | | path: 'jsek_banner\\jsek_homeBannerApplet', |
| | | fields: { |
| | | jsek_link: [] |
| | | }, |
| | | coverSize: { |
| | | width: 400 |
| | | }, |
| | | paging: { |
| | | start: 0, |
| | |
| | | app.MG.store.getProductList(obj).then((res) => { |
| | | res.datas.forEach((item) => { |
| | | item.price = item.price ? item.price.toFixed(2) : item.price; |
| | | item.isbuy = item.purchasedSaleMethodIdList.indexOf(item.defaultSaleMethodId) > -1 |
| | | }); |
| | | this.setData({ |
| | | courseList: res.datas |
| | |
| | | app.MG.store.getProductList(obj).then((res) => { |
| | | res.datas.forEach((item) => { |
| | | item.price = item.price ? item.price.toFixed(2) : item.price; |
| | | item.isbuy = item.purchasedSaleMethodIdList.indexOf(item.defaultSaleMethodId) > -1 |
| | | }); |
| | | this.setData({ |
| | | textbookList: res.datas |
| | |
| | | info |
| | | } = e.currentTarget.dataset; |
| | | if (wx.getStorageSync(app.config.tokenKey)) { |
| | | let query = { |
| | | start: 0, |
| | | size: 999, |
| | | filterList: [], |
| | | searchList: [] |
| | | } |
| | | try { |
| | | if ( |
| | | this.data.shoppingCartGetId.includes( |
| | | info.defaultSaleMethodId |
| | | ) |
| | | ) { |
| | | wx.showToast({ |
| | | title: "该商品已在购物车,请勿重复添加", |
| | | icon: 'none', |
| | | duration: 1000 |
| | | }) |
| | | } else { |
| | | let query = { |
| | | requests: [{ |
| | | saleMethodId: info.defaultSaleMethodId, |
| | | storeEventId: null, |
| | | agentCode: '电子书' |
| | | }] |
| | | } |
| | | const addRes = await app.MG.store.addShoppingCart(query) |
| | | if (addRes) { |
| | | if (info.isbuy) { |
| | | wx.showToast({ |
| | | title: "该商品已购买", |
| | | icon: 'none', |
| | | duration: 1000 |
| | | }) |
| | | } else { |
| | | let query = { |
| | | start: 0, |
| | | size: 999, |
| | | filterList: [], |
| | | searchList: [] |
| | | } |
| | | try { |
| | | if ( |
| | | this.data.shoppingCartGetId.includes( |
| | | info.defaultSaleMethodId |
| | | ) |
| | | ) { |
| | | wx.showToast({ |
| | | title: "添加成功", |
| | | icon: 'success', |
| | | title: "该商品已在购物车,请勿重复添加", |
| | | icon: 'none', |
| | | duration: 1000 |
| | | }) |
| | | } else { |
| | | let query = { |
| | | requests: [{ |
| | | saleMethodId: info.defaultSaleMethodId, |
| | | storeEventId: null, |
| | | agentCode: '电子书' |
| | | }] |
| | | } |
| | | const addRes = await 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) |
| | | } |
| | | } |
| | | |
| | | }, |
| | | onMoreGuide(e) { |
| | | let type = e.currentTarget.dataset.info |
| | |
| | | success(res) { |
| | | console.log(res); |
| | | if (res.errMsg == "scanCode:ok" && res.path || res.result) { |
| | | let path = res.path || res.result |
| | | wx.redirectTo({ |
| | | url: '/' + path, |
| | | }) |
| | | if (res.path) { |
| | | let path = res.path || res.result |
| | | wx.redirectTo({ |
| | | url: '/' + path, |
| | | }) |
| | | } else { |
| | | wx.redirectTo({ |
| | | url: '/pages/scanResult/index?result=' + res.result, |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | }) |