闫增涛
2024-03-25 810be121d0ad95211ad13ebed9fb4e834c0c2f72
添加资源购买功能页面
2个文件已删除
12个文件已修改
4个文件已添加
352 ■■■■■ 已修改文件
packageBookService/pages/bookServices/buyResource/index.json 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/buyResource/index.wxss 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/detail/buyResource/index.js 210 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/detail/buyResource/index.json 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/detail/buyResource/index.wxml 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/detail/buyResource/index.wxss 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/detail/components/learnResource/learnResource.js 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/detail/components/learnResource/learnResource.wxml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/detail/index.js 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/detail/index.wxml 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/examination/examination.wxml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/examination/questionOptions/index.wxml 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/examination/questionSchedule/index.js 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageDomain/pages/resourceDetails/myAudio/index.wxss 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
static/images/bookService/examination/chongzuo-w.png 补丁 | 查看 | 原始文档 | blame | 历史
static/images/bookService/examination/datika-w.png 补丁 | 查看 | 原始文档 | blame | 历史
static/images/bookService/examination/setting-w.png 补丁 | 查看 | 原始文档 | blame | 历史
static/images/bookService/examination/wodeshoucang-w.png 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/buyResource/index.json
File was deleted
packageBookService/pages/bookServices/buyResource/index.wxss
File was deleted
packageBookService/pages/bookServices/detail/buyResource/index.js
@@ -1,18 +1,34 @@
// 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 })
  },
  /**
@@ -62,5 +78,193 @@
   */
  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
      })
    })
  },
})
packageBookService/pages/bookServices/detail/buyResource/index.json
@@ -1,3 +1,8 @@
{
  "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
@@ -1,2 +1,27 @@
<!--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
@@ -1 +1,33 @@
/* packageBookService/pages/bookServices/detail/buyResource/index.wxss */
/* 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;
}
packageBookService/pages/bookServices/detail/components/learnResource/learnResource.js
@@ -4,7 +4,12 @@
   * 组件的属性列表
   */
  properties: {
    buyResourceData: {
      type: Object,
    },
    bookId: {
      type: Number
    }
  },
  /**
@@ -27,14 +32,20 @@
      } // 触发事件的选项
      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
packageBookService/pages/bookServices/detail/components/learnResource/learnResource.wxml
@@ -16,10 +16,10 @@
    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"
packageBookService/pages/bookServices/detail/index.js
@@ -72,7 +72,11 @@
      fileType: "",
      md5: "",
      freePage: ""
    }//阅读器数据
    },  //阅读器数据
    buyResourceData: {
      productLinkPath: '',
      refCode: '',
    }
  },
@@ -490,6 +494,12 @@
    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)) {
packageBookService/pages/bookServices/detail/index.wxml
@@ -219,6 +219,8 @@
            bind:getFreeResource="getFreeResource"
            bind:allAddShoppiingCar="allAddShoppiingCar"
            id="learn-resource"
            buyResourceData="{{buyResourceData}}"
            bookId="{{bookDetail.id}}"
          ></learn-resource>
          <tree
            id="tree"
packageBookService/pages/bookServices/examination/examination.wxml
@@ -22,7 +22,7 @@
  />
</view> -->
<view class="page-content">
<view class="page-content" style="background-color:{{isNight ? '#222' : ''}}">
  <question-schedule
    wx:if="{{!loading}}"
    id="countDownRef"
@@ -57,7 +57,7 @@
<!-- 底部区域-->
<view class="page-bottom">
<view class="page-bottom" style="background-color:{{isNight ? '#202020' : ''}}">
  <question-options
    id="question-options"
    isNight="{{isNight}}"
packageBookService/pages/bookServices/examination/questionOptions/index.wxml
@@ -9,7 +9,7 @@
    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>
@@ -18,7 +18,9 @@
    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
@@ -26,7 +28,9 @@
    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
@@ -35,7 +39,9 @@
    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">
packageBookService/pages/bookServices/examination/questionSchedule/index.js
@@ -79,6 +79,9 @@
      this.setData({
        percentage: (this.data.ready / this.data.questionList.length) * 100
      })
    },
    'isNight': function (newValue) {
      console.log('is', newValue);
    }
  },
  /**
packageDomain/pages/resourceDetails/myAudio/index.wxss
@@ -321,10 +321,6 @@
  background-color: #FF6C00 !important;
}
.audioIconBox {
  /* margin-top: 10rpx; */
}
.publicBtn {
  margin-right: 10rpx;
  /* margin-left: 40rpx; */
static/images/bookService/examination/chongzuo-w.png
static/images/bookService/examination/datika-w.png
static/images/bookService/examination/setting-w.png
static/images/bookService/examination/wodeshoucang-w.png