| | |
| | | // packageBookService/pages/bookServices/detail/buyResource/index.js |
| | | const app = getApp() |
| | | Page({ |
| | | |
| | | /** |
| | | * 页面的初始数据 |
| | | */ |
| | | data: { |
| | | |
| | | barHeight: '', |
| | | navBarHeight: '', |
| | | learn: [], |
| | | openLearnids: [], |
| | | bookId: '', |
| | | loading: false, |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | 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, |
| | | bookId: options.bookId |
| | | }); |
| | | this.getResourceClass() |
| | | console.log(options); |
| | | this.getResourceData({ productLinkPath: options.productLinkPath, refCode: options.refCode }) |
| | | }, |
| | | |
| | | /** |
| | |
| | | */ |
| | | onShareAppMessage() { |
| | | |
| | | }, |
| | | goBack() { |
| | | wx.navigateBack() |
| | | }, |
| | | // 获取教学资源 云学习 云测试 |
| | | getResourceData(type) { |
| | | this.setData({ |
| | | loading: true, |
| | | noResources: false |
| | | }) |
| | | let query = { |
| | | path: '*', |
| | | queryType: '*', |
| | | productId: this.data.bookId, |
| | | 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 (!res.datas.cmsDatas[0].datas.length) { |
| | | return this.setData({ |
| | | noResources: true, |
| | | loading: false |
| | | }) |
| | | } |
| | | //教学资源 云学习 |
| | | if (type.refCode == 'jsek_teachingResources' || type.refCode == 'jsek_cloudLearning') { |
| | | if (res.datas.cmsDatas[0].datas.length > 0) { |
| | | res.datas.cmsDatas[0].datas.forEach(item => { |
| | | item.checked = false |
| | | }) |
| | | const list = await this.getAllResource(res.datas.cmsDatas[0].datas) |
| | | if (type.refCode == 'jsek_teachingResources') { |
| | | this.setData({ |
| | | teach: list, |
| | | loading: false |
| | | }) |
| | | this.findChildIds(this.data.teach, this.data.openTeachids = []) |
| | | } else if (type.refCode == 'jsek_cloudLearning') { |
| | | res.datas.cmsDatas[0].datas.forEach(item => { |
| | | item.checked = false |
| | | }) |
| | | 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.bookId, |
| | | 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.checked = false |
| | | 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 |
| | | } |
| | | } |
| | | }, |
| | | // 获取资源所属分类 |
| | | getResourceClass() { |
| | | let query = { |
| | | refCodes: ['resourcesClassification'] |
| | | } |
| | | app.MG.store.getProductTypeField(query).then((res) => { |
| | | this.setData({ |
| | | resourceClassList: JSON.parse(res[0].config).option |
| | | }) |
| | | }) |
| | | }, |
| | | }) |
| | |
| | | { |
| | | "usingComponents": {} |
| | | "usingComponents": { |
| | | "t-icon": "tdesign-miniprogram/icon/icon", |
| | | "tree": "/packageBookService/pages/bookServices/detail/components/tree/index", |
| | | "t-loading": "tdesign-miniprogram/loading/loading" |
| | | }, |
| | | "navigationStyle": "custom" |
| | | } |
| | |
| | | <!--packageBookService/pages/bookServices/detail/buyResource/index.wxml--> |
| | | <text>packageBookService/pages/bookServices/detail/buyResource/index.wxml</text> |
| | | <!--导航区域 --> |
| | | <view style="width: 100%; height: {{barHeight}}px; "></view> |
| | | <view class="nacigationBar" style="width: 70%; height: {{navBarHeight}}px;"> |
| | | <view class="flex"> |
| | | <view> |
| | | <t-icon |
| | | name="chevron-left" |
| | | size="30" |
| | | data-name="{{item}}" |
| | | bind:click="goBack" |
| | | /> |
| | | </view> |
| | | <view class="navbar-title">资源购买</view> |
| | | </view> |
| | | <view> 全选 </view> |
| | | </view> |
| | | |
| | | <!-- 内容 --> |
| | | |
| | | <view class="buy-resource" wx:if="{{!loading}}"> |
| | | <tree treeList="{{learn}}" tab="{{'jsek_cloudLearning'}}" /> |
| | | </view> |
| | | |
| | | <view class="noData" wx:if="{{loading}}"> |
| | | <t-loading size="60rpx" loading="{{loading}}" /> |
| | | </view> |
| | |
| | | /* packageBookService/pages/bookServices/detail/buyResource/index.wxss */ |
| | | .nacigationBar { |
| | | background-color: #fff; |
| | | display: flex; |
| | | align-items: center; |
| | | justify-content: space-between; |
| | | } |
| | | |
| | | .navbar-title { |
| | | white-space: nowrap; |
| | | overflow: hidden; |
| | | text-overflow: ellipsis; |
| | | color: #0F1214; |
| | | font-size: 40rpx; |
| | | font-weight: bold; |
| | | } |
| | | |
| | | .flex { |
| | | display: flex; |
| | | } |
| | | |
| | | .space-between { |
| | | justify-content: space-between; |
| | | } |
| | | |
| | | .noData { |
| | | width: 100%; |
| | | height: 100%; |
| | | display: flex; |
| | | justify-content: center; |
| | | align-items: center; |
| | | --td-loading-color: #ff6c00; |
| | | } |
| | |
| | | * 组件的属性列表 |
| | | */ |
| | | properties: { |
| | | |
| | | buyResourceData: { |
| | | type: Object, |
| | | }, |
| | | bookId: { |
| | | type: Number |
| | | } |
| | | }, |
| | | |
| | | /** |
| | |
| | | } // 触发事件的选项 |
| | | this.triggerEvent('getFreeResource', myEventDetail, myEventOption) |
| | | }, |
| | | allAddShoppiingCar() { |
| | | var myEventDetail = {} // detail对象,提供给事件监听函数 |
| | | var myEventOption = { |
| | | bubbles: true, |
| | | composed: true |
| | | } // 触发事件的选项 |
| | | this.triggerEvent('allAddShoppiingCar', myEventDetail, myEventOption) |
| | | // allAddShoppiingCar() { |
| | | // var myEventDetail = {} // detail对象,提供给事件监听函数 |
| | | // var myEventOption = { |
| | | // bubbles: true, |
| | | // composed: true |
| | | // } // 触发事件的选项 |
| | | // this.triggerEvent('allAddShoppiingCar', myEventDetail, myEventOption) |
| | | // }, |
| | | goBuyResource() { |
| | | wx.navigateTo({ |
| | | url: `/packageBookService/pages/bookServices/detail/buyResource/index?productLinkPath=${this.properties.buyResourceData.productLinkPath}&refCode=${this.properties.buyResourceData.refCode}&bookId=${this.properties.bookId}`, |
| | | }) |
| | | }, |
| | | |
| | | changeReceive(type) { |
| | | this.setData({ |
| | | receive: type |
| | |
| | | class="btn" |
| | | theme="primary" |
| | | style="height: 72rpx; font-size: 28rpx" |
| | | bind:tap="allAddShoppiingCar" |
| | | bind:tap="goBuyResource" |
| | | > |
| | | <image src="/static/images/bookService/detail/yijiangoumai.png" /> |
| | | 一键购买 |
| | | 资源购买 |
| | | </t-button> |
| | | <t-button |
| | | class="btn" |
| | |
| | | fileType: "", |
| | | md5: "", |
| | | freePage: "" |
| | | }//阅读器数据 |
| | | }, //阅读器数据 |
| | | buyResourceData: { |
| | | productLinkPath: '', |
| | | refCode: '', |
| | | } |
| | | }, |
| | | |
| | | |
| | |
| | | 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_cloudLearning') { |
| | | this.setData({ |
| | | 'buyResourceData.productLinkPath': checkData.productLinkPath, |
| | | 'buyResourceData.refCode': checkData.refCode |
| | | }) |
| | | } |
| | | if ((e.detail.value == 'jsek_teachingResources' && !this.data.teach.length) |
| | | || (e.detail.value == 'jsek_cloudLearning' && !this.data.learn.length) |
| | | || (e.detail.value == 'questionBank' && !this.data.test.length)) { |
| | |
| | | bind:getFreeResource="getFreeResource" |
| | | bind:allAddShoppiingCar="allAddShoppiingCar" |
| | | id="learn-resource" |
| | | buyResourceData="{{buyResourceData}}" |
| | | bookId="{{bookDetail.id}}" |
| | | ></learn-resource> |
| | | <tree |
| | | id="tree" |
| | |
| | | /> |
| | | </view> --> |
| | | |
| | | <view class="page-content"> |
| | | <view class="page-content" style="background-color:{{isNight ? '#222' : ''}}"> |
| | | <question-schedule |
| | | wx:if="{{!loading}}" |
| | | id="countDownRef" |
| | |
| | | |
| | | <!-- 底部区域--> |
| | | |
| | | <view class="page-bottom"> |
| | | <view class="page-bottom" style="background-color:{{isNight ? '#202020' : ''}}"> |
| | | <question-options |
| | | id="question-options" |
| | | isNight="{{isNight}}" |
| | |
| | | style="color: {{isNight ? '#fff' : '#000'}};" |
| | | > |
| | | <image |
| | | src="{{ questionDataList[currentIndex].isCollect ? '/static/images/bookService/detail/collecting.png' : '/static/images/bookService/examination/collect.png'}}" |
| | | src="{{ questionDataList[currentIndex].isCollect ? '/static/images/bookService/detail/collecting.png' : isNight ? '/static/images/bookService/examination/wodeshoucang-w.png' : '/static/images/bookService/examination/collect.png'}}" |
| | | /> |
| | | 收藏 |
| | | </view> |
| | |
| | | bind:tap="handlePopup" |
| | | style="color: {{isNight ? '#fff' : '#000'}};" |
| | | > |
| | | <image src="/static/images/bookService/examination/questionCard.png" /> |
| | | <image |
| | | src="{{isNight ? '/static/images/bookService/examination/datika-w.png' : '/static/images/bookService/examination/questionCard.png'}}" |
| | | /> |
| | | 答题卡 |
| | | </view> |
| | | <view |
| | |
| | | bind:tap="setUpBtn" |
| | | style="color: {{isNight ? '#fff' : '#000'}};" |
| | | > |
| | | <image src="/static/images/bookService/examination/setting.png" /> |
| | | <image |
| | | src="{{isNight ? '/static/images/bookService/examination/setting-w.png' : '/static/images/bookService/examination/setting.png'}}" |
| | | /> |
| | | 设置 |
| | | </view> |
| | | <view |
| | |
| | | wx:if="{{answerType == 'option' || (answerType == 'mock' && !submitStatus)}}" |
| | | style="color: {{isNight ? '#fff' : '#000'}};" |
| | | > |
| | | <image src="/static/images/bookService/examination/reset.png" /> |
| | | <image |
| | | src="{{isNight ? '/static/images/bookService/examination/chongzuo-w.png' : '/static/images/bookService/examination/reset.png'}}" |
| | | /> |
| | | 重做 |
| | | </view> |
| | | <view class="bottom-submit"> |
| | |
| | | this.setData({ |
| | | percentage: (this.data.ready / this.data.questionList.length) * 100 |
| | | }) |
| | | }, |
| | | 'isNight': function (newValue) { |
| | | console.log('is', newValue); |
| | | } |
| | | }, |
| | | /** |
| | |
| | | background-color: #FF6C00 !important; |
| | | } |
| | | |
| | | .audioIconBox { |
| | | /* margin-top: 10rpx; */ |
| | | } |
| | | |
| | | .publicBtn { |
| | | margin-right: 10rpx; |
| | | /* margin-left: 40rpx; */ |