| | |
| | | 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.getBookInfo(options.id); |
| | | this.getResourceClass() // 获取资源所属分类 |
| | | this.getApplyInfo(options.id) |
| | | const token = wx.getStorageSync('jsek-token') |
| | | if (token) { |
| | | this.getShoppingCartProductGet() |
| | | this.getApplyInfo(options.id) |
| | | this.getMockData() |
| | | } |
| | | }, |
| | | |
| | |
| | | }, |
| | | // 获取图书详情 |
| | | getBookInfo(id) { |
| | | this.setData({ |
| | | "mockData'.id": 0, |
| | | "mockData.price": 0, |
| | | "mockData.count": 0 |
| | | }) |
| | | const query = { |
| | | path: '*', |
| | | queryType: '*', |
| | |
| | | }, |
| | | }; |
| | | app.MG.store.getProductDetail(query).then(async (res) => { |
| | | |
| | | console.log(res.datas); |
| | | this.setData({ |
| | | bookDetail: res.datas, |
| | | cmsDatas: res.datas.cmsDatas[0].datas, |
| | |
| | | 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.paperPrice': this.numFormat(this.data.bookDetail.paperPrice), |
| | | }); |
| | | }); |
| | | |
| | | }, |
| | | // 获取图书分类 |
| | | async getBookClass(iconType, classType) { |
| | |
| | | goShop(e) { |
| | | const { link } = e.currentTarget.dataset; |
| | | wx.navigateTo({ |
| | | url: link, |
| | | }); |
| | | url: `/pages/bookServices/webpage/index?url=${link}`, |
| | | }) |
| | | }, |
| | | onTabsChange(e) { |
| | | this.setData({ |
| | |
| | | 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 |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | }) |