yiming
2024-03-28 8f1835f66ef83bbd752e080178afb98632a6970d
云学习购买
5个文件已修改
295 ■■■■ 已修改文件
packageBookService/pages/bookServices/detail/buyResource/index.js 56 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/detail/components/tree/index.js 54 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/home/home.wxss 补丁 | 查看 | 原始文档 | blame | 历史
pages/retrievalPage/index.wxml 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/retrievalPage/index.wxss 174 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/detail/buyResource/index.js
@@ -34,7 +34,10 @@
    });
    this.getResourceClass()
    console.log(options);
    this.getResourceData({ productLinkPath: options.productLinkPath, refCode: options.refCode })
    this.getResourceData({
      productLinkPath: options.productLinkPath,
      refCode: options.refCode
    })
    this.getShoppingCartProductGet()
    this.getBookInfo(options.bookId)
  },
@@ -369,19 +372,52 @@
  checkAll() {
    const child = this.selectComponent('#tree')
    child.checkAll()
  },
  //购买按钮
  batchPurchase() {
    let saleMethodIds = []
    let requests = []
    let item = []
    let selectAllId = []
    const child = this.selectComponent('#tree')
    console.log(child.data.superiorPurchaseSaleMethodId, 'superiorPurchaseSaleMethodId');
    console.log(child.data.sonPurchaseSaleMethodId, 'child.data');
    // console.log(child.data.selectAll, 'selectAll');
    item = child.data.superiorPurchaseSaleMethodId
    const sonItem = child.data.sonPurchaseSaleMethodId
    let selectAll = child.data.selectAll
    if (selectAll) {
      // console.log(selectAll);
      selectAll.forEach(item => {
        if (item.saleMethod != 0) {
          // console.log(item, 'item');
          selectAllId.push(item.saleMethod[0].Id)
        }
      })
      console.log(selectAllId);
      app.MG.store.initOrder({
        requests: selectAllId.map(id => ({
          saleMethodId: id,
          count: 1,
        })),
      }).then(res => {
        if (res) {
          wx.navigateTo({
            url: '/pages/cart/paymentPage/index?orderNumber=' + res.orderNumber,
          })
          selectAllId = []
          child.setData({
            selectAll: []
          })
        }
      })
    }
    if (item) {
      console.log(item, 'sadsdasd');
      // 拿到id
@@ -402,22 +438,14 @@
          wx.navigateTo({
            url: '/pages/cart/paymentPage/index?orderNumber=' + res.orderNumber,
          })
          this.setData({
            superior: true
          })
          child.setData({
            superiorPurchaseSaleMethodId: [] // 使用setData方法清空sonPurchaseSaleMethodId数据
          })
        }
      })
    }
    if (item.length == 0 && sonItem) {
      app.MG.store.initOrder({
        requests: sonItem.map(id => ({
          saleMethodId: id,
@@ -431,7 +459,9 @@
          this.setData({
            paymentPage: true
          })
          child.setData({
            sonPurchaseSaleMethodId: [] // 使用setData方法清空sonPurchaseSaleMethodId数据
          })
        }
      })
    }
packageBookService/pages/bookServices/detail/components/tree/index.js
@@ -1,4 +1,3 @@
import Message from 'tdesign-miniprogram/message/message';
const util = require('./components/util') // 引入封装过的加载提示
const app = getApp()
@@ -29,8 +28,7 @@
    openIds: {
      type: Array,
      value: [],
    }
    ,
    },
    isShowCheck: {
      type: Boolean,
      value: false,
@@ -49,7 +47,8 @@
    superiorPurchaseSaleMethodId: [],
    activeValues: [1, 2],
    webpageSrc: '',
    cloudShoppingCart: []
    cloudShoppingCart: [],
    selectAll: []
  },
  ready() {
    this.setData({
@@ -57,16 +56,12 @@
    })
    console.log('准备');
  },
  onShow() {
    debugger
    this.setData({
      sonPurchaseSaleMethodId: ''
    })
  },
  onLoad() {
    this.setData({
      sonPurchaseSaleMethodId: ''
      sonPurchaseSaleMethodId: []
    })
    console.log(this.data.sonPurchaseSaleMethodId, 'sonPurchaseSaleMethodId789');
  },
  observers: {
    'openIds': function (newValue) {
@@ -201,6 +196,7 @@
    // 拿到所有项
    getAllChildren(id) {
      let result = [];
      function findChildren(item) {
        if (item.id === id) {
          if (item.children && item.children.length > 0) {
@@ -228,6 +224,7 @@
    // 拿到当前项子项
    flattenTree(tree) {
      let result = [];
      function flatten(node) {
        result.push(node);
        if (node.children && node.children.length > 0) {
@@ -273,8 +270,7 @@
            const element = node.children[index];
            findAndUpdate(element)
          }
        }
        else if (id == node.id && node.sysType == "CmsItem") {
        } else if (id == node.id && node.sysType == "CmsItem") {
          node.checked = !node.checked  // 将目标项的 check 属性设置为 true
        }
      }
@@ -287,6 +283,7 @@
    checkAll() {
      const ids = []
      const list = []
      let checked = ''
      this.properties.treeList.forEach(item => {
        if (item.children && item.children.length > 0) {
          list.push(...this.flattenTree([item]))
@@ -294,8 +291,21 @@
      })
      list.forEach(item => {
        ids.push(item.id)
        checked = item.checked
      })
      const updataList = this.findAndUpdateItemsByIds(this.properties.treeList, ids);
      console.log(checked, 'list');
      if (!checked) {
        this.setData({
          selectAll: list
        })
      }
      this.setData({
        treeList: updataList
      })
@@ -317,21 +327,14 @@
      this.setData({
        treeList: updatedTreeList  // 更新 treeList 数据
      });
      console.log(list, 'list.checked');
      if (!list.checked) {
        if (this.properties.superior) {
          console.log(852);
          this.properties.superior = false
          this.setData({
            superiorPurchaseSaleMethodId: []
          })
        }
        if (!this.properties.superior) {
          this.setData({
            superiorPurchaseSaleMethodId: list
          })
        }
      }
      // console.log(this.data.superiorPurchaseSaleMethodId, 'superiorPurchaseSaleMethodId');
@@ -363,20 +366,15 @@
        if (!this.properties.paymentPage) {
          sonPurchaseSaleMethodId.push(citem.saleMethod[0].Id)
        }
        this.setData({
          sonPurchaseSaleMethodId: sonPurchaseSaleMethodId
        })
        console.log(this.data.sonPurchaseSaleMethodId);
      } else {
        // 取消选中的时候删除id
      }
      this.setData({
        treeList: updataList,
      })
    },
    // 加入购物车
pages/home/home.wxss
pages/retrievalPage/index.wxml
@@ -120,19 +120,18 @@
      <t-empty icon="folder-open" description="暂无数据" />
    </view>
    <view class="listBox">
      <view wx:for="{{seminarData}}" wx:for-item="item" wx:for-index="index" wx:key="index" bindtap="toList" data-info="{{item}}" class="listItemBox">
        <view class="listItem">
        <view wx:for="{{seminarData}}" wx:for-item="item" wx:for-index="index" wx:key="index" class="listItemBox">
          <view class="listItem" bindtap="goSubjectDetail" data-book="{{item}}">
          <view class="specialSubject-img">
            <image src="{{item.icon}}" mode="aspectFill" class="img" />
          </view>
          <view class="body-info">
            <view class="name">{{item.name}}</view>
            <view class="time" wx:if="{{item.liveTime}}">直播时间:<text>{{item.liveTime}}</text></view>
            <view class="time" wx:if="{{item.startTime}}">开播时间:<text>{{ item.startTime }}</text></view>
              <view class="time" wx:if="{{item.liveTime}}">直播时间:{{item.liveTime}}</view>
              <view class="time" wx:if="{{item.startTime}}">开播时间:{{ item.startTime }}</view>
            <view class="time" wx:if="{{!item.liveTime && !item.startTime}}">开播时间:<text class="grey">待定</text></view>
            <view class="flex jc-sb">
              <text class="author">{{item.lecturer}}</text>
                <text class="author">{{item.lecturer}} {{item.position}}</text>
              <text class="price" wx:if="{{item.price == 0}}">免费</text>
              <text class="price" wx:if="{{item.price !== 0}}">¥{{item.price}}</text>
            </view>
pages/retrievalPage/index.wxss
@@ -94,76 +94,6 @@
  overflow: hidden;
}
.listBox {
  padding: 20rpx 0;
  display: flex;
  flex-flow: row wrap;
  justify-content: space-between;
  margin: 20rpx;
}
.listBox .listItemBox {
  width: 49%;
  margin-bottom: 50rpx;
}
.listItemBox .listItem {
  background: #fff;
  box-sizing: border-box;
  border-radius: 5px;
  overflow: hidden;
  box-shadow: 0px 0px 20rpx 2px #f1f1f1;
  min-height: 170rpx;
}
.listBox .specialSubject-img {
  width: 100%;
  height: 120rpx;
}
.specialSubject-img image {
  width: 176.63px;
  height: 109px;
  object-fit: contain;
}
.body-info {
  padding: 20rpx;
  font-size: 28rpx;
  min-height: 110rpx;
  width: 148px;
}
.body-info .name {
  font-size: 25rpx;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  margin-bottom: 10rpx;
}
.body-info .time {
  font-size: 26rpx;
  margin-bottom: 10rpx;
}
.body-info .author {
  font-size: 26rpx;
  display: flex;
  justify-content: space-between;
}
.body-info .price {
  font-size: 26rpx;
  color: #ff6d00;
}
.flex {
  display: flex;
}
@@ -204,32 +134,23 @@
  flex-wrap: wrap;
  justify-content: space-between;
  margin: 15px;
}
.contentBox {
  width: 330rpx;
  /* height: 231rpx; */
  /* border: 1px #000 solid; */
  margin: 10px 0;
  background-color: #fff;
}
.textBox {
  width: 280rpx;
  /* height: 75rpx; */
  font-size: 25rpx;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  /* text-align: center; */
  margin: 20rpx;
}
.bookFairImage {
@@ -244,13 +165,11 @@
.higherBox {
  width: 220rpx;
  /* height: 390rpx; */
  box-shadow: 10rpx 10rpx 10rpx 10rpx rgba(0, 0, 0, 0.08);
  margin: 30rpx 15rpx;
}
.outsideHigherImageBox {
  position: relative;
}
@@ -263,7 +182,6 @@
.downloadIcon {
  width: 34rpx;
  height: 34rpx;
  border-radius: 5rpx 5rpx 5rpx 5rpx;
  background: rgba(0, 0, 0, 0.3);
  position: absolute;
@@ -272,9 +190,7 @@
  padding: 10rpx;
}
.download {
  /* background-color: #8bc34a; */
  width: 100%;
  height: 100%;
@@ -295,7 +211,6 @@
.t-tabs__item--active {
  color: #FF6C00 !important;
}
.t-tabs__track {
@@ -303,9 +218,6 @@
}
.noDataBox {
  /* display: flex;
  justify-content: center;
  align-items: center */
  margin: 0 auto;
  margin-top: 250rpx;
}
@@ -347,3 +259,89 @@
.tabsBox {
  margin-top: 300rpx;
}
/* 专题 */
.listBox {
  padding: 20rpx 0;
  display: flex;
  flex-flow: row wrap;
  justify-content: space-between;
  margin: 20rpx;
}
.listBox .listItemBox {
  width: 49%;
  margin-bottom: 30rpx;
}
.listItemBox .listItem {
  background: #fff;
  box-sizing: border-box;
  border-radius: 5px;
  overflow: hidden;
  box-shadow: 0px 0px 20rpx 2px #f1f1f1;
}
.listBox .specialSubject-img {
  width: 100%;
  height: 120rpx;
}
.specialSubject-img image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.body-info {
  padding: 16rpx;
  font-size: 28rpx;
}
.body-info .name {
  font-size: 30rpx;
  height: 80rpx;
  color: #333333;
  font-weight: bold;
  line-height: 40rpx;
  display: -webkit-box;
  margin-bottom: 10rpx;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
}
.body-info .time {
  font-size: 26rpx;
  margin-bottom: 10rpx;
}
.body-info .author {
  font-size: 26rpx;
  display: flex;
  justify-content: space-between;
  display: -webkit-box;
  /* 使用弹性盒子布局模型 */
  -webkit-line-clamp: 1;
  /* 控制文本的行数 */
  -webkit-box-orient: vertical;
  /* 设置盒子的子元素排列方向 */
  overflow: hidden;
  /* 超出部分隐藏 */
  text-overflow: ellipsis;
  /* 超出部分显示省略号 */
  white-space: normal;
  flex: 1;
}
.body-info .price {
  font-size: 26rpx;
  color: #ff6d00;
}