| | |
| | | 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 |
| | | item.checked = false, |
| | | item.checkAll = true |
| | | }) |
| | | const list = await this.getAllResource(res.datas.cmsDatas[0].datas) |
| | | if (type.refCode == 'jsek_teachingResources') { |
| | |
| | | }) |
| | | this.findChildIds(this.data.teach, this.data.openTeachids = []) |
| | | } else if (type.refCode == 'jsek_cloudLearning') { |
| | | const result = [] |
| | | res.datas.cmsDatas[0].datas.forEach(item => { |
| | | item.checked = false |
| | | }) |
| | | const list = await this.getAllResource(res.datas.cmsDatas[0].datas) |
| | | this.findChildIds(list, result) |
| | | this.setData({ |
| | | learn: list, |
| | | loading: false |
| | | loading: false, |
| | | openLearnids: result |
| | | }) |
| | | this.findChildIds(this.data.learn, this.data.openLearnids = []) |
| | | } |
| | | } else { |
| | | // 无数据 |
| | |
| | | }) |
| | | }) |
| | | }, |
| | | checkAll() { |
| | | const child = this.selectComponent('#tree') |
| | | child.checkAll() |
| | | } |
| | | }) |
| | |
| | | </view> |
| | | <view class="navbar-title">资源购买</view> |
| | | </view> |
| | | <view> 全选 </view> |
| | | <view bind:tap="checkAll"> 全选 </view> |
| | | </view> |
| | | |
| | | <!-- 内容 --> |
| | | |
| | | <view class="buy-resource" wx:if="{{!loading}}"> |
| | | <tree |
| | | id="tree" |
| | | treeList="{{learn}}" |
| | | tab="{{'jsek_cloudLearning'}}" |
| | | isShowCheck="{{true}}" |
| | |
| | | t-class="external-class" |
| | | bind:tap="getFreeResource" |
| | | > |
| | | <view slot="content" class="btn-content"> |
| | | <image src=" /static/images/bookService/detail/yijianlingqu.png" /> |
| | | <text>领取查看</text> |
| | | </view> |
| | | </t-button> |
| | | <t-button |
| | | loading="{{buy}}" |
| | |
| | | style="height: 72rpx; font-size: 28rpx" |
| | | bind:tap="goBuyResource" |
| | | > |
| | | <view slot="content" class="btn-content"> |
| | | <image src="/static/images/bookService/detail/yijiangoumai.png" /> |
| | | 资源购买 |
| | | <text>资源购买</text> |
| | | </view> |
| | | </t-button> |
| | | <t-button |
| | | class="btn" |
| | |
| | | align-items: center; |
| | | } |
| | | |
| | | .btn-content { |
| | | display: flex; |
| | | align-items: center; |
| | | } |
| | | |
| | | .btn image { |
| | | margin-right: 4rpx; |
| | | width: 28rpx; |
| | | height: 32rpx; |
| | | margin: 25rpx 10rpx 0 0; |
| | | } |
| | |
| | | } |
| | | }, |
| | | data: { |
| | | |
| | | activeValues: [1, 2], |
| | | webpageSrc: '', |
| | | cloudShoppingCart: [] |
| | | }, |
| | | onShow() { |
| | | }, |
| | | observers: { |
| | | 'treeList': function (newValue) { |
| | | |
| | | } |
| | | }, |
| | | |
| | | methods: { |
| | | handleList(tree) { |
| | | for (let index = 0; index < tree.length; index++) { |
| | | const item = tree[index]; |
| | | if (item.sysType == 'CmsItem' && !item.checked) { |
| | | |
| | | } |
| | | if (item.children && item.children.length > 0) { |
| | | this.handleList(item.children) |
| | | } |
| | | } |
| | | }, |
| | | // 节点展开 |
| | | handleChange(e) { |
| | | // console.log(this.properties.treeList, 'this.properties.treeList'); |
| | |
| | | }, |
| | | // 拿到当前项子项 |
| | | flattenTree(tree) { |
| | | |
| | | let result = []; |
| | | |
| | | function flatten(node) { |
| | | |
| | | result.push(node); |
| | | |
| | | if (node.children && node.children.length > 0) { |
| | | |
| | | node.children.forEach(child => { |
| | | flatten(child); |
| | | }); |
| | |
| | | } |
| | | } |
| | | else if (id == node.id && node.sysType == "CmsItem") { |
| | | debugger |
| | | node.checked = !node.checked // 将目标项的 check 属性设置为 true |
| | | } |
| | | } |
| | |
| | | findAndUpdate(node); // 对每个顶层节点执行查找和更新操作 |
| | | } |
| | | return tree; // 返回修改后的完整数组 |
| | | }, |
| | | |
| | | checkAll() { |
| | | const ids = [] |
| | | const list = [] |
| | | this.properties.treeList.forEach(item => { |
| | | if (item.children && item.children.length > 0) { |
| | | list.push(...this.flattenTree([item])) |
| | | } |
| | | }) |
| | | list.forEach(item => { |
| | | ids.push(item.id) |
| | | }) |
| | | const updataList = this.findAndUpdateItemsByIds(this.properties.treeList, ids); |
| | | this.setData({ |
| | | treeList: updataList |
| | | }) |
| | | }, |
| | | |
| | | // 章节勾选 |
| | |
| | | // 子项勾选 |
| | | checkResource(e) { |
| | | const citem = e.currentTarget.dataset.item |
| | | this.checkResoucrceInfo(this.properties.treeList, citem.id) |
| | | console.log(e); |
| | | const updataList = this.checkResoucrceInfo(this.properties.treeList, citem.id) |
| | | console.log(updataList); |
| | | this.setData({ |
| | | treeList: updataList |
| | | }) |
| | | }, |
| | | // 加入购物车 |
| | | async onCloudShoppingCart() { |
| | |
| | | // } |
| | | }, |
| | | }, |
| | | onCheckAllChange(e) { |
| | | debugger |
| | | console.log('checkbox', e.detail.value); |
| | | // this.setData({ |
| | | // checkAllValues: event.detail, |
| | | // }); |
| | | } |
| | | }) |
| | |
| | | position: relative; |
| | | background-color: #fff; |
| | | line-height: 90rpx; |
| | | height: 94rpx; |
| | | height: 90rpx; |
| | | width: 15vw; |
| | | font-size: 28rpx; |
| | | color: #999; |