| | |
| | | * 页面的初始数据 |
| | | */ |
| | | data: { |
| | | // 进页面默认切换 展开的id |
| | | // defaultactiveTeachid 教学资源 |
| | | // defaultactiveLearnid 云学习 |
| | | bookId: "", |
| | | barHeight: "", |
| | | navBarHeight: "", |
| | |
| | | learnPath: '', |
| | | applyResourceState: false, // 申请教学资源按钮防抖 |
| | | resourceClassList: [], // 资源所属分类 |
| | | applyState: "", // 教学资源申请状态 |
| | | applyState: "1", // 教学资源申请状态 |
| | | deadline: "", // 教学资源申请有效日期, |
| | | isShowBuyCloundBtn: false, |
| | | isshowDrawBtn: true, // 云学习领取查看按钮是否显示 |
| | |
| | | list: e.detail.changeList, |
| | | }); |
| | | }, |
| | | |
| | | logInFun(callback) { |
| | | loginInfo(app, (data) => { |
| | | if (data) { |
| | | this.getShoppingCartProductGet(); |
| | | this.getApplyInfo(this.data.options.id); |
| | | this.getAlreadyPBookList(); |
| | | this.getAlreadyEBookList(); |
| | | if (wx.getStorageSync(app.config.userInfoKey)) { |
| | | this.setData({ |
| | | userInfo: JSON.parse(wx.getStorageSync(app.config.userInfoKey)), |
| | | }); |
| | | // 获取申请次数 |
| | | this.getSelectPaperBookCount(); |
| | | this.getSelectBookCount(); |
| | | } |
| | | callback() |
| | | } |
| | | }) |
| | | }, |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | |
| | | wx.setNavigationBarTitle({ |
| | | title: decodeURI(options.name), |
| | | }) |
| | | let token = wx.getStorageSync(app.config.tokenKey) |
| | | if (!token) { |
| | | loginInfo(app, (data) => { |
| | | if (data) {} else {} |
| | | }) |
| | | } |
| | | this.getBookInfo(options.id); |
| | | // this.getResourceClass(); // 获取资源所属分类 |
| | | token = wx.getStorageSync(app.config.tokenKey) |
| | | if (options.tabValue) { |
| | | this.setData({ |
| | | tabValue: options.tabValue, |
| | | }); |
| | | } |
| | | const token = wx.getStorageSync(app.config.tokenKey); |
| | | if (token) { |
| | | this.getShoppingCartProductGet(); |
| | | this.getApplyInfo(options.id); |
| | | this.getApplyInfo(this.data.options.id); |
| | | this.getAlreadyPBookList(); |
| | | this.getAlreadyEBookList(); |
| | | } |
| | | if (wx.getStorageSync(app.config.userInfoKey)) { |
| | | this.setData({ |
| | | userInfo: JSON.parse(wx.getStorageSync(app.config.userInfoKey)), |
| | |
| | | this.getSelectPaperBookCount(); |
| | | this.getSelectBookCount(); |
| | | } |
| | | if (options.tabValue) { |
| | | this.setData({ |
| | | tabValue: options.tabValue, |
| | | }); |
| | | } |
| | | }, |
| | | |
| | |
| | | setCollect() { |
| | | const token = wx.getStorageSync(app.config.tokenKey); |
| | | if (!token) { |
| | | // 检查登录状态 |
| | | loginInfo(app, (data) => { |
| | | // 如果不是第一次登录,会执行回调 |
| | | if (data) { |
| | | // 登录成功,自动记录token和用户信息,并返回true |
| | | this.logInFun(() => { |
| | | this.getBookInfo(this.data.bookId); |
| | | }) |
| | | } else { |
| | | // 出现错误,返回false |
| | | this.collectFun() |
| | | } |
| | | }); |
| | | } else { |
| | | }, |
| | | collectFun() { |
| | | if (this.data.bookDetail.isFavourite) { |
| | | app.MG.store |
| | | .delProductLink({ |
| | |
| | | }); |
| | | }); |
| | | } |
| | | } |
| | | }, |
| | | |
| | | // 联系 |
| | | editPhone() { |
| | | this.setData({ |
| | |
| | | suggestBtn() { |
| | | // 检查登录状态 |
| | | const token = wx.getStorageSync(app.config.tokenKey); |
| | | const child = this.selectComponent("#suggest-component"); |
| | | if (token) |
| | | // child.showDialog(); |
| | | if (token) { |
| | | this.setData({ |
| | | showIndex: '1' |
| | | }) |
| | | } else { |
| | | this.logInFun(() => { |
| | | this.setData({ |
| | | showIndex: '1' |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | }, |
| | | // 跳转网店 |
| | | goShop(e) { |
| | |
| | | "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") { |
| | | // wx.setStorageSync('teachResourcesPath', checkData.productLinkPath) |
| | | // } |
| | | // this.getResourceData(checkData); |
| | | // } |
| | | if ((e.detail.value == "jsek_teachingResources" && !this.data.teach.length) || (e.detail.value == "jsek_cloudLearning" && !this.data.learn.length)) { |
| | | wx.setStorageSync('teachResourcesPath', checkData.productLinkPath) |
| | | this.getResourceDataList(checkData) |
| | |
| | | loading: false, |
| | | }); |
| | | } |
| | | |
| | | let list = [] |
| | | // 判断云学习有无销售方式和有效期 |
| | | const cloundSaleMethod = |
| | |
| | | learnPath: type.productLinkPath |
| | | }); |
| | | } |
| | | console.log('1', this.data.teach); |
| | | }) |
| | | }, |
| | | // 获取 云测试 |
| | |
| | | }, |
| | | |
| | | // 图书添加购物车 |
| | | async addBookShopcCar() { |
| | | addBookShopcCar() { |
| | | const token = wx.getStorageSync(app.config.tokenKey); |
| | | if (token) { |
| | | addFun() |
| | | } else { |
| | | this.logInFun(() => {}) |
| | | } |
| | | const addFun = async () => { |
| | | if (!this.data.expire) { |
| | | const shoppingCartGetId = []; |
| | | let query = { |
| | |
| | | icon: "none", |
| | | duration: 1000, |
| | | }); |
| | | } |
| | | } |
| | | }, |
| | | |
| | |
| | | return flattenedArray; |
| | | }, |
| | | // 云学习一键领取 |
| | | async getFreeResource() { |
| | | getFreeResource() { |
| | | const child = this.selectComponent("#learn-resource"); |
| | | const token = wx.getStorageSync(app.config.tokenKey); |
| | | if (!token) { |
| | | loginInfo(app, (data) => { |
| | | // 如果不是第一次登录,会执行回调 |
| | | if (data) { |
| | | // 登录成功,自动记录token和用户信息,并返回true |
| | | this.logInFun(() => {}); |
| | | } else { |
| | | // 出现错误,返回false |
| | | getFreeFun() |
| | | } |
| | | }); |
| | | } |
| | | const getFreeFun = async () => { |
| | | // 领取查看 ,先看云学习上的 再看资源上的 |
| | | const cloundMenu = this.data.resourceCodeList.find((item) => item.refCode == 'jsek_cloudLearning') |
| | | const cloundMenuSaleMethod = |
| | |
| | | } catch (error) { |
| | | console.log(error); |
| | | } |
| | | } |
| | | }, |
| | | // 云学习一键购买 |
| | | async allAddShoppiingCar() { |
| | |
| | | } |
| | | }, |
| | | // 云学习全部购买 |
| | | async buyCloudLearnClass() { |
| | | buyCloudLearnClass() { |
| | | const token = wx.getStorageSync(app.config.tokenKey); |
| | | if (token) { |
| | | buyClass() |
| | | } else { |
| | | this.logInFun(() => {}) |
| | | } |
| | | const buyClass = async () => { |
| | | const cloundMenu = this.data.resourceCodeList.find((item) => item.refCode == 'jsek_cloudLearning') |
| | | let query = { |
| | | remarks: '云学习', |
| | |
| | | title: "请重试", |
| | | }); |
| | | } |
| | | }, |
| | | // 云学习字段购买 |
| | | async buyCloundMenu() { |
| | | const cloundData = this.data.resourceCodeList.find(item => item.refCode == 'jsek_cloudLearning') |
| | | |
| | | } |
| | | }, |
| | | // 变为所有check true |
| | | findAndUpdateItemsByIds(tree, ids) { |
| | |
| | | findAndUpdate(node); // 对每个顶层节点执行查找和更新操作 |
| | | } |
| | | return tree; // 返回修改后的完整数组 |
| | | }, |
| | | handleTrue() { |
| | | // findAndUpdateItemsByIds(this.date.) |
| | | }, |
| | | |
| | | // 题库购买 |
| | |
| | | }); |
| | | }, |
| | | // 购买组卷 |
| | | async buyMock() { |
| | | buyMock() { |
| | | const token = wx.getStorageSync(app.config.tokenKey); |
| | | if (token) { |
| | | buyMockFun() |
| | | } else { |
| | | this.logInFun(() => {}) |
| | | } |
| | | const buyMockFun = async () => { |
| | | let res; |
| | | if (!this.data.mockData.id) |
| | | return wx.showToast({ |
| | |
| | | } |
| | | } catch (error) { |
| | | console.log(error); |
| | | } |
| | | } |
| | | }, |
| | | // 记录购买组卷时间 |
| | |
| | | }, |
| | | // 底部购买按钮 |
| | | buyBtn() { |
| | | const token = wx.getStorageSync(app.config.tokenKey); |
| | | if (token) { |
| | | buyFun() |
| | | } else { |
| | | this.logInFun(() => {}) |
| | | } |
| | | const buyFun = () => { |
| | | if (this.data.tabValue == "brief" && !this.data.bookBuy) { |
| | | this.buyBook(); |
| | | } else if (this.data.tabValue == "jsek_cloudLearning") { |
| | |
| | | } else { |
| | | console.log(this.data.tabValue); |
| | | } |
| | | } |
| | | }, |
| | | |
| | | goRead() { |
| | | goRead(e) { |
| | | const readFun = (bookBuy) => { |
| | | if (!this.data.noFile) { |
| | | wx.showToast({ |
| | | title: "暂无阅读文件", |
| | |
| | | "&freePage=" + |
| | | this.data.fileInfo.freePage + |
| | | "&bookBuy=" + |
| | | this.data.bookBuy + |
| | | bookBuy + |
| | | "&bookId=" + |
| | | this.data.bookDetail.id, |
| | | |
| | | }); |
| | | } |
| | | const { |
| | | type |
| | | } = e.currentTarget.dataset |
| | | if (type == 'freeFile') return readFun(this.data.bookBuy) |
| | | if (this.data.bookDetail.price == '0.00') |
| | | return readFun(true) |
| | | const token = wx.getStorageSync(app.config.tokenKey); |
| | | if (token) { |
| | | readFun(this.data.bookBuy) |
| | | } else { |
| | | this.logInFun(() => { |
| | | readFun(this.data.bookBuy) |
| | | }) |
| | | } |
| | | |
| | | }, |
| | | |
| | | //样书申请 |
| | |
| | | |
| | | //申请电子样书 |
| | | appplyElectronicBook() { |
| | | const token = wx.getStorageSync(app.config.tokenKey); |
| | | if (token) { |
| | | applyFun() |
| | | } else { |
| | | this.logInFun(() => {}) |
| | | } |
| | | const applyFun = () => { |
| | | // 先判断下教师认证,未对原有逻辑修改 |
| | | let role = this.data.userInfo != null ? this.data.userInfo.role : null; |
| | | if (role && role == "Teacher") {} else { |
| | |
| | | duration: 1000, |
| | | }); |
| | | } |
| | | } |
| | | }, |
| | | //申请纸质样书 |
| | | appplyPaperBook() { |
| | | const token = wx.getStorageSync(app.config.tokenKey); |
| | | if (token) { |
| | | applyFun() |
| | | } else { |
| | | this.logInFun(() => {}) |
| | | } |
| | | const applyFun = () => { |
| | | let role = this.data.userInfo != null ? this.data.userInfo.role : null; |
| | | if (role && role == "Teacher") {} else { |
| | | return wx.showModal({ |
| | |
| | | icon: "none", |
| | | duration: 1000, |
| | | }); |
| | | } |
| | | } |
| | | }, |
| | | // 添加样书 |
| | |
| | | return childrenList |
| | | }, |
| | | uploadFile(e) { |
| | | const token = wx.getStorageSync(app.config.tokenKey); |
| | | if (token) { |
| | | uploadFun() |
| | | } else { |
| | | this.logInFun(() => { |
| | | uploadFun() |
| | | }) |
| | | } |
| | | const uploadFun = () => { |
| | | const userInfo = JSON.parse(wx.getStorageSync(app.config.userInfoKey)) |
| | | if (userInfo.role != 'Teacher') return wx.showToast({ |
| | | icon: 'error', |
| | |
| | | dialogBox: true, |
| | | isShowUp: true |
| | | }); |
| | | } |
| | | }, |
| | | closeDialog() { |
| | | this.setData({ |