| | |
| | | // pages/bookServices/detail/index.js |
| | | import Toast from "tdesign-miniprogram/toast"; |
| | | import tool from "../../../../assets/js/toolClass"; |
| | | import moment from 'moment' |
| | | import { |
| | | loginInfo |
| | | } from "../../../../assets/js/login"; |
| | | import FormData from '../../../../utils/formdata/index.js'; |
| | | const app = getApp(); |
| | | var pastData = require('../../psychologyAnswer/testdata/index') |
| | | Page({ |
| | | /** |
| | | * 页面的初始数据 |
| | |
| | | learnPath: '', |
| | | applyResourceState: false, // 申请教学资源按钮防抖 |
| | | resourceClassList: [], // 资源所属分类 |
| | | applyState: "", // 教学资源申请状态 |
| | | applyState: "1", // 教学资源申请状态 |
| | | deadline: "", // 教学资源申请有效日期, |
| | | isShowBuyCloundBtn: false, |
| | | isshowDrawBtn: true, // 云学习领取查看按钮是否显示 |
| | | isShowBuyCloundMenu: false, // 云学习全部购买按钮是否显示 |
| | | isCloundHaveSaleMethod: false, // 云学习是否有销售方式 |
| | | cloundMenuIsBuy: false, |
| | | learnTaskData: {}, |
| | | rejectCause: "", // 下载拒绝原因 |
| | | buyIdList: [], |
| | | shoppingCartGetId: [], // 已购买id列表 |
| | |
| | | residue: 0, // 组卷剩余次数 |
| | | mockList: [], // 用户组卷提交信息 |
| | | }, |
| | | isBuyBank: false, // 题库是否购买 |
| | | isShoppingBank: false, // 题库是否加入购物车 |
| | | bankSaleData: null, |
| | | relatedBookLoading: false, |
| | | noRelatedBookData: false, |
| | | relatedBookPath: "", // 相关图书path |
| | |
| | | description: '', |
| | | agree: false |
| | | }, |
| | | resourceVisible: false, |
| | | resourceValue: [], |
| | | fileTypeList: [{ |
| | | label: '音频', |
| | | value: '音频' |
| | | }, |
| | | { |
| | | label: '视频', |
| | | value: '视频' |
| | | }, |
| | | { |
| | | label: '图片', |
| | | value: '图片' |
| | | }, |
| | | { |
| | | label: 'PDF', |
| | | value: 'PDF' |
| | | }, |
| | | { |
| | | label: '资源包', |
| | | value: '资源包' |
| | | }, |
| | | { |
| | | label: '文档', |
| | | value: '文档' |
| | | }, |
| | | { |
| | | label: '其他', |
| | | value: '其他' |
| | | } |
| | | ], |
| | | fileList: [], |
| | | isShowUp: true, |
| | | protocolShow: false, |
| | | protocolTxt: '' |
| | | protocolTxt: '', |
| | | learnMenu: null, |
| | | md5List: [], |
| | | editDialog: false |
| | | }, |
| | | |
| | | resetTree: function (e) { |
| | |
| | | currentCheck: e.detail.checkedItem, |
| | | 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() |
| | | } |
| | | }) |
| | | }, |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | |
| | | bookId: options.id + "", |
| | | barHeight: systInfo.statusBarHeight, |
| | | navBarHeight: navBarHeight, |
| | | }); |
| | | this.setData({ |
| | | options: { |
| | | id: options.id, |
| | | name: options.name, |
| | | name: decodeURI(options.name), |
| | | storeInfo: options.storeInfo, |
| | | }, |
| | | }); |
| | | wx.setNavigationBarTitle({ |
| | | title: options.name, |
| | | title: decodeURI(options.name), |
| | | }) |
| | | this.getBookInfo(options.id); |
| | | // this.getResourceClass(); // 获取资源所属分类 |
| | | 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 (wx.getStorageSync(app.config.userInfoKey)) { |
| | | this.setData({ |
| | | userInfo: JSON.parse(wx.getStorageSync(app.config.userInfoKey)), |
| | | }); |
| | | // 获取申请次数 |
| | | this.getSelectPaperBookCount(); |
| | | this.getSelectBookCount(); |
| | | } |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面初次渲染完成 |
| | | */ |
| | | onReady() {}, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面显示 |
| | | */ |
| | | onShow() { |
| | | onShow(options) { |
| | | if (wx.getStorageSync("paperBookList")) { |
| | | this.setData({ |
| | | paperBookList: JSON.parse(wx.getStorageSync("paperBookList")), |
| | |
| | | } |
| | | this.setData({ |
| | | num: Number(this.data.paperBookList.length) + Number(this.data.electronicBookList.length), |
| | | editDialog: false |
| | | }); |
| | | if (this.data.bookDetail.id) { |
| | | this.getBookInfo(this.data.bookDetail.id) |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面隐藏 |
| | | */ |
| | | onHide() {}, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面卸载 |
| | | */ |
| | | onUnload() {}, |
| | | |
| | | /** |
| | | * 页面相关事件处理函数--监听用户下拉动作 |
| | | */ |
| | | onPullDownRefresh() {}, |
| | | |
| | | /** |
| | | * 页面上拉触底事件的处理函数 |
| | |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * 用户点击右上角分享 |
| | | */ |
| | | onShareAppMessage() {}, |
| | | // 格式化日期 |
| | | formatDate(dateString) { |
| | | if (!dateString) { |
| | |
| | | protectedEpub: [], |
| | | probationPage: [], //pdf试读页数 |
| | | freeEpubPage: [], //epub试读百分比 |
| | | bookEditor: [], //图书编辑 |
| | | contactInformation: [], //联系方式 |
| | | }, |
| | | }; |
| | | app.MG.store.getProductDetail(query).then(async (res) => { |
| | | this.getResourceCode(id, res.datas.rootCmsItemId) |
| | | res.datas.bookEditor = res.datas.bookEditor ? res.datas.bookEditor : '-' |
| | | res.datas.contactInformation = res.datas.contactInformation ? res.datas.contactInformation : '-' |
| | | this.setData({ |
| | | bookDetail: res.datas, |
| | | buyIdList: res.datas.purchasedSaleMethodIdList, |
| | |
| | | await this.getBookClass(classData); |
| | | } |
| | | } |
| | | // 扫码从题库跳转回图书详情 |
| | | const localData = wx.getStorageSync('tabValue') |
| | | if (localData) { |
| | | this.setData({ |
| | | tabValue: localData |
| | | }) |
| | | wx.removeStorage({ |
| | | key: 'tabValue', |
| | | }) |
| | | } |
| | | if (this.data.tabValue == 'questionBank' || this.data.tabValue == 'jsek_cloudLearning' || this.data.tabValue == 'jsek_teachingResources') { |
| | | const checkData = this.data.cmsDatas.find( |
| | | (item) => item.refCode == this.data.tabValue |
| | | ); |
| | | if (this.data.tabValue == "questionBank") { |
| | | this.getResourceData(checkData) |
| | | } else { |
| | | this.getResourceDataList(checkData) |
| | | } |
| | | } |
| | | |
| | | // 获取组卷销售id |
| | | if (res.datas.saleMethod && res.datas.saleMethod.length) { |
| | |
| | | } |
| | | } |
| | | this.setData({ |
| | | "bookDetail.publicationDate": this.formatDate( |
| | | this.data.bookDetail.publicationDate |
| | | ), |
| | | "bookDetail.publicationDate": this.data.bookDetail.publicationDate ? moment(this.data.bookDetail.publicationDate).format("YYYY年MM月") : '', |
| | | "bookDetail.price": this.numFormat(this.data.bookDetail.price), |
| | | "bookDetail.oldPrice": this.numFormat(this.data.bookDetail.oldPrice), |
| | | "bookDetail.paperPrice": this.numFormat( |
| | | this.data.bookDetail.paperPrice |
| | | ), |
| | | |
| | | }); |
| | | }); |
| | | }, |
| | |
| | | } |
| | | } |
| | | app.MG.store.getProductDetail(query).then((res) => { |
| | | let isBuyBank = true |
| | | let isShoppingBank = true |
| | | let bankSaleData = null |
| | | // 判断题库是否整体购买 |
| | | const bank = res.datas.cmsDatas[0].datas.find((item) => item.refCode == 'questionBank') |
| | | if (bank) { |
| | | if (bank.saleMethod.length) { |
| | | bankSaleData = bank.saleMethod.find((item) => item.SaleType == 'Normal') |
| | | if (bankSaleData) { |
| | | isBuyBank = this.data.buyIdList.includes(bankSaleData.Id) |
| | | isShoppingBank = this.data.buyIdList.includes(bankSaleData.Id) ? true : this.data.shoppingCartGetId.includes(bankSaleData.Id) |
| | | } |
| | | } |
| | | } |
| | | this.setData({ |
| | | resourceCodeList: res.datas.cmsDatas[0].datas |
| | | resourceCodeList: res.datas.cmsDatas[0].datas, |
| | | learnTaskData: res.datas.cmsDatas[0].datas.filter((item) => item.refCode == 'jsek_learningTasks')[0], |
| | | isBuyBank, |
| | | isShoppingBank, |
| | | bankSaleData |
| | | }) |
| | | // console.log('图书资源', res.datas.cmsDatas[0].datas) |
| | | if (res.datas.cmsDatas[0].datas.length) this.setData({ |
| | | learnMenu: res.datas.cmsDatas[0].datas.find(item => item.refCode == 'jsek_cloudLearning') |
| | | }) |
| | | }) |
| | | }, |
| | | //请求子商品的文件 |
| | |
| | | setCollect() { |
| | | const token = wx.getStorageSync(app.config.tokenKey); |
| | | if (!token) { |
| | | // 检查登录状态 |
| | | loginInfo(app, (data) => { |
| | | // 如果不是第一次登录,会执行回调 |
| | | if (data) { |
| | | // 登录成功,自动记录token和用户信息,并返回true |
| | | this.getBookInfo(this.data.bookId); |
| | | } else { |
| | | // 出现错误,返回false |
| | | } |
| | | }); |
| | | this.logInFun(() => { |
| | | this.getBookInfo(this.data.bookId); |
| | | }) |
| | | } else { |
| | | if (this.data.bookDetail.isFavourite) { |
| | | app.MG.store |
| | | .delProductLink({ |
| | | productIds: [this.data.bookDetail.id], |
| | | linkType: "FavoriteBookCity", |
| | | }) |
| | | .then(() => { |
| | | this.setData({ |
| | | "bookDetail.isFavourite": false, |
| | | }); |
| | | }); |
| | | } else { |
| | | const params = { |
| | | this.collectFun() |
| | | } |
| | | }, |
| | | collectFun() { |
| | | if (this.data.bookDetail.isFavourite) { |
| | | app.MG.store |
| | | .delProductLink({ |
| | | productIds: [this.data.bookDetail.id], |
| | | linkType: "FavoriteBookCity", |
| | | }; |
| | | app.MG.store.addProductLink(params).then((res) => { |
| | | }) |
| | | .then(() => { |
| | | this.setData({ |
| | | "bookDetail.isFavourite": true, |
| | | "bookDetail.isFavourite": false, |
| | | }); |
| | | }); |
| | | } |
| | | } else { |
| | | const params = { |
| | | productIds: [this.data.bookDetail.id], |
| | | linkType: "FavoriteBookCity", |
| | | }; |
| | | app.MG.store.addProductLink(params).then((res) => { |
| | | this.setData({ |
| | | "bookDetail.isFavourite": true, |
| | | }); |
| | | }); |
| | | } |
| | | }, |
| | | // 联系 |
| | | editPhone() { |
| | | this.setData({ |
| | | editDialog: true |
| | | }) |
| | | }, |
| | | closeEditDialog() { |
| | | this.setData({ |
| | | editDialog: false |
| | | }) |
| | | }, |
| | | // 我要建议 |
| | | 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) { |
| | |
| | | link |
| | | } = e.currentTarget.dataset; |
| | | wx.navigateTo({ |
| | | url: `/packageBookService/pages/bookServices/webpage/index?url=${link}`, |
| | | url: `/packageBookService/pages/bookServices/linkPage/index?path=${link}`, |
| | | }); |
| | | }, |
| | | // tag切换 |
| | |
| | | e.detail.label == "云测试" |
| | | ) { |
| | | const checkData = this.data.cmsDatas.find( |
| | | (item) => item.refCode == e.detail.value |
| | | (item) => item.refCode == this.data.tabValue |
| | | ); |
| | | if (!this.data.resourceClassList.length) this.getResourceClass() |
| | | if (checkData) { |
| | |
| | | "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) |
| | |
| | | }, |
| | | |
| | | // 扁平化数据转换tree |
| | | getTreeList(rootList, pathLength, newArr, path, addNum) { |
| | | getTreeList(rootList, newArr, path) { |
| | | for (const item of rootList) { |
| | | // 此处原本 item.productLinkPath.length == pathLength 但 productLinkPath 长度个别书存在4、5位交错 |
| | | if ((pathLength - item.productLinkPath.length >= 0 && pathLength - item.productLinkPath.length <= 3) && item.productLinkPath.includes(path)) { |
| | | if (path == item.productLinkPath.replace('\\' + item.id, '')) { |
| | | if (item.sysType == 'CmsItem') { |
| | | if (item.selectType == 'webpage') { |
| | | item.disabled = true |
| | |
| | | } |
| | | // newArr.push(item) |
| | | // 在插入过程中对数据进行排序 |
| | | newArr = this.insertAndSortObjectsByProductLinkPath(newArr, item, addNum) |
| | | newArr = this.insertAndSortObjectsById(newArr, item) |
| | | // 插进数组后 从原数据中删除 |
| | | rootList = rootList.filter(nitem => nitem.id != item.id) |
| | | } |
| | | } |
| | | //给数组里面再添加一个children的空数组 |
| | | // let addnum1 = pathLength - path.length == 6 ? 6 : 7 |
| | | for (const i of newArr) { |
| | | i.children = [] |
| | | let addnum1 = i.productLinkPath.length - path.length == 6 ? 6 : 7 |
| | | this.getTreeList(rootList, pathLength + addnum1, i.children, i.productLinkPath, addnum1) |
| | | this.getTreeList(rootList, i.children, i.productLinkPath) |
| | | if (i.children.length == 0) { |
| | | delete i.children |
| | | } |
| | |
| | | return tree |
| | | }, |
| | | |
| | | // 排序数组 按照productLinkPath |
| | | insertAndSortObjectsByProductLinkPath(array, newObj, addNum) { |
| | | // 排序数组 按照id |
| | | insertAndSortObjectsById(array, newObj) { |
| | | // 查找新对象应该插入的位置 |
| | | let insertIndex = array.findIndex(obj => Number(newObj.productLinkPath.substring(newObj.productLinkPath.length - addNum, newObj.productLinkPath.length)) < Number(obj.productLinkPath.substring(obj.productLinkPath.length - addNum, obj.productLinkPath.length))); |
| | | let insertIndex = array.findIndex(obj => newObj.id < obj.id); |
| | | // 如果没有找到合适的位置,则放在数组末尾 |
| | | if (insertIndex === -1) { |
| | | insertIndex = array.length; |
| | | } |
| | | // 插入新对象到数组 |
| | | array.splice(insertIndex, 0, newObj); |
| | | // 测试6 正式5 |
| | | // 对数组进行排序 |
| | | array.sort((a, b) => { |
| | | if (Number(a.productLinkPath.substring(a.productLinkPath.length - addNum, a.productLinkPath.length)) < Number(b.productLinkPath.substring(b.productLinkPath.length - addNum, b.productLinkPath.length))) { |
| | | return -1; |
| | | } |
| | | if (Number(a.productLinkPath.substring(a.productLinkPath.length - addNum, a.productLinkPath.length)) > Number(b.productLinkPath.substring(b.productLinkPath.length - addNum, b.productLinkPath.length))) { |
| | | return 1; |
| | | } |
| | | // a must be equal to b |
| | | if (a.id < b.id) return -1; |
| | | if (a.id > b.id) return 1; |
| | | return 0; |
| | | }); |
| | | |
| | | // 返回更新后的数组 |
| | | return array; |
| | | }, |
| | | // 递归树结构,如果父级有销售方式(有效期),去掉所有子集的销售方式 |
| | | clearTreeSealmethod(clearSaleMethod, tree) { |
| | | for (let item of tree) { |
| | | const saleData = item.saleMethod && |
| | | item.saleMethod.length ? |
| | | item.saleMethod.find((citem) => citem.SaleType == 'Normal') : null |
| | | if ( |
| | | ((saleData && new Date(saleData.EndDate).getTime() >= new Date().getTime() && new Date(saleData.BeginDate).getTime() <= new Date().getTime()) || |
| | | clearSaleMethod) && item.children && item.children.length |
| | | ) { |
| | | item.children.forEach((ditem) => (ditem.saleMethod = [])) |
| | | } |
| | | if (item.children && item.children.length) |
| | | this.clearTreeSealmethod( |
| | | saleData && new Date(saleData.EndDate).getTime() >= new Date().getTime() && new Date(saleData.BeginDate).getTime() <= new Date().getTime(), |
| | | item.children |
| | | ) |
| | | } |
| | | return tree |
| | | }, |
| | | // 教学资源 云学习 获取 |
| | | getResourceDataList(type) { |
| | |
| | | let query = { |
| | | path: '*', |
| | | queryType: '*', |
| | | storeInfo: this.data.options.storeInfo, |
| | | productId: this.data.bookDetail.id, |
| | | cmsPath: type.productLinkPath, |
| | | cmsType: '*', |
| | |
| | | file: [], |
| | | protectedFile: [], |
| | | resourcesClassification: [], |
| | | isDownload: [], |
| | | // isDownload: [], |
| | | jsek_resourceBrief: [], |
| | | jsek_link: [], |
| | | jsek_questionBank: [] |
| | | }, |
| | | pading: { |
| | | start: 0, |
| | |
| | | }, |
| | | } |
| | | app.MG.store.getProductDetailNoChildren(query).then((res) => { |
| | | if (!res.datas.cmsDatas[0].datas.length) { |
| | | if (!res.datas.cmsDatas[0].datas.length || res.datas.cmsDatas[0].datas.length == 0) { |
| | | return this.setData({ |
| | | noResources: true, |
| | | loading: false, |
| | | }); |
| | | } |
| | | let list = [] |
| | | // 测试 6位// 正式 5位// 测试调用传20,内部7 正式调用传17 内部传6 |
| | | //教学资源 云学习 |
| | | if ( |
| | | type.refCode == "jsek_teachingResources" || |
| | | type.refCode == "jsek_cloudLearning" |
| | | ) { |
| | | res.datas.cmsDatas[0].datas.forEach((item) => { |
| | | item.checked = false; |
| | | if (item.sysType == 'CmsItem') { |
| | | // 教学资源 类型名称赋值 |
| | | this.data.resourceClassList.forEach((type) => { |
| | | if (type.value == item.resourcesClassification) |
| | | item.resourceClass = type.name; |
| | | }); |
| | | if (this.data.tabValue == "jsek_teachingResources") {} else if (this.data.tabValue == "jsek_cloudLearning") { |
| | | item.isbuy = this.isShowNeedBuy(item); |
| | | item.isShopCar = this.isShoppingCart(item); |
| | | } |
| | | // 判断云学习有无销售方式和有效期 |
| | | const cloundSaleMethod = |
| | | type.saleMethod && type.saleMethod.length ? |
| | | type.saleMethod.find((citem) => citem.SaleType == 'Normal') : |
| | | null |
| | | let flags = |
| | | type.refCode == 'jsek_cloudLearning' && |
| | | cloundSaleMethod && |
| | | new Date().getTime() <= new Date(cloundSaleMethod.EndDate).getTime() && |
| | | new Date().getTime() >= new Date(cloundSaleMethod.BeginDate).getTime() |
| | | let md5s = [] |
| | | res.datas.cmsDatas[0].datas.forEach((item) => { |
| | | // 云学习上有销售方式,去掉云学习下所有销售方式 |
| | | if (this.data.tabValue == "jsek_teachingResources") { |
| | | if (item.file || item.freeFile) { |
| | | let md5 = item.file ? item.file : item.freeFile |
| | | md5s.push(md5) |
| | | } |
| | | }); |
| | | if (type.refCode == "jsek_cloudLearning") { |
| | | this.setData({ |
| | | learnPath: type.productLinkPath |
| | | }) |
| | | const dataList = res.datas.cmsDatas[0].datas |
| | | // 先判断是否否买云学习整个目录 |
| | | let couldId = null |
| | | let codeData = null |
| | | if (this.data.resourceCodeList.length) { |
| | | codeData = this.data.resourceCodeList.find(item => item.refCode == 'jsek_cloudLearning') |
| | | if (codeData && codeData.saleMethod && codeData.saleMethod.length) |
| | | couldId = codeData.saleMethod[0].Id |
| | | } |
| | | if (couldId) { |
| | | this.setData({ |
| | | isGoBuyResource: this.data.buyIdList.indexOf(couldId) > -1 ? false : true |
| | | }) |
| | | } else if (dataList.length) { |
| | | const tag = dataList.findIndex(item => item.saleMethod.length && item.saleMethod[0].Price > 0) |
| | | this.setData({ |
| | | isGoBuyResource: tag > -1 ? true : false |
| | | }) |
| | | } else { |
| | | this.setData({ |
| | | isGoBuyResource: false |
| | | }) |
| | | } |
| | | } |
| | | const addNum = query.cmsPath.length > 10 ? 7 : query.cmsPath.length > 13 ? 8 : 6 |
| | | const num = query.cmsPath.length + addNum |
| | | this.getTreeList(res.datas.cmsDatas[0].datas, num, list, '\\', addNum) |
| | | list = this.ensureTreeConsistency(list) |
| | | list = this.changeResourceChildren(list) |
| | | let result = []; |
| | | if (type.refCode == "jsek_teachingResources") { |
| | | this.findChildIds(list, result); |
| | | // const newUSeList = this.deleteTreeData(list, result) |
| | | // console.log('树剔除', result, newUSeList); |
| | | |
| | | this.setData({ |
| | | openTeachids: result, |
| | | loading: false, |
| | | teach: list, |
| | | }); |
| | | } else if (type.refCode == "jsek_cloudLearning") { |
| | | let arr = this.handleTreeData(list).filter( |
| | | (item) => item.saleMethod[0] |
| | | ); |
| | | let freeIds = arr.filter((item) => { |
| | | return item.saleMethod[0].Price == 0; |
| | | }); |
| | | if (!freeIds.length) |
| | | this.setData({ |
| | | isshowDrawBtn: false, |
| | | }); |
| | | this.findChildIds(list, result); |
| | | this.setData({ |
| | | learn: list, |
| | | loading: false, |
| | | openLearnids: result, |
| | | md5List: md5s, |
| | | }); |
| | | } |
| | | if (flags && cloundSaleMethod.Price > 0) item.saleMethod = [] |
| | | item.checked = false; |
| | | if (item.sysType == 'CmsItem') { |
| | | // 教学资源 类型名称赋值 |
| | | this.data.resourceClassList.forEach((type) => { |
| | | if (type.value == item.resourcesClassification) |
| | | item.resourceClass = type.name; |
| | | }); |
| | | // if (this.data.tabValue == "jsek_teachingResources") {} else if (this.data.tabValue == "jsek_cloudLearning") { |
| | | // item.isbuy = this.isShowNeedBuy(item); |
| | | // item.isShopCar = this.isShoppingCart(item); |
| | | // } |
| | | } |
| | | }); |
| | | // 判断处理资源 |
| | | if (res.datas.cmsDatas[0].datas.some((item) => item.sysType == 'CmsFolder')) { |
| | | if (!res.datas.cmsDatas[0].datas.some((item) => item.sysType == 'CmsItem')) { |
| | | // 1.只有目录,没有资源 |
| | | list = res.datas.cmsDatas[0].datas |
| | | } else { |
| | | this.getTreeList(res.datas.cmsDatas[0].datas, list, query.cmsPath) |
| | | list = this.ensureTreeConsistency(list) |
| | | list = this.changeResourceChildren(list) |
| | | } |
| | | } else { |
| | | // 3.只有资源,没有目录 |
| | | list = res.datas.cmsDatas[0].datas |
| | | } |
| | | let result = []; |
| | | if (type.refCode == "jsek_teachingResources") { |
| | | this.findChildIds(list, result); |
| | | this.setData({ |
| | | openTeachids: result, |
| | | loading: false, |
| | | teach: list, |
| | | }); |
| | | } else if (type.refCode == "jsek_cloudLearning") { |
| | | // 云学习上无销售方式,走目录 资源 销售方式去除方法 |
| | | if (!flags) list = this.clearTreeSealmethod(false, list) |
| | | // 判断领取查看是否显示(云学习,或资源目录,有售价为0) |
| | | let isshowDrawBtn = res.datas.cmsDatas[0].datas.some( |
| | | (item) => |
| | | item.saleMethod.length && |
| | | item.saleMethod.find((citem) => citem.SaleType == 'Normal').Price == 0 && |
| | | new Date(item.saleMethod.find((citem) => citem.SaleType == 'Normal').EndDate).getTime() >= new Date().getTime() && |
| | | new Date(item.saleMethod.find((citem) => citem.SaleType == 'Normal').BeginDate).getTime() <= new Date().getTime() |
| | | ) || (flags && cloundSaleMethod.Price == 0) |
| | | // 判断云学习全部购买按钮是否显示 |
| | | let isShowBuyCloundMenu = flags && cloundSaleMethod.Price > 0 && !this.data.buyIdList.includes(cloundSaleMethod.Id) |
| | | // 判断资源购买按钮是否显示 |
| | | let isShowBuyCloundBtn = !flags && res.datas.cmsDatas[0].datas.some(citem => citem.saleMethod.length != 0) |
| | | // 判断购物车按钮和锁按钮是否显示 |
| | | this.handleTreeData(list).forEach(item => { |
| | | item.isbuy = this.resourceIsBuy(item); |
| | | item.isShopCar = this.isShoppingCart(item); |
| | | }) |
| | | this.findChildIds(list, result); |
| | | this.setData({ |
| | | isshowDrawBtn, |
| | | isShowBuyCloundMenu, |
| | | isShowBuyCloundBtn, |
| | | isCloundHaveSaleMethod: flags && cloundSaleMethod.Price > 0, |
| | | learn: list, |
| | | loading: false, |
| | | openLearnids: result, |
| | | learnPath: type.productLinkPath |
| | | }); |
| | | } |
| | | console.log('1', this.data.teach); |
| | | }) |
| | | }, |
| | | // 获取 云测试 |
| | |
| | | } |
| | | } else { |
| | | if (isTSFW.length > 0) { |
| | | data = res.datas.cmsDatas[0].datas.filter((item) => item.type == 'questionBankFolder' && item.childrenFolderCount > 0) |
| | | data = res.datas.cmsDatas[0].datas.filter((item) => item.type == 'questionBankFolder' && item.refCode != 'jsek_interaction' && (item.childrenFolderCount > 0 || item.childrenCount > 0) && (item.name !== '填空题' && |
| | | item.name !== '判断题' && |
| | | item.name !== '多选题' && |
| | | item.name !== '简答题') && item.name !== '单选题') |
| | | that.setData({ |
| | | jslx: false, |
| | | }); |
| | | } else { |
| | | data = res.datas.cmsDatas[0].datas.filter((item) => item.type == 'questionBankFolder') |
| | | // && item.refCode != 'jsek_interaction' |
| | | that.setData({ |
| | | jslx: true, |
| | | }); |
| | | } |
| | | if (data.length > 0) { |
| | | console.log('data', data); |
| | | let list = [] |
| | | // 测试 6位// 正式 5位// 测试调用传20,内部7 正式调用传17 内部传6 |
| | | |
| | | const addNum = query.cmsPath.length > 10 ? 7 : query.cmsPath.length > 13 ? 8 : 6 |
| | | const num = query.cmsPath.length + addNum |
| | | that.getTreeList(data, num, list, '\\', addNum) |
| | | that.getTreeList(data, list, query.cmsPath) |
| | | list = that.ensureTreeConsistency(list) |
| | | that.findChildIds(list[0].children, result); |
| | | that.setData({ |
| | |
| | | loading: false, |
| | | openTeachids: result, |
| | | }); |
| | | //Json赋值 |
| | | // const bookId = that.data.bookId |
| | | // if (bookId == 6619) { |
| | | // const jsonData = {} |
| | | // jsonData.name = "心理测评" |
| | | // jsonData.children = [...pastData.postData.list] |
| | | // var test = that.data.test; |
| | | // test.push(jsonData); |
| | | // that.setData({ |
| | | // test: test, |
| | | // }); |
| | | // console.log(that.data.test, "教学互动"); |
| | | // } |
| | | |
| | | } else { |
| | | that.setData({ |
| | | noResources: true, |
| | |
| | | console.log(e); |
| | | }); |
| | | }, |
| | | // 获取tag下所有资源 |
| | | async getAllResource(data) { |
| | | if (!data.length) return false; |
| | | for (let i = 0; i < data.length; i++) { |
| | | let item = data[i]; |
| | | if (item.sysType == "CmsFolder" && item.childrenCount > 0) { |
| | | item.children = []; |
| | | item.children = await this.getFolderItem(item.productLinkPath); |
| | | await this.getAllResource(item.children); |
| | | } |
| | | } |
| | | return data; |
| | | }, |
| | | // 获取资源接口 |
| | | async getFolderItem(path) { |
| | | let query = { |
| | | path: "*", |
| | | queryType: "*", |
| | | storeInfo: this.data.options.storeInfo, |
| | | productId: this.data.bookDetail.id, |
| | | cmsPath: path, |
| | | itemFields: { |
| | | SysType: "CmsFolder", |
| | | // 资源类型,试读文件,是否允许下载等参数 |
| | | selectType: [], |
| | | freeFile: [], |
| | | file: [], |
| | | protectedFile: [], |
| | | resourcesClassification: [], |
| | | isDownload: [], |
| | | jsek_resourceBrief: [], |
| | | jsek_link: [], |
| | | accessType: [], |
| | | learnSelectType: [], |
| | | }, |
| | | pading: { |
| | | start: 0, |
| | | size: 999, |
| | | }, |
| | | }; |
| | | let data = await app.MG.store.getProductDetail(query); |
| | | // 如果item层级里有floder,删除floder |
| | | const flag = data.datas.cmsDatas[0].datas.findIndex( |
| | | (item) => item.sysType == "CmsItem" |
| | | ); |
| | | if (flag > -1) |
| | | data.datas.cmsDatas[0].datas = data.datas.cmsDatas[0].datas.filter( |
| | | (item) => item.sysType == "CmsItem" |
| | | ); |
| | | data.datas.cmsDatas[0].datas.forEach((item) => { |
| | | // if (item.sysType == "CmsFolder" && flag > -1) { |
| | | // item.isShow = false; |
| | | // } else { |
| | | // item.isShow = true; |
| | | // } |
| | | this.data.resourceClassList.forEach((type) => { |
| | | if (type.value == item.resourcesClassification) |
| | | item.resourceClass = type.name; |
| | | }); |
| | | // 网页 不能下载 私有文件 |
| | | if (item.sysType == "CmsItem") { |
| | | if (item.selectType == "webpage") { |
| | | item.disabled = true; |
| | | } else { |
| | | if (item.isDownload != 1) { |
| | | item.disabled = true; |
| | | } |
| | | } |
| | | if (item.file && item.fileMap && item.fileMap[item.file]) { |
| | | if (item.fileMap[item.file].protectType == "Private") |
| | | item.disabled = true; |
| | | } |
| | | } |
| | | }); |
| | | data.datas.cmsDatas[0].datas.forEach((item) => { |
| | | if (this.data.tabValue == "jsek_teachingResources") { |
| | | item.checked = false; |
| | | } else if (this.data.tabValue == "jsek_cloudLearning") { |
| | | item.checked = false; |
| | | item.isbuy = this.isShowNeedBuy(item); |
| | | item.isShopCar = this.isShoppingCart(item); |
| | | } |
| | | }); |
| | | return data.datas.cmsDatas[0].datas; |
| | | }, |
| | | |
| | | // 获取展开项 |
| | | findChildIds(data, result) { |
| | | let index = 0 |
| | |
| | | }, |
| | | |
| | | // 图书添加购物车 |
| | | async addBookShopcCar() { |
| | | if (!this.data.expire) { |
| | | const shoppingCartGetId = []; |
| | | let query = { |
| | | start: 0, |
| | | size: 9999, |
| | | filterList: [], |
| | | searchList: [], |
| | | }; |
| | | const res = await app.MG.store.getShoppingCartProductList(query); |
| | | res.datas.forEach((item) => { |
| | | shoppingCartGetId.push(item.saleMethod.id); |
| | | }); |
| | | const determine = shoppingCartGetId.some( |
| | | (item) => item == this.data.selectedIds |
| | | ); |
| | | if (!determine) { |
| | | addBookShopcCar() { |
| | | const addFun = async () => { |
| | | if (!this.data.expire) { |
| | | const shoppingCartGetId = []; |
| | | let query = { |
| | | requests: [{ |
| | | saleMethodId: this.data.selectedIds, |
| | | storeEventId: null, |
| | | agentCode: "电子书", |
| | | }, ], |
| | | start: 0, |
| | | size: 9999, |
| | | filterList: [], |
| | | searchList: [], |
| | | }; |
| | | const addRes = app.MG.store.addShoppingCart(query); |
| | | this.showSuccessToast(); |
| | | const res = await app.MG.store.getShoppingCartProductList(query); |
| | | res.datas.forEach((item) => { |
| | | shoppingCartGetId.push(item.saleMethod.id); |
| | | }); |
| | | const determine = shoppingCartGetId.some( |
| | | (item) => item == this.data.selectedIds |
| | | ); |
| | | if (!determine) { |
| | | let query = { |
| | | requests: [{ |
| | | saleMethodId: this.data.selectedIds, |
| | | storeEventId: null, |
| | | agentCode: "电子书", |
| | | }, ], |
| | | }; |
| | | const addRes = app.MG.store.addShoppingCart(query); |
| | | this.showSuccessToast(); |
| | | } else { |
| | | Toast({ |
| | | context: this, |
| | | selector: "#t-toast", |
| | | message: "该书已在购物车,请勿重复添加", |
| | | theme: "warning", |
| | | direction: "column", |
| | | }); |
| | | } |
| | | } else { |
| | | Toast({ |
| | | context: this, |
| | | selector: "#t-toast", |
| | | message: "该书已在购物车,请勿重复添加", |
| | | theme: "warning", |
| | | direction: "column", |
| | | wx.showToast({ |
| | | title: "商品不在有效期", |
| | | icon: "none", |
| | | duration: 1000, |
| | | }); |
| | | } |
| | | } else { |
| | | wx.showToast({ |
| | | title: "商品不在有效期", |
| | | icon: "none", |
| | | duration: 1000, |
| | | }); |
| | | } |
| | | const token = wx.getStorageSync(app.config.tokenKey); |
| | | if (token) { |
| | | addFun() |
| | | } else { |
| | | this.logInFun(() => {}) |
| | | } |
| | | |
| | | }, |
| | | |
| | | showSuccessToast() { |
| | |
| | | applyState: "Normal", |
| | | deadline: "永久", |
| | | }); |
| | | console.log("有效日期", this.data.deadline); |
| | | } else { |
| | | let endTime = new Date(endDate + " 23:59:59").getTime(); |
| | | this.setData({ |
| | |
| | | }, |
| | | // 判断资源是否购买 |
| | | resourceIsBuy(data) { |
| | | let couldId = null |
| | | let codeData = null |
| | | if (this.data.resourceCodeList.length) { |
| | | codeData = this.data.resourceCodeList.find(item => item.refCode == 'jsek_cloudLearning') |
| | | if (codeData && codeData.saleMethod && codeData.saleMethod.length) |
| | | couldId = codeData.saleMethod[0].Id |
| | | } |
| | | if (couldId) { |
| | | return this.data.buyIdList.indexOf(couldId) > -1 ? false : true |
| | | } else if (data.saleMethod && data.saleMethod.length) { |
| | | const isSHow = this.data.buyIdList.some( |
| | | (item) => item == data.saleMethod[0].Id |
| | | if (data.saleMethod && data.saleMethod.length) { |
| | | const saleData = data.saleMethod.find((item) => item.SaleType == 'Normal') |
| | | if (saleData.State == 'Disable') return false |
| | | const isShow = this.data.buyIdList.some( |
| | | (item) => item == saleData.Id |
| | | ); |
| | | return !isSHow; |
| | | // 已经购买 |
| | | if (isShow || saleData.Price == 0) return false |
| | | // 未购买,查看销售方式是否过期 |
| | | if (!isShow) { |
| | | const flag = new Date(saleData.EndDate).getTime() >= new Date().getTime() && |
| | | new Date(saleData.BeginDate).getTime() <= new Date().getTime() |
| | | if (flag) { |
| | | // 为过期 ,需要购买 |
| | | return true |
| | | } else { |
| | | // 已过期 无需购买 |
| | | return false |
| | | } |
| | | } |
| | | } else { |
| | | return false; |
| | | } |
| | |
| | | }, |
| | | // 判断资源加入购物车按钮是否显示 |
| | | isShoppingCart(data) { |
| | | let couldId = null |
| | | let codeData = null |
| | | if (this.data.resourceCodeList.length) { |
| | | codeData = this.data.resourceCodeList.find(item => item.refCode == 'jsek_cloudLearning') |
| | | if (codeData && codeData.saleMethod && codeData.saleMethod.length) |
| | | couldId = codeData.saleMethod[0].Id |
| | | } |
| | | if (couldId) { |
| | | return this.data.buyIdList.indexOf(couldId) > -1 ? false : true |
| | | } else if (data.saleMethod && data.saleMethod.length) { |
| | | if (data.saleMethod[0].Price <= 0) return false; |
| | | if (data.saleMethod && data.saleMethod.length) { |
| | | const saleData = data.saleMethod.find((item) => item.SaleType == 'Normal') |
| | | // 先判断是否免费 |
| | | if (saleData.Price <= 0) return false |
| | | // 再判断是否购买 |
| | | const isBuy = this.data.buyIdList.some( |
| | | (item) => item == data.saleMethod[0].Id |
| | | ); |
| | | const isBuy = this.data.buyIdList.some((item) => item == saleData.Id) |
| | | if (isBuy) { |
| | | // 购买了 |
| | | return false; |
| | | return false |
| | | } else { |
| | | // 判断是否加入购物车 |
| | | const isSHow = this.data.shoppingCartGetId.some( |
| | | (item) => item == data.saleMethod[0].Id |
| | | ); |
| | | return !isSHow; |
| | | const isShow = this.data.shoppingCartGetId.some((item) => item == saleData.Id) |
| | | if (isShow) return false |
| | | // 未购买,查看销售方式是否过期 |
| | | if (!isShow) { |
| | | const flag = new Date(saleData.EndDate).getTime() >= new Date().getTime() && |
| | | new Date(saleData.BeginDate).getTime() <= new Date().getTime() |
| | | if (flag) { |
| | | // 为过期 ,需要购买 |
| | | return true |
| | | } else { |
| | | // 已过期 无需购买 |
| | | return false |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | return false; |
| | |
| | | flattenedArray.push(...childrenArray); |
| | | } |
| | | }); |
| | | return flattenedArray.filter((item) => item.sysType == "CmsItem"); |
| | | return flattenedArray; |
| | | }, |
| | | // 云学习一键领取 |
| | | async getFreeResource() { |
| | | const child = this.selectComponent("#learn-resource"); |
| | | const token = wx.getStorageSync(app.config.tokenKey); |
| | | if (!token) { |
| | | loginInfo(app, (data) => { |
| | | // 如果不是第一次登录,会执行回调 |
| | | if (data) { |
| | | // 登录成功,自动记录token和用户信息,并返回true |
| | | } else { |
| | | // 出现错误,返回false |
| | | getFreeResource() { |
| | | const getFreeFun = async () => { |
| | | // 领取查看 ,先看云学习上的 再看资源上的 |
| | | const cloundMenu = this.data.resourceCodeList.find((item) => item.refCode == 'jsek_cloudLearning') |
| | | const cloundMenuSaleMethod = |
| | | cloundMenu.saleMethod && cloundMenu.saleMethod.length ? |
| | | cloundMenu.saleMethod.find((ditem) => ditem.SaleType == 'Normal') : |
| | | undefined |
| | | let query = {} |
| | | if (this.data.isCloundHaveSaleMethod && !cloundMenuSaleMethod.Price) { |
| | | // 云学习上有销售方式,且为0元,直接领取云学习 |
| | | query = { |
| | | remarks: '云学习', |
| | | requests: [{ |
| | | saleMethodId: cloundMenuSaleMethod.Id, |
| | | count: 1 |
| | | }] |
| | | } |
| | | }); |
| | | } else { |
| | | let arr = this.handleTreeData(this.data.learn).filter((item) => |
| | | this.resourceIsBuy(item) |
| | | ); |
| | | let freeIds = arr.filter((item) => { |
| | | return item.saleMethod[0].Price == 0; |
| | | }); |
| | | if (!freeIds.length) |
| | | return wx.showToast({ |
| | | icon: "error", |
| | | title: "暂无免费资源", |
| | | }); |
| | | child.changeReceive(true); |
| | | let requests = []; |
| | | freeIds.forEach((item, index) => { |
| | | if (this.resourceIsBuy(item)) { |
| | | requests.push({ |
| | | saleMethodId: item.saleMethod[0].Id, |
| | | count: 1, |
| | | } else { |
| | | // 领取资源 |
| | | let arr = this.handleTreeData(this.data.learn).filter(item => this.resourceIsBuy(item)) |
| | | let freeIds = arr.filter((item) => { |
| | | return item.saleMethod.find((citem) => citem.SaleType == 'Normal').Price == 0 |
| | | }) |
| | | if (!freeIds.length) |
| | | return wx.showToast({ |
| | | icon: "error", |
| | | title: "暂无免费资源", |
| | | }); |
| | | } |
| | | }); |
| | | let query = { |
| | | remarks: "云学习", |
| | | requests, |
| | | }; |
| | | let requests = []; |
| | | freeIds.forEach((item, index) => { |
| | | if (this.resourceIsBuy(item)) { |
| | | requests.push({ |
| | | saleMethodId: item.saleMethod[0].Id, |
| | | count: 1, |
| | | }); |
| | | } |
| | | }); |
| | | query = { |
| | | remarks: "云学习", |
| | | requests, |
| | | }; |
| | | } |
| | | child.changeReceive(true); |
| | | try { |
| | | const initOrderRes = await app.MG.store.initOrder(query); |
| | | let parameter = { |
| | |
| | | console.log(error); |
| | | } |
| | | } |
| | | const child = this.selectComponent("#learn-resource"); |
| | | const token = wx.getStorageSync(app.config.tokenKey); |
| | | if (!token) { |
| | | this.logInFun(() => {}); |
| | | } else { |
| | | getFreeFun() |
| | | } |
| | | |
| | | }, |
| | | // 云学习一键购买 |
| | | async allAddShoppiingCar() { |
| | |
| | | }, |
| | | }); |
| | | } |
| | | let shopList = this.handleTreeData(this.data.learn).filter((item) => |
| | | let shopList = this.handleTreeData(this.data.learn).filter(item => item.cmsType == 'cmsItem') |
| | | shopList = shopList.filter((item) => |
| | | this.resourceIsBuy(item) |
| | | ); |
| | | this.getShoppingCartProductGet(); |
| | |
| | | }); |
| | | } |
| | | }, |
| | | // 云学习全部购买 |
| | | buyCloudLearnClass() { |
| | | const buyClass = async () => { |
| | | const cloundMenu = this.data.resourceCodeList.find((item) => item.refCode == 'jsek_cloudLearning') |
| | | let query = { |
| | | remarks: '云学习', |
| | | requests: [{ |
| | | saleMethodId: cloundMenu.saleMethod.find((eitem) => eitem.SaleType == 'Normal').Id, |
| | | count: 1 |
| | | }] |
| | | } |
| | | const initOrderRes = await app.MG.store.initOrder(query) |
| | | // 检查订单号是否存在 |
| | | if (initOrderRes.orderNumber) { |
| | | // bookService: orderNumber.value, 少传这个 ,暂时不知道有什么用 |
| | | wx.navigateTo({ |
| | | url: `/pages/cart/paymentPage/index?&bookId=${this.data.bookDetail.id}&bookName=${this.data.bookDetail.name}&orderNumber=${initOrderRes.orderNumber}`, |
| | | }); |
| | | } else { |
| | | // 订单号不存在,显示警告消息 |
| | | wx.showToast({ |
| | | icon: "error", |
| | | title: "请重试", |
| | | }); |
| | | } |
| | | } |
| | | const token = wx.getStorageSync(app.config.tokenKey); |
| | | if (token) { |
| | | buyClass() |
| | | } else { |
| | | this.logInFun(() => {}) |
| | | } |
| | | |
| | | }, |
| | | // 变为所有check true |
| | | findAndUpdateItemsByIds(tree, ids) { |
| | | function findAndUpdate(node) { |
| | |
| | | } |
| | | return tree; // 返回修改后的完整数组 |
| | | }, |
| | | handleTrue() { |
| | | // findAndUpdateItemsByIds(this.date.) |
| | | |
| | | // 题库购买 |
| | | async buyBank() { |
| | | let query = { |
| | | remarks: '云测试', |
| | | requests: [{ |
| | | saleMethodId: this.data.bankSaleData.Id, |
| | | count: 1 |
| | | }] |
| | | } |
| | | const initOrderRes = await app.MG.store.initOrder(query) |
| | | if (this.data.bankSaleData.Price) { |
| | | // 购买 |
| | | const url = "/pages/cart/paymentPage/index?orderNumber=" + initOrderRes.orderNumber + '&onNorderSaleMethod=' + initOrderRes.saleMethodLinks[0].orderSaleMethod.id; |
| | | wx.navigateTo({ |
| | | url, |
| | | }); |
| | | } else { |
| | | // 免费领取 |
| | | app.MG.store |
| | | .confirmOrder({ |
| | | orderNum: initOrderRes.orderNumber, |
| | | }) |
| | | .then((res) => { |
| | | if (res) { |
| | | wx.showToast({ |
| | | title: "领取成功", |
| | | icon: "none", |
| | | duration: 1000, |
| | | }); |
| | | this.getBookInfo(this.data.bookDetail.id); |
| | | } |
| | | }); |
| | | } |
| | | }, |
| | | // 题库加入购物车 |
| | | handleShoppingBank() { |
| | | let query = { |
| | | requests: [{ |
| | | saleMethodId: this.data.bankSaleData.Id, |
| | | storeEventId: null, |
| | | agentCode: "云测试", |
| | | }, ], |
| | | }; |
| | | app.MG.store.addShoppingCart(query).then(res => { |
| | | wx.showToast({ |
| | | icon: 'success', |
| | | title: '加入成功', |
| | | }) |
| | | this.getShoppingCartProductGet(); |
| | | this.getBookInfo(this.data.bookDetail.id) |
| | | }) |
| | | }, |
| | | // 组卷格式化日期显示 |
| | | DateFormat(date, fmt) { |
| | |
| | | }); |
| | | }, |
| | | // 购买组卷 |
| | | async buyMock() { |
| | | let res; |
| | | if (!this.data.mockData.id) |
| | | return wx.showToast({ |
| | | icon: "error", |
| | | title: "暂无组卷", |
| | | mask: true, |
| | | }); |
| | | // 构建订单查询对象 |
| | | try { |
| | | let query = { |
| | | remarks: "组卷", |
| | | requests: [{ |
| | | saleMethodId: this.data.mockData.id, |
| | | count: 1, |
| | | }, ], |
| | | }; |
| | | if (this.data.flag) { |
| | | this.setData({ |
| | | flag: false, |
| | | buyMock() { |
| | | const buyMockFun = async () => { |
| | | let res; |
| | | if (!this.data.mockData.id) |
| | | return wx.showToast({ |
| | | icon: "error", |
| | | title: "暂无组卷", |
| | | mask: true, |
| | | }); |
| | | res = await app.MG.store.initOrder(query); |
| | | } |
| | | if (res.orderNumber && this.data.mockData.price) { |
| | | wx.navigateTo({ |
| | | url: `/pages/cart/paymentPage/index?orderNumber=${res.orderNumber}`, |
| | | }); |
| | | } else { |
| | | // 0元直接领取 |
| | | // 确认订单 |
| | | const confirmOrderRes = await app.MG.store.confirmOrder({ |
| | | orderNum: res.orderNumber, |
| | | }); |
| | | if (confirmOrderRes) { |
| | | wx.showToast({ |
| | | icon: "success", |
| | | title: "领取成功", |
| | | }); |
| | | // 构建订单查询对象 |
| | | try { |
| | | let query = { |
| | | remarks: "组卷", |
| | | requests: [{ |
| | | saleMethodId: this.data.mockData.id, |
| | | count: 1, |
| | | }, ], |
| | | }; |
| | | if (this.data.flag) { |
| | | this.setData({ |
| | | flag: true, |
| | | flag: false, |
| | | }); |
| | | await this.recordBuyMock(); // 记录购买时间 |
| | | res = await app.MG.store.initOrder(query); |
| | | } |
| | | if (res.orderNumber && this.data.mockData.price) { |
| | | wx.navigateTo({ |
| | | url: `/pages/cart/paymentPage/index?orderNumber=${res.orderNumber}`, |
| | | }); |
| | | } else { |
| | | // 0元直接领取 |
| | | // 确认订单 |
| | | const confirmOrderRes = await app.MG.store.confirmOrder({ |
| | | orderNum: res.orderNumber, |
| | | }); |
| | | if (confirmOrderRes) { |
| | | wx.showToast({ |
| | | icon: "success", |
| | | title: "领取成功", |
| | | }); |
| | | this.setData({ |
| | | flag: true, |
| | | }); |
| | | await this.recordBuyMock(); // 记录购买时间 |
| | | } |
| | | } |
| | | } catch (error) { |
| | | console.log(error); |
| | | } |
| | | } catch (error) { |
| | | console.log(error); |
| | | } |
| | | const token = wx.getStorageSync(app.config.tokenKey); |
| | | if (token) { |
| | | buyMockFun() |
| | | } else { |
| | | this.logInFun(() => {}) |
| | | } |
| | | |
| | | }, |
| | | // 记录购买组卷时间 |
| | | recordBuyMock() { |
| | |
| | | }, |
| | | // 底部购买按钮 |
| | | buyBtn() { |
| | | if (this.data.tabValue == "brief" && !this.data.bookBuy) { |
| | | this.buyBook(); |
| | | } else if (this.data.tabValue == "jsek_cloudLearning") { |
| | | const tree = this.selectComponent("#tree"); |
| | | tree.onCloudShoppingCart(); |
| | | } else { |
| | | console.log(this.data.tabValue); |
| | | const buyFun = () => { |
| | | if (this.data.tabValue == "brief" && !this.data.bookBuy) { |
| | | this.buyBook(); |
| | | } else if (this.data.tabValue == "jsek_cloudLearning") { |
| | | const tree = this.selectComponent("#tree"); |
| | | tree.onCloudShoppingCart(); |
| | | } else { |
| | | console.log(this.data.tabValue); |
| | | } |
| | | } |
| | | const token = wx.getStorageSync(app.config.tokenKey); |
| | | if (token) { |
| | | buyFun() |
| | | } else { |
| | | this.logInFun(() => {}) |
| | | } |
| | | |
| | | }, |
| | | |
| | | goRead() { |
| | | if (!this.data.noFile) { |
| | | wx.showToast({ |
| | | title: "暂无阅读文件", |
| | | icon: "none", |
| | | duration: 2000, |
| | | goRead(e) { |
| | | const readFun = (bookBuy) => { |
| | | if (!this.data.noFile) { |
| | | wx.showToast({ |
| | | title: "暂无阅读文件", |
| | | icon: "none", |
| | | duration: 2000, |
| | | }); |
| | | return false; |
| | | } |
| | | wx.navigateTo({ |
| | | url: "/packageBookService/pages/components/webView/index?md5=" + |
| | | this.data.fileInfo.md5 + |
| | | "&fileName=" + |
| | | this.data.fileInfo.bookName + |
| | | "&fileType=" + |
| | | this.data.fileInfo.fileType + |
| | | "&freePage=" + |
| | | this.data.fileInfo.freePage + |
| | | "&bookBuy=" + |
| | | bookBuy + |
| | | "&bookId=" + |
| | | this.data.bookDetail.id, |
| | | }); |
| | | return false; |
| | | } |
| | | wx.navigateTo({ |
| | | url: "/packageBookService/pages/components/webView/index?md5=" + |
| | | this.data.fileInfo.md5 + |
| | | "&fileName=" + |
| | | this.data.fileInfo.bookName + |
| | | "&fileType=" + |
| | | this.data.fileInfo.fileType + |
| | | "&freePage=" + |
| | | this.data.fileInfo.freePage + |
| | | "&bookBuy=" + |
| | | this.data.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) |
| | | }) |
| | | } |
| | | |
| | | }); |
| | | }, |
| | | |
| | | //样书申请 |
| | |
| | | } |
| | | }); |
| | | const smBook = list.find(item => item.content[0].id == this.data.bookDetail.id) |
| | | console.log('已申请', smBook); |
| | | if (smBook && smBook.state == 'Normal') { |
| | | const flag = new Date(smBook.feedBack.endDate + ' 23:59:59').getTime() > new Date().getTime() |
| | | if (flag) { |
| | |
| | | |
| | | //申请电子样书 |
| | | appplyElectronicBook() { |
| | | // 先判断下教师认证,未对原有逻辑修改 |
| | | let role = this.data.userInfo != null ? this.data.userInfo.role : null; |
| | | if (role && role == "Teacher") {} else { |
| | | return wx.showModal({ |
| | | title: "尊敬的用户,您好!", //提示的标题 |
| | | content: "请先进行教师认证?", //提示的内容 |
| | | confirmColor: "#ff6c00", |
| | | cancelColor: "#949494", |
| | | success: function (res) { |
| | | if (res.confirm) { |
| | | wx.navigateTo({ |
| | | url: "/packageDomain/pages/teacherCertification/index", |
| | | }); |
| | | } else if (res.cancel) {} |
| | | }, |
| | | }); |
| | | } |
| | | if ( |
| | | this.data.bookDetail.isApplyBook == 2 || |
| | | this.data.bookDetail.isApplyBook == 4 |
| | | ) { |
| | | const applyFun = () => { |
| | | // 先判断下教师认证,未对原有逻辑修改 |
| | | let role = this.data.userInfo != null ? this.data.userInfo.role : null; |
| | | if (role && role == "Teacher") { |
| | | if (!this.data.noFile) { |
| | | wx.showToast({ |
| | | title: "暂无电子书文件,请联系管理员!", |
| | | icon: "none", |
| | | duration: 1000, |
| | | }); |
| | | return; |
| | | } |
| | | if (this.data.ebookCount == 0) { |
| | | wx.showToast({ |
| | | title: "您的电子样书申请次数已用尽,若要继续,请联系管理员!", |
| | | icon: "none", |
| | | duration: 1000, |
| | | }); |
| | | return false; |
| | | } |
| | | |
| | | let isHas = this.data.electronicBookList.find( |
| | | (eitem) => eitem.id == this.data.bookDetail.id |
| | | ); |
| | | if (isHas) { |
| | | wx.showToast({ |
| | | title: "该书已在清单列表中", |
| | | icon: "none", |
| | | duration: 1000, |
| | | }); |
| | | return false; |
| | | } |
| | | let isApply = this.data.alreadyElectronicBookList.find( |
| | | (eitem) => eitem.content[0].id == this.data.bookDetail.id |
| | | ); |
| | | if (isApply) { |
| | | if (isApply.state == 'WaitAudit') { |
| | | if (role && role == "Teacher") {} else { |
| | | return wx.showModal({ |
| | | title: "尊敬的用户,您好!", //提示的标题 |
| | | content: "请先进行教师认证?", //提示的内容 |
| | | confirmColor: "#ff6c00", |
| | | cancelColor: "#949494", |
| | | success: function (res) { |
| | | if (res.confirm) { |
| | | wx.navigateTo({ |
| | | url: "/packageDomain/pages/teacherCertification/index", |
| | | }); |
| | | } else if (res.cancel) {} |
| | | }, |
| | | }); |
| | | } |
| | | if ( |
| | | this.data.bookDetail.isApplyBook == 2 || |
| | | this.data.bookDetail.isApplyBook == 4 |
| | | ) { |
| | | let role = this.data.userInfo != null ? this.data.userInfo.role : null; |
| | | if (role && role == "Teacher") { |
| | | if (!this.data.noFile) { |
| | | wx.showToast({ |
| | | title: "该书已申请!", |
| | | title: "暂无电子书文件,请联系管理员!", |
| | | icon: "none", |
| | | duration: 1000, |
| | | }); |
| | | return; |
| | | } |
| | | if (this.data.ebookCount == 0) { |
| | | wx.showToast({ |
| | | title: "您的电子样书申请次数已用尽,若要继续,请联系管理员!", |
| | | icon: "none", |
| | | duration: 1000, |
| | | }); |
| | | return false; |
| | | } else if (isApply.state == 'Normal') { |
| | | const flag = new Date(isApply.feedBack.endDate + ' 23:59:59').getTime() > new Date().getTime() |
| | | if (flag) { |
| | | } |
| | | |
| | | let isHas = this.data.electronicBookList.find( |
| | | (eitem) => eitem.id == this.data.bookDetail.id |
| | | ); |
| | | if (isHas) { |
| | | wx.showToast({ |
| | | title: "该书已在清单列表中", |
| | | icon: "none", |
| | | duration: 1000, |
| | | }); |
| | | return false; |
| | | } |
| | | let isApply = this.data.alreadyElectronicBookList.find( |
| | | (eitem) => eitem.content[0].id == this.data.bookDetail.id |
| | | ); |
| | | if (isApply) { |
| | | if (isApply.state == 'WaitAudit') { |
| | | wx.showToast({ |
| | | title: "该书已申请!", |
| | | icon: "none", |
| | | duration: 1000, |
| | | }); |
| | | return false; |
| | | } else if (isApply.state == 'Normal') { |
| | | const flag = new Date(isApply.feedBack.endDate + ' 23:59:59').getTime() > new Date().getTime() |
| | | if (flag) { |
| | | wx.showToast({ |
| | | title: "该书已申请!", |
| | | icon: "none", |
| | | duration: 1000, |
| | | }); |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (this.data.electronicBookList.length >= 2) { |
| | | wx.showToast({ |
| | | title: "每次最多只可申请2本样书", |
| | | icon: "none", |
| | | duration: 1000, |
| | | if (this.data.electronicBookList.length >= 2) { |
| | | wx.showToast({ |
| | | title: "每次最多只可申请2本样书", |
| | | icon: "none", |
| | | duration: 1000, |
| | | }); |
| | | return false; |
| | | } |
| | | this.addBookFun(this.data.bookDetail, "eBook"); |
| | | } else { |
| | | wx.showModal({ |
| | | title: "尊敬的用户,您好!", //提示的标题 |
| | | content: "请先进行教师认证?", //提示的内容 |
| | | confirmColor: "#ff6c00", |
| | | cancelColor: "#949494", |
| | | success: function (res) { |
| | | if (res.confirm) { |
| | | wx.navigateTo({ |
| | | url: "/packageDomain/pages/teacherCertification/index", |
| | | }); |
| | | } else if (res.cancel) {} |
| | | }, |
| | | }); |
| | | return false; |
| | | } |
| | | this.addBookFun(this.data.bookDetail, "eBook"); |
| | | } else { |
| | | wx.showModal({ |
| | | title: "尊敬的用户,您好!", //提示的标题 |
| | | content: "请先进行教师认证?", //提示的内容 |
| | | confirmColor: "#ff6c00", |
| | | cancelColor: "#949494", |
| | | success: function (res) { |
| | | if (res.confirm) { |
| | | wx.navigateTo({ |
| | | url: "/packageDomain/pages/teacherCertification/index", |
| | | }); |
| | | } else if (res.cancel) {} |
| | | }, |
| | | wx.showToast({ |
| | | title: "该书不能申请电子样书", |
| | | icon: "none", |
| | | duration: 1000, |
| | | }); |
| | | } |
| | | } else { |
| | | wx.showToast({ |
| | | title: "该书不能申请电子样书", |
| | | icon: "none", |
| | | duration: 1000, |
| | | }); |
| | | } |
| | | const token = wx.getStorageSync(app.config.tokenKey); |
| | | if (token) { |
| | | applyFun() |
| | | } else { |
| | | this.logInFun(() => {}) |
| | | } |
| | | |
| | | }, |
| | | //申请纸质样书 |
| | | appplyPaperBook() { |
| | | let role = this.data.userInfo != null ? this.data.userInfo.role : null; |
| | | if (role && role == "Teacher") {} else { |
| | | return wx.showModal({ |
| | | title: "尊敬的用户,您好!", //提示的标题 |
| | | content: "请先进行教师认证?", //提示的内容 |
| | | confirmColor: "#ff6c00", |
| | | cancelColor: "#949494", |
| | | success: function (res) { |
| | | if (res.confirm) { |
| | | wx.navigateTo({ |
| | | url: "/packageDomain/pages/teacherCertification/index", |
| | | }); |
| | | } else if (res.cancel) {} |
| | | }, |
| | | }); |
| | | } |
| | | if ( |
| | | this.data.bookDetail.isApplyBook == 3 || |
| | | this.data.bookDetail.isApplyBook == 4 |
| | | ) { |
| | | const applyFun = () => { |
| | | let role = this.data.userInfo != null ? this.data.userInfo.role : null; |
| | | if (role && role == "Teacher") { |
| | | // 点击选中 |
| | | if (this.data.paperBookCount == 0) { |
| | | wx.showToast({ |
| | | title: "您的纸质样书申请次数已用尽,若要继续,请联系管理员!", |
| | | icon: "none", |
| | | duration: 1000, |
| | | }); |
| | | return false; |
| | | } |
| | | let isApply = this.data.alreadyPaperBookList.find( |
| | | (pitem) => pitem.content[0].id == this.data.bookDetail.id |
| | | ); |
| | | if (isApply) { |
| | | wx.showToast({ |
| | | title: "该书已申请!", |
| | | icon: "none", |
| | | duration: 1000, |
| | | }); |
| | | return false; |
| | | } |
| | | |
| | | let isHas = this.data.paperBookList.find( |
| | | (pitem) => pitem.id == this.data.bookDetail.id |
| | | ); |
| | | if (isHas) { |
| | | wx.showToast({ |
| | | title: "该书已在清单列表中", |
| | | icon: "none", |
| | | duration: 1000, |
| | | }); |
| | | return false; |
| | | } |
| | | if (this.data.paperBookList.length >= 2) { |
| | | wx.showToast({ |
| | | title: "每次最多只可申请2本样书", |
| | | icon: "none", |
| | | duration: 1000, |
| | | }); |
| | | return false; |
| | | } |
| | | this.addBookFun(this.data.bookDetail, "pBook"); |
| | | } else { |
| | | wx.showModal({ |
| | | if (role && role == "Teacher") {} else { |
| | | return wx.showModal({ |
| | | title: "尊敬的用户,您好!", //提示的标题 |
| | | content: "请先进行教师认证?", //提示的内容 |
| | | confirmColor: "#ff6c00", |
| | |
| | | }, |
| | | }); |
| | | } |
| | | } else { |
| | | wx.showToast({ |
| | | title: "该书不能申请纸质样书", |
| | | icon: "none", |
| | | duration: 1000, |
| | | }); |
| | | if ( |
| | | this.data.bookDetail.isApplyBook == 3 || |
| | | this.data.bookDetail.isApplyBook == 4 |
| | | ) { |
| | | let role = this.data.userInfo != null ? this.data.userInfo.role : null; |
| | | if (role && role == "Teacher") { |
| | | // 点击选中 |
| | | if (this.data.paperBookCount == 0) { |
| | | wx.showToast({ |
| | | title: "您的纸质样书申请次数已用尽,若要继续,请联系管理员!", |
| | | icon: "none", |
| | | duration: 1000, |
| | | }); |
| | | return false; |
| | | } |
| | | let isApply = this.data.alreadyPaperBookList.find( |
| | | (pitem) => pitem.content[0].id == this.data.bookDetail.id |
| | | ); |
| | | if (isApply) { |
| | | wx.showToast({ |
| | | title: "该书已申请!", |
| | | icon: "none", |
| | | duration: 1000, |
| | | }); |
| | | return false; |
| | | } |
| | | |
| | | let isHas = this.data.paperBookList.find( |
| | | (pitem) => pitem.id == this.data.bookDetail.id |
| | | ); |
| | | if (isHas) { |
| | | wx.showToast({ |
| | | title: "该书已在清单列表中", |
| | | icon: "none", |
| | | duration: 1000, |
| | | }); |
| | | return false; |
| | | } |
| | | if (this.data.paperBookList.length >= 2) { |
| | | wx.showToast({ |
| | | title: "每次最多只可申请2本样书", |
| | | icon: "none", |
| | | duration: 1000, |
| | | }); |
| | | return false; |
| | | } |
| | | this.addBookFun(this.data.bookDetail, "pBook"); |
| | | } else { |
| | | wx.showModal({ |
| | | title: "尊敬的用户,您好!", //提示的标题 |
| | | content: "请先进行教师认证?", //提示的内容 |
| | | confirmColor: "#ff6c00", |
| | | cancelColor: "#949494", |
| | | success: function (res) { |
| | | if (res.confirm) { |
| | | wx.navigateTo({ |
| | | url: "/packageDomain/pages/teacherCertification/index", |
| | | }); |
| | | } else if (res.cancel) {} |
| | | }, |
| | | }); |
| | | } |
| | | } else { |
| | | wx.showToast({ |
| | | title: "该书不能申请纸质样书", |
| | | icon: "none", |
| | | duration: 1000, |
| | | }); |
| | | } |
| | | } |
| | | const token = wx.getStorageSync(app.config.tokenKey); |
| | | if (token) { |
| | | applyFun() |
| | | } else { |
| | | this.logInFun(() => {}) |
| | | } |
| | | |
| | | }, |
| | | // 添加样书 |
| | | addBookFun(item, type) { |
| | |
| | | |
| | | //去样书申请单 |
| | | goApply() { |
| | | wx.navigateTo({ |
| | | url: "/packageDomain/pages/sampleBookList/applicationForm/index", |
| | | }); |
| | | const token = wx.getStorageSync(app.config.tokenKey); |
| | | if (token) { |
| | | wx.navigateTo({ |
| | | url: "/packageDomain/pages/sampleBookList/applicationForm/index", |
| | | }); |
| | | } else { |
| | | this.logInFun(() => {}) |
| | | } |
| | | }, |
| | | handleTree() { |
| | | // const child = this.selectComponent('#teach-tree') |
| | |
| | | return childrenList |
| | | }, |
| | | uploadFile(e) { |
| | | console.log(123) |
| | | this.setData({ |
| | | dialogBox: true, |
| | | isShowUp: true |
| | | }); |
| | | const uploadFun = () => { |
| | | const userInfo = JSON.parse(wx.getStorageSync(app.config.userInfoKey)) |
| | | if (userInfo.role != 'Teacher') return wx.showToast({ |
| | | icon: 'error', |
| | | title: '请先进行教师认证', |
| | | }) |
| | | this.setData({ |
| | | dialogBox: true, |
| | | isShowUp: true |
| | | }); |
| | | } |
| | | const token = wx.getStorageSync(app.config.tokenKey); |
| | | if (token) { |
| | | uploadFun() |
| | | } else { |
| | | this.logInFun(() => { |
| | | uploadFun() |
| | | }) |
| | | } |
| | | |
| | | }, |
| | | closeDialog() { |
| | | this.setData({ |
| | | dialogBox: false, |
| | | resourceInfo: { |
| | | resourceName: '', |
| | | fileType: '', |
| | | description: '', |
| | | agree: false |
| | | }, |
| | | }); |
| | | }, |
| | | onCloseProtocol() { |
| | |
| | | |
| | | }, |
| | | onNameInput(e) { |
| | | console.log(e.detail.value) |
| | | this.setData({ |
| | | 'resourceInfo.resourceName': e.detail.value, |
| | | }); |
| | | }, |
| | | onFileTypeInput(e) { |
| | | onResourcePicker(e) { |
| | | this.setData({ |
| | | 'resourceInfo.fileType': e.detail.value, |
| | | resourceValue: [this.data.resourceInfo.fileType], |
| | | resourceVisible: true, |
| | | }); |
| | | }, |
| | | onPickerChange(e) { |
| | | const { |
| | | value |
| | | } = e.detail; |
| | | this.setData({ |
| | | resourceVisible: false, |
| | | resourceValue: value, |
| | | 'resourceInfo.fileType': value.join(' '), |
| | | }); |
| | | }, |
| | | onPickerCancel(e) { |
| | | this.setData({ |
| | | resourceVisible: false, |
| | | }); |
| | | }, |
| | | textareaChange(e) { |
| | |
| | | const pdfData = ['pdf'] |
| | | const Compression = ['rar', 'zip'] |
| | | const pictureData = ['jpg', 'png'] |
| | | const documentData = ['doc', 'docx', 'xls', 'xlsx', "ppt", "pptx"] |
| | | if (audioData.indexOf(Extension) > -1) { |
| | | medioType = '音频' |
| | | } else if (videoData.indexOf(Extension) > -1) { |
| | |
| | | medioType = '资源包' |
| | | } else if (pictureData.indexOf(Extension) > -1) { |
| | | medioType = '图片' |
| | | } else if (documentData.indexOf(Extension) > -1) { |
| | | medioType = '文档' |
| | | } else { |
| | | medioType = '其他' |
| | | } |
| | |
| | | that.setData({ |
| | | "resourceInfo.resourceName": FileName, |
| | | "resourceInfo.fileType": medioType, |
| | | |
| | | fileList: file, |
| | | isShowUp: false |
| | | }) |
| | |
| | | |
| | | }, |
| | | handleRemove(e) { |
| | | console.log(e) |
| | | let md5 = e.currentTarget.dataset.md5 |
| | | for (let i = 0; i < this.data.fileList.length; i++) { |
| | | if (this.data.fileList.md5 == md5) { |
| | | this.data.fileList.splice(i, 1) |
| | | } |
| | | } |
| | | this.setData({ |
| | | isShowUp: true, |
| | | fileList: [] |
| | | }); |
| | | }, |
| | | confirmM() { |
| | |
| | | if (this.data.resourceInfo.fileType == '') { |
| | | return wx.showToast({ |
| | | icon: "error", |
| | | title: "请填写资源类型", |
| | | title: "请选择资源类型", |
| | | }); |
| | | } |
| | | |
| | |
| | | app.MG.ugc.newTopicMessage(query).then((res) => { |
| | | wx.showToast({ |
| | | icon: "success", |
| | | title: "请上传资源文件", |
| | | title: "上传成功", |
| | | }); |
| | | this.setData({ |
| | | dialogBox: false, |
| | | }); |
| | | this.closeDialog() |
| | | }) |
| | | } |
| | | }, |
| | | getCloundIsBuy() { |
| | | let flag = false |
| | | if (!this.data.isCloundHaveSaleMethod) flag = false |
| | | const cloundData = this.data.resourceCodeList.find(item => item.refCode == 'jsek_cloudLearning') |
| | | const saleData = cloundData.saleMethod.find(item => item.SaleType == "Normal") |
| | | if (!saleData) flag = false |
| | | flag = this.data.buyIdList.some(item => item == saleData.Id) |
| | | this.setData({ |
| | | cloundMenuIsBuy: flag |
| | | }) |
| | | }, |
| | | /** |
| | | * 用户点击右上角分享 |
| | | */ |
| | | onShareAppMessage() {}, |
| | | onShareTimeline() {} |
| | | }) |