339个文件已删除
12个文件已修改
2 文件已复制
108 文件已重命名
24个文件已添加
| | |
| | | { |
| | | "pages": [ |
| | | "pages/student/index", |
| | | "pages/home/home", |
| | | "pages/resourceDetails/myAudio/index", |
| | | "pages/resourceDetails/myVideo/index", |
| | | "pages/resourceDetails/document/index", |
| | | "pages/retrievalPage/index", |
| | | "pages/cart/paymentPage/index", |
| | | "pages/cart/index", |
| | | "pages/aboutUs/index", |
| | | "pages/bookServices/assort/index", |
| | | "pages/bookServices/detail/index", |
| | | "pages/bookServices/list/index", |
| | | "pages/bookExhibitionList/index", |
| | | "pages/bookExhibitionDetails/index", |
| | | "pages/bibliographyList/index", |
| | | "pages/usercenter/index", |
| | | "pages/usercenter/person-info/index", |
| | | "pages/usercenter/address/list/index", |
| | | "pages/usercenter/address/edit/index", |
| | | "pages/goods/list/index", |
| | | "pages/goods/details/index", |
| | | "pages/goods/category/index", |
| | | "pages/goods/search/index", |
| | | "pages/goods/result/index", |
| | | "pages/order/order-confirm/index", |
| | | "pages/order/receipt/index", |
| | | "pages/order/pay-result/index", |
| | | "pages/order/order-list/index", |
| | | "pages/order/order-detail/index", |
| | | "pages/goods/comments/index", |
| | | "pages/order/apply-service/index", |
| | | "pages/order/after-service-list/index", |
| | | "pages/order/after-service-detail/index", |
| | | "pages/goods/comments/create/index", |
| | | "pages/coupon/coupon-list/index", |
| | | "pages/coupon/coupon-detail/index", |
| | | "pages/coupon/coupon-activity-goods/index", |
| | | "pages/promotion-detail/index", |
| | | "pages/order/fill-tracking-no/index", |
| | | "pages/order/delivery-detail/index", |
| | | "pages/order/invoice/index", |
| | | "pages/usercenter/name-edit/index", |
| | | "pages/teacherCertification/index", |
| | | "pages/sampleBookList/index", |
| | | "pages/sampleBookList/applicationForm/index", |
| | | "pages/personalCenter/index", |
| | | "pages/personalCenter/myOrder/index", |
| | | "pages/personalCenter/myCollection/index", |
| | | "pages/personalCenter/myMassage/index", |
| | | "pages/personalCenter/myMassage/massageDetail/index", |
| | | "pages/personalCenter/feedBack/index", |
| | | "pages/personalCenter/feedBackSubmit/index", |
| | | "pages/personalCenter/certificate/index", |
| | | "pages/personalCenter/publishBooks/index", |
| | | "pages/personalCenter/sampleBooks/index", |
| | | "pages/personalCenter/downloads/index", |
| | | "pages/personalCenter/activateProduct/index", |
| | | "pages/testLogin/index", |
| | | "pages/bookServices/examination/examination", |
| | | "pages/bookServices/webpage/index" |
| | | "pages/bookServices/assort/index" |
| | | ], |
| | | "subPackages": [ |
| | | { |
| | | "root": "packageDomain", |
| | | "name": "packageDomain", |
| | | "pages": [ |
| | | "pages/resourceDetails/myAudio/index", |
| | | "pages/resourceDetails/myVideo/index", |
| | | "pages/resourceDetails/document/index", |
| | | "pages/sampleBookList/index", |
| | | "pages/sampleBookList/applicationForm/index", |
| | | "pages/teacherCertification/index" |
| | | ] |
| | | }, |
| | | { |
| | | "root": "packagePersonal", |
| | | "name": "packagePersonal", |
| | | "pages": [ |
| | | "pages/myOrder/index", |
| | | "pages/myCollection/index", |
| | | "pages/myMassage/index", |
| | | "pages/myMassage/massageDetail/index", |
| | | "pages/downloads/index", |
| | | "pages/activateProduct/index", |
| | | "pages/sampleBooks/index", |
| | | "pages/personalCenter/publishBooks/index", |
| | | "pages/feedBack/index", |
| | | "pages/aboutUs/index" |
| | | ] |
| | | }, |
| | | { |
| | | "root": "packageBookService", |
| | | "name": "packageBookService", |
| | | "pages": [ |
| | | "pages/bookServices/list/index", |
| | | "pages/bookServices/detail/index", |
| | | "pages/bookServices/examination/examination", |
| | | "pages/bookServices/webpage/index" |
| | | ] |
| | | } |
| | | ], |
| | | "tabBar": { |
| | | "custom": true, |
| | |
| | | "selectedIconPatn": "/static/images/home/service-click@2x.png" |
| | | }, |
| | | { |
| | | "pagePath": "pages/goods/category/index", |
| | | "pagePath": "pages/student/index", |
| | | "text": "学习", |
| | | "iconPath": "/static/images/home/learn@2x.png", |
| | | "selectedIconPatn": "/static/images/home/learn-click@2x.png" |
| | |
| | | |
| | | { |
| | | text: '学习', |
| | | url: 'pages/goods/category/index', |
| | | url: 'pages/student/index', |
| | | icon: '/static/images/home/learn@2x.png', |
| | | activeIcon: '/static/images/home/learn-click@2x.png' |
| | | }, |
New file |
| | |
| | | // pages/bookServices/detail/components/testResource/testResource.js |
| | | const app = getApp() |
| | | Component({ |
| | | /** |
| | | * 组件的属性列表 |
| | | */ |
| | | properties: { |
| | | list: { |
| | | type: Array, |
| | | value: [] |
| | | }, |
| | | bookInfo: { |
| | | type: Object, |
| | | value: "", |
| | | }, |
| | | mockData: { |
| | | type: Object, |
| | | value: {} |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * 组件的初始数据 |
| | | */ |
| | | data: { |
| | | selectBtn: 'test', // test mock |
| | | radioItem: 'test', |
| | | }, |
| | | |
| | | /** |
| | | * 组件的方法列表 |
| | | */ |
| | | methods: { |
| | | async goTest(e) { |
| | | const value = e.currentTarget.dataset.value |
| | | const token = wx.getStorageSync('jsek-token') |
| | | if (!token) { |
| | | return wx.getUserProfile({ |
| | | desc: '用户登录', |
| | | success: (res) => { |
| | | console.log(res); |
| | | } |
| | | }) |
| | | } |
| | | // 获取章节下是否有题目 |
| | | let idPathList = [] |
| | | let query = { |
| | | path: '*', |
| | | queryType: '*', |
| | | productId: this.properties.bookInfo.id, |
| | | cmsPath: value.productLinkPath, |
| | | pading: { |
| | | start: 0, |
| | | size: 999 |
| | | } |
| | | } |
| | | if (value.childrenFolderCount == 0) { |
| | | return wx.showToast({ |
| | | icon: "error", |
| | | title: '暂无数据', |
| | | }) |
| | | } else { |
| | | const res = await app.MG.store.getProductDetail(query) |
| | | res.datas.cmsDatas[0].datas.forEach((item) => { |
| | | idPathList.push({ |
| | | id: item.id, |
| | | name: item.name, |
| | | productLinkPath: item.productLinkPath, |
| | | type: item.type |
| | | }) |
| | | }) |
| | | } |
| | | // query: { |
| | | // title: bookData.value.test, |
| | | // bookId: route.query.bookId, |
| | | // productLinkPath: data.productLinkPath, |
| | | // answerTitle: data.name, |
| | | // answerType: 'option', |
| | | // rootCmsItemId: bookData.value.rootCmsItemId, |
| | | // idPathList: JSON.stringify(idPathList) |
| | | // } |
| | | |
| | | wx.navigateTo({ |
| | | url: `/packageBookService/pages/bookServices/examination/examination?bookId=${this.properties.bookInfo.id}&productLinkPath=${value.productLinkPath}&rootCmsItemId=${this.properties.bookInfo.rootCmsItemId}&idPathList=${JSON.stringify(idPathList)}&answerTitle=${value.name}&answerType=${'option'}`, |
| | | }) |
| | | }, |
| | | goMycollect(e) { |
| | | const answertype = e.currentTarget.dataset.answertype |
| | | const token = wx.getStorageSync('jsek-token') |
| | | if (!token) { |
| | | return wx.getUserProfile({ |
| | | desc: '用户登录', |
| | | success: (res) => { |
| | | console.log(res); |
| | | } |
| | | }) |
| | | } |
| | | wx.navigateTo({ |
| | | url: `/packageBookService/pages/bookServices/examination/examination?bookId=${this.properties.bookInfo.id}&rootCmsItemId=${this.properties.bookInfo.rootCmsItemId}&answerTitle=${answertype == 'collectQuestion' ? '我的收藏' : '我的错题'}&answerType=${answertype}`, |
| | | }) |
| | | }, |
| | | // 练习 组件切换 |
| | | onRadioChange(e) { |
| | | this.setData({ |
| | | radioItem: e.detail.value |
| | | }) |
| | | }, |
| | | async getMockId() { |
| | | let id |
| | | let query = { |
| | | start: 0, |
| | | size: 99, |
| | | productId: this.properties.bookInfo.id |
| | | } |
| | | await app.MG.edu.getQuizConfigListByProduct(query).then((res) => { |
| | | id = res.datas[0].id |
| | | }) |
| | | return id |
| | | }, |
| | | // 组卷跳转答题界面 |
| | | async goMackPaper(e) { |
| | | // const token = localStorage.getItem('jsek-token') |
| | | // if (!token) { |
| | | // return logIn() |
| | | // } |
| | | const mockid = await this.getMockId() |
| | | const item = e.currentTarget.dataset.item |
| | | wx.navigateTo({ |
| | | url: `/packageBookService/pages/bookServices/examination/examination?bookId=${this.properties.bookInfo.id}&rootCmsItemId=${this.properties.bookInfo.rootCmsItemId}&answerTitle=${item.name}&answerType=${'mock'}&uuid=${item.id}&mockid=${mockid}`, |
| | | }) |
| | | } |
| | | } |
| | | }) |
New file |
| | |
| | | |
| | | import Message from 'tdesign-miniprogram/message/message'; |
| | | const util = require('./components/util') // 引入封装过的加载提示 |
| | | const app = getApp() |
| | | Component({ |
| | | properties: { |
| | | treeList: { |
| | | type: Array, |
| | | value: [] |
| | | }, |
| | | bookInfo: { |
| | | type: Object, |
| | | value: {} |
| | | }, |
| | | buyIds: { |
| | | type: Array, |
| | | value: [] |
| | | }, |
| | | tab: { |
| | | type: String, |
| | | value: '' |
| | | }, |
| | | applyState: { |
| | | type: String, |
| | | value: '' |
| | | }, |
| | | openTeachids: { |
| | | type: Array, |
| | | value: '' |
| | | }, |
| | | openLearnids: { |
| | | type: Array, |
| | | value: "" |
| | | } |
| | | }, |
| | | data: { |
| | | activeValues: [0], |
| | | webpageSrc: '' |
| | | }, |
| | | onShow() { |
| | | |
| | | }, |
| | | |
| | | |
| | | methods: { |
| | | // 节点展开 |
| | | handleChange(e) { |
| | | this.setData({ |
| | | activeValues: e.detail.value, |
| | | }); |
| | | console.log('传递', this.properties.buyIds); |
| | | }, |
| | | handleCheck(data) { |
| | | for (let index = 0; index < data.length; index++) { |
| | | const element = data[index]; |
| | | element.checked = true |
| | | if (element.childrenCount && element.type == "productFolder") { |
| | | handleCheck(element.children) |
| | | } |
| | | } |
| | | }, |
| | | downloadTeach(e) { |
| | | const value = e.currentTarget.dataset.value |
| | | var myEventDetail = { |
| | | value, |
| | | } // detail对象,提供给事件监听函数 |
| | | var myEventOption = { |
| | | bubbles: true, |
| | | composed: true |
| | | } // 触发事件的选项 |
| | | this.triggerEvent('downloadTeach', myEventDetail, myEventOption) |
| | | |
| | | }, |
| | | // 判断资源是否购买 |
| | | resourceIsBuy(data) { |
| | | if (data.saleMethod && data.saleMethod.length) { |
| | | const isSHow = buyIdList.value.some((item) => item == data.saleMethod[0].Id) |
| | | return !isSHow |
| | | } else { |
| | | return false |
| | | } |
| | | }, |
| | | // 跳转音视频播放器 |
| | | goPlayer(e) { |
| | | const item = e.currentTarget.dataset.item |
| | | const parent = e.currentTarget.dataset.parent |
| | | |
| | | |
| | | |
| | | let url |
| | | if (item.selectType == 'video') { |
| | | url = '/packageDomain/pages/resourceDetails/myVideo/index' |
| | | } else if (item.selectType == 'audio') { |
| | | url = '/packageDomain/pages/resourceDetails/myAudio/index' |
| | | } else if (item.selectType == 'picture' || item.selectType == 'zip') { |
| | | url = '/packageDomain/pages/resourceDetails/document/index' |
| | | } |
| | | |
| | | // else { |
| | | // |
| | | // } |
| | | wx.navigateTo({ |
| | | url: `${url}?productLinkPath=${item.productLinkPath}&parentProductLinkPath=${parent.productLinkPath}&parentName=${parent.name}&activeId=${item.id}&bookId=${this.properties.bookInfo.id}&bookName=${this.properties.bookInfo.name}&cmsId=${this.properties.bookInfo.rootCmsItemId}`, |
| | | }) |
| | | |
| | | |
| | | if (item.selectType == 'document' || item.selectType == 'pdf') { |
| | | const fileLink = app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.file |
| | | console.log(fileLink, 'fileLink'); |
| | | //提示加载中 |
| | | util.showLoading() |
| | | // 单次下载允许的最大文件为 200MB |
| | | wx.downloadFile({ |
| | | url: fileLink, // 地址已打码,自己换个其他的地址("https://www.xxxxx.com/file/测试通知.pdf") |
| | | success: function (res) { |
| | | console.log(res, "wx.downloadFile success res") |
| | | if (res.statusCode != 200) { |
| | | util.hideLoadingWithErrorTips() |
| | | return false |
| | | } |
| | | var Path = res.tempFilePath //返回的文件临时地址,用于后面打开本地预览所用 |
| | | wx.openDocument({ |
| | | filePath: Path, |
| | | showMenu: true, |
| | | success: function (res) { |
| | | console.log('打开成功'); |
| | | util.hideLoading() |
| | | } |
| | | }) |
| | | }, |
| | | fail: function (err) { |
| | | console.log(err, "wx.downloadFile fail err"); |
| | | util.hideLoadingWithErrorTips() |
| | | } |
| | | }) |
| | | |
| | | |
| | | } |
| | | |
| | | if (item.selectType == 'webpage') { |
| | | console.log(11); |
| | | this.setData({ |
| | | webpageSrc: item.jsek_link |
| | | }) |
| | | console.log(this.data.webpageSrc, 'webpageSrc'); |
| | | } |
| | | |
| | | |
| | | |
| | | }, |
| | | // 拿到所有项 |
| | | getAllChildren(id) { |
| | | let result = []; |
| | | function findChildren(item) { |
| | | if (item.id === id) { |
| | | if (item.children && item.children.length > 0) { |
| | | item.children.forEach(child => { |
| | | findChildren(child); |
| | | }); |
| | | } |
| | | } else { |
| | | if (item.children && item.children.length > 0) { |
| | | item.children.forEach(child => { |
| | | findChildren(child); |
| | | }); |
| | | } |
| | | } |
| | | if (item.children && item.children.length > 0) { |
| | | result.push(...item.children); |
| | | } |
| | | } |
| | | console.log(this.properties.treeList); |
| | | this.properties.treeList.forEach(item => { |
| | | findChildren(item); |
| | | }); |
| | | return result; |
| | | }, |
| | | // 拿到当前项子项 |
| | | flattenTree(tree) { |
| | | let result = []; |
| | | function flatten(node) { |
| | | result.push(node); |
| | | if (node.children && node.children.length > 0) { |
| | | node.children.forEach(child => { |
| | | flatten(child); |
| | | }); |
| | | } |
| | | } |
| | | tree.forEach(node => { |
| | | flatten(node); |
| | | }); |
| | | return result |
| | | }, |
| | | findAndUpdateItemById(tree, id) { |
| | | function findAndUpdate(node) { |
| | | if (node.id === id) { |
| | | node.check = true; // 将目标项的 check 属性设置为 true |
| | | return true; // 返回 true 表示找到了目标项 |
| | | } |
| | | if (node.children && node.children.length > 0) { |
| | | for (let child of node.children) { |
| | | if (findAndUpdate(child)) { |
| | | return true; // 如果在子节点中找到了目标项,则直接返回 true |
| | | } |
| | | } |
| | | } |
| | | return false; // 表示未找到目标项 |
| | | } |
| | | |
| | | for (let node of tree) { |
| | | if (findAndUpdate(node)) { |
| | | break; // 如果在顶层节点中找到了目标项,直接退出循环 |
| | | } |
| | | } |
| | | }, |
| | | // 变为true |
| | | findAndUpdateItemsByIds(tree, ids) { |
| | | function findAndUpdate(node) { |
| | | if (ids.includes(node.id)) { |
| | | node.checked = true; // 将目标项的 check 属性设置为 true |
| | | } |
| | | if (node.children && node.children.length > 0) { |
| | | for (let child of node.children) { |
| | | findAndUpdate(child); // 递归处理子节点 |
| | | } |
| | | } |
| | | } |
| | | |
| | | for (let node of tree) { |
| | | findAndUpdate(node); // 对每个顶层节点执行查找和更新操作 |
| | | } |
| | | return tree; // 返回修改后的完整数组 |
| | | }, |
| | | // 章节勾选 |
| | | checkResourceTitle(e) { |
| | | const item = e.currentTarget.dataset.item |
| | | console.log(item, 'item'); |
| | | let list = this.flattenTree([item]) |
| | | let ids = [] |
| | | list.forEach(item => { |
| | | ids.push(item.id) |
| | | }) |
| | | const tab = this.findAndUpdateItemsByIds([item], ids) |
| | | console.log(ids, tab); |
| | | } |
| | | }, |
| | | onCloudShoppingCart() { |
| | | console.log(this.properties.treeList); |
| | | }, |
| | | oncheckbox() { |
| | | console.log(111); |
| | | } |
| | | }) |
New file |
| | |
| | | { |
| | | "component": true, |
| | | "usingComponents": { |
| | | "t-icon": "tdesign-miniprogram/icon/icon", |
| | | "t-image": "tdesign-miniprogram/image/image", |
| | | "t-collapse": "tdesign-miniprogram/collapse/collapse", |
| | | "t-collapse-panel": "tdesign-miniprogram/collapse-panel/collapse-panel", |
| | | "t-button": "tdesign-miniprogram/button/button", |
| | | "t-checkbox": "tdesign-miniprogram/checkbox/checkbox", |
| | | "tree": "/packageBookService/pages/bookServices/detail/components/tree/index" |
| | | } |
| | | } |
New file |
| | |
| | | // pages/bookServices/detail/index.js |
| | | import Message from 'tdesign-miniprogram/message/index.js'; |
| | | import Toast from 'tdesign-miniprogram/toast'; |
| | | const app = getApp(); |
| | | Page({ |
| | | /** |
| | | * 页面的初始数据 |
| | | */ |
| | | data: { |
| | | bookId: '', |
| | | barHeight: '', |
| | | navBarHeight: '', |
| | | options: { |
| | | id: '', |
| | | name: '', |
| | | }, |
| | | bookDetail: {}, |
| | | link: { |
| | | jd: '', |
| | | tamll: '', |
| | | dang: '', |
| | | micro: '', |
| | | }, |
| | | tabValue: 'brief', |
| | | cmsDatas: [], // 资源refCode列表 |
| | | ids: [1], |
| | | list: [], |
| | | teachResources: [], |
| | | teach: [], |
| | | learn: [], |
| | | test: [], |
| | | openTeachids: [], |
| | | openLearnids: [], |
| | | openTestids: [], |
| | | resourceClassList: [], // 资源所属分类 |
| | | applyState: "", // 教学资源申请状态 |
| | | deadline: "", // 教学资源申请有效日期 |
| | | rejectCause: "", // 下载拒绝原因 |
| | | buyIdList: [], |
| | | shoppingCartGetId: [], // 已购买id列表 |
| | | shoppingList: [], |
| | | loading: false, |
| | | isShowTeachDownload: false, // 提示PC下载弹窗状态 |
| | | confirmBtn: { content: '我知道了', variant: 'base' }, |
| | | mockData: { |
| | | id: 0, // 销售id |
| | | price: 0, // 售价 |
| | | count: 0, // 组卷已购买次数 |
| | | useCount: 0, // 组件已使用次数 |
| | | residue: 0, // 组卷剩余次数 |
| | | mockList: [] // 用户组卷提交信息 |
| | | } |
| | | }, |
| | | |
| | | |
| | | resetTree: function (e) { |
| | | this.setData({ |
| | | currentCheck: e.detail.checkedItem, |
| | | list: e.detail.changeList |
| | | }) |
| | | }, |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | onLoad(options) { |
| | | const systInfo = wx.getSystemInfoSync(); |
| | | const menu = wx.getMenuButtonBoundingClientRect(); // 胶囊信息 |
| | | const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度 |
| | | this.setData({ |
| | | bookId: options.id, |
| | | barHeight: systInfo.statusBarHeight, |
| | | navBarHeight: navBarHeight, |
| | | }); |
| | | this.setData({ |
| | | options: { |
| | | id: options.id, |
| | | name: options.name, |
| | | }, |
| | | }); |
| | | this.getBookInfo(options.id); |
| | | this.getResourceClass() // 获取资源所属分类 |
| | | const token = wx.getStorageSync('jsek-token') |
| | | if (token) { |
| | | this.getShoppingCartProductGet() |
| | | this.getApplyInfo(options.id) |
| | | this.getMockData() |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面初次渲染完成 |
| | | */ |
| | | onReady() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面显示 |
| | | */ |
| | | onShow() { }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面隐藏 |
| | | */ |
| | | onHide() { }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面卸载 |
| | | */ |
| | | onUnload() { }, |
| | | |
| | | /** |
| | | * 页面相关事件处理函数--监听用户下拉动作 |
| | | */ |
| | | onPullDownRefresh() { |
| | | |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 页面上拉触底事件的处理函数 |
| | | */ |
| | | onReachBottom() { |
| | | if (this.data.tabValue == 'jesk_note') { |
| | | const child = this.selectComponent('#note') |
| | | child.onReachBottom() |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * 用户点击右上角分享 |
| | | */ |
| | | onShareAppMessage() { }, |
| | | // 格式化日期 |
| | | formatDate(dateString) { |
| | | if (!dateString) { |
| | | return 'Invalid date'; |
| | | } |
| | | const match = dateString.match(/^(\d{4})\/(\d{1,2})\/(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/); |
| | | if (!match) { |
| | | throw new Error('Invalid date format'); |
| | | } |
| | | |
| | | const [, year, month, day, hours, minutes, seconds] = match; |
| | | const date = new Date( |
| | | parseInt(year, 10), |
| | | parseInt(month, 10) - 1, |
| | | parseInt(day, 10), |
| | | parseInt(hours, 10), |
| | | parseInt(minutes, 10), |
| | | parseInt(seconds, 10), |
| | | ); |
| | | |
| | | if (isNaN(date.getTime())) { |
| | | throw new Error('Invalid date'); |
| | | } |
| | | |
| | | // 由于小程序环境可能不支持 Intl.DateTimeFormat,我们使用简化的格式化方法 |
| | | const formatted = `${year}年${this.formatMonth(month)}`; |
| | | return formatted; |
| | | }, |
| | | // 简化的月份格式化函数,返回月份的中文表达 |
| | | formatMonth(month) { |
| | | const months = ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']; |
| | | return months[parseInt(month, 10) - 1]; |
| | | }, |
| | | // 金额显示.00格式 |
| | | numFormat(value) { |
| | | if (!value) return '0.00'; |
| | | value = Number(value).toFixed(2); |
| | | var intPart = Math.trunc(value); // 获取整数部分 |
| | | var intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,'); // 将整数部分逢三一断 |
| | | var floatPart = '.00'; // 预定义小数部分 |
| | | var value2Array = value.split('.'); |
| | | // =2表示数据有小数位 |
| | | if (value2Array.length === 2) { |
| | | floatPart = value2Array[1].toString(); // 拿到小数部分 |
| | | if (floatPart.length === 1) { |
| | | return `${intPartFormat}.${floatPart}0`; |
| | | } |
| | | return `${intPartFormat}.${floatPart}`; |
| | | } |
| | | return intPartFormat + floatPart; |
| | | }, |
| | | // 返回 |
| | | goBack() { |
| | | wx.navigateBack(); |
| | | }, |
| | | // 获取图书详情 |
| | | getBookInfo(id) { |
| | | this.setData({ |
| | | "mockData'.id": 0, |
| | | "mockData.price": 0, |
| | | "mockData.count": 0 |
| | | }) |
| | | const query = { |
| | | path: '*', |
| | | queryType: '*', |
| | | productId: id, |
| | | favoriteTypes: 'FavoriteBookCity', |
| | | itemFields: { |
| | | 'SysType=': 'CmsFolder', |
| | | }, |
| | | coverSize: { |
| | | height: 300, |
| | | }, |
| | | fields: { |
| | | seriesName: [], |
| | | author: [], |
| | | isbn: [], |
| | | publicationDate: [], |
| | | bookClassification: [], |
| | | paperPrice: [], |
| | | JDLink: [], |
| | | tmallLink: [], |
| | | dangdangLink: [], |
| | | weidianLink: [], |
| | | content: [], |
| | | authorIntroduction: [], |
| | | // isApplyPaperBook: [], |
| | | // isApplyEBook: [], |
| | | isApplyBook: [], |
| | | isSell: [], |
| | | pdf: [], |
| | | protectedEpub: [], |
| | | probationPage: [], //pdf试读页数 |
| | | freeEpubPage: [], //epub试读百分比 |
| | | }, |
| | | }; |
| | | app.MG.store.getProductDetail(query).then(async (res) => { |
| | | console.log(res.datas); |
| | | this.setData({ |
| | | bookDetail: res.datas, |
| | | cmsDatas: res.datas.cmsDatas[0].datas, |
| | | buyIdList: res.datas.purchasedSaleMethodIdList |
| | | }); |
| | | // 获取图书分类 |
| | | const iconType = JSON.parse(res.datas.bookClassification)[0][0]; |
| | | const classType = JSON.parse(res.datas.bookClassification)[0][1]; |
| | | const className = await this.getBookClass(iconType, classType) |
| | | // 获取组卷销售id |
| | | if (res.datas.saleMethod && res.datas.saleMethod.length) { |
| | | res.datas.saleMethod.forEach((item) => { |
| | | if (item.SaleType == 'combinationTestPaper') { |
| | | this.setData({ |
| | | 'mockData.id': item.Id, |
| | | 'mockData.price': item.Price |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | // 获取组卷已购买次数 |
| | | if (res.datas.purchasedSaleMethodIdList && res.datas.purchasedSaleMethodIdList.length) { |
| | | if (this.data.mockData.id) { |
| | | let count = res.datas.purchasedSaleMethodIdList.filter( |
| | | (item) => item == this.data.mockData.id |
| | | ).length |
| | | this.setData({ |
| | | 'mockData.count': count |
| | | }) |
| | | } |
| | | } |
| | | console.log('组卷信息', this.data.mockData); |
| | | this.setData({ |
| | | 'bookDetail.publicationDate': this.formatDate(this.data.bookDetail.publicationDate), |
| | | 'bookDetail.class': className, |
| | | 'bookDetail.price': this.numFormat(this.data.bookDetail.price), |
| | | 'bookDetail.oldPrice': this.numFormat(this.data.bookDetail.oldPrice), |
| | | 'bookDetail.paperPrice': this.numFormat(this.data.bookDetail.paperPrice), |
| | | }); |
| | | }); |
| | | |
| | | }, |
| | | // 获取图书分类 |
| | | async getBookClass(iconType, classType) { |
| | | let name = ''; |
| | | const query = { |
| | | refCodes: ['bookClassification'], |
| | | }; |
| | | await app.MG.store.getProductTypeField(query).then((res) => { |
| | | JSON.parse(res[0].config).option.forEach((item) => { |
| | | if (item.value == iconType) { |
| | | item.child.forEach((citem) => { |
| | | if (citem.value == classType) { |
| | | name = citem.name; |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | }); |
| | | return name; |
| | | }, |
| | | // 收藏 |
| | | setCollect() { |
| | | if (this.data.bookDetail.isFavourite) { |
| | | app.MG.store |
| | | .delProductLink({ |
| | | productIds: [this.data.bookDetail.id], |
| | | linkType: 'FavoriteBookCity', |
| | | }) |
| | | .then(() => { |
| | | this.setData({ |
| | | 'bookDetail.isFavourite': false |
| | | }) |
| | | Message.success({ |
| | | context: this, |
| | | offset: [20, 32], |
| | | duration: 5000, |
| | | content: '这是一条成功的提示消息', |
| | | }); |
| | | }); |
| | | } else { |
| | | const params = { |
| | | productIds: [this.data.bookDetail.id], |
| | | linkType: 'FavoriteBookCity', |
| | | }; |
| | | app.MG.store.addProductLink(params).then((res) => { |
| | | this.setData({ |
| | | 'bookDetail.isFavourite': true |
| | | }) |
| | | Message.success({ |
| | | context: this, |
| | | offset: ['20rpx', '32rpx'], |
| | | duration: 2000, |
| | | content: '收藏成功', |
| | | }); |
| | | }); |
| | | } |
| | | }, |
| | | // 我要建议 |
| | | suggestBtn() { |
| | | const child = this.selectComponent('#suggest-component') |
| | | child.showDialog() |
| | | }, |
| | | // 跳转网店 |
| | | goShop(e) { |
| | | const { link } = e.currentTarget.dataset; |
| | | wx.navigateTo({ |
| | | url: `/packageBookService/pages/bookServices/webpage/index?url=${link}`, |
| | | }) |
| | | }, |
| | | onTabsChange(e) { |
| | | this.setData({ |
| | | tabValue: e.detail.value |
| | | }) |
| | | if (e.detail.label == '教学资源' || e.detail.label == '云学习' || e.detail.label == '云测试') { |
| | | const checkData = this.data.cmsDatas.find(item => item.refCode == e.detail.value) |
| | | if (checkData) { |
| | | 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)) { |
| | | this.getResourceData(checkData) |
| | | } |
| | | |
| | | } |
| | | } else if (e.detail.label == '云笔记') { |
| | | const token = wx.getStorageSync('jsek-token') |
| | | const child = this.selectComponent('#note') |
| | | child.handleSubmitTitle() |
| | | if (token) { |
| | | child.changeLoading() |
| | | child.getNoteList() |
| | | } |
| | | |
| | | } |
| | | }, |
| | | // 获取资源所属分类 |
| | | getResourceClass() { |
| | | let query = { |
| | | refCodes: ['resourcesClassification'] |
| | | } |
| | | app.MG.store.getProductTypeField(query).then((res) => { |
| | | this.setData({ |
| | | resourceClassList: JSON.parse(res[0].config).option |
| | | }) |
| | | }) |
| | | }, |
| | | // 获取教学资源 云学习 云测试 |
| | | getResourceData(type) { |
| | | this.setData({ |
| | | loading: true |
| | | }) |
| | | let query = { |
| | | path: '*', |
| | | queryType: '*', |
| | | productId: this.data.bookDetail.id, |
| | | cmsPath: type.productLinkPath, |
| | | itemFields: { |
| | | SysType: 'CmsFolder', |
| | | // 资源类型,试读文件,是否允许下载等参数 |
| | | selectType: [], |
| | | freeFile: [], |
| | | file: [], |
| | | resourcesClassification: [], |
| | | isDownload: [], |
| | | jsek_resourceBrief: [], |
| | | jsek_link: [], |
| | | jsek_questionBank: [] |
| | | }, |
| | | pading: { |
| | | start: 0, |
| | | size: 999 |
| | | }, |
| | | } |
| | | app.MG.store |
| | | .getProductDetail(query) |
| | | .then(async (res) => { |
| | | // 云测试,递归请求里层数据 |
| | | if (type.refCode == 'questionBank') { |
| | | const data = res.datas.cmsDatas[0].datas.filter( |
| | | (item) => item.refCode == 'jsek_questionBank' |
| | | ) |
| | | if (data.length) return this.getResourceData(data[0]) |
| | | } |
| | | //教学资源 云学习 |
| | | if (type.refCode == 'jsek_teachingResources' || type.refCode == 'jsek_cloudLearning') { |
| | | if (res.datas.cmsDatas[0].datas.length > 0) { |
| | | if (type.refCode == 'jsek_teachingResources') { |
| | | res.datas.cmsDatas[0].datas.forEach(item => { |
| | | item.checked = false |
| | | }) |
| | | const list = await this.getAllResource(res.datas.cmsDatas[0].datas) |
| | | |
| | | console.log(list, 'list'); |
| | | this.setData({ |
| | | teach: list, |
| | | loading: false |
| | | }) |
| | | this.findChildIds(this.data.teach, this.data.openTeachids = []) |
| | | } else if (type.refCode == 'jsek_cloudLearning') { |
| | | const list = await this.getAllResource(res.datas.cmsDatas[0].datas) |
| | | this.setData({ |
| | | learn: list, |
| | | loading: false |
| | | }) |
| | | this.findChildIds(this.data.learn, this.data.openLearnids = []) |
| | | } |
| | | } else { |
| | | // 无数据 |
| | | } |
| | | } else if (type.refCode == 'jsek_questionBank') { |
| | | // const list = await this.getAllResource(res.datas.cmsDatas[0].datas) |
| | | this.setData({ |
| | | test: res.datas.cmsDatas[0].datas, |
| | | loading: false |
| | | }) |
| | | } else { |
| | | console.log('其他'); |
| | | } |
| | | }) |
| | | .catch((e) => { |
| | | 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: '*', |
| | | productId: this.data.bookDetail.id, |
| | | cmsPath: path, |
| | | itemFields: { |
| | | SysType: 'CmsFolder', |
| | | // 资源类型,试读文件,是否允许下载等参数 |
| | | selectType: [], |
| | | freeFile: [], |
| | | file: [], |
| | | protectedFile: [], |
| | | resourcesClassification: [], |
| | | isDownload: [], |
| | | jsek_resourceBrief: [], |
| | | jsek_link: [], |
| | | accessType: [] |
| | | }, |
| | | pading: { |
| | | start: 0, |
| | | size: 999 |
| | | }, |
| | | } |
| | | const data = await app.MG.store.getProductDetail(query) |
| | | data.datas.cmsDatas[0].datas.forEach((item) => { |
| | | 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) { |
| | | 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.isbuy = this.resourceIsBuy(item) |
| | | item.isShopCar = this.isShoppingCart(item) |
| | | } |
| | | }) |
| | | return data.datas.cmsDatas[0].datas |
| | | }, |
| | | // 获取展开项 |
| | | findChildIds(data, result) { |
| | | let index = 0 |
| | | for (let i = 0; i < data.length; i++) { |
| | | if (index < 3) { |
| | | const item = data[i] |
| | | if (item.childrenFolderCount > 0) { |
| | | result.push(item.id) |
| | | for (let j = 0; j < item.children.length; j++) { |
| | | if (index < 3) { |
| | | const childrenItme = item.children[j] |
| | | if (item.childrenCount > 0) { |
| | | result.push(childrenItme.id) |
| | | index += 1 |
| | | } |
| | | } else { |
| | | break |
| | | } |
| | | } |
| | | } else if (item.childrenCount > 0) { |
| | | result.push(item.id) |
| | | index += 1 |
| | | } |
| | | } else { |
| | | break |
| | | } |
| | | } |
| | | }, |
| | | |
| | | // 图书添加购物车 |
| | | async addBookShopcCar() { |
| | | const shoppingCartGetId = [] |
| | | |
| | | let query = { |
| | | start: 0, |
| | | size: 999, |
| | | filterList: [], |
| | | searchList: [] |
| | | } |
| | | const res = await app.MG.store.getShoppingCartProductList(query) |
| | | res.datas.forEach((item) => { |
| | | shoppingCartGetId.push(item.saleMethod.id) |
| | | }) |
| | | console.log(shoppingCartGetId, 'shoppingCartGetId'); |
| | | console.log(this.data.bookDetail.defaultSaleMethodId, 'this.data.bookDetail.defaultSaleMethodId'); |
| | | const determine = shoppingCartGetId.some((item) => item == this.data.bookDetail.defaultSaleMethodId) |
| | | console.log(determine); |
| | | |
| | | if (!determine) { |
| | | let query = { |
| | | requests: [ |
| | | { |
| | | saleMethodId: this.data.bookDetail.defaultSaleMethodId, |
| | | storeEventId: null, |
| | | agentCode: '电子书' |
| | | } |
| | | ] |
| | | } |
| | | const addRes = app.MG.store.addShoppingCart(query) |
| | | this.showSuccessToast() |
| | | |
| | | } else { |
| | | Toast({ |
| | | context: this, |
| | | selector: '#t-toast', |
| | | message: '已添加', |
| | | theme: 'success', |
| | | direction: 'column', |
| | | }); |
| | | } |
| | | |
| | | }, |
| | | |
| | | showSuccessToast() { |
| | | Toast({ |
| | | context: this, |
| | | selector: '#t-toast', |
| | | message: '添加成功', |
| | | theme: 'success', |
| | | direction: 'column', |
| | | }); |
| | | }, |
| | | |
| | | |
| | | |
| | | async buyBook() { |
| | | let bookOrdersId = '' |
| | | let query = { |
| | | remarks: '电子书', |
| | | requests: [ |
| | | { |
| | | saleMethodId: this.data.bookDetail.defaultSaleMethodId, |
| | | count: 1 |
| | | } |
| | | ] |
| | | } |
| | | // 发起订单初始化请求并等待结果 |
| | | const res = await app.MG.store.initOrder(query) |
| | | // 获取订单号并赋值给 orderNumber.value |
| | | bookOrdersId = res.orderNumber |
| | | console.log(bookOrdersId); |
| | | // 检查订单号是否存在 |
| | | if (bookOrdersId) { |
| | | const url = '/pages/cart/paymentPage/index?orderNumber=' + bookOrdersId |
| | | wx.navigateTo({ |
| | | url |
| | | }) |
| | | } else { |
| | | console.log(222); |
| | | } |
| | | |
| | | }, |
| | | |
| | | // 获取教学资源下载是否申请通过 |
| | | getApplyInfo(id) { |
| | | // 获取当前时间 |
| | | const currentDate = new Date() |
| | | let query = { |
| | | sort: { |
| | | type: 'Desc', |
| | | field: 'CreateDate' |
| | | }, |
| | | start: 0, |
| | | size: 99999, |
| | | appRefCode: app.config.appRefCode, |
| | | topicIdOrRefCode: 'productDownLoad' |
| | | } |
| | | app.MG.ugc.getTopicMessageList(query).then((res) => { |
| | | const applyResource = res.datas.find((item) => { |
| | | let content = [] |
| | | try { |
| | | content = JSON.parse(item.content) |
| | | } catch (error) { |
| | | content = [] |
| | | } |
| | | if (Array.isArray(content)) return content.find((citem) => citem.id == id) |
| | | return false |
| | | }) |
| | | // 有申请记录 |
| | | if (applyResource) { |
| | | if (applyResource.state == 'Reject') { |
| | | this.setData({ |
| | | rejectCause: JSON.parse(applyResource.feedBack).reason, |
| | | applyState: 'Reject' |
| | | }) |
| | | } else if (applyResource.state == 'Normal') { |
| | | const endDate = JSON.parse(applyResource.feedBack).endDate |
| | | // const endDate = new Date(JSON.parse(applyResource.feedBack).endDate + ' 23:59:59').getTime() |
| | | if (endDate == '永久') { |
| | | this.setData({ |
| | | applyState: 'Normal', |
| | | deadline: '永久', |
| | | }) |
| | | console.log('有效日期', this.data.deadline); |
| | | } else { |
| | | |
| | | let endTime = new Date(endDate + ' 23:59:59').getTime() |
| | | this.setData({ |
| | | deadline: endDate + ' 23:59:59' |
| | | }) |
| | | if (currentDate.getTime() < endTime) { |
| | | // 未超时 |
| | | this.setData({ |
| | | applyState: 'Normal' |
| | | }) |
| | | } else { |
| | | this.setData({ |
| | | applyState: 'none' |
| | | }) |
| | | } |
| | | } |
| | | } else { |
| | | this.setData({ |
| | | applyState: applyResource.state |
| | | }) |
| | | } |
| | | } else { |
| | | this.setData({ |
| | | applyState: 'none' |
| | | }) |
| | | } |
| | | }) |
| | | console.log('有效日期', this.data.deadline); |
| | | }, |
| | | // 申请教学资源 |
| | | applyResource() { |
| | | // let role = userStore.userInfo ? userStore.userInfo.role : null |
| | | // if (role) { |
| | | // if (role == 'Teacher') { |
| | | // 申请教学资源 |
| | | let query = { |
| | | topicIdOrRefCode: 'productDownLoad', |
| | | type: 'applyForDownload', |
| | | state: 'WaitAudit', |
| | | cmsTypeRefCode: '', |
| | | newDataListRequest: [], |
| | | name: this.data.bookDetail.name, // name为申请的书本名称 |
| | | content: JSON.stringify([ |
| | | { |
| | | name: this.data.bookDetail.name, |
| | | id: this.data.bookDetail.id, |
| | | // defaultSaleMethodId: bookData.value.defaultSaleMethodId, |
| | | icon: this.data.bookDetail.icon |
| | | } |
| | | ]) |
| | | } |
| | | app.MG.ugc.newTopicMessage(query).then((res) => { |
| | | if (res) { |
| | | Message.success('申请已提交,请待审核通过后下载') |
| | | } |
| | | this.getApplyInfo(this.data.bookDetail.id) |
| | | }) |
| | | // } else { |
| | | // ElMessageBox.confirm('请先进行教师认证!', '尊敬的用户,您好!', { |
| | | // confirmButtonText: '去认证', |
| | | // cancelButtonText: '取消', |
| | | // type: 'warning' |
| | | // }) |
| | | // .then(() => { |
| | | // isShow.value = true |
| | | // }) |
| | | // .catch(() => { }) |
| | | // } |
| | | // } else { |
| | | // // logIn() |
| | | // } |
| | | }, |
| | | // 教学资源下载前往PC提示Diialog |
| | | closeTeachDownload() { |
| | | this.setData({ |
| | | isShowTeachDownload: false |
| | | }) |
| | | }, |
| | | // 下载功能 |
| | | downloadTeach(e) { |
| | | this.setData({ |
| | | isShowTeachDownload: true |
| | | }) |
| | | console.log('zhuan', this.data.isShowTeachDownload); |
| | | // const data = e.detail.value |
| | | // // const data |
| | | // // let role = userStore.userInfo ? userStore.userInfo.role : null |
| | | // // if (role) { |
| | | // // if (role == 'Teacher') { |
| | | // if (this.properties.applyState == 'Normal' || this.properties.applyState == 'none') { |
| | | // // 是否允许下载 |
| | | // if (data.isDownload == 1) { |
| | | // // 申请通过 |
| | | // let url = app.config.requestCtx + '/file/api/ApiDownloadForAuthorize?md5=' |
| | | // if (data.file) { |
| | | // // 判断是否私有 |
| | | // if (data.fileMap[data.file].protectType == 'Private') |
| | | // return Message.error({ |
| | | // context: this, |
| | | // offset: ['20rpx', '32rpx'], |
| | | // duration: 5000, |
| | | // content: '该文件无法下载' |
| | | // }) |
| | | // url = url + data.file + '&token=' + wx.getStorageSync('jsek-token') |
| | | // } else if (data.freeFile) { |
| | | // url = url + data.freeFile + '&token=' + wx.getStorageSync('jsek-token') |
| | | // } else { |
| | | // Message.error({ |
| | | // context: this, |
| | | // offset: ['20rpx', '32rpx'], |
| | | // duration: 5000, |
| | | // content: '暂无资源', |
| | | // }) |
| | | // } |
| | | // this.downloadFile(url) |
| | | // } else { |
| | | // Message.error({ |
| | | // context: this, |
| | | // offset: ['20rpx', '32rpx'], |
| | | // duration: 5000, |
| | | // content: '该资源无法下载', |
| | | // }) |
| | | // } |
| | | // } else if (this.properties.applyState == 'WaitAudit') { |
| | | // // ElMessageBox.confirm('请先申请下载!', '尊敬的用户,您好!', { |
| | | // // confirmButtonText: '申请', |
| | | // // cancelButtonText: '取消', |
| | | // // type: 'warning' |
| | | // // }) |
| | | // // .then(() => applyBookInfo()) |
| | | // // .catch() |
| | | // Message.error({ |
| | | // context: this, |
| | | // offset: ['20rpx', '32rpx'], |
| | | // duration: 5000, |
| | | // content: '该资源下载申请审核中', |
| | | // }) |
| | | // } else if (this.properties.applyState == 'Reject') { |
| | | // Message.error({ |
| | | // context: this, |
| | | // offset: ['20rpx', '32rpx'], |
| | | // duration: 5000, |
| | | // content: '资源下载申请未通过' |
| | | // }) |
| | | |
| | | // } else { |
| | | // // Message.error({ |
| | | // // context: this, |
| | | // // offset: ['20rpx', '32rpx'], |
| | | // // duration: 5000, |
| | | // // content: '请先申请下载' |
| | | // // }) |
| | | // console.log('请先申请下载'); |
| | | // } |
| | | // // } else { |
| | | // // ElMessageBox.confirm('请先进行教师认证!', '尊敬的用户,您好!', { |
| | | // // confirmButtonText: '去认证', |
| | | // // cancelButtonText: '取消', |
| | | // // type: 'warning' |
| | | // // }) |
| | | // // .then(() => { |
| | | // // isShow.value = true |
| | | // // }) |
| | | // // .catch(() => { }) |
| | | // // } |
| | | // // } else { |
| | | // // logIn() |
| | | // // } |
| | | }, |
| | | downloadFile(url) { |
| | | wx.downloadFile({ |
| | | url: url, |
| | | success: function (res) { |
| | | // 下载成功后,调用saveImageToPhotosAlbum函数保存图片到本地 |
| | | wx.saveFile({ |
| | | tempFilePath: res.tempFilePath, |
| | | success: function (res) { |
| | | wx.showToast({ |
| | | title: '下载成功', |
| | | icon: 'success' |
| | | }) |
| | | }, |
| | | fail: function (res) { |
| | | wx.showToast({ |
| | | title: '下载失败', |
| | | icon: 'none' |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | fail: function (res) { |
| | | wx.showToast({ |
| | | title: '下载失败', |
| | | icon: 'none' |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | // 判断资源是否购买 |
| | | resourceIsBuy(data) { |
| | | if (data.saleMethod && data.saleMethod.length) { |
| | | const isSHow = this.data.buyIdList.some((item) => item == data.saleMethod[0].Id) |
| | | return !isSHow |
| | | } else { |
| | | return false |
| | | } |
| | | }, |
| | | // 获取已购买商品 |
| | | getShoppingCartProductGet() { |
| | | let query = { |
| | | start: 0, |
| | | size: 999, |
| | | filterList: [], |
| | | searchList: [] |
| | | } |
| | | app.MG.store.getShoppingCartProductList(query).then((res) => { |
| | | const list = [] |
| | | res.datas.forEach((item) => { |
| | | list.push(item.saleMethod.id) |
| | | }) |
| | | this.setData({ |
| | | shoppingList: res.datas, |
| | | shoppingCartGetId: list |
| | | }) |
| | | }) |
| | | }, |
| | | // 判断资源加入购物车按钮是否显示 |
| | | isShoppingCart(data) { |
| | | if (data.saleMethod && data.saleMethod.length) { |
| | | if (data.saleMethod[0].Price <= 0) return false |
| | | // 再判断是否购买 |
| | | const isBuy = this.data.buyIdList.some((item) => item == data.saleMethod[0].Id) |
| | | if (isBuy) { |
| | | // 购买了 |
| | | return false |
| | | } else { |
| | | // 判断是否加入购物车 |
| | | const isSHow = this.data.shoppingCartGetId.some((item) => item == data.saleMethod[0].Id) |
| | | return !isSHow |
| | | } |
| | | } else { |
| | | return false |
| | | } |
| | | }, |
| | | // 遍历树结构转换为数组方法 |
| | | handleTreeData(array) { |
| | | const flattenedArray = [] |
| | | array.forEach((node) => { |
| | | // 将当前节点添加到展开的数组中 |
| | | flattenedArray.push(node) |
| | | // 递归处理子节点 |
| | | if (node.children && node.children.length > 0) { |
| | | const childrenArray = this.handleTreeData(node.children) |
| | | flattenedArray.push(...childrenArray) |
| | | } |
| | | }) |
| | | return flattenedArray.filter((item) => item.sysType == 'CmsItem') |
| | | }, |
| | | // 云学习一键领取 |
| | | async getFreeResource() { |
| | | const child = this.selectComponent('#learn-resource') |
| | | const token = wx.getStorageSync('jsek-token') |
| | | if (!token) { |
| | | return wx.getUserProfile({ |
| | | desc: '用户登录', |
| | | success: (res) => { |
| | | console.log(res); |
| | | } |
| | | }) |
| | | } |
| | | 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 |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | let query = { |
| | | remarks: '云学习', |
| | | requests, |
| | | } |
| | | try { |
| | | const initOrderRes = await app.MG.store.initOrder(query) |
| | | let parameter = { |
| | | orderNum: initOrderRes.orderNumber |
| | | } |
| | | // 确认订单 |
| | | const confirmOrderRes = await app.MG.store.confirmOrder(parameter) |
| | | if (confirmOrderRes.orderNumber) { |
| | | child.changeReceive(false) |
| | | wx.showToast({ |
| | | title: '领取成功', |
| | | }) |
| | | this.getBookInfo(this.data.bookId) |
| | | } |
| | | } catch (error) { |
| | | console.log(error) |
| | | } |
| | | }, |
| | | // 云学习一键购买 |
| | | async allAddShoppiingCar() { |
| | | const child = this.selectComponent('#learn-resource') |
| | | const token = wx.getStorageSync('jsek-token') |
| | | if (!token) { |
| | | return wx.getUserProfile({ |
| | | desc: '用户登录', |
| | | success: (res) => { |
| | | console.log(res); |
| | | } |
| | | }) |
| | | } |
| | | let shopList = this.handleTreeData(this.data.learn).filter((item) => this.resourceIsBuy(item)) |
| | | this.getShoppingCartProductGet() |
| | | if (!shopList.length) return wx.showToast({ |
| | | icon: "error", |
| | | title: '已全部购买', |
| | | }) |
| | | child.changeBuy(true) |
| | | let requests = [] |
| | | shopList.forEach((item) => { |
| | | requests.push({ |
| | | saleMethodId: item.saleMethod[0].Id, |
| | | count: 1, |
| | | }) |
| | | }) |
| | | let query = { |
| | | remarks: '云学习', |
| | | requests, |
| | | } |
| | | const initOrderRes = await app.MG.store.initOrder(query) |
| | | child.changeBuy(false) |
| | | // 检查订单号是否存在 |
| | | 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: '请重试', |
| | | }) |
| | | } |
| | | }, |
| | | // 变为所有check true |
| | | findAndUpdateItemsByIds(tree, ids) { |
| | | function findAndUpdate(node) { |
| | | if (ids.includes(node.id)) { |
| | | node.checked = true; // 将目标项的 check 属性设置为 true |
| | | } |
| | | if (node.children && node.children.length > 0) { |
| | | for (let child of node.children) { |
| | | findAndUpdate(child); // 递归处理子节点 |
| | | } |
| | | } |
| | | } |
| | | |
| | | for (let node of tree) { |
| | | findAndUpdate(node); // 对每个顶层节点执行查找和更新操作 |
| | | } |
| | | return tree; // 返回修改后的完整数组 |
| | | }, |
| | | handleTrue() { |
| | | // findAndUpdateItemsByIds(this.date.) |
| | | }, |
| | | // 组卷格式化日期显示 |
| | | DateFormat(date, fmt) { |
| | | if (date && fmt) { |
| | | let _date = new Date(date) |
| | | var o = { |
| | | 'M+': _date.getMonth() + 1, //月份 |
| | | 'd+': _date.getDate(), //日 |
| | | 'h+': _date.getHours(), //小时 |
| | | 'm+': _date.getMinutes(), //分 |
| | | 's+': _date.getSeconds(), //秒 |
| | | 'q+': Math.floor((_date.getMonth() + 3) / 3), //季度 |
| | | S: _date.getMilliseconds() //毫秒 |
| | | } |
| | | if (/(y+)/.test(fmt)) { |
| | | fmt = fmt.replace(RegExp.$1, (_date.getFullYear() + '').substr(4 - RegExp.$1.length)) |
| | | } |
| | | for (var k in o) { |
| | | if (new RegExp('(' + k + ')').test(fmt)) { |
| | | fmt = fmt.replace( |
| | | RegExp.$1, |
| | | RegExp.$1.length == 1 |
| | | ? (o)[k] |
| | | : ('00' + (o)[k]).substr(('' + (o)[k]).length) |
| | | ) |
| | | } |
| | | } |
| | | return fmt |
| | | } else { |
| | | return '' |
| | | } |
| | | }, |
| | | // 获取组卷答题数据 |
| | | getMockData() { |
| | | this.setData({ |
| | | 'mockData.useCount': 0, |
| | | 'mockData.mockList': [] |
| | | }) |
| | | app.MG.identity |
| | | .getUserKey({ |
| | | domain: 'mockData', |
| | | keys: [this.data.bookId] |
| | | }) |
| | | .then((res) => { |
| | | console.log(JSON.parse(res[0].value)); |
| | | if (res && res.length) { |
| | | const mock = JSON.parse(res[0].value) |
| | | mock.forEach(item => { |
| | | item.createDate = this.DateFormat(item.createDate, 'yyyy-MM-dd') |
| | | }) |
| | | this.setData({ |
| | | 'mockData.mockList': mock |
| | | }) |
| | | // 组卷已使用次数 |
| | | res.forEach((item) => { |
| | | // 已经有答题分数等数据,证明组卷已经使用完毕 |
| | | if (item.resultData) { |
| | | this.setData({ |
| | | 'mockData.useCount': this.data.mockData.useCount + 1 |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | }) |
New file |
| | |
| | | { |
| | | "component": true, |
| | | "usingComponents": { |
| | | "t-icon": "tdesign-miniprogram/icon/icon", |
| | | "t-image": "tdesign-miniprogram/image/image", |
| | | "t-tabs": "tdesign-miniprogram/tabs/tabs", |
| | | "t-tab-panel": "tdesign-miniprogram/tab-panel/tab-panel", |
| | | "t-button": "tdesign-miniprogram/button/button", |
| | | "t-message": "tdesign-miniprogram/message/message", |
| | | "book-brief": "/packageBookService/pages/bookServices/detail/components/brief/index", |
| | | "teach-resource": "/packageBookService/pages/bookServices/detail/components/teachResource/index", |
| | | "learn-resource": "/packageBookService/pages/bookServices/detail/components/learnResource/learnResource", |
| | | "test-resource": "/packageBookService/pages/bookServices/detail/components/testResource/testResource", |
| | | "note": "/packageBookService/pages/bookServices/detail/components/note/note", |
| | | "tree": "/packageBookService/pages/bookServices/detail/components/tree/index", |
| | | "suggest": "/packageBookService/pages/bookServices/detail/components/suggest/suggest", |
| | | "t-loading": "tdesign-miniprogram/loading/loading", |
| | | "t-dialog": "tdesign-miniprogram/dialog/dialog", |
| | | "t-toast": "tdesign-miniprogram/toast/toast" |
| | | }, |
| | | "navigationStyle": "custom", |
| | | "onReachBottomDistance": 200 |
| | | } |
New file |
| | |
| | | import { getPublicImage } from '../../../../assets/js/middleGround/tool' |
| | | const app = getApp() |
| | | Page({ |
| | | |
| | | /** |
| | | * 页面的初始数据 |
| | | */ |
| | | data: { |
| | | barHeight: "", |
| | | navBarHeight: "", |
| | | loading: false, |
| | | answerTitle: "", // 导航栏标题 |
| | | countdownInterval: null, // 计时器 |
| | | isCountdownRunning: true, // 是否倒计时 |
| | | countdownTime: 0, // 倒计时时间 |
| | | bookId: "", |
| | | productLinkPath: "", |
| | | rootCmsItemId: "", |
| | | idPathList: [], // 题目列表 |
| | | answerType: "", // 答题模式 |
| | | submitStatus: false, // 提交状态 |
| | | currentIndex: 0, // 当前显示的题号 |
| | | collectList: [], // 收藏题目列表 |
| | | errorList: [], // 错题列表 |
| | | subjectiveTotal: 0, // 客观题总数 |
| | | subjectiveNum: 0, // 客观题得分 |
| | | subjectiveGrade: 0, // 客观题总分 |
| | | correctNum: 0, // 正确题目数量 |
| | | total: 0, // 题目总数 |
| | | cardList: [], // 提交项, |
| | | questionDataList: [], // 显示题目列表 |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | onLoad(options) { |
| | | const systInfo = wx.getSystemInfoSync(); |
| | | const menu = wx.getMenuButtonBoundingClientRect(); // 胶囊信息 |
| | | const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度 |
| | | this.setData({ |
| | | barHeight: systInfo.statusBarHeight, |
| | | navBarHeight: navBarHeight, |
| | | answerTitle: options.answerTitle, |
| | | bookId: options.bookId, |
| | | productLinkPath: options.productLinkPath ? options.productLinkPath : '', |
| | | rootCmsItemId: options.rootCmsItemId, |
| | | idPathList: options.idPathList ? JSON.parse(options.idPathList) : [], |
| | | answerType: options.answerType |
| | | }); |
| | | this.init() |
| | | console.log('传参', options); |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面初次渲染完成 |
| | | */ |
| | | onReady() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面显示 |
| | | */ |
| | | onShow() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面隐藏 |
| | | */ |
| | | onHide() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面卸载 |
| | | */ |
| | | onUnload() { |
| | | if (this.data.countdownInterval !== null) { |
| | | clearInterval(this.data.countdownInterval) |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * 页面相关事件处理函数--监听用户下拉动作 |
| | | */ |
| | | onPullDownRefresh() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 页面上拉触底事件的处理函数 |
| | | */ |
| | | onReachBottom() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 用户点击右上角分享 |
| | | */ |
| | | onShareAppMessage() { |
| | | }, |
| | | // 返回 |
| | | goBack() { |
| | | wx.navigateBack(); |
| | | }, |
| | | |
| | | // 获取保存的倒计时时间 |
| | | getSavedTime() { |
| | | const savedTime = wx.getStorageSync('countdownTime') |
| | | return savedTime ? parseInt(savedTime) : null |
| | | }, |
| | | // 保存倒计时时间到本地存储 |
| | | saveTime() { |
| | | wx.setStorageSync('countdownTime', this.data.countdownTime.toString()) |
| | | }, |
| | | clearTime() { |
| | | this.setData({ |
| | | countdownTime: 2 * 60 * 60 * 1000 |
| | | }) |
| | | }, |
| | | // 暂停或继续倒计时 |
| | | toggleCountdown() { |
| | | if (this.data.countdownInterval) { |
| | | clearInterval(this.data.countdownInterval) |
| | | this.setData({ |
| | | countdownInterval: null, |
| | | isCountdownRunning: false |
| | | }) |
| | | } else { |
| | | this.startCountdown() |
| | | this.setData({ |
| | | isCountdownRunning: true |
| | | }) |
| | | } |
| | | }, |
| | | // 开始倒计时 |
| | | startCountdown() { |
| | | // 如果计时器已经存在,先清除之前的计时器 |
| | | if (this.data.countdownInterval) { |
| | | clearInterval(this.data.countdownInterval) |
| | | this.setData({ |
| | | countdownInterval: null |
| | | }) |
| | | } |
| | | this.setData({ |
| | | countdownInterval: setInterval(() => { |
| | | this.setData({ |
| | | countdownTime: this.data.countdownTime - 1000 |
| | | }) |
| | | if (this.data.countdownTime <= 0) { |
| | | clearInterval(this.data.countdownInterval) |
| | | this.setData({ |
| | | countdownTime: 0, |
| | | isCountdownRunning: false |
| | | }) |
| | | } |
| | | this.saveTime() |
| | | }, 1000) |
| | | }) |
| | | }, |
| | | // 切换题目 |
| | | changeSwiper(e) { |
| | | this.setData({ |
| | | currentIndex: e.detail.index |
| | | }) |
| | | let index = e.detail.index - 1 >= 0 ? e.detail.index - 1 : 0 |
| | | let flag = this.isHaveAnswer(this.data.questionDataList[index].userAnswer) |
| | | if (flag) this.handleQuestion(e.detail.index) |
| | | |
| | | }, |
| | | // 点击答题卡跳转题目 |
| | | goQuestion(e) { |
| | | console.log(e); |
| | | const id = e.detail.id |
| | | this.data.questionDataList.forEach((item, index) => { |
| | | if (item.id == id) { |
| | | this.setData({ |
| | | currentIndex: index |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | // 单选 多选 触发 |
| | | onChangeRadio(e) { |
| | | const radioData = e.detail.value.currentTarget.dataset.value |
| | | const id = e.detail.value.currentTarget.dataset.id |
| | | const radioChecked = e.detail.value.detail.value |
| | | const questionList = this.data.questionDataList |
| | | questionList.forEach(item => { |
| | | if (item.id == id) { |
| | | item.userAnswer = radioChecked |
| | | } |
| | | }) |
| | | this.setData({ |
| | | questionDataList: questionList |
| | | }) |
| | | console.log(this.data.questionDataList); |
| | | }, |
| | | // 输入框触发 |
| | | onChangeInput(e) { |
| | | const inputData = e.detail.value.detail.value |
| | | const id = e.detail.value.currentTarget.dataset.id |
| | | const index = e.detail.value.currentTarget.dataset.index |
| | | const questionList = this.data.questionDataList |
| | | questionList.forEach(item => { |
| | | if (item.id == id) { |
| | | item.userAnswer[index] = inputData |
| | | } |
| | | }) |
| | | this.setData({ |
| | | questionDataList: questionList |
| | | }) |
| | | console.log(this.data.questionDataList); |
| | | }, |
| | | // 数组转为字符串方法 |
| | | arrayToString(data) { |
| | | // 检查是否为数组 |
| | | if (Array.isArray(data)) { |
| | | // 使用 join 方法将数组转换为字符串,默认使用逗号分隔 |
| | | return data.join(',').replace(/<[^>]*>/g, '') |
| | | } else { |
| | | // 如果不是数组,直接返回原始值 |
| | | return data.replace(/<[^>]*>/g, '') |
| | | } |
| | | }, |
| | | // 判断是否有用户答案 |
| | | isHaveAnswer(data) { |
| | | if (typeof data == 'string') { |
| | | data = data |
| | | .replace(/<[^>]*>/g, '') |
| | | .replace(/ /g, '') |
| | | .trim() |
| | | if (data.length) { |
| | | return true |
| | | } else { |
| | | return false |
| | | } |
| | | } else { |
| | | const answer = data.find((item) => item.length > 0) |
| | | if (answer) { |
| | | return true |
| | | } else { |
| | | return false |
| | | } |
| | | } |
| | | }, |
| | | // 提交逻辑 |
| | | submitPaper() { |
| | | this.setData({ |
| | | submitStatus: true |
| | | }) |
| | | if (this.data.answerType == 'option') { |
| | | this.toggleCountdown() |
| | | const child = this.selectComponent('#question-options') |
| | | if (this.data.answerType == 'option' || this.data.answerType == 'errorQuestion') { |
| | | // 先遍历所有题目,将未批改的题目批改 |
| | | const qustionList = this.data.questionDataList |
| | | for (let index = 0; index < qustionList.length; index++) { |
| | | const item = qustionList[index]; |
| | | if (!item.isComplete) this.handleQuestion(index + 1) |
| | | } |
| | | } |
| | | if (this.data.answerType == 'option') { |
| | | this.recordAnswerData() |
| | | child.openTestReportDialog() |
| | | } |
| | | } else if (this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') { |
| | | this.goBack() |
| | | } |
| | | |
| | | }, |
| | | // 初始化函数 |
| | | async init() { |
| | | this.setData({ |
| | | loading: true, |
| | | subjectiveTotal: 0, |
| | | subjectiveNum: 0, |
| | | subjectiveGrade: 0 |
| | | }) |
| | | if (this.data.answerType == 'option') { |
| | | if (this.data) |
| | | this.startCountdown() |
| | | this.setData({ |
| | | countdownTime: 2 * 60 * 60 * 1000 |
| | | }) |
| | | // 测试答题 |
| | | await this.getCollectIdList() // 获取收藏id列表 |
| | | await this.getErrorList() // 获取错题id列表 |
| | | } else if (this.data.answerType == 'collectQuestion') { |
| | | // 我的收藏 |
| | | await this.getcollectId() // 获取收藏题目 |
| | | } else if (this.data.answerType == 'errorQuestion') { |
| | | // 我的错题 |
| | | // loadings.value = true |
| | | await this.getErrorIdList() |
| | | await this.getCollectIdList() // 获取收藏id列表 |
| | | } |
| | | }, |
| | | async restart() { |
| | | const countDownRef = this.selectComponent('#countDownRef') |
| | | this.setData({ |
| | | loading: true, |
| | | total: 0, |
| | | subjectiveGrade: 0, |
| | | subjectiveTotal: 0, |
| | | subjectiveNum: 0, |
| | | currentIndex: 0, |
| | | submitStatus: false |
| | | }) |
| | | if (this.data.answerType == 'option') { |
| | | this.setData({ |
| | | countdownTime: 2 * 60 * 60 * 1000 |
| | | }) |
| | | this.delAnswerInfo(() => { |
| | | this.getQuestionList() |
| | | this.clearTime() |
| | | }) |
| | | if (!this.data.submitStatus) { |
| | | this.startCountdown() |
| | | } |
| | | } else if (this.data.answerType == 'mock') { |
| | | // 组卷模式 |
| | | // 清空答题记录 |
| | | await app.MG.identity.setUserKey({ |
| | | setKeyRequests: [ |
| | | { |
| | | domain: 'mockAnswerData', |
| | | key: route.query.uuid, |
| | | value: JSON.stringify({ |
| | | time: countDownRef.value.countdownTime, |
| | | answerData: [] |
| | | }) |
| | | } |
| | | ] |
| | | }) |
| | | this.init() |
| | | } else { |
| | | this.init() |
| | | this.clearTime() |
| | | if (submitStatus.value) { |
| | | this.startCountdown() |
| | | } |
| | | } |
| | | }, |
| | | // 获取收藏题目列表id |
| | | getCollectIdList() { |
| | | app.MG.identity |
| | | .getUserKey({ |
| | | domain: 'collectData', |
| | | keys: [this.data.rootCmsItemId] |
| | | }) |
| | | .then((res) => { |
| | | try { |
| | | this.setData({ |
| | | collectList: JSON.parse(res[0].value) |
| | | }) |
| | | } catch (error) { |
| | | } |
| | | if (this.data.answerType == 'option') { |
| | | // 先获取用户答题记录 |
| | | this.getAnswerInfo(async (res) => { |
| | | if (res.length) { |
| | | // 有记录,不能答题,状态设为已提交 |
| | | this.setData({ |
| | | submitStatus: true |
| | | }) |
| | | let value = JSON.parse(res[0].value) |
| | | // 有答题记录,得分赋值 |
| | | if (value) { |
| | | this.setData({ |
| | | submitStatus: true |
| | | }) |
| | | value.dataList.forEach((item) => { |
| | | if (item.name == '客观题得分' && item.path == this.data.productLinkPath) |
| | | this.setData({ |
| | | subjectiveNum: item.score |
| | | }) |
| | | }) |
| | | } |
| | | this.setData({ |
| | | currentIndex: value.currentIndex |
| | | }) |
| | | // 携带答题记录 获取题目 |
| | | await this.getQuestionList(value.dataList) |
| | | } else { |
| | | await this.getQuestionList() // 获取题库题目 |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | // 获取错题id列表 |
| | | getErrorList() { |
| | | app.MG.identity |
| | | .getUserKey({ |
| | | domain: 'errorData', |
| | | keys: [this.data.rootCmsItemId] |
| | | }) |
| | | .then((res) => { |
| | | try { |
| | | this.setData({ |
| | | errorList: JSON.parse(res[0].value) |
| | | }) |
| | | } catch (error) { |
| | | |
| | | } |
| | | }) |
| | | }, |
| | | // 获取题库题目 |
| | | getQuestionList(oldData) { |
| | | // 清空正确题数记录 |
| | | this.setData({ |
| | | cardList: [], |
| | | correctNum: 0, |
| | | }) |
| | | let flag = 0 |
| | | this.data.idPathList.forEach((pathitem) => { |
| | | const pathList = this.data.cardList |
| | | pathList.push({ |
| | | path: pathitem.productLinkPath, |
| | | catalogName: pathitem.name, |
| | | infoList: [] |
| | | }) |
| | | this.setData({ |
| | | cardList: pathList |
| | | }) |
| | | // 获取题目 |
| | | let query = { |
| | | path: '*', |
| | | queryType: '*', |
| | | productId: this.data.bookId, |
| | | cmsPath: pathitem.productLinkPath, |
| | | itemFields: { |
| | | // SysType: 'CmsFolder', |
| | | Embedded_QuestionBank_Stem: [], |
| | | Embedded_QuestionBank_AnalysisCon: [], |
| | | Embedded_QuestionBank_Answer: [], |
| | | Embedded_QuestionBank_Option: [], |
| | | Embedded_QuestionBank_QuestionType: [], |
| | | Embedded_QuestionBank_StemStyle: [], |
| | | Embedded_QuestionBank_OptionStyle: [], |
| | | Embedded_QuestionBank_KnowledgePoint: [], |
| | | Embedded_QuestionBank_Difficulty: [] |
| | | }, |
| | | pading: { |
| | | start: 0, |
| | | size: 999 |
| | | } |
| | | } |
| | | app.MG.store.getProductDetail(query).then((res) => { |
| | | this.setData({ |
| | | total: res.datas.cmsDatas[0].datas.length |
| | | }) |
| | | // total.value += res.datas.cmsDatas[0].datas.length |
| | | let oldList |
| | | if (oldData) { |
| | | // 提交过,存在答题记录 |
| | | oldList = oldData.find((item) => item.path == pathitem.productLinkPath).infoList |
| | | this.setData({ |
| | | submitStatus: true |
| | | }) |
| | | } |
| | | res.datas.cmsDatas[0].datas.forEach((item, index) => { |
| | | let oldObj = '' |
| | | if (oldList) oldObj = oldList.find((oldItem) => oldItem.id == item.id) |
| | | let questionObj = { |
| | | // num: index, // 题号 |
| | | id: item.id, |
| | | type: pathitem.name, |
| | | stem: |
| | | item.Embedded_QuestionBank_QuestionType == 'completion' |
| | | ? JSON.parse(item.Embedded_QuestionBank_Stem) |
| | | .stemTxt.replaceAll('<vacancy>', ',input,') |
| | | .split(',') |
| | | : JSON.parse(item.Embedded_QuestionBank_Stem), // 题干 |
| | | answer: item.Embedded_QuestionBank_Answer, // 答案 |
| | | option: item.Embedded_QuestionBank_Option |
| | | ? JSON.parse(item.Embedded_QuestionBank_Option) |
| | | : '', // 选择题选项 |
| | | analysisCon: item.Embedded_QuestionBank_AnalysisCon, // 解析 |
| | | questionType: item.Embedded_QuestionBank_QuestionType, // 题型 |
| | | optionStyle: item.Embedded_QuestionBank_OptionStyle, // 选项显示类型 |
| | | stemStyle: item.Embedded_QuestionBank_StemStyle, // 题干显示类型 |
| | | difficulty: item.Embedded_QuestionBank_Difficulty |
| | | ? 4 - item.Embedded_QuestionBank_Difficulty |
| | | : 0, // 难度等级 |
| | | userAnswer: oldObj |
| | | ? oldObj.userAnswer |
| | | : item.Embedded_QuestionBank_QuestionType == 'completion' || |
| | | item.Embedded_QuestionBank_QuestionType == 'multipleChoice' |
| | | ? [] |
| | | : '', |
| | | isRight: oldObj ? oldObj.isRight : null, |
| | | isComplete: oldObj ? oldObj.isComplete : false, |
| | | isCollect: this.data.collectList.indexOf(item.id) > -1 ? true : false, |
| | | isUnfold: '' // 控制解析的折叠面板是否展开 |
| | | } |
| | | // 多选和填空答案肯为数组,要转换JSON格式 |
| | | if ( |
| | | questionObj.questionType == 'completion' || |
| | | questionObj.questionType == 'multipleChoice' |
| | | ) { |
| | | try { |
| | | questionObj.answer = JSON.parse(questionObj.answer) |
| | | } catch (error) { |
| | | questionObj.answer = item.Embedded_QuestionBank_Answer |
| | | } |
| | | } |
| | | // questionObj.userAnswer = this.arrayToString(questionObj.userAnswer) |
| | | // questionObj.isHaveAnswer = this.isHaveAnswer(questionObj.userAnswer) |
| | | // 填空题改造 |
| | | if (questionObj.questionType == 'completion') { |
| | | let index = 0 |
| | | for (let i = 0; i < questionObj.stem.length; i++) { |
| | | const item = questionObj.stem[i] |
| | | if (item == 'input') { |
| | | questionObj.stem[i] = { |
| | | num: index, |
| | | data: 'input' |
| | | } |
| | | if (!oldObj) questionObj.userAnswer[index] = '' |
| | | index++ |
| | | } |
| | | } |
| | | } |
| | | // 获取图片 |
| | | if (questionObj.stemStyle == 'Image' || questionObj.stemStyle == 'TxtAndImage') { |
| | | questionObj.stem.stemImage = getPublicImage(questionObj.stem.stemImage, 150) |
| | | } |
| | | if (questionObj.optionStyle == 'Image' || questionObj.optionStyle == 'TxtAndImage') { |
| | | questionObj.option.forEach(optionItem => { |
| | | if (optionItem.img) optionItem.img = getPublicImage(optionItem.img, 150) |
| | | }) |
| | | } |
| | | // if (questionObj.optionStyle == 'RichText') { |
| | | // questionObj.option.forEach(optionItem => { |
| | | // optionItem.txt.replace(/<img>/g, "<img class='imgClass'>") |
| | | // }) |
| | | // } |
| | | // 旧数据里 题目已经作答,修改已答题目数量 |
| | | // if (oldObj && oldObj.userAnswer.length > 0) countDownRef.value.changeAlready() |
| | | // 旧数据里 题目正确 记录正确数量 |
| | | if (questionObj.isRight) { |
| | | this.setData({ |
| | | correctNum: this.data.correctNum + 1 |
| | | }) |
| | | } |
| | | if (pathitem.name == '判断题' || pathitem.name == '填空题' || pathitem.name == '多选题' || pathitem.name == '单选题' || pathitem.name == '听力题') { |
| | | if (oldObj) { |
| | | this.setData({ |
| | | subjectiveTotal: this.data.subjectiveTotal + 1 |
| | | }) |
| | | } |
| | | |
| | | } |
| | | // cardList赋值 |
| | | let cardIndex = this.data.cardList.findIndex((item) => item.path == pathitem.productLinkPath) |
| | | let infoList = this.data.cardList[cardIndex].infoList |
| | | infoList.push(questionObj) |
| | | this.setData({ |
| | | [`cardList[${cardIndex}].infoList`]: infoList |
| | | }) |
| | | // this.data.cardList[this.data.cardList.findIndex((item) => item.path == pathitem.productLinkPath)] |
| | | // .infoList |
| | | // infoList.push(questionObj) |
| | | flag++; |
| | | let questionList = [] |
| | | const cardUpdatedList = this.data.cardList |
| | | // if (flag == this.data.idPathList.length) { |
| | | cardUpdatedList.forEach(aitem => { |
| | | aitem.infoList.forEach((bitem, bindex) => { |
| | | questionList.push(bitem) |
| | | bitem.number = bindex + 1 |
| | | bitem.grade = 2 |
| | | }) |
| | | }) |
| | | this.setData({ |
| | | questionDataList: questionList, |
| | | cardList: cardUpdatedList |
| | | }) |
| | | }) |
| | | }) |
| | | }) |
| | | this.setData({ |
| | | loading: false, |
| | | }) |
| | | }, |
| | | // 批改题目 (练习,我的错题,我的收藏) |
| | | handleQuestion(num) { |
| | | const questionList = this.data.questionDataList |
| | | const index = num - 1 >= 0 ? num - 1 : 0 |
| | | if (questionList[index].isComplete) { |
| | | // 题目已完成,跳过 |
| | | return true |
| | | } |
| | | questionList[index].isComplete = true |
| | | const item = questionList[index] |
| | | // 批改题目 |
| | | if (item.questionType == 'multipleChoice') { |
| | | // 多选题 |
| | | // subjectiveGrade.value += item.score |
| | | if (item.answer.length == item.userAnswer.length) { |
| | | const sortedArr1 = item.answer.slice().sort() |
| | | const sortedArr2 = item.userAnswer.slice().sort() |
| | | questionList[index].isRight = sortedArr1.every( |
| | | (value, valueIndex) => value === sortedArr2[valueIndex] |
| | | ) |
| | | } else { |
| | | questionList[index].isRight = false |
| | | } |
| | | } else if (item.questionType == 'singleChoice' || item.questionType == 'judge') { |
| | | // 单选 判断 |
| | | // subjectiveGrade.value += item.score |
| | | questionList[index].isRight = item.answer == item.userAnswer |
| | | } else if (item.questionType == 'shortAnswer') { |
| | | // 简答 翻译 |
| | | questionList[index].isRight = null |
| | | } else if (item.questionType == 'completion') { |
| | | // 填空 |
| | | // subjectiveGrade.value += item.score |
| | | if (typeof item.answer == 'string') { |
| | | questionList[index].isRight = item.answer == item.userAnswer[0] |
| | | } else { |
| | | if (item.answer.length != item.userAnswer.length) { |
| | | questionList[index].isRight = false |
| | | } else { |
| | | questionList[index].isRight = item.answer.every( |
| | | (value, valueIndex) => value === item.userAnswer[valueIndex] |
| | | ) |
| | | } |
| | | } |
| | | } |
| | | if (item.questionType != 'shortAnswer') { |
| | | this.setData({ |
| | | subjectiveTotal: this.data.subjectiveTotal + 1, |
| | | subjectiveGrade: this.data.subjectiveGrade + item.grade |
| | | }) |
| | | } |
| | | if (questionList[index].isRight && item.questionType != 'shortAnswer') { |
| | | // 客观题回答正确 |
| | | this.setData({ |
| | | subjectiveNum: this.data.subjectiveNum + item.grade, |
| | | correctNum: this.data.correctNum + 1 |
| | | }) |
| | | } |
| | | if (!questionList[index].isRight && item.questionType != 'shortAnswer') { |
| | | // 客观题回答错误 记录错题 |
| | | if (this.data.errorList.findIndex((errorItem) => errorItem == item.id) == -1) { |
| | | this.data.errorList.push(item.id) |
| | | } |
| | | } else { |
| | | if (this.data.answerType == 'errorQuestion' || this.data.answerType == 'option') { |
| | | // 从错题集中移除 |
| | | let errorIndex = this.data.errorList.findIndex((erroritem) => erroritem == item.id) |
| | | if (errorIndex > -1) { |
| | | this.data.errorList.splice(errorIndex, 1) |
| | | } |
| | | } |
| | | } |
| | | if (this.data.answerType != 'collectQuestion') { |
| | | // 记录错题 |
| | | app.MG.identity |
| | | .setUserKey({ |
| | | setKeyRequests: [ |
| | | { |
| | | domain: 'errorData', |
| | | key: this.data.rootCmsItemId, |
| | | value: JSON.stringify(this.data.errorList) |
| | | } |
| | | ] |
| | | }) |
| | | .then((res) => { |
| | | console.log(res) |
| | | }) |
| | | } |
| | | this.setData({ |
| | | questionDataList: questionList |
| | | }) |
| | | const cardUpdatedList = this.data.cardList |
| | | cardUpdatedList.forEach((item) => { |
| | | item.infoList.forEach((citem) => { |
| | | if (citem.id == questionList[index].id) { |
| | | citem = questionList[index]; |
| | | } |
| | | }); |
| | | }); |
| | | this.setData({ |
| | | cardList: cardUpdatedList |
| | | }) |
| | | // console.log(this.data.questionDataList, this.data.cardList); |
| | | }, |
| | | // 题目收藏按钮,收藏和取消同一接口,取消数组减去该项id |
| | | setCollect() { |
| | | const citem = this.data.questionDataList[this.data.currentIndex] |
| | | const questionList = this.data.questionDataList |
| | | for (let index = 0; index < questionList.length; index++) { |
| | | const item = questionList[index]; |
| | | if (item.id == citem.id) { |
| | | item.isCollect = !item.isCollect |
| | | } |
| | | } |
| | | this.setData({ |
| | | questionDataList: questionList |
| | | }) |
| | | if (this.data.collectList.length == 0) { |
| | | this.setData({ |
| | | collectList: [citem.id] |
| | | }) |
| | | } else { |
| | | const collectItme = this.data.collectList.filter((item) => item == citem.id) |
| | | if (collectItme.length) { |
| | | const arr = this.data.collectList.filter((item) => item != citem.id) |
| | | this.setData({ |
| | | collectList: arr |
| | | }) |
| | | } else { |
| | | const collectArr = this.data.collectList |
| | | collectArr.push(citem.id) |
| | | this.setData({ |
| | | collectList: collectArr |
| | | }) |
| | | } |
| | | } |
| | | app.MG.identity |
| | | .setUserKey({ |
| | | setKeyRequests: [ |
| | | { |
| | | domain: 'collectData', |
| | | key: this.data.rootCmsItemId, |
| | | value: JSON.stringify(this.data.collectList) |
| | | } |
| | | ] |
| | | }) |
| | | .then((res) => { }) |
| | | }, |
| | | // 处理答题数据 |
| | | recordAnswerData() { |
| | | this.data.cardList.push( |
| | | { |
| | | name: '客观题得分', |
| | | score: this.data.subjectiveNum, |
| | | path: this.data.productLinkPath, |
| | | // infoList: [], |
| | | // catalogName: '' |
| | | } |
| | | ) |
| | | let setInfoData = { |
| | | currentIndex: this.data.currentIndex, |
| | | dataList: JSON.parse(JSON.stringify(this.data.cardList)) |
| | | } |
| | | for (let i = 0; i < setInfoData.dataList.length; i++) { |
| | | const item = setInfoData.dataList[i] |
| | | if (!item.name && !item.name == '客观题得分') { |
| | | for (let j = 0; j < item.infoList.length; j++) { |
| | | let obj = { |
| | | id: item.infoList[j].id, |
| | | userAnswer: item.infoList[j].userAnswer, |
| | | isComplete: item.infoList[j].isComplete, |
| | | isRight: item.infoList[j].isRight, |
| | | isCollect: item.infoList[j].isCollect |
| | | } |
| | | item.infoList[j] = obj |
| | | } |
| | | } |
| | | } |
| | | |
| | | this.setAnswerInfo(setInfoData) |
| | | }, |
| | | // 提交答题数据 |
| | | setAnswerInfo(data) { |
| | | app.MG.identity |
| | | .setUserKey({ |
| | | setKeyRequests: [ |
| | | { |
| | | domain: 'answerData', |
| | | key: this.data.productLinkPath, |
| | | value: JSON.stringify(data) |
| | | } |
| | | ] |
| | | }) |
| | | .then((res) => { }) |
| | | }, |
| | | // 获取答题数据 |
| | | getAnswerInfo(callback) { |
| | | app.MG.identity |
| | | .getUserKey({ |
| | | domain: 'answerData', |
| | | keys: [this.data.productLinkPath] |
| | | }) |
| | | .then((res) => { |
| | | if (callback) callback(res) |
| | | }) |
| | | }, |
| | | // 删除答题数据 |
| | | delAnswerInfo(callback) { |
| | | app.MG.identity |
| | | .delUserKey({ |
| | | domain: 'answerData', |
| | | keys: [this.data.productLinkPath] |
| | | }) |
| | | .then((res) => { |
| | | if (callback) callback() |
| | | }) |
| | | }, |
| | | // 我的收藏模式下获取收藏题目id |
| | | async getcollectId() { |
| | | app.MG.identity |
| | | .getUserKey({ |
| | | domain: 'collectData', |
| | | keys: [this.data.rootCmsItemId] |
| | | }) |
| | | .then(async (res) => { |
| | | try { |
| | | this.setData({ |
| | | collectList: JSON.parse(res[0].value) |
| | | }) |
| | | // total.value = collectList.value.length |
| | | } catch (error) { |
| | | } |
| | | if (this.data.collectList && this.data.collectList.length) { |
| | | await this.getCollectDataList() |
| | | } else { |
| | | this.setData({ |
| | | loading: false |
| | | }) |
| | | wx.showModal({ |
| | | title: '提示', |
| | | content: '收藏夹暂无数据',//editable如果为true,这就是输入框的内容 |
| | | editable: false,//是否显示输入框 |
| | | showCancel: false, |
| | | success: (res) => { |
| | | if (res.confirm) { |
| | | this.setData({ |
| | | submitStatus: true |
| | | }) |
| | | this.goBack() |
| | | } |
| | | |
| | | } |
| | | }) |
| | | } |
| | | // console.log('收藏', collectList.value) |
| | | }) |
| | | }, |
| | | // 获取收藏夹 |
| | | async getCollectDataList() { |
| | | let questionArr = [] |
| | | this.setData({ |
| | | cardList: [ |
| | | { |
| | | catalogName: '收藏夹', |
| | | infoList: [] |
| | | } |
| | | ] |
| | | }) |
| | | let query = { |
| | | path: '*', |
| | | cmsPath: this.data.rootCmsItemId, |
| | | cmsType: '*', |
| | | productId: this.data.bookId, |
| | | queryType: '*', |
| | | itemIds: this.data.collectList.map((item) => item + ''), |
| | | itemFields: { |
| | | Embedded_QuestionBank_Stem: [], |
| | | Embedded_QuestionBank_AnalysisCon: [], |
| | | Embedded_QuestionBank_Answer: [], |
| | | Embedded_QuestionBank_Option: [], |
| | | Embedded_QuestionBank_QuestionType: [], |
| | | Embedded_QuestionBank_StemStyle: [], |
| | | Embedded_QuestionBank_OptionStyle: [], |
| | | Embedded_QuestionBank_KnowledgePoint: [], |
| | | Embedded_QuestionBank_Difficulty: [] |
| | | } |
| | | } |
| | | app.MG.store.getProductDetail(query).then((res) => { |
| | | let questionArr = [] |
| | | res.datas.cmsDatas[0].datas.forEach((item, index) => { |
| | | const questionObj = { |
| | | number: index + 1, // 题号 |
| | | id: item.id, |
| | | stem: |
| | | item.Embedded_QuestionBank_QuestionType == 'completion' |
| | | ? JSON.parse(item.Embedded_QuestionBank_Stem) |
| | | .stemTxt.replaceAll('<vacancy>', ',input,') |
| | | .split(',') |
| | | : JSON.parse(item.Embedded_QuestionBank_Stem), // 题干 |
| | | answer: item.Embedded_QuestionBank_Answer, // 答案 |
| | | option: item.Embedded_QuestionBank_Option |
| | | ? JSON.parse(item.Embedded_QuestionBank_Option) |
| | | : '', // 选择题选项 |
| | | analysisCon: item.Embedded_QuestionBank_AnalysisCon, // 解析 |
| | | questionType: item.Embedded_QuestionBank_QuestionType, // 题型 |
| | | optionStyle: item.Embedded_QuestionBank_OptionStyle, // 选项显示类型 |
| | | stemStyle: item.Embedded_QuestionBank_StemStyle, // 题干显示类型 |
| | | difficulty: item.Embedded_QuestionBank_Difficulty |
| | | ? 4 - item.Embedded_QuestionBank_Difficulty |
| | | : 0, // 难度等级 |
| | | userAnswer: |
| | | item.Embedded_QuestionBank_QuestionType == 'completion' || |
| | | item.Embedded_QuestionBank_QuestionType == 'multipleChoice' |
| | | ? [] |
| | | : '', |
| | | isSubmit: false, // 查看解析 |
| | | isRight: null, // 是否正确 |
| | | isComplete: false, |
| | | isCollect: true |
| | | } |
| | | // 多选和填空答案肯为数组,要转换JSON格式 |
| | | if ( |
| | | questionObj.questionType == 'completion' || |
| | | questionObj.questionType == 'multipleChoice' |
| | | ) { |
| | | try { |
| | | questionObj.answer = JSON.parse(questionObj.answer) |
| | | } catch (error) { |
| | | // |
| | | } |
| | | } |
| | | // 填空题改造 |
| | | if (questionObj.questionType == 'completion') { |
| | | let index = 0 |
| | | for (let i = 0; i < questionObj.stem.length; i++) { |
| | | const item = questionObj.stem[i] |
| | | if (item == 'input') { |
| | | questionObj.stem[i] = { |
| | | num: index, |
| | | data: 'input' |
| | | } |
| | | questionObj.userAnswer[index] = '' |
| | | index++ |
| | | } |
| | | } |
| | | } |
| | | // 获取图片 |
| | | if (questionObj.stemStyle == 'Image' || questionObj.stemStyle == 'TxtAndImage') { |
| | | questionObj.stem.stemImage = getPublicImage(questionObj.stem.stemImage, 150) |
| | | } |
| | | if (questionObj.optionStyle == 'Image' || questionObj.optionStyle == 'TxtAndImage') { |
| | | questionObj.option.forEach(optionItem => { |
| | | if (optionItem.img) optionItem.img = getPublicImage(optionItem.img, 150) |
| | | }) |
| | | } |
| | | // if (item.Embedded_QuestionBank_QuestionType == 'judge') { |
| | | // topicList.value.judge.data.push(questionObj) |
| | | // } else if (item.Embedded_QuestionBank_QuestionType == 'singleChoice') { |
| | | // topicList.value.radio.data.push(questionObj) |
| | | // } else if (item.Embedded_QuestionBank_QuestionType == 'multipleChoice') { |
| | | // topicList.value.check.data.push(questionObj) |
| | | // } else if (item.Embedded_QuestionBank_QuestionType == 'completion') { |
| | | // topicList.value.gap.data.push(questionObj) |
| | | // } else if (item.Embedded_QuestionBank_QuestionType == 'shortAnswer') { |
| | | // topicList.value.short.data.push(questionObj) |
| | | // } |
| | | questionArr.push(questionObj) |
| | | // cardList.value[0].infoList.push(questionObj) |
| | | }) |
| | | // loadings.value = false |
| | | this.setData({ |
| | | questionDataList: questionArr, |
| | | ['cardList[0].infoList']: questionArr, |
| | | loading: false, |
| | | }) |
| | | }) |
| | | }, |
| | | // 我的错题模式下获取错题id列表 |
| | | async getErrorIdList() { |
| | | await app.MG.identity |
| | | .getUserKey({ |
| | | domain: 'errorData', |
| | | keys: [this.data.rootCmsItemId] |
| | | }) |
| | | .then((res) => { |
| | | try { |
| | | this.setData({ |
| | | errorList: JSON.parse(res[0].value) |
| | | }) |
| | | } catch (error) { |
| | | } |
| | | if (this.data.errorList && this.data.errorList.length) { |
| | | this.getErrorDataList() |
| | | } else { |
| | | this.setData({ |
| | | loading: true |
| | | }) |
| | | wx.showModal({ |
| | | title: '提示', |
| | | content: '错题集暂无数据',//editable如果为true,这就是输入框的内容 |
| | | editable: false,//是否显示输入框 |
| | | showCancel: false, |
| | | success: (res) => { |
| | | if (res.confirm) { |
| | | this.setData({ |
| | | submitStatus: true |
| | | }) |
| | | this.goBack() |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | // 获取错题集 |
| | | async getErrorDataList() { |
| | | this.setData({ |
| | | cardList: [ |
| | | { |
| | | catalogName: '错题集', |
| | | infoList: [] |
| | | } |
| | | ] |
| | | }) |
| | | let query = { |
| | | path: '*', |
| | | cmsPath: this.data.rootCmsItemId, |
| | | cmsType: '*', |
| | | productId: this.data.bookId, |
| | | queryType: '*', |
| | | itemIds: this.data.errorList.map((item) => item + ''), |
| | | itemFields: { |
| | | Embedded_QuestionBank_Stem: [], |
| | | Embedded_QuestionBank_AnalysisCon: [], |
| | | Embedded_QuestionBank_Answer: [], |
| | | Embedded_QuestionBank_Option: [], |
| | | Embedded_QuestionBank_QuestionType: [], |
| | | Embedded_QuestionBank_StemStyle: [], |
| | | Embedded_QuestionBank_OptionStyle: [], |
| | | Embedded_QuestionBank_KnowledgePoint: [], |
| | | Embedded_QuestionBank_Difficulty: [] |
| | | } |
| | | } |
| | | await app.MG.store.getProductDetail(query).then((res) => { |
| | | let questionArr = [] |
| | | res.datas.cmsDatas[0].datas.forEach((item, index) => { |
| | | const questionObj = { |
| | | number: index + 1, // 题号 |
| | | id: item.id, |
| | | stem: |
| | | item.Embedded_QuestionBank_QuestionType == 'completion' |
| | | ? JSON.parse(item.Embedded_QuestionBank_Stem) |
| | | .stemTxt.replaceAll('<vacancy>', ',input,') |
| | | .split(',') |
| | | : JSON.parse(item.Embedded_QuestionBank_Stem), // 题干 |
| | | answer: item.Embedded_QuestionBank_Answer, // 答案 |
| | | option: item.Embedded_QuestionBank_Option |
| | | ? JSON.parse(item.Embedded_QuestionBank_Option) |
| | | : '', // 选择题选项 |
| | | analysisCon: item.Embedded_QuestionBank_AnalysisCon, // 解析 |
| | | questionType: item.Embedded_QuestionBank_QuestionType, // 题型 |
| | | optionStyle: item.Embedded_QuestionBank_OptionStyle, // 选项显示类型 |
| | | stemStyle: item.Embedded_QuestionBank_StemStyle, // 题干显示类型 |
| | | difficulty: item.Embedded_QuestionBank_Difficulty |
| | | ? 4 - item.Embedded_QuestionBank_Difficulty |
| | | : 0, // 难度等级 |
| | | userAnswer: |
| | | item.Embedded_QuestionBank_QuestionType == 'completion' || |
| | | item.Embedded_QuestionBank_QuestionType == 'multipleChoice' |
| | | ? [] |
| | | : '', |
| | | isSubmit: false, // 查看解析 |
| | | isRight: null, // 是否正确 |
| | | isComplete: false, |
| | | isCollect: this.data.collectList.some((collectItem) => collectItem == item.id) |
| | | } |
| | | // 多选和填空答案肯为数组,要转换JSON格式 |
| | | if ( |
| | | questionObj.questionType == 'completion' || |
| | | questionObj.questionType == 'multipleChoice' |
| | | ) { |
| | | try { |
| | | questionObj.answer = JSON.parse(questionObj.answer) |
| | | } catch (error) { |
| | | // |
| | | } |
| | | } |
| | | // 填空题改造 |
| | | if (questionObj.questionType == 'completion') { |
| | | let index = 0 |
| | | for (let i = 0; i < questionObj.stem.length; i++) { |
| | | const item = questionObj.stem[i] |
| | | if (item == 'input') { |
| | | questionObj.stem[i] = { |
| | | num: index, |
| | | data: 'input' |
| | | } |
| | | questionObj.userAnswer[index] = '' |
| | | index++ |
| | | } |
| | | } |
| | | } |
| | | // 获取图片 |
| | | if (questionObj.stemStyle == 'Image' || questionObj.stemStyle == 'TxtAndImage') { |
| | | questionObj.stem.stemImage = getPublicImage(questionObj.stem.stemImage, 150) |
| | | } |
| | | if (questionObj.optionStyle == 'Image' || questionObj.optionStyle == 'TxtAndImage') { |
| | | questionObj.option.forEach(optionItem => { |
| | | if (optionItem.img) optionItem.img = getPublicImage(optionItem.img, 150) |
| | | }) |
| | | } |
| | | // if (item.Embedded_QuestionBank_QuestionType == 'judge') { |
| | | // topicList.value.judge.data.push(questionObj) |
| | | // } else if (item.Embedded_QuestionBank_QuestionType == 'singleChoice') { |
| | | // topicList.value.radio.data.push(questionObj) |
| | | // } else if (item.Embedded_QuestionBank_QuestionType == 'multipleChoice') { |
| | | // topicList.value.check.data.push(questionObj) |
| | | // } else if (item.Embedded_QuestionBank_QuestionType == 'completion') { |
| | | // topicList.value.gap.data.push(questionObj) |
| | | // } else if (item.Embedded_QuestionBank_QuestionType == 'shortAnswer') { |
| | | // topicList.value.short.data.push(questionObj) |
| | | // } |
| | | questionArr.push(questionObj) |
| | | }) |
| | | this.setData({ |
| | | questionDataList: questionArr, |
| | | ['cardList[0].infoList']: questionArr, |
| | | loading: false |
| | | }) |
| | | }) |
| | | // loadings.value = false |
| | | // console.log('错题集', topicList.value) |
| | | } |
| | | }) |
New file |
| | |
| | | { |
| | | "usingComponents": { |
| | | "question-options": "./questionOptions/index", |
| | | "question-schedule": "./questionSchedule/index", |
| | | "question-list": "./questionList/index", |
| | | "t-icon": "tdesign-miniprogram/icon/icon", |
| | | "t-image": "tdesign-miniprogram/image/image", |
| | | "t-button": "tdesign-miniprogram/button/button", |
| | | "t-loading": "tdesign-miniprogram/loading/loading" |
| | | }, |
| | | "navigationStyle": "custom" |
| | | } |
New file |
| | |
| | | const app = getApp(); |
| | | Page({ |
| | | /** |
| | | * 页面的初始数据 |
| | | */ |
| | | data: { |
| | | barHeight: '', |
| | | navBarHeight: '', |
| | | searchValue: '', |
| | | path: '', |
| | | pathList: [], |
| | | pageCount: { |
| | | page: 1, |
| | | total: 0, |
| | | }, |
| | | isMore: null, |
| | | assortCheck: { |
| | | name: '', |
| | | code: '', |
| | | }, |
| | | bookList: [], |
| | | stairList: { |
| | | value: '', |
| | | options: [ |
| | | { |
| | | value: '', |
| | | label: '一级', |
| | | }, |
| | | ], |
| | | }, |
| | | secondList: { |
| | | value: [], |
| | | options: [], |
| | | }, |
| | | majorProjectList: { |
| | | value: [], |
| | | options: [], |
| | | }, |
| | | newTextBook: { |
| | | value: [], |
| | | options: [], |
| | | }, |
| | | stairCode: '', // 一级分类选中项 |
| | | secondCode: '', // 二级分类选中项 |
| | | sort: '', // 排序 |
| | | enable: false, |
| | | loadingProps: { |
| | | size: '50rpx', |
| | | }, |
| | | }, |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | onLoad(options) { |
| | | const systInfo = wx.getSystemInfoSync(); |
| | | const menu = wx.getMenuButtonBoundingClientRect(); // 胶囊信息 |
| | | const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度 |
| | | this.setData({ |
| | | barHeight: systInfo.statusBarHeight, |
| | | navBarHeight: navBarHeight, |
| | | }); |
| | | // 搜索赋值 |
| | | if (options.searchValue) { |
| | | this.setData({ |
| | | searchValue: options.searchValue, |
| | | }); |
| | | } |
| | | // 高级分类赋值 |
| | | this.setData({ |
| | | assortCheck: { |
| | | name: options.assorName, |
| | | code: options.assortCode, |
| | | }, |
| | | }); |
| | | if (this.data.assortCheck.code) { |
| | | this.setData({}); |
| | | } |
| | | // 获取一级分类 |
| | | this.getStairList(options.assortCode); |
| | | // 一级分类和path赋值 |
| | | if (options.stairCode) { |
| | | this.setData({ |
| | | 'stairList.value': options.stairCode, |
| | | stairCode: options.stairCode, |
| | | path: `${options.assortCode}\\${options.stairCode}`, |
| | | }); |
| | | } |
| | | // 二级分类赋值 |
| | | if (options.secondCode) { |
| | | this.setData({ |
| | | secondCode: options.secondCode, |
| | | pathList: [{ |
| | | Path: options.secondCode, |
| | | Type: '*', |
| | | StoreRefCode: app.config.goodsStore, |
| | | } |
| | | ], |
| | | }) |
| | | } |
| | | // 获取二级分类 |
| | | this.getSecondList(`${options.assortCode}\\${options.stairCode}`); |
| | | this.getBookList(`${options.assortCode}\\${options.stairCode}`); |
| | | // 获取重点项目 |
| | | this.getProjectList('bookClassification'); |
| | | this.getProjectList('newFormsTextbooks'); |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面初次渲染完成 |
| | | */ |
| | | onReady() { |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面显示 |
| | | */ |
| | | onShow() { |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面隐藏 |
| | | */ |
| | | onHide() { }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面卸载 |
| | | */ |
| | | onUnload() { }, |
| | | |
| | | /** |
| | | * 页面相关事件处理函数--监听用户下拉动作 |
| | | */ |
| | | onPullDownRefresh() { |
| | | console.log('下拉'); |
| | | }, |
| | | |
| | | /** |
| | | * 页面上拉触底事件的处理函数 |
| | | */ |
| | | onReachBottom(e) { |
| | | console.log('底部'); |
| | | const flag = this.data.bookList.length < this.data.pageCount.total |
| | | if (flag) { |
| | | this.setData({ |
| | | isMore: true, |
| | | "pageCount.page": this.data.pageCount.page + 1 |
| | | }) |
| | | this.getBookList(this.data.path) |
| | | } else { |
| | | this.setData({ |
| | | isMore: true, |
| | | }) |
| | | setTimeout(() => { |
| | | this.setData({ |
| | | isMore: false |
| | | }) |
| | | }, 100) |
| | | console.log('没有更多了'); |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * 用户点击右上角分享 |
| | | */ |
| | | onShareAppMessage() { }, |
| | | goBack() { |
| | | wx.navigateBack(); |
| | | }, |
| | | // 获取一级列表 |
| | | getStairList(path) { |
| | | const query = { |
| | | path, |
| | | filterList: [], |
| | | queryType: '\\', |
| | | searchList: [], |
| | | size: '30', |
| | | start: '0', |
| | | storeRefCode: app.config.goodsStore, |
| | | sort: { type: 'Asc', field: 'LinkOrder' }, |
| | | }; |
| | | app.MG.store.getStoreChannelList(query).then(async (res) => { |
| | | const options = [ |
| | | { |
| | | value: '', |
| | | label: '一级', |
| | | }, |
| | | ]; |
| | | for (let index = 0; index < res.datas.length; index++) { |
| | | const item = res.datas[index]; |
| | | options.push({ |
| | | value: item.refCode, |
| | | label: item.name, |
| | | }); |
| | | } |
| | | this.setData({ |
| | | 'stairList.options': options, |
| | | 'stairList.value': this.data.stairCode, |
| | | }); |
| | | }); |
| | | }, |
| | | // 获取一级分类下二级分类 |
| | | getSecondList(path) { |
| | | const options = []; |
| | | const query = { |
| | | path, |
| | | filterList: [], |
| | | queryType: '\\', |
| | | searchList: [], |
| | | size: '30', |
| | | start: '0', |
| | | storeRefCode: app.config.goodsStore, |
| | | sort: { type: 'Asc', field: 'LinkOrder' }, |
| | | }; |
| | | app.MG.store.getStoreChannelList(query).then((res) => { |
| | | for (let index = 0; index < res.datas.length; index++) { |
| | | const item = res.datas[index]; |
| | | options.push({ |
| | | value: `${item.pathLinks[0].linkPath}\\${item.id}`, |
| | | label: item.name, |
| | | }); |
| | | } |
| | | this.setData({ |
| | | 'secondList.options': options, |
| | | }); |
| | | const second = [this.data.secondCode] |
| | | this.setData({ |
| | | 'secondList.value': second |
| | | }) |
| | | }); |
| | | }, |
| | | // 获取重点项目 |
| | | getProjectList(type) { |
| | | const options = []; |
| | | const arr = []; |
| | | let array = []; |
| | | const query = { |
| | | refCodes: [type], |
| | | }; |
| | | app.MG.store.getProductTypeField(query).then((res) => { |
| | | array = JSON.parse(res[0].config).option; |
| | | for (let index = 0; index < array.length; index++) { |
| | | const element = array[index]; |
| | | if (element.child) { |
| | | for (let index = 0; index < element.child.length; index++) { |
| | | const item = element.child[index]; |
| | | arr.push(item); |
| | | } |
| | | } |
| | | } |
| | | if (type == 'bookClassification') { |
| | | for (let index = 0; index < arr.length; index++) { |
| | | const element = arr[index]; |
| | | options.push({ |
| | | value: element.value, |
| | | label: element.name, |
| | | }); |
| | | } |
| | | this.setData({ |
| | | 'majorProjectList.options': options, |
| | | }); |
| | | } else if (type == 'newFormsTextbooks') { |
| | | for (let index = 0; index < arr.length; index++) { |
| | | const element = arr[index]; |
| | | options.push({ |
| | | value: element.value, |
| | | label: element.name, |
| | | }); |
| | | } |
| | | this.setData({ |
| | | 'newTextBook.options': options, |
| | | }); |
| | | console.log('重点项目', this.data.newTextBook); |
| | | } |
| | | }); |
| | | }, |
| | | // 获取图书列表 |
| | | getBookList(path) { |
| | | let sort; |
| | | let pathObj = {}; |
| | | if (this.data.pathList.length) { |
| | | pathObj = { |
| | | subAccess: this.data.pathList, |
| | | }; |
| | | } else { |
| | | pathObj = { |
| | | path, |
| | | queryType: '*', |
| | | }; |
| | | } |
| | | if (this.data.sort) { |
| | | sort = { |
| | | Name: this.data.sort, |
| | | BaseType: '', |
| | | }; |
| | | } else { |
| | | sort = { |
| | | type: 'Desc', |
| | | field: 'ViewCount', |
| | | }; |
| | | } |
| | | // 搜索 |
| | | let searchObj = {}; |
| | | if (this.data.searchValue) { |
| | | searchObj = { |
| | | 'Name*': this.data.searchValue, |
| | | '||author*': this.data.searchValue, |
| | | '||isbn*': this.data.searchValue, |
| | | '||seriesName*': this.data.searchValue, |
| | | }; |
| | | } |
| | | const query = { |
| | | ...pathObj, |
| | | filterList: [ |
| | | { |
| | | value: 'Normal', |
| | | field: 'state', |
| | | }, |
| | | ], |
| | | sort, |
| | | coverSize: { |
| | | height: 145, |
| | | }, |
| | | paging: { |
| | | start: 0, |
| | | size: this.data.pageCount.page * 8, |
| | | }, |
| | | fields: { |
| | | author: [], |
| | | publicationDate: [], |
| | | ...searchObj, |
| | | 'bookClassification*': this.data.majorProjectList.value, |
| | | 'newFormsTextbooks*': this.data.newTextBook.value, |
| | | }, |
| | | }; |
| | | app.MG.store.getProductList(query).then((res) => { |
| | | this.setData({ |
| | | bookList: res.datas, |
| | | enable: false, |
| | | "pageCount.total": res.total |
| | | }); |
| | | console.log('图书列表', res, this.data.pageCount); |
| | | }); |
| | | }, |
| | | // 一级分类切换 |
| | | onChangeStair(e) { |
| | | const path = e.detail.value.length |
| | | ? `${this.data.assortCheck.code}\\${e.detail.value}` |
| | | : this.data.assortCheck.code; |
| | | this.setData({ |
| | | pathList: [], |
| | | stairCode: e.detail.value, |
| | | secondCode: '', |
| | | path: path, |
| | | 'stairList.value': e.detail.value, |
| | | }); |
| | | this.getBookList(path); |
| | | this.getSecondList(path); |
| | | }, |
| | | // 二级分类切换 |
| | | onChangeSecond(e) { |
| | | const pathList = []; |
| | | for (let index = 0; index < e.detail.value.length; index++) { |
| | | const element = e.detail.value[index]; |
| | | pathList.push({ |
| | | Path: element, |
| | | Type: '*', |
| | | StoreRefCode: app.config.goodsStore, |
| | | }); |
| | | } |
| | | this.setData({ |
| | | pathList: pathList, |
| | | 'secondList.value': e.detail.value, |
| | | }); |
| | | |
| | | }, |
| | | // |
| | | onConfirmSecond() { |
| | | this.getBookList(this.data.path); |
| | | }, |
| | | // 重点项目改变 |
| | | changeMajorProject(e) { |
| | | this.setData({ |
| | | 'majorProjectList.value': e.detail.value, |
| | | }); |
| | | this.getBookList(this.data.path); |
| | | }, |
| | | // 重点项目重置 |
| | | resetMajorProject() { |
| | | this.setData({ |
| | | 'majorProjectList.value': [], |
| | | }); |
| | | this.getBookList(this.data.path); |
| | | }, |
| | | changeNewText(e) { |
| | | this.setData({ |
| | | 'newTextBook.value': e.detail.value, |
| | | }); |
| | | this.getBookList(this.data.path); |
| | | }, |
| | | resetNewText() { |
| | | this.setData({ |
| | | 'newTextBook.value': [], |
| | | }); |
| | | this.getBookList(this.data.path); |
| | | }, |
| | | // 排序按钮 |
| | | sortClick() { |
| | | if (!this.data.sort.length) { |
| | | this.setData({ |
| | | sort: 'Desc', |
| | | }); |
| | | } else if (this.data.sort == 'Desc') { |
| | | this.setData({ |
| | | sort: 'Asc', |
| | | }); |
| | | } else if (this.data.sort == 'Asc') { |
| | | this.setData({ |
| | | sort: '', |
| | | }); |
| | | } |
| | | let path; |
| | | if (this.data.secondCode) { |
| | | path = this.data.secondCode; |
| | | } else if (this.data.stairCode) { |
| | | path = `${this.data.assortCheck.code}\\${this.data.stairCode}`; |
| | | } else { |
| | | path = this.data.assortCheck.code; |
| | | } |
| | | this.setData({ |
| | | path: path, |
| | | }); |
| | | this.getBookList(path); |
| | | }, |
| | | // 搜索图书 |
| | | searchBook(e) { |
| | | console.log(e.detail.value); |
| | | this.setData({ |
| | | searchValue: e.detail.value, |
| | | }); |
| | | this.getBookList(this.data.path); |
| | | }, |
| | | // 跳转图书详情 |
| | | goDetail(e) { |
| | | const { book } = e.currentTarget.dataset; |
| | | wx.navigateTo({ |
| | | url: `/packageBookService/pages/bookServices/detail/index?id=${book.id}&name=${book.name}`, |
| | | }); |
| | | }, |
| | | onRefresh() { |
| | | this.setData({ enable: true }); |
| | | this.getBookList(this.data.path) |
| | | }, |
| | | }); |
New file |
| | |
| | | import { worksDataBytool } from "../../../../assets/js/toolClass.js"; |
| | | const app = getApp(); |
| | | Page({ |
| | | data: { |
| | | userInfo: null, |
| | | active: 0, |
| | | description: "", //申请规则 |
| | | teacherInfo: { |
| | | workInfo: null, |
| | | schoolName: "", |
| | | courseName: "", |
| | | }, |
| | | contactInfo: { |
| | | fullName: "", |
| | | phone: "", |
| | | detailedAddress: "" |
| | | }, |
| | | paperBookList: [], //样书单纸质书 |
| | | electronicBookList: [], //样书单电子书 |
| | | ebookCount: 0, |
| | | paperBookCount: 0, |
| | | bookList: [], |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | onLoad() { }, |
| | | /** |
| | | * 生命周期函数--监听页面显示 |
| | | */ |
| | | onShow() { |
| | | if (wx.getStorageSync(app.config.userInfoKey)) { |
| | | this.setData({ |
| | | userInfo: JSON.parse(wx.getStorageSync(app.config.userInfoKey)) |
| | | }) |
| | | if (this.data.userInfo.role == 'Teacher') { |
| | | this.setData({ |
| | | teacherInfo: { |
| | | schoolName: JSON.parse(this.data.userInfo.data).schoolName, |
| | | courseName: JSON.parse(this.data.userInfo.data).courseName, |
| | | }, |
| | | contactInfo: { |
| | | fullName: JSON.parse(this.data.userInfo.data).fullName, |
| | | phone: JSON.parse(this.data.userInfo.data).phone, |
| | | detailedAddress: JSON.parse(this.data.userInfo.data).detailedAddress |
| | | } |
| | | }) |
| | | } |
| | | if (wx.getStorageSync("paperBookList")) { |
| | | this.setData({ |
| | | paperBookList: JSON.parse(wx.getStorageSync("paperBookList")), |
| | | bookList: JSON.parse(wx.getStorageSync("paperBookList")) |
| | | }) |
| | | } |
| | | if (wx.getStorageSync("electronicBookList")) { |
| | | this.setData({ |
| | | electronicBookList: JSON.parse(wx.getStorageSync("electronicBookList")) |
| | | }) |
| | | } |
| | | this.getSelectBookCount(); |
| | | this.getSelectPaperBookCount(); |
| | | this.getPaperType(); |
| | | } else { |
| | | wx.navigateTo({ |
| | | url: "/pages/testLogin/index", |
| | | }); |
| | | } |
| | | |
| | | }, |
| | | |
| | | tabClick(item) { |
| | | let that = this; |
| | | if (item.detail.value == '1') { |
| | | that.setData({ |
| | | active: item.detail.value, |
| | | bookList: this.data.electronicBookList |
| | | }) |
| | | this.getElectronType(); |
| | | } else { |
| | | that.setData({ |
| | | active: item.detail.value, |
| | | bookList: this.data.paperBookList |
| | | }) |
| | | this.getPaperType(); |
| | | } |
| | | }, |
| | | |
| | | getElectronType() { |
| | | app.MG.resource.getCmsTypeByRefCode({ refCodes: ['jsek_electronicSampleBook'] }).then((res) => { |
| | | this.setData({ |
| | | description: res[0].description, |
| | | teacherInfo: { |
| | | workInfo: res[0].cmsTypeLinks[0].children |
| | | }, |
| | | }) |
| | | }) |
| | | }, |
| | | getPaperType() { |
| | | app.MG.resource.getCmsTypeByRefCode({ |
| | | refCodes: ['jsek_paperVersionSampleBook'] |
| | | }). |
| | | then((res) => { |
| | | if (res && res.length > 0) { |
| | | this.setData({ |
| | | description: res[0].description, |
| | | teacherInfo: { |
| | | workInfo: res[0].cmsTypeLinks[0].children |
| | | }, |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | //获取当前已申请次数(电子) |
| | | getSelectBookCount() { |
| | | let that = this; |
| | | app.MG.app.getTicketResult({ |
| | | ticketRefCodeOrGuid: 'electronicSampleBookapplyNum', |
| | | roleId: that.data.userInfo.roleId |
| | | }) |
| | | .then((res) => { |
| | | let num = res.totalCount - res.usedCount; |
| | | that.setData({ |
| | | ebookCount: num |
| | | }) |
| | | }) |
| | | }, |
| | | //获取当前已申请次数(纸质) |
| | | getSelectPaperBookCount() { |
| | | let that = this; |
| | | app.MG.app.getTicketResult({ |
| | | ticketRefCodeOrGuid: 'paperSampleBookapplyNum', |
| | | roleId: that.data.userInfo.roleId |
| | | }) |
| | | .then((res) => { |
| | | let count = res.totalCount - res.usedCount; |
| | | that.setData({ |
| | | paperBookCount: count, |
| | | }) |
| | | }) |
| | | }, |
| | | |
| | | submit() { |
| | | let that = this; |
| | | if (that.data.bookList.length > 0) { |
| | | if (that.data.active == '1' && that.data.ebookCount == 0) { |
| | | wx.showToast({ |
| | | title: "您的电子样书申请次数已用尽,若要继续,请联系管理员!", |
| | | icon: 'none', |
| | | duration: 1000, |
| | | }) |
| | | return |
| | | } |
| | | if (that.data.active == '0' && that.data.paperBookCount == 0) { |
| | | wx.showToast({ |
| | | title: "您的纸质样书申请次数已用尽,若要继续,请联系管理员!", |
| | | icon: 'none', |
| | | duration: 1000, |
| | | }) |
| | | return |
| | | } |
| | | let data = {} |
| | | let applyInfo = {} |
| | | if (that.data.active == '1') { |
| | | data = { |
| | | topicIdOrRefCode: 'applyBook', |
| | | name: that.data.userInfo.name || '', |
| | | content: JSON.stringify(that.data.bookList), |
| | | state: 'WaitAudit', |
| | | type: 'applyForEbook', |
| | | cmsTypeRefCode: 'jsek_electronicSampleBook', |
| | | newDataListRequest: worksDataBytool(that.data.teacherInfo.workInfo, that.data.teacherInfo) |
| | | } |
| | | applyInfo = { |
| | | ticketRefCodeOrGuid: 'electronicSampleBookapplyNum', |
| | | roleId: userStore.userInfo.roleId, |
| | | refType: 'applyBook' |
| | | } |
| | | } else { |
| | | if (!(that.data.contactInfo.fullName && that.data.contactInfo.phone && that.data.contactInfo.detailedAddress)) { |
| | | wx.showToast({ |
| | | title: "请将收货人信息填写完整!", |
| | | icon: 'none', |
| | | duration: 1000, |
| | | }) |
| | | return |
| | | } |
| | | const mailAddress = JSON.stringify(that.data.contactInfo) |
| | | that.setData({ |
| | | teacherInfo: { |
| | | detailedAddress: mailAddress, |
| | | } |
| | | }) |
| | | data = { |
| | | topicIdOrRefCode: 'applyEntityBook', |
| | | name: that.data.userInfo.name || '', |
| | | content: JSON.stringify(that.data.bookList), |
| | | state: 'WaitAudit', |
| | | type: 'applyForPbook', |
| | | cmsTypeRefCode: 'jsek_paperVersionSampleBook', |
| | | newDataListRequest: worksDataBytool(that.data.teacherInfo.workInfo, that.data.teacherInfo) |
| | | } |
| | | applyInfo = { |
| | | ticketRefCodeOrGuid: 'paperSampleBookapplyNum', |
| | | roleId: that.data.userInfo.roleId, |
| | | refType: 'applyEntityBook' |
| | | } |
| | | } |
| | | app.MG.ugc.newTopicMessage(data).then((res) => { |
| | | if (res) { |
| | | app.MG.app.useTicket(applyInfo).then(() => { |
| | | if (that.data.active == '1') { |
| | | that.setData({ |
| | | electronicBookList: [], |
| | | bookList: [], |
| | | }) |
| | | wx.setStorageSync("electronicBookList", that.data.electronicBookList); |
| | | } else { |
| | | that.setData({ |
| | | paperBookList: [], |
| | | bookList: [], |
| | | }) |
| | | wx.setStorageSync("paperBookList", that.data.paperBookList); |
| | | } |
| | | |
| | | wx.showModal({ |
| | | title: '提示!', //提示的标题 |
| | | content: '您的样书申请已提交,管理员审核中!申请状态在【个人中心—样书申请】中查询。', //提示的内容 |
| | | success: function (res) { |
| | | if (res.confirm) { |
| | | wx.navigateTo({ |
| | | url: "/packagePersonal/pages/sampleBooks/index", |
| | | }); |
| | | } else if (res.cancel) { |
| | | } |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | }) |
| | | } else { |
| | | wx.showToast({ |
| | | title: "您还未选择图书加入申请单!", |
| | | icon: 'none', |
| | | duration: 1000, |
| | | }) |
| | | } |
| | | |
| | | }, |
| | | |
| | | onDelete(e) { |
| | | let that = this; |
| | | const item = e.currentTarget.dataset.book; |
| | | wx.showModal({ |
| | | title: '提示!', //提示的标题 |
| | | content: '确定要删除该书吗?', //提示的内容 |
| | | success: function (res) { |
| | | if (res.confirm) { |
| | | if (that.data.active == '1') { |
| | | that.data.electronicBookList.forEach((obj, index) => { |
| | | if (obj.id == item.id) { |
| | | that.data.electronicBookList.splice(index, 1); |
| | | } |
| | | }) |
| | | that.setData({ |
| | | bookList: that.data.electronicBookList |
| | | }) |
| | | wx.setStorageSync("electronicBookList", that.data.electronicBookList); |
| | | } else { |
| | | that.data.paperBookList.forEach((obj, index) => { |
| | | if (obj.id == item.id) { |
| | | that.data.paperBookList.splice(index, 1); |
| | | } |
| | | }) |
| | | that.setData({ |
| | | bookList: this.data.paperBookList |
| | | }) |
| | | wx.setStorageSync("paperBookList", that.data.paperBookList); |
| | | } |
| | | } else if (res.cancel) { |
| | | } |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | /** |
| | | * 页面相关事件处理函数--监听用户下拉动作 |
| | | */ |
| | | onPullDownRefresh() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 页面上拉触底事件的处理函数 |
| | | */ |
| | | onReachBottom() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 用户点击右上角分享 |
| | | */ |
| | | onShareAppMessage() { |
| | | |
| | | } |
| | | }) |
New file |
| | |
| | | const app = getApp(); |
| | | Page({ |
| | | |
| | | /** |
| | | * 页面的初始数据 |
| | | */ |
| | | data: { |
| | | barHeight: '', |
| | | navBarHeight: '', |
| | | searchValue: '', |
| | | userInfo: null, |
| | | path: '*', |
| | | pathList: [], |
| | | |
| | | bookList: [], |
| | | //高级分类 |
| | | iconList: { |
| | | value: "", |
| | | options: [], |
| | | }, |
| | | //一级分类 |
| | | stairList: { |
| | | value: '', |
| | | options: [], |
| | | }, |
| | | //二级分类 |
| | | secondList: { |
| | | value: [], |
| | | options: [], |
| | | }, |
| | | //重点项目 |
| | | majorProjectList: { |
| | | value: [], |
| | | options: [], |
| | | }, |
| | | //新形态教材 |
| | | newTextBook: { |
| | | value: [], |
| | | options: [], |
| | | }, |
| | | //高级分类选中 |
| | | assortCheck: { |
| | | name: '', |
| | | code: '', |
| | | }, |
| | | |
| | | stairCode: '', // 一级分类选中项 |
| | | secondCode: '', // 二级分类选中项 |
| | | sort: '', // 排序 |
| | | //分页 |
| | | page: 1, |
| | | limit: 10, |
| | | pageTotalCount: 0, |
| | | bottomLoading: false, |
| | | isMoreData: false, |
| | | // 返回顶部 |
| | | isBackTop: false, |
| | | setScrollValue: 0, |
| | | skeletonLoding: true, |
| | | alreadyPaperBookList: [], //已申请纸质样书 |
| | | alreadyElectronicBookList: [], //已申请电子样书 |
| | | paperBookList: [], //样书单纸质书 |
| | | electronicBookList: [], //样书单电子书 |
| | | paperBookCount: 0, //纸质书剩余次数 |
| | | ebookCount: 0, //电子书剩余次数 |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | onLoad(options) { |
| | | const systInfo = wx.getSystemInfoSync(); |
| | | const menu = wx.getMenuButtonBoundingClientRect(); // 胶囊信息 |
| | | const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度 |
| | | this.setData({ |
| | | barHeight: systInfo.statusBarHeight, |
| | | navBarHeight: navBarHeight, |
| | | }); |
| | | // 搜索赋值 |
| | | if (options && options.searchValue) { |
| | | this.setData({ |
| | | searchValue: options.searchValue, |
| | | }); |
| | | } |
| | | // 高级分类赋值 |
| | | if (options && options.assortCode) { |
| | | this.setData({ |
| | | assortCheck: { |
| | | name: options.assorName, |
| | | code: options.assortCode, |
| | | 'iconList.value': options.assortCode |
| | | }, |
| | | }); |
| | | } |
| | | if (this.data.assortCheck.code) { |
| | | // 获取一级分类 |
| | | this.getStairList(this.data.assortCheck.code); |
| | | } |
| | | // 一级分类和path赋值 |
| | | if (options && options.assortCode && options.stairCode) { |
| | | this.setData({ |
| | | 'stairList.value': options.stairCode, |
| | | stairCode: options.stairCode, |
| | | path: `${options.assortCode}\\${options.stairCode}`, |
| | | }); |
| | | } |
| | | // 二级分类赋值 |
| | | if (options && options.secondCode) { |
| | | this.setData({ |
| | | secondCode: options.secondCode, |
| | | pathList: [{ |
| | | Path: options.secondCode, |
| | | Type: '*', |
| | | StoreRefCode: app.config.goodsStore, |
| | | } |
| | | ], |
| | | }) |
| | | } |
| | | this.getIconTypeList(); |
| | | this.getBookList(false); |
| | | // 获取重点项目 |
| | | this.getProjectList('bookClassification'); |
| | | //新形态教材 |
| | | this.getProjectList('newFormsTextbooks'); |
| | | if (wx.getStorageSync(app.config.tokenKey)) { |
| | | this.getAlreadyPBookList() |
| | | this.getAlreadyEBookList() |
| | | } |
| | | if (wx.getStorageSync(app.config.userInfoKey)) { |
| | | this.setData({ |
| | | userInfo: JSON.parse(wx.getStorageSync(app.config.userInfoKey)) |
| | | }) |
| | | } |
| | | if (wx.getStorageSync("paperBookList")) { |
| | | this.setData({ |
| | | paperBookList: wx.getStorageSync("paperBookList") |
| | | }) |
| | | } |
| | | if (wx.getStorageSync("electronicBookList")) { |
| | | this.setData({ |
| | | electronicBookList: wx.getStorageSync("electronicBookList") |
| | | }) |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面初次渲染完成 |
| | | */ |
| | | onReady() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面显示 |
| | | */ |
| | | onShow() { |
| | | |
| | | }, |
| | | goBack() { |
| | | wx.navigateBack(); |
| | | }, |
| | | //获取高级分类 |
| | | getIconTypeList() { |
| | | let query = { |
| | | path: '*', |
| | | filterList: [ |
| | | { |
| | | value: 'Normal', |
| | | field: 'state' |
| | | } |
| | | ], |
| | | queryType: '\\', |
| | | searchList: [], |
| | | size: '5', |
| | | start: '0', |
| | | storeRefCode: app.config.goodsStore, |
| | | sort: { type: 'Asc', field: 'LinkOrder' } |
| | | } |
| | | app.MG.store.getStoreChannelList(query).then((res) => { |
| | | let list = []; |
| | | if (res.datas.length > 0) ( |
| | | res.datas.forEach((item) => { |
| | | item.value = item.refCode; |
| | | item.label = item.name; |
| | | if (item.refCode == 'jsek_higherEducation') { |
| | | list.push(item) |
| | | } |
| | | if (item.refCode == 'jsek_vocationalEducation') { |
| | | list.push(item) |
| | | } |
| | | |
| | | }) |
| | | ) |
| | | this.setData({ |
| | | 'iconList.options': list, |
| | | 'iconList.value': this.data.assortCode, |
| | | }); |
| | | }) |
| | | }, |
| | | // 获取一级列表 |
| | | getStairList(path) { |
| | | const query = { |
| | | path, |
| | | filterList: [], |
| | | queryType: '\\', |
| | | searchList: [], |
| | | size: '30', |
| | | start: '0', |
| | | storeRefCode: app.config.goodsStore, |
| | | sort: { type: 'Asc', field: 'LinkOrder' }, |
| | | }; |
| | | app.MG.store.getStoreChannelList(query).then(async (res) => { |
| | | let options = []; |
| | | if (res.datas.length > 0) { |
| | | for (let index = 0; index < res.datas.length; index++) { |
| | | let item = res.datas[index]; |
| | | options.push({ |
| | | value: item.refCode, |
| | | label: item.name, |
| | | }); |
| | | } |
| | | } |
| | | this.setData({ |
| | | 'stairList.options': options, |
| | | 'stairList.value': this.data.stairCode, |
| | | }); |
| | | }); |
| | | }, |
| | | // 获取一级分类下二级分类 |
| | | getSecondList(path) { |
| | | let options = []; |
| | | let query = { |
| | | path, |
| | | filterList: [], |
| | | queryType: '\\', |
| | | searchList: [], |
| | | size: '30', |
| | | start: '0', |
| | | storeRefCode: app.config.goodsStore, |
| | | sort: { type: 'Asc', field: 'LinkOrder' }, |
| | | }; |
| | | app.MG.store.getStoreChannelList(query).then((res) => { |
| | | if (res.datas.length > 0) { |
| | | for (let index = 0; index < res.datas.length; index++) { |
| | | const item = res.datas[index]; |
| | | options.push({ |
| | | value: `${item.pathLinks[0].linkPath}\\${item.id}`, |
| | | label: item.name, |
| | | }); |
| | | } |
| | | } |
| | | this.setData({ |
| | | 'secondList.options': options, |
| | | }); |
| | | const second = [this.data.secondCode] |
| | | this.setData({ |
| | | 'secondList.value': second |
| | | }) |
| | | }); |
| | | }, |
| | | // 获取重点项目 |
| | | getProjectList(type) { |
| | | const options = []; |
| | | const arr = []; |
| | | let array = []; |
| | | const query = { |
| | | refCodes: [type], |
| | | }; |
| | | app.MG.store.getProductTypeField(query).then((res) => { |
| | | array = JSON.parse(res[0].config).option; |
| | | for (let index = 0; index < array.length; index++) { |
| | | const element = array[index]; |
| | | if (element.child) { |
| | | for (let index = 0; index < element.child.length; index++) { |
| | | const item = element.child[index]; |
| | | arr.push(item); |
| | | } |
| | | } |
| | | } |
| | | if (type == 'bookClassification') { |
| | | for (let index = 0; index < arr.length; index++) { |
| | | const element = arr[index]; |
| | | options.push({ |
| | | value: element.value, |
| | | label: element.name, |
| | | }); |
| | | } |
| | | this.setData({ |
| | | 'majorProjectList.options': options, |
| | | }); |
| | | } else if (type == 'newFormsTextbooks') { |
| | | for (let index = 0; index < arr.length; index++) { |
| | | const element = arr[index]; |
| | | options.push({ |
| | | value: element.value, |
| | | label: element.name, |
| | | }); |
| | | } |
| | | this.setData({ |
| | | 'newTextBook.options': options, |
| | | }); |
| | | console.log('重点项目', this.data.newTextBook); |
| | | } |
| | | }); |
| | | }, |
| | | // 获取图书列表 |
| | | getBookList(isReachBottom) { |
| | | let that = this; |
| | | let sort; |
| | | let pathObj = {}; |
| | | if (that.data.pathList.length) { |
| | | pathObj = { |
| | | subAccess: this.data.pathList, |
| | | }; |
| | | } else { |
| | | pathObj = { |
| | | path: that.data.path, |
| | | queryType: '*', |
| | | }; |
| | | } |
| | | if (that.data.sort) { |
| | | sort = { |
| | | Name: that.data.sort, |
| | | BaseType: '', |
| | | }; |
| | | } else { |
| | | sort = { |
| | | type: 'Desc', |
| | | field: 'ViewCount', |
| | | }; |
| | | } |
| | | // 搜索 |
| | | let searchObj = {}; |
| | | if (that.data.searchValue) { |
| | | searchObj = { |
| | | 'Name*': that.data.searchValue, |
| | | '||author*': that.data.searchValue, |
| | | '||isbn*': that.data.searchValue, |
| | | '||seriesName*': that.data.searchValue, |
| | | }; |
| | | } |
| | | const query = { |
| | | ...pathObj, |
| | | filterList: [ |
| | | { |
| | | value: 'Normal', |
| | | field: 'state', |
| | | }, |
| | | ], |
| | | sort, |
| | | coverSize: { |
| | | height: 145, |
| | | }, |
| | | paging: { |
| | | start: that.data.page * that.data.limit - that.data.limit, |
| | | size: that.data.limit |
| | | }, |
| | | fields: { |
| | | author: [], |
| | | isbn: [], |
| | | publicationDate: [], |
| | | isApplyBook: [], |
| | | 'isApplyBook>': ['1'], |
| | | ...searchObj, |
| | | }, |
| | | }; |
| | | app.MG.store.getProductList(query).then((res) => { |
| | | try { |
| | | if (res.datas.length > 0) { |
| | | res.datas.forEach((item) => { |
| | | item.paperDisabled = false |
| | | item.paperChecked = false |
| | | item.electronDisabled = false |
| | | item.electronChecked = false |
| | | if (item.purchasedSaleMethodIdList.indexOf(item.defaultSaleMethodId) > -1) { |
| | | item.electronDisabled = true |
| | | item.electronChecked = true |
| | | } |
| | | if (that.data.alreadyPaperBookList.length > 0) { |
| | | that.data.alreadyPaperBookList.forEach((pBook) => { |
| | | pBook.content.forEach((pBookItem) => { |
| | | if (pBookItem.id === item.id && pBook.state == 'WaitAudit') { |
| | | item.paperDisabled = true |
| | | item.paperChecked = true |
| | | } |
| | | if (pBookItem.id === item.id && pBook.state == 'Normal') { |
| | | item.paperDisabled = false |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | if (that.data.alreadyElectronicBookList.length > 0) { |
| | | that.data.alreadyElectronicBookList.forEach((eBook) => { |
| | | eBook.content.forEach((eBookItem) => { |
| | | if (eBookItem.id === item.id && !eBook.isExpiry && eBook.state != 'Reject') { |
| | | item.electronDisabled = true |
| | | item.electronChecked = true |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | if (that.data.paperBookList.length > 0) { |
| | | for (let i = 0; i < that.data.paperBookList.length; i++) { |
| | | if (that.data.paperBookList[i].id == item.id) { |
| | | item.paperChecked = true |
| | | } |
| | | } |
| | | } |
| | | if (that.data.electronicBookList.length > 0) { |
| | | for (let i = 0; i < that.data.electronicBookList.length; i++) { |
| | | if (that.data.electronicBookList[i].id == item.id) { |
| | | item.electronChecked = true |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | let list = res.datas; |
| | | //触底加载新数据并保留老数据 |
| | | if (isReachBottom) { |
| | | list = [...this.data.bookList, ...list] //将新数据加入老数据中 |
| | | } |
| | | that.setData({ |
| | | bookList: list, |
| | | pageTotalCount: res.total, |
| | | bottomLoading: false, |
| | | isMoreData: list.length > 0 ? false : true, |
| | | skeletonLoding: false, |
| | | loading: false |
| | | }) |
| | | } else { |
| | | that.setData({ |
| | | skeletonLoding: false, |
| | | loading: false |
| | | }) |
| | | } |
| | | } catch (error) { |
| | | console.log(error) |
| | | } |
| | | }); |
| | | }, |
| | | //高级分类选择 |
| | | onChangeIcon(e) { |
| | | this.setData({ |
| | | assortCheck: { |
| | | code: e.detail.value, |
| | | }, |
| | | stairCode: '', |
| | | secondCode: '', |
| | | path: `${e.detail.value}`, |
| | | 'iconList.value': e.detail.value, |
| | | }); |
| | | this.getBookList(false); |
| | | this.getStairList(this.data.assortCheck.code); |
| | | |
| | | }, |
| | | // 一级分类切换 |
| | | onChangeStair(e) { |
| | | const path = e.detail.value.length |
| | | ? `${this.data.assortCheck.code}\\${e.detail.value}` |
| | | : this.data.assortCheck.code; |
| | | this.setData({ |
| | | pathList: [], |
| | | stairCode: e.detail.value, |
| | | secondCode: '', |
| | | path: path, |
| | | 'stairList.value': e.detail.value, |
| | | }); |
| | | this.getBookList(false); |
| | | this.getSecondList(path); |
| | | }, |
| | | // 二级分类切换 |
| | | onChangeSecond(e) { |
| | | const pathList = []; |
| | | for (let index = 0; index < e.detail.value.length; index++) { |
| | | const element = e.detail.value[index]; |
| | | pathList.push({ |
| | | Path: element, |
| | | Type: '*', |
| | | StoreRefCode: app.config.goodsStore, |
| | | }); |
| | | } |
| | | this.setData({ |
| | | pathList: pathList, |
| | | 'secondList.value': e.detail.value, |
| | | }); |
| | | |
| | | }, |
| | | // |
| | | onConfirmSecond() { |
| | | this.getBookList(false); |
| | | }, |
| | | // 重点项目改变 |
| | | changeMajorProject(e) { |
| | | this.setData({ |
| | | 'majorProjectList.value': e.detail.value, |
| | | }); |
| | | this.getBookList(false); |
| | | }, |
| | | // 重点项目重置 |
| | | resetMajorProject() { |
| | | this.setData({ |
| | | 'majorProjectList.value': [], |
| | | }); |
| | | this.getBookList(false); |
| | | }, |
| | | changeNewText(e) { |
| | | this.setData({ |
| | | 'newTextBook.value': e.detail.value, |
| | | }); |
| | | this.getBookList(false); |
| | | }, |
| | | resetNewText() { |
| | | this.setData({ |
| | | 'newTextBook.value': [], |
| | | }); |
| | | this.getBookList(false); |
| | | }, |
| | | // 排序按钮 |
| | | sortClick() { |
| | | if (!this.data.sort.length) { |
| | | this.setData({ |
| | | sort: 'Desc', |
| | | }); |
| | | } else if (this.data.sort == 'Desc') { |
| | | this.setData({ |
| | | sort: 'Asc', |
| | | }); |
| | | } else if (this.data.sort == 'Asc') { |
| | | this.setData({ |
| | | sort: '', |
| | | }); |
| | | } |
| | | let path; |
| | | if (this.data.secondCode) { |
| | | path = this.data.secondCode; |
| | | } else if (this.data.stairCode) { |
| | | path = `${this.data.assortCheck.code |
| | | }\\${this.data.stairCode}`; |
| | | } else { |
| | | path = this.data.assortCheck.code; |
| | | } |
| | | this.setData({ |
| | | path: path, |
| | | }); |
| | | this.getBookList(false); |
| | | }, |
| | | // 搜索图书 |
| | | searchBook(e) { |
| | | console.log(e.detail.value); |
| | | this.setData({ |
| | | searchValue: e.detail.value, |
| | | }); |
| | | this.getBookList(false); |
| | | }, |
| | | // 跳转图书详情 |
| | | goDetail(e) { |
| | | const { book } = e.currentTarget.dataset; |
| | | wx.navigateTo({ |
| | | url: `/packageBookService/pages/bookServices/detail/index?id=${book.id}&name=${book.name}`, |
| | | }); |
| | | }, |
| | | //获取已申请纸质样书 |
| | | getAlreadyPBookList() { |
| | | const data = { |
| | | start: 0, |
| | | size: 9999, |
| | | topicIdOrRefCode: 'applyEntityBook', |
| | | appRefCode: app.config.appRefCode, |
| | | sort: { |
| | | type: 'Desc', |
| | | field: 'CreateDate' |
| | | } |
| | | } |
| | | app.MG.ugc.getTopicMessageList(data).then((res) => { |
| | | res.datas.map((item) => { |
| | | if (item.content) { |
| | | item.content = JSON.parse(item.content) |
| | | } |
| | | }) |
| | | this.setData({ |
| | | alreadyPaperBookList: res.datas, |
| | | }); |
| | | }) |
| | | }, |
| | | //获取已申请电子样书 |
| | | getAlreadyEBookList() { |
| | | const data = { |
| | | start: 0, |
| | | size: 9999, |
| | | topicIdOrRefCode: 'applyBook', |
| | | appRefCode: app.config.appRefCode, |
| | | sort: { |
| | | type: 'Desc', |
| | | field: 'CreateDate' |
| | | } |
| | | } |
| | | app.MG.ugc.getTopicMessageList(data).then((res) => { |
| | | let list = [] |
| | | res.datas.map((item) => { |
| | | if (item.feedBack) { |
| | | item.feedBack = JSON.parse(item.feedBack) |
| | | if (item.feedBack.endDate) { |
| | | let times = new Date(item.feedBack.endDate + ' 23:59:59').getTime() |
| | | let currentDate = new Date().getTime() |
| | | if (times < currentDate) { |
| | | item.isExpiry = true |
| | | } |
| | | } |
| | | } |
| | | if (item.content) { |
| | | item.content = JSON.parse(item.content) |
| | | } |
| | | if (item.state != 'Reject') { |
| | | list.push(item) |
| | | } |
| | | }) |
| | | this.setData({ |
| | | alreadyElectronicBookList: list, |
| | | }); |
| | | }) |
| | | }, |
| | | |
| | | |
| | | |
| | | /** |
| | | * 页面相关事件处理函数--监听用户下拉动作 |
| | | */ |
| | | onPullDownRefresh() { |
| | | if (this._freshing) return |
| | | this.setData({ |
| | | page: 1, |
| | | limit: 10, |
| | | pageTotalCount: 0, |
| | | bottomLoading: false, |
| | | isMoreData: false |
| | | }) |
| | | this._freshing = true; |
| | | this.setData({ |
| | | triggered: false, |
| | | }) |
| | | this.getBookList(false); |
| | | this._freshing = false |
| | | }, |
| | | |
| | | /** |
| | | * 页面上拉触底事件的处理函数 |
| | | */ |
| | | onReachBottom() { |
| | | this.setData({ |
| | | bottomLoading: true, |
| | | isMoreData: false |
| | | }) |
| | | let bool = false; |
| | | if (this.data.pageTotalCount > this.data.bookList.length) { |
| | | bool = true; |
| | | this.setData({ |
| | | page: this.data.page + 1, |
| | | }) |
| | | |
| | | } else { |
| | | setTimeout(() => { |
| | | this.setData({ |
| | | bottomLoading: false, |
| | | isMoreData: true |
| | | }) |
| | | }, 100) |
| | | return false; |
| | | } |
| | | this.getBookList(bool); |
| | | }, |
| | | //纸质样书 |
| | | onChangePaper(e) { |
| | | const item = e.currentTarget.dataset.book; |
| | | let role = this.data.userInfo != null ? this.data.userInfo.role : null |
| | | if (role) { |
| | | if (item.paperDisabled) { |
| | | wx.showToast({ |
| | | title: "该样书已申请", |
| | | icon: 'none', |
| | | duration: 1000, |
| | | }) |
| | | return |
| | | } |
| | | |
| | | if (item.paperChecked) { |
| | | if (this.data.paperBookList.length > 0) { |
| | | this.data.paperBookList.forEach((obj, index) => { |
| | | if (obj.id == item.id) { |
| | | this.data.paperBookList.splice(index, 1); |
| | | } |
| | | }) |
| | | } |
| | | item.paperChecked = false; |
| | | if (this.data.bookList.length > 0) { |
| | | this.data.bookList.forEach(i => { |
| | | if (i.id == item.id) { |
| | | i.paperChecked = false; |
| | | } |
| | | }) |
| | | } |
| | | wx.showToast({ |
| | | title: "已从样书申请单移除", |
| | | icon: 'none', |
| | | duration: 1000, |
| | | }) |
| | | wx.setStorageSync("paperBookList", JSON.stringify(this.data.paperBookList)); |
| | | return |
| | | } |
| | | if (role == 'Teacher') { |
| | | this.getSelectPaperBookCount(item) |
| | | } else { |
| | | item.paperChecked = false |
| | | wx.showModal({ |
| | | title: '尊敬的用户,您好!', //提示的标题 |
| | | content: '请先进行教师认证?', //提示的内容 |
| | | success: function (res) { |
| | | if (res.confirm) { |
| | | wx.navigateTo({ |
| | | url: "/packageDomain/pages/teacherCertification/index", |
| | | }); |
| | | } else if (res.cancel) { |
| | | item.paperChecked = false |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | } else { |
| | | item.paperChecked = false |
| | | } |
| | | }, |
| | | getSelectPaperBookCount(item) { |
| | | app.MG.app |
| | | .getTicketResult({ |
| | | ticketRefCodeOrGuid: 'paperSampleBookapplyNum', |
| | | roleId: this.data.userInfo.roleId |
| | | }) |
| | | .then((res) => { |
| | | this.setData({ |
| | | paperBookCount: res.totalCount - res.usedCount |
| | | }) |
| | | if (!item.paperDisabled) { |
| | | this.getAlreadyBookList(item, 'pBook') |
| | | } |
| | | }) |
| | | }, |
| | | //选择电子样书 |
| | | onChangeElectron(e) { |
| | | const item = e.currentTarget.dataset.book; |
| | | let role = this.data.userInfo != null ? this.data.userInfo.role : null; |
| | | if (role) { |
| | | if (item.electronDisabled) { |
| | | wx.showToast({ |
| | | title: "该样书已申请", |
| | | icon: 'none', |
| | | duration: 1000, |
| | | }) |
| | | return |
| | | } |
| | | if (item.electronChecked) { |
| | | if (this.data.electronicBookList) { |
| | | this.data.electronicBookList.forEach((obj, index) => { |
| | | if (obj.id == item.id) { |
| | | this.data.electronicBookList.splice(index, 1); |
| | | } |
| | | }) |
| | | } |
| | | if (this.data.bookList.length > 0) { |
| | | this.data.bookList.forEach(i => { |
| | | if (i.id == item.id) { |
| | | i.electronChecked = false; |
| | | } |
| | | }) |
| | | } |
| | | item.electronChecked = false; |
| | | wx.showToast({ |
| | | title: "已从样书申请单移除", |
| | | icon: 'none', |
| | | duration: 1000, |
| | | }) |
| | | wx.setStorageSync("electronicBookList", JSON.stringify(this.data.electronicBookList)); |
| | | return |
| | | } |
| | | if (role == 'Teacher') { |
| | | //有无子商品,子商品有无电子书文件 |
| | | const obj = { |
| | | path: '*', |
| | | queryType: 'SubProduct', |
| | | sort: { |
| | | type: 'Desc', |
| | | field: 'CreateDate' |
| | | }, |
| | | paging: { |
| | | start: 0, |
| | | size: 6 |
| | | }, |
| | | mainProductId: item.id, |
| | | fields: { |
| | | bookshelf_pdf: [], |
| | | bookshelf_protectedEpub: [], |
| | | } |
| | | } |
| | | app.MG.store.getProductList(obj).then((res) => { |
| | | if (res.datas.length > 0) { |
| | | if (res.datas[0].bookshelf_pdf || res.datas[0].bookshelf_protectedEpub) { |
| | | this.getSelectBookCount(item) |
| | | } else { |
| | | wx.showToast({ |
| | | title: "暂无电子书文件,请联系管理员!", |
| | | icon: 'none', |
| | | duration: 1000, |
| | | }) |
| | | } |
| | | } else { |
| | | this.getSelectBookCount(item) |
| | | } |
| | | }) |
| | | } else { |
| | | item.electronChecked = false |
| | | wx.showModal({ |
| | | title: '尊敬的用户,您好!', //提示的标题 |
| | | content: '请先进行教师认证?', //提示的内容 |
| | | success: function (res) { |
| | | if (res.confirm) { |
| | | wx.navigateTo({ |
| | | url: "/packageDomain/pages/teacherCertification/index", |
| | | }); |
| | | } else if (res.cancel) { |
| | | item.electronChecked = false |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | }, |
| | | getSelectBookCount(item) { |
| | | app.MG.app |
| | | .getTicketResult({ |
| | | ticketRefCodeOrGuid: 'electronicSampleBookapplyNum', |
| | | roleId: this.data.userInfo.roleId |
| | | }) |
| | | .then((res) => { |
| | | this.setData({ |
| | | ebookCount: res.totalCount - res.usedCount |
| | | }) |
| | | if (!item.electronDisabled) { |
| | | this.getAlreadyBookList(item, 'eBook') |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | getAlreadyBookList(item, type) { |
| | | let itemAttr = null |
| | | let isHas = false |
| | | itemAttr = { |
| | | id: item.id, |
| | | title: item.name || '-', |
| | | icon: item.icon, |
| | | checked: false, |
| | | defaultSaleMethodId: item.defaultSaleMethodId, |
| | | md5: item.datas.Icon, |
| | | author: item.author || '-', |
| | | price: item.price || '-', |
| | | isbn: item.isbn || '-', |
| | | publicationDate: item.publicationDate |
| | | } |
| | | |
| | | if (type == 'eBook') { |
| | | if (this.data.ebookCount > 0) { |
| | | const eBookData = this.data.electronicBookList |
| | | if (eBookData.length == 2) { |
| | | item.electronChecked = false |
| | | wx.showToast({ |
| | | title: "每次最多只可申请2本样书", |
| | | icon: 'none', |
| | | duration: 1000, |
| | | }) |
| | | return false |
| | | } |
| | | if (eBookData.length > 0) { |
| | | for (let i = 0; i < eBookData.length; i++) { |
| | | if (eBookData[i].id == item.id) { |
| | | isHas = true |
| | | } |
| | | } |
| | | if (!isHas) { |
| | | wx.showToast({ |
| | | title: "添加成功,在样书申请单等您哦~", |
| | | icon: "none", |
| | | duration: 1000, |
| | | }) |
| | | this.setData({ |
| | | electronicBookList: [...this.data.electronicBookList, ...[item]] |
| | | }) |
| | | wx.setStorageSync("electronicBookList", JSON.stringify(this.data.electronicBookList)); |
| | | } else { |
| | | item.electronChecked = false |
| | | wx.showToast({ |
| | | title: "该书已在清单列表中", |
| | | icon: "none", |
| | | duration: 1000, |
| | | }) |
| | | } |
| | | } else { |
| | | wx.showToast({ |
| | | title: "添加成功,在样书申请单等您哦~", |
| | | icon: "none", |
| | | duration: 1000, |
| | | }) |
| | | this.setData({ |
| | | electronicBookList: [...this.data.electronicBookList, ...[item]] |
| | | }) |
| | | wx.setStorageSync("electronicBookList", JSON.stringify(this.data.electronicBookList)); |
| | | } |
| | | } else { |
| | | item.electronChecked = false |
| | | wx.showToast({ |
| | | title: "您的电子样书申请次数已用尽,若要继续,请联系管理员!", |
| | | icon: "none", |
| | | duration: 1000, |
| | | }) |
| | | } |
| | | } else { |
| | | if (this.data.paperBookCount > 0) { |
| | | const pBookData = this.data.paperBookList |
| | | if (pBookData.length == 2) { |
| | | item.paperChecked = false |
| | | wx.showToast({ |
| | | title: "每次最多只可申请2本样书", |
| | | icon: 'none', |
| | | duration: 1000, |
| | | }) |
| | | return false |
| | | } |
| | | if (pBookData.length > 0) { |
| | | for (let i = 0; i < pBookData.length; i++) { |
| | | if (pBookData[i].id == item.id) { |
| | | isHas = true |
| | | } |
| | | } |
| | | if (!isHas) { |
| | | item.paperChecked = true |
| | | wx.showToast({ |
| | | title: "添加成功,在样书申请单等您哦~", |
| | | icon: 'none', |
| | | duration: 1000, |
| | | }) |
| | | this.setData({ |
| | | paperBookList: [...this.data.paperBookList, ...[item]] |
| | | }) |
| | | wx.setStorageSync("paperBookList", JSON.stringify(this.data.paperBookList)); |
| | | console.log(this.data.paperBookList, "3") |
| | | } else { |
| | | item.paperChecked = false |
| | | wx.showToast({ |
| | | title: "该书已在清单列表中", |
| | | icon: 'none', |
| | | duration: 1000, |
| | | }) |
| | | } |
| | | } else { |
| | | item.paperChecked = true; |
| | | wx.showToast({ |
| | | title: "添加成功,在样书申请单等您哦~", |
| | | icon: 'none', |
| | | duration: 1000, |
| | | }) |
| | | this.setData({ |
| | | paperBookList: [item] |
| | | }) |
| | | wx.setStorageSync("paperBookList", JSON.stringify(this.data.paperBookList)); |
| | | console.log(this.data.paperBookList, "4") |
| | | } |
| | | } else { |
| | | item.paperChecked = false |
| | | wx.showToast({ |
| | | title: "您的纸质样书申请次数已用尽,若要继续,请联系管理员!", |
| | | icon: 'none', |
| | | duration: 1000, |
| | | }) |
| | | } |
| | | } |
| | | }, |
| | | //去样书申请单 |
| | | goApply() { |
| | | wx.navigateTo({ |
| | | url: "/packageDomain/pages/sampleBookList/applicationForm/index", |
| | | }); |
| | | }, |
| | | /** |
| | | * 用户点击右上角分享 |
| | | */ |
| | | onShareAppMessage() { |
| | | |
| | | } |
| | | }) |
New file |
| | |
| | | const app = getApp(); |
| | | import moment from 'moment' |
| | | Page({ |
| | | |
| | | /** |
| | | * 页面的初始数据 |
| | | */ |
| | | data: { |
| | | list: [], |
| | | //分页 |
| | | page: 1, |
| | | limit: 10, |
| | | pageTotalCount: 0, |
| | | bottomLoading: false, |
| | | isMoreData: false, |
| | | // 返回顶部 |
| | | isBackTop: false, |
| | | setScrollValue: 0, |
| | | skeletonLoding: true, |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | onLoad(options) { |
| | | console.log(options); |
| | | this.getDataList(false); |
| | | }, |
| | | |
| | | getDataList(isReachBottom) { |
| | | app.MG.ugc.getTopicMessageList({ |
| | | appRefCode: app.config.appRefCode, |
| | | topicIdOrRefCode: "productDownLoad", |
| | | start: this.data.page * this.data.limit - this.data.limit, |
| | | size: this.data.limit, |
| | | sort: { |
| | | type: "Desc", |
| | | field: "CreateDate" |
| | | } |
| | | }) |
| | | .then(res => { |
| | | try { |
| | | if (res.datas.length > 0) { |
| | | res.datas.forEach((item) => { |
| | | item.createDate = moment(item.createDate).format("YYYY-MM-DD HH:mm:ss"); |
| | | item.updateDate = moment(item.updateDate).format("YYYY-MM-DD HH:mm:ss"); |
| | | if (item.feedBack) { |
| | | item.feedBack = JSON.parse(item.feedBack); |
| | | } |
| | | if (item.content) { |
| | | item.product = JSON.parse(item.content)[0]; |
| | | } |
| | | }); |
| | | |
| | | let dataList = res.datas; |
| | | |
| | | //触底加载新数据并保留老数据 |
| | | if (isReachBottom) { |
| | | dataList = [...this.data.list, ...dataList] //将新数据加入老数据中 |
| | | } |
| | | this.setData({ |
| | | list: dataList, |
| | | pageTotalCount: res.totalSize, |
| | | bottomLoading: false, |
| | | isMoreData: dataList.length > 0 ? false : true, |
| | | skeletonLoding: false, |
| | | }) |
| | | } else { |
| | | this.setData({ |
| | | skeletonLoding: false, |
| | | }) |
| | | } |
| | | } catch (error) { |
| | | console.log(error) |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | goBookDetails(e) { |
| | | const { book } = e.currentTarget.dataset; |
| | | wx.navigateTo({ |
| | | url: `/packageBookService/pages/bookServices/detail/index?id=${book.id}&name=${book.name}`, |
| | | }); |
| | | }, |
| | | |
| | | /** |
| | | * 页面相关事件处理函数--监听用户下拉动作 |
| | | */ |
| | | onPullDownRefresh() { |
| | | if (this._freshing) return |
| | | this.setData({ |
| | | page: 1, |
| | | limit: 10, |
| | | pageTotalCount: 0, |
| | | bottomLoading: false, |
| | | isMoreData: false |
| | | }) |
| | | this._freshing = true; |
| | | this.setData({ |
| | | triggered: false, |
| | | }) |
| | | this.getDataList(false); |
| | | this._freshing = false |
| | | }, |
| | | |
| | | /** |
| | | * 页面上拉触底事件的处理函数 |
| | | */ |
| | | onReachBottom() { |
| | | this.setData({ |
| | | bottomLoading: true, |
| | | isMoreData: false |
| | | }) |
| | | let bool = false; |
| | | if (this.data.pageTotalCount > this.data.list.length) { |
| | | bool = true; |
| | | this.setData({ |
| | | page: this.data.page + 1, |
| | | }) |
| | | } else { |
| | | setTimeout(() => { |
| | | this.setData({ |
| | | bottomLoading: false, |
| | | isMoreData: true |
| | | }) |
| | | }, 100) |
| | | return false; |
| | | } |
| | | this.getDataList(bool); |
| | | }, |
| | | // 监听滚动距离 |
| | | onPageScroll(e) { |
| | | if (e && e.scrollTop >= 1000) { |
| | | this.setData({ |
| | | isBackTop: true |
| | | }) |
| | | } else { |
| | | this.setData({ |
| | | isBackTop: false |
| | | }) |
| | | } |
| | | }, |
| | | /** |
| | | * 用户点击右上角分享 |
| | | */ |
| | | onShareAppMessage() { |
| | | |
| | | } |
| | | }) |
New file |
| | |
| | | const app = getApp(); |
| | | Page({ |
| | | |
| | | /** |
| | | * 页面的初始数据 |
| | | */ |
| | | data: { |
| | | active: 0, |
| | | activeName: "FavoriteBookCity", |
| | | tabList: [ |
| | | { |
| | | label: '图书', |
| | | key: 0, |
| | | linkType: 'FavoriteBookCity', |
| | | }, |
| | | { |
| | | label: '课程', |
| | | key: 1, |
| | | linkType: 'Favoriteclass', |
| | | } |
| | | ], |
| | | list: [], |
| | | //分页 |
| | | page: 1, |
| | | limit: 18, |
| | | pageTotalCount: 0, |
| | | bottomLoading: false, |
| | | isMoreData: false, |
| | | // 返回顶部 |
| | | isBackTop: false, |
| | | setScrollValue: 0, |
| | | skeletonLoding: true, |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | onLoad(options) { |
| | | console.log(options); |
| | | this.getDataList(false); |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面初次渲染完成 |
| | | */ |
| | | onReady() { |
| | | |
| | | }, |
| | | |
| | | tabBookClick(item) { |
| | | console.log(item, 1) |
| | | let that = this; |
| | | let info = this.data.tabList[item.detail.value] |
| | | that.setData({ |
| | | skeletonLoding: true, |
| | | active: item.detail.value, |
| | | activeName: info.linkType, |
| | | list: [], |
| | | page: 1, |
| | | bottomLoading: false, |
| | | isMoreData: false, |
| | | }) |
| | | that.getDataList(false); |
| | | }, |
| | | getDataList(isReachBottom) { |
| | | app.MG.store.getProductList({ |
| | | handelEBooK: true, |
| | | queryType: "AppUserProductLink", |
| | | linkType: this.data.activeName, |
| | | paging: { |
| | | start: this.data.page * this.data.limit - this.data.limit, |
| | | size: this.data.limit |
| | | }, |
| | | fields: { |
| | | author: [] |
| | | } |
| | | }).then((res) => { |
| | | try { |
| | | if (res.datas.length > 0) { |
| | | let dataList = res.datas; |
| | | //触底加载新数据并保留老数据 |
| | | if (isReachBottom) { |
| | | dataList = [...this.data.list, ...dataList] //将新数据加入老数据中 |
| | | } |
| | | this.setData({ |
| | | list: dataList, |
| | | pageTotalCount: res.total, |
| | | bottomLoading: false, |
| | | isMoreData: dataList.length > 0 ? false : true, |
| | | skeletonLoding: false, |
| | | loading: false |
| | | }) |
| | | } else { |
| | | this.setData({ |
| | | skeletonLoding: false, |
| | | loading: false |
| | | }) |
| | | } |
| | | } catch (error) { |
| | | console.log(error) |
| | | } |
| | | }) |
| | | }, |
| | | /** |
| | | * 页面相关事件处理函数--监听用户下拉动作 |
| | | */ |
| | | onPullDownRefresh() { |
| | | if (this._freshing) return |
| | | this.setData({ |
| | | // list: [], |
| | | page: 1, |
| | | limit: 18, |
| | | pageTotalCount: 0, |
| | | bottomLoading: false, |
| | | isMoreData: false |
| | | }) |
| | | this._freshing = true; |
| | | this.setData({ |
| | | triggered: false, |
| | | }) |
| | | this.getDataList(false); |
| | | this._freshing = false |
| | | }, |
| | | |
| | | /** |
| | | * 页面上拉触底事件的处理函数 |
| | | */ |
| | | onReachBottom() { |
| | | this.setData({ |
| | | bottomLoading: true, |
| | | isMoreData: false |
| | | }) |
| | | let bool = false; |
| | | if (this.data.pageTotalCount > this.data.list.length) { |
| | | bool = true; |
| | | this.setData({ |
| | | page: this.data.page + 1, |
| | | }) |
| | | } else { |
| | | setTimeout(() => { |
| | | this.setData({ |
| | | bottomLoading: false, |
| | | isMoreData: true |
| | | }) |
| | | }, 100) |
| | | return false; |
| | | } |
| | | this.getDataList(bool); |
| | | }, |
| | | |
| | | setCoolect(itemData) { |
| | | let that = this; |
| | | let info = itemData.currentTarget.dataset.info; |
| | | wx.showModal({ |
| | | title: '提示', //提示的标题 |
| | | content: '确定要取消收藏?', //提示的内容 |
| | | success: function (res) { |
| | | if (res.confirm) { |
| | | app.MG.store |
| | | .delProductLink({ |
| | | productIds: [info.id], |
| | | linkType: that.data.activeName, |
| | | }) |
| | | .then(() => { |
| | | wx.showToast({ |
| | | title: "收藏已取消", |
| | | icon: 'success', |
| | | duration: 1000, |
| | | }) |
| | | this.getDataList(false) |
| | | }); |
| | | } else if (res.cancel) { |
| | | console.log('用户点击了取消') |
| | | } |
| | | } |
| | | }) |
| | | }, |
| | | goBookDetails(e) { |
| | | const { book } = e.currentTarget.dataset; |
| | | wx.navigateTo({ |
| | | url: `/packageBookService/pages/bookServices/detail/index?id=${book.id}&name=${book.name}`, |
| | | }); |
| | | }, |
| | | |
| | | |
| | | /** |
| | | * 用户点击右上角分享 |
| | | */ |
| | | onShareAppMessage() { |
| | | |
| | | } |
| | | }) |
New file |
| | |
| | | import moment from 'moment' |
| | | const app = getApp(); |
| | | Page({ |
| | | /** |
| | | * 页面的初始数据 |
| | | */ |
| | | data: { |
| | | list: [], |
| | | //分页 |
| | | page: 1, |
| | | limit: 10, |
| | | pageTotalCount: 0, |
| | | bottomLoading: false, |
| | | isMoreData: false, |
| | | // 返回顶部 |
| | | isBackTop: false, |
| | | setScrollValue: 0, |
| | | skeletonLoding: true, |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | onLoad(options) { |
| | | this.getDataList(false); |
| | | console.log(options); |
| | | }, |
| | | |
| | | getDataList(isReachBottom) { |
| | | app.MG.app.getAppMessageList({ |
| | | appRefCode: app.config.appRefCode, |
| | | start: this.data.page * this.data.limit - this.data.limit, |
| | | size: this.data.limit, |
| | | sort: { |
| | | type: "Desc", |
| | | field: "CreateDate" |
| | | } |
| | | }) |
| | | .then(res => { |
| | | try { |
| | | if (res.datas.length > 0) { |
| | | res.datas.forEach((item) => { |
| | | item.createDate = moment(item.createDate).format("YYYY-MM-DD HH:mm"); |
| | | }); |
| | | |
| | | let dataList = res.datas; |
| | | |
| | | //触底加载新数据并保留老数据 |
| | | if (isReachBottom) { |
| | | dataList = [...this.data.list, ...dataList] //将新数据加入老数据中 |
| | | } |
| | | this.setData({ |
| | | list: dataList, |
| | | pageTotalCount: res.totalSize, |
| | | bottomLoading: false, |
| | | isMoreData: dataList.length > 0 ? false : true, |
| | | skeletonLoding: false, |
| | | }) |
| | | } else { |
| | | this.setData({ |
| | | skeletonLoding: false, |
| | | }) |
| | | } |
| | | } catch (error) { |
| | | console.log(error) |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | toList(itemData) { |
| | | let info = itemData.currentTarget.dataset.info; |
| | | wx.navigateTo({ |
| | | url: "/packagePersonal/pages/myMassage/massageDetail/index?id=" + info.id, |
| | | }); |
| | | }, |
| | | /** |
| | | * 生命周期函数--监听页面初次渲染完成 |
| | | */ |
| | | onReady() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面显示 |
| | | */ |
| | | onShow() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 页面相关事件处理函数--监听用户下拉动作 |
| | | */ |
| | | onPullDownRefresh() { |
| | | if (this._freshing) return |
| | | this.setData({ |
| | | page: 1, |
| | | limit: 10, |
| | | pageTotalCount: 0, |
| | | bottomLoading: false, |
| | | isMoreData: false |
| | | }) |
| | | this._freshing = true; |
| | | this.setData({ |
| | | triggered: false, |
| | | }) |
| | | this.getDataList(false); |
| | | this._freshing = false |
| | | }, |
| | | |
| | | /** |
| | | * 页面上拉触底事件的处理函数 |
| | | */ |
| | | onReachBottom() { |
| | | this.setData({ |
| | | bottomLoading: true, |
| | | isMoreData: false |
| | | }) |
| | | let bool = false; |
| | | if (this.data.pageTotalCount > this.data.list.length) { |
| | | bool = true; |
| | | this.setData({ |
| | | page: this.data.page + 1, |
| | | }) |
| | | } else { |
| | | setTimeout(() => { |
| | | this.setData({ |
| | | bottomLoading: false, |
| | | isMoreData: true |
| | | }) |
| | | }, 100) |
| | | return false; |
| | | } |
| | | this.getDataList(bool); |
| | | |
| | | }, |
| | | |
| | | // 监听滚动距离 |
| | | onPageScroll(e) { |
| | | if (e && e.scrollTop >= 1000) { |
| | | this.setData({ |
| | | isBackTop: true |
| | | }) |
| | | } else { |
| | | this.setData({ |
| | | isBackTop: false |
| | | }) |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * 用户点击右上角分享 |
| | | */ |
| | | onShareAppMessage() { |
| | | |
| | | } |
| | | }) |
New file |
| | |
| | | // packagePersonal/pages/personalCenter/myMassage/index.js |
| | | Page({ |
| | | |
| | | /** |
| | | * 页面的初始数据 |
| | | */ |
| | | data: { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | onLoad(options) { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面初次渲染完成 |
| | | */ |
| | | onReady() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面显示 |
| | | */ |
| | | onShow() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面隐藏 |
| | | */ |
| | | onHide() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面卸载 |
| | | */ |
| | | onUnload() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 页面相关事件处理函数--监听用户下拉动作 |
| | | */ |
| | | onPullDownRefresh() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 页面上拉触底事件的处理函数 |
| | | */ |
| | | onReachBottom() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 用户点击右上角分享 |
| | | */ |
| | | onShareAppMessage() { |
| | | |
| | | } |
| | | }) |
New file |
| | |
| | | <!--packagePersonal/pages/personalCenter/myMassage/index.wxml--> |
| | | <text>packagePersonal/pages/personalCenter/myMassage/index.wxml</text> |
New file |
| | |
| | | // packagePersonal/pages/personalCenter/myMassage/massageDetail/index.js |
| | | Page({ |
| | | |
| | | /** |
| | | * 页面的初始数据 |
| | | */ |
| | | data: { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | onLoad(options) { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面初次渲染完成 |
| | | */ |
| | | onReady() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面显示 |
| | | */ |
| | | onShow() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面隐藏 |
| | | */ |
| | | onHide() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面卸载 |
| | | */ |
| | | onUnload() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 页面相关事件处理函数--监听用户下拉动作 |
| | | */ |
| | | onPullDownRefresh() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 页面上拉触底事件的处理函数 |
| | | */ |
| | | onReachBottom() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 用户点击右上角分享 |
| | | */ |
| | | onShareAppMessage() { |
| | | |
| | | } |
| | | }) |
New file |
| | |
| | | <!--packagePersonal/pages/personalCenter/myMassage/massageDetail/index.wxml--> |
| | | <text>packagePersonal/pages/personalCenter/myMassage/massageDetail/index.wxml</text> |
New file |
| | |
| | | // packagePersonal/pages/personalCenter/publishBooks/index.js |
| | | Page({ |
| | | |
| | | /** |
| | | * 页面的初始数据 |
| | | */ |
| | | data: { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | onLoad(options) { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面初次渲染完成 |
| | | */ |
| | | onReady() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面显示 |
| | | */ |
| | | onShow() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面隐藏 |
| | | */ |
| | | onHide() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面卸载 |
| | | */ |
| | | onUnload() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 页面相关事件处理函数--监听用户下拉动作 |
| | | */ |
| | | onPullDownRefresh() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 页面上拉触底事件的处理函数 |
| | | */ |
| | | onReachBottom() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 用户点击右上角分享 |
| | | */ |
| | | onShareAppMessage() { |
| | | |
| | | } |
| | | }) |
copy from pages/bookServices/webpage/index.json
copy to packagePersonal/pages/personalCenter/publishBooks/index.json
New file |
| | |
| | | <!--packagePersonal/pages/personalCenter/publishBooks/index.wxml--> |
| | | <text>packagePersonal/pages/personalCenter/publishBooks/index.wxml</text> |
New file |
| | |
| | | /* packagePersonal/pages/personalCenter/publishBooks/index.wxss */ |
| | |
| | | if (stair) { |
| | | const secondCode = `${stair.pathLinks[0].linkPath}\\${stair.id}`; |
| | | wx.navigateTo({ |
| | | url: `/pages/bookServices/list/index?assorName=${this.data.assortCheck.name}&assortCode=${this.data.assortCheck.code}&stairCode=${this.data.startCheck}&secondCode=${secondCode}`, |
| | | url: `/packageBookService/pages/bookServices/list/index?assorName=${this.data.assortCheck.name}&assortCode=${this.data.assortCheck.code}&stairCode=${this.data.startCheck}&secondCode=${secondCode}`, |
| | | }); |
| | | } else { |
| | | wx.navigateTo({ |
| | | url: `/pages/bookServices/list/index?assorName=${this.data.assortCheck.name}&assortCode=${this.data.assortCheck.code}`, |
| | | url: `/packageBookService/pages/bookServices/list/index?assorName=${this.data.assortCheck.name}&assortCode=${this.data.assortCheck.code}`, |
| | | }); |
| | | } |
| | | |
| | |
| | | navToSearchPage(e) { |
| | | console.log(e.detail.value); |
| | | wx.navigateTo({ |
| | | url: `/pages/bookServices/list/index?assorName=${this.data.assortCheck.name}&assortCode=${this.data.assortCheck.code}&stairCode=${this.data.startCheck}&searchValue=${e.detail.value}`, |
| | | url: `/packageBookService/pages/bookServices/list/index?assorName=${this.data.assortCheck.name}&assortCode=${this.data.assortCheck.code}&stairCode=${this.data.startCheck}&searchValue=${e.detail.value}`, |
| | | }); |
| | | }, |
| | | }); |
| | |
| | | "t-radio-group": "tdesign-miniprogram/radio-group/radio-group", |
| | | "t-button": "tdesign-miniprogram/button/button", |
| | | "t-loading": "tdesign-miniprogram/loading/loading", |
| | | "t-image": "/components/webp-image/index" |
| | | "t-image": "tdesign-miniprogram/image/image" |
| | | } |
| | | } |
| | | } |
| | |
| | | goDetail(e) { |
| | | const { book } = e.currentTarget.dataset; |
| | | wx.navigateTo({ |
| | | url: `/pages/bookServices/detail/index?id=${book.id}&name=${book.name}`, |
| | | url: `/packageBookService/pages/bookServices/detail/index?id=${book.id}&name=${book.name}`, |
| | | }); |
| | | }, |
| | | getShoppingCartList() { |
| | |
| | | console.log(e, 1) |
| | | if (type == "tushufuwu") { |
| | | wx.navigateTo({ |
| | | url: '/pages/bookServices/list/index' |
| | | url: '/packageBookService/pages/bookServices/list/index' |
| | | }) |
| | | } else { |
| | | wx.showToast({ |
| | |
| | | "t-loading": "tdesign-miniprogram/loading/loading", |
| | | "t-swiper": "tdesign-miniprogram/swiper/swiper", |
| | | "t-swiper-nav": "tdesign-miniprogram/swiper-nav/swiper-nav", |
| | | "t-image": "/components/webp-image/index", |
| | | "t-image": "tdesign-miniprogram/image/image", |
| | | "t-icon": "tdesign-miniprogram/icon/icon", |
| | | "t-toast": "tdesign-miniprogram/toast/toast", |
| | | "t-tabs": "tdesign-miniprogram/tabs/tabs", |
| | | "t-tab-panel": "tdesign-miniprogram/tab-panel/tab-panel", |
| | | "goods-list": "/components/goods-list/index", |
| | | "load-more": "/components/load-more/index", |
| | | "t-grid": "tdesign-miniprogram/grid/grid", |
| | | "t-grid-item": "tdesign-miniprogram/grid-item/grid-item", |
| | | "t-empty": "tdesign-miniprogram/empty/empty" |
| | |
| | | </view> |
| | | <view class="home-page-header"> |
| | | <view class="bg"> |
| | | <image src="/static/images/home/home-bg@2x.png" mode="heightFix" class="image" /> |
| | | <image src="/static/images/home/home-bg.png" mode="heightFix" class="image" /> |
| | | </view> |
| | | <view class="search"> |
| | | <t-search t-class-input="t-search__input" t-class-input-container="t-search__input-container" placeholder="请输入关键词/书名/ISBN/作者" leftIcon="" bind:submit="onRetrievalPage" model:value="{{searchVal}}"> |
| | | <t-search t-class-input="t-search__input" t-class-input-container="t-search__input-container" placeholder="请输入关键词/书名/ISBN/作者" leftIcon="" bind:submit="onRetrievalPage" model:value="{{searchVal}}"> |
| | | <t-icon slot="left-icon" prefix="wr" name="search" size="40rpx" color="#bbb" bind:tap="navToSearchPage" /> |
| | | </t-search> |
| | | </view> |
| | |
| | | </scroll-view> |
| | | </view> |
| | | </view> |
| | | <load-more list-is-empty="{{!goodsList.length}}" status="{{goodsListLoadStatus}}" bind:retry="onReTry" /> |
| | | <t-toast id="t-toast" /> |
| | | </view> |
| | |
| | | { |
| | | title: '我的订单', |
| | | icon: '/static/images/personal/order.png', |
| | | url: '/pages/personalCenter/myOrder/index', |
| | | url: '/packagePersonal/pages/myOrder/index', |
| | | type: 'order', |
| | | }, |
| | | { |
| | | title: '激活商品', |
| | | icon: '/static/images/personal/jihuo.png', |
| | | url: '/pages/personalCenter/activateProduct/index', |
| | | url: '/packagePersonal/pages/activateProduct/index', |
| | | type: 'activateProduct', |
| | | }, |
| | | { |
| | |
| | | { |
| | | title: '我的收藏', |
| | | icon: '/static/images/personal/wodeshoucang.png', |
| | | url: '/pages/personalCenter/myCollection/index', |
| | | url: '/packagePersonal/pages/myCollection/index', |
| | | type: 'collection', |
| | | }, |
| | | { |
| | | title: '我的下载', |
| | | icon: '/static/images/personal/download.png', |
| | | url: '/pages/personalCenter/downloads/index', |
| | | url: '/packagePersonal/pages/downloads/index', |
| | | type: 'download', |
| | | }, |
| | | { |
| | | title: '样书申请', |
| | | icon: '/static/images/personal/yangshushenqing.png', |
| | | url: '/pages/personalCenter/sampleBooks/index', |
| | | url: '/packagePersonal/pages/sampleBooks/index', |
| | | type: 'sampleBook', |
| | | }, |
| | | { |
| | |
| | | { |
| | | title: '出书申请', |
| | | icon: '/static/images/personal/chushu.png', |
| | | url: '/pages/personalCenter/publishBooks/index', |
| | | url: '/packagePersonal/pages/publishBooks/index', |
| | | type: 'publishBooks', |
| | | } |
| | | ]; |
| | |
| | | { |
| | | title: '我的消息', |
| | | icon: '/static/images/personal/notification.png', |
| | | url: '/pages/personalCenter/myMassage/index', |
| | | url: '/packagePersonal/pages/myMassage/index', |
| | | type: 'message', |
| | | }, |
| | | { |
| | | title: '建议与反馈', |
| | | icon: '/static/images/personal/feedback.png', |
| | | url: '/pages/personalCenter/feedBack/index', |
| | | url: '/packagePersonal/pages/feedBack/index', |
| | | type: 'feedback', |
| | | } |
| | | ]; |
| | |
| | | { |
| | | title: '关于我们', |
| | | icon: '/static/images/personal/about.png', |
| | | url: '/pages/aboutUs/index?types=jsek_aboutUs', |
| | | url: '/packagePersonal/pages/aboutUs/index?types=jsek_aboutUs', |
| | | type: 'aboutUs', |
| | | }, |
| | | { |
| | | title: '联系我们', |
| | | icon: '/static/images/personal/contact.png', |
| | | url: '/pages/aboutUs/index?types=jsek_contactUs', |
| | | url: '/packagePersonal/pages/aboutUs/index?types=jsek_contactUs', |
| | | type: 'contact', |
| | | } |
| | | ]; |
| | |
| | | //教师认证 |
| | | toCertification() { |
| | | wx.navigateTo({ |
| | | url: "/pages/teacherCertification/index", |
| | | url: "/packageDomain/pages/teacherCertification/index", |
| | | }); |
| | | }, |
| | | |
| | |
| | | "navigationStyle": "custom", |
| | | "usingComponents": { |
| | | "t-user-center-card": "./components/user-center-card/index", |
| | | "t-image": "/components/webp-image/index" |
| | | "t-image": "tdesign-miniprogram/image/image" |
| | | }, |
| | | "enablePullDownRefresh": true |
| | | } |
| | |
| | | console.log(e.currentTarget.dataset.item); |
| | | const item = e.currentTarget.dataset.item |
| | | wx.navigateTo({ |
| | | url: '/pages/bookServices/detail/index?id=' + item.id + '&name' + item.name |
| | | url: '/packageBookService/pages/bookServices/detail/index?id=' + item.id + '&name' + item.name |
| | | |
| | | |
| | | }) |
New file |
| | |
| | | // pages/student/index.js |
| | | Page({ |
| | | |
| | | /** |
| | | * 页面的初始数据 |
| | | */ |
| | | data: { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | onLoad(options) { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面初次渲染完成 |
| | | */ |
| | | onReady() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面显示 |
| | | */ |
| | | onShow() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面隐藏 |
| | | */ |
| | | onHide() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面卸载 |
| | | */ |
| | | onUnload() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 页面相关事件处理函数--监听用户下拉动作 |
| | | */ |
| | | onPullDownRefresh() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 页面上拉触底事件的处理函数 |
| | | */ |
| | | onReachBottom() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 用户点击右上角分享 |
| | | */ |
| | | onShareAppMessage() { |
| | | |
| | | } |
| | | }) |
copy from pages/bookServices/webpage/index.json
copy to pages/student/index.json
New file |
| | |
| | | <!--pages/student/index.wxml--> |
| | | <text> 学习</text> |
New file |
| | |
| | | /* pages/student/index.wxss */ |
| | |
| | | import { config } from '../../config/index'; |
| | | |
| | | /** 获取首页数据 */ |
| | | function mockFetchHome() { |
| | | const { delay } = require('../_utils/delay'); |
| | |
| | | text: '教师认证', |
| | | key: 7, |
| | | icon: '/static/images/home/jiaoshirenzheng@2x.png', |
| | | url: '/pages/teacherCertification/index', |
| | | url: '/packageDomain/pages/teacherCertification/index', |
| | | }, |
| | | { |
| | | text: '样书申请', |
| | | key: 8, |
| | | icon: '/static/images/home/yangshushenqing@2x.png', |
| | | url: '/pages/sampleBookList/index', |
| | | url: '/packageDomain/pages/sampleBookList/index', |
| | | }, |
| | | { |
| | | text: '我要出书', |
| | |
| | | |
| | | /** 获取首页数据 */ |
| | | export function fetchHome() { |
| | | if (config.useMock) { |
| | | return mockFetchHome(); |
| | | } |
| | | return new Promise((resolve) => { |
| | | resolve('real api'); |
| | | }); |
| | | return mockFetchHome(); |
| | | } |