闫增涛
2024-04-03 6d8464c9524c1c8550450615bc9c47fb298d424d
图书详情页、答题器bug修改
14个文件已修改
6个文件已添加
4674 ■■■■■ 已修改文件
packageBookService/pages/bookServices/detail/buyResource/index.js 434 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/detail/buyResource/index.wxml 26 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/detail/components/learnResource/learnResource.js 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/detail/components/learnResource/learnResource.wxml 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/detail/components/relatedBooks/index.js 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/detail/components/relatedBooks/index.json 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/detail/components/relatedBooks/index.wxml 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/detail/components/relatedBooks/index.wxss 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/detail/components/testResource/testResource.wxml 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/detail/components/tree/index.js 357 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/detail/components/tree/index.wxml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/detail/index.js 1499 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/detail/index.json 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/detail/index.wxml 267 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/examination/examination.js 1994 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/examination/questionList/index.wxml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/examination/questionOptions/index.wxml 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/examination/questionOptions/index.wxss 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
static/images/bookService/detail/link-click.png 补丁 | 查看 | 原始文档 | blame | 历史
static/images/bookService/detail/link.png 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/detail/buyResource/index.js
@@ -1,111 +1,102 @@
// packageBookService/pages/bookServices/detail/buyResource/index.js
const app = getApp()
const app = getApp();
Page({
  /**
   * 页面的初始数据
   */
  data: {
    barHeight: '',
    navBarHeight: '',
    barHeight: "",
    navBarHeight: "",
    learn: [],
    openLearnids: [],
    bookId: '',
    bookId: "",
    loading: false,
    shoppingList: [],
    shoppingCartGetId: [],
    methodId: [],
    paymentPage: false,
    superior: false
    superior: false,
    checkAllState: false,
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    const systInfo = wx.getSystemInfoSync();
    const menu = wx.getMenuButtonBoundingClientRect(); // 胶囊信息
    const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度
    const navBarHeight =
      (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度
    this.setData({
      barHeight: systInfo.statusBarHeight,
      navBarHeight: navBarHeight,
      bookId: options.bookId
      bookId: options.bookId,
    });
    this.getResourceClass()
    this.getResourceClass();
    console.log(options);
    this.getResourceData({
      productLinkPath: options.productLinkPath,
      refCode: options.refCode
    })
    this.getShoppingCartProductGet()
    this.getBookInfo(options.bookId)
      refCode: options.refCode,
    });
    this.getShoppingCartProductGet();
    this.getBookInfo(options.bookId);
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
  },
  onReady() {},
  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
  },
  onShow() {},
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {
  },
  onHide() {},
  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {
  },
  onUnload() {},
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {
  },
  onPullDownRefresh() {},
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
  },
  onReachBottom() {},
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {
  onShareAppMessage() {},
  changeCheckAll(e) {
    this.setData({
      checkAllState: e.detail.value,
    });
  },
  goBack() {
    wx.navigateBack()
    wx.navigateBack();
  },
  //  获取教学资源  云学习  云测试
  getResourceData(type) {
    this.setData({
      loading: true,
      noResources: false
    })
      noResources: false,
    });
    let query = {
      path: '*',
      queryType: '*',
      path: "*",
      queryType: "*",
      productId: this.data.bookId,
      cmsPath: type.productLinkPath,
      itemFields: {
        SysType: 'CmsFolder',
        SysType: "CmsFolder",
        // 资源类型,试读文件,是否允许下载等参数
        selectType: [],
        freeFile: [],
@@ -114,88 +105,90 @@
        isDownload: [],
        jsek_resourceBrief: [],
        jsek_link: [],
        jsek_questionBank: []
        jsek_questionBank: [],
      },
      pading: {
        start: 0,
        size: 999
        size: 999,
      },
    }
    };
    app.MG.store
      .getProductDetail(query)
      .then(async (res) => {
        if (!res.datas.cmsDatas[0].datas.length) {
          return this.setData({
            noResources: true,
            loading: false
          })
            loading: false,
          });
        }
        //教学资源 云学习
        if (type.refCode == 'jsek_teachingResources' || type.refCode == 'jsek_cloudLearning') {
        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.checkAll = true
            })
            const list = await this.getAllResource(res.datas.cmsDatas[0].datas)
            if (type.refCode == 'jsek_teachingResources') {
            res.datas.cmsDatas[0].datas.forEach((item) => {
              (item.checked = false), (item.checkAll = true);
            });
            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') {
              const result = []
              res.datas.cmsDatas[0].datas.forEach(item => {
                item.checked = false
              })
              this.findChildIds(list, result)
                loading: false,
              });
              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;
              });
              this.findChildIds(list, result);
              this.setData({
                learn: list,
                loading: false,
                openLearnids: result
              })
              console.log('教学资源', list);
                openLearnids: result,
              });
              console.log("教学资源", list);
            }
          } else {
            // 无数据
          }
        } else if (type.refCode == 'jsek_questionBank') {
        } 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
          })
            loading: false,
          });
        } else {
          console.log('其他');
          console.log("其他");
        }
      })
      .catch((e) => {
        console.log(e)
      })
        console.log(e);
      });
  },
  // 获取tag下所有资源
  async getAllResource(data) {
    if (!data.length) return false
    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)
      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
    return data;
  },
  // 获取资源接口
  async getFolderItem(path) {
    let query = {
      path: '*',
      queryType: '*',
      path: "*",
      queryType: "*",
      productId: this.data.bookId,
      cmsPath: path,
      itemFields: {
        SysType: 'CmsFolder',
        SysType: "CmsFolder",
        // 资源类型,试读文件,是否允许下载等参数
        selectType: [],
        freeFile: [],
@@ -205,52 +198,54 @@
        isDownload: [],
        jsek_resourceBrief: [],
        jsek_link: [],
        accessType: []
        accessType: [],
      },
      pading: {
        start: 0,
        size: 999
        size: 999,
      },
    }
    const data = await app.MG.store.getProductDetail(query)
    };
    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 (type.value == item.resourcesClassification)
          item.resourceClass = type.name;
      });
      // 网页 不能下载 私有文件
      if (item.sysType == 'CmsItem') {
        if (item.selectType == 'webpage') {
          item.disabled = true
      if (item.sysType == "CmsItem") {
        if (item.selectType == "webpage") {
          item.disabled = true;
        } else {
          if (item.isDownload != 1) {
            item.disabled = true
            item.disabled = true;
          }
        }
        if (item.file) {
          if (item.fileMap[item.file].protectType == 'Private') item.disabled = true
          if (item.fileMap[item.file].protectType == "Private")
            item.disabled = true;
        }
      }
    })
    data.datas.cmsDatas[0].datas.forEach(item => {
      item.checked = false
      item.isbuy = this.resourceIsBuy(item)
      item.isShopCar = this.isShoppingCart(item)
    })
    return data.datas.cmsDatas[0].datas
    });
    data.datas.cmsDatas[0].datas.forEach((item) => {
      item.checked = false;
      item.isbuy = this.resourceIsBuy(item);
      item.isShopCar = this.isShoppingCart(item);
    });
    return data.datas.cmsDatas[0].datas;
  },
  getBookInfo(id) {
    this.setData({
      "mockData'.id": 0,
      "mockData.price": 0,
      "mockData.count": 0
    })
      "mockData.count": 0,
    });
    const query = {
      path: '*',
      queryType: '*',
      path: "*",
      queryType: "*",
      productId: id,
      favoriteTypes: 'FavoriteBookCity',
      favoriteTypes: "FavoriteBookCity",
      itemFields: {
        'SysType=': 'CmsFolder',
        "SysType=": "CmsFolder",
      },
      coverSize: {
        height: 300,
@@ -279,10 +274,9 @@
    app.MG.store.getProductDetail(query).then(async (res) => {
      this.setData({
        bookDetail: res.datas,
        buyIdList: res.datas.purchasedSaleMethodIdList
        buyIdList: res.datas.purchasedSaleMethodIdList,
      });
    });
  },
  // 获取已购买商品
  getShoppingCartProductGet() {
@@ -290,181 +284,193 @@
      start: 0,
      size: 999,
      filterList: [],
      searchList: []
    }
      searchList: [],
    };
    app.MG.store.getShoppingCartProductList(query).then((res) => {
      const list = []
      const list = [];
      res.datas.forEach((item) => {
        list.push(item.saleMethod.id)
      })
        list.push(item.saleMethod.id);
      });
      this.setData({
        shoppingList: res.datas,
        shoppingCartGetId: list
      })
    })
        shoppingCartGetId: list,
      });
    });
  },
  // 判断资源是否购买
  resourceIsBuy(data) {
    if (data.saleMethod && data.saleMethod.length) {
      const isSHow = this.data.buyIdList.some((item) => item == data.saleMethod[0].Id)
      return !isSHow
      const isSHow = this.data.buyIdList.some(
        (item) => item == data.saleMethod[0].Id
      );
      return !isSHow;
    } else {
      return false
      return false;
    }
  },
  // 判断资源加入购物车按钮是否显示
  isShoppingCart(data) {
    if (data.saleMethod && data.saleMethod.length) {
      if (data.saleMethod[0].Price <= 0) return false
      if (data.saleMethod[0].Price <= 0) return false;
      // 再判断是否购买
      const isBuy = this.data.buyIdList.some((item) => item == data.saleMethod[0].Id)
      const isBuy = this.data.buyIdList.some(
        (item) => item == data.saleMethod[0].Id
      );
      if (isBuy) {
        // 购买了
        return false
        return false;
      } else {
        // 判断是否加入购物车
        const isSHow = this.data.shoppingCartGetId.some((item) => item == data.saleMethod[0].Id)
        return !isSHow
        const isSHow = this.data.shoppingCartGetId.some(
          (item) => item == data.saleMethod[0].Id
        );
        return !isSHow;
      }
    } else {
      return false
      return false;
    }
  },
  // 获取展开项
  findChildIds(data, result) {
    let index = 0
    let index = 0;
    for (let i = 0; i < data.length; i++) {
      if (index < 3) {
        const item = data[i]
        const item = data[i];
        if (item.children && item.children.length > 0) {
          result.push(item.id)
          result.push(item.id);
          for (let j = 0; j < item.children.length; j++) {
            if (index < 3) {
              const childrenItme = item.children[j]
              const childrenItme = item.children[j];
              if (item.children && item.children.length > 0) {
                result.push(childrenItme.id)
                index += 1
                result.push(childrenItme.id);
                index += 1;
              }
            } else {
              break
              break;
            }
          }
        } else if (item.children && item.children.length > 0) {
          result.push(item.id)
          index += 1
          result.push(item.id);
          index += 1;
        }
      } else {
        break
        break;
      }
    }
  },
  // 获取资源所属分类
  getResourceClass() {
    let query = {
      refCodes: ['resourcesClassification']
    }
      refCodes: ["resourcesClassification"],
    };
    app.MG.store.getProductTypeField(query).then((res) => {
      this.setData({
        resourceClassList: JSON.parse(res[0].config).option
      })
    })
        resourceClassList: JSON.parse(res[0].config).option,
      });
    });
  },
  checkAll() {
    const child = this.selectComponent('#tree')
    child.checkAll()
    const child = this.selectComponent("#tree");
    child.checkAll();
  },
  //购买按钮
  batchPurchase() {
    let saleMethodIds = [];
    let requests = [];
    let item = [];
    let selectAllId = [];
    const child = this.selectComponent("#tree");
    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.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
    item = child.data.superiorPurchaseSaleMethodId;
    const sonItem = child.data.sonPurchaseSaleMethodId;
    let selectAll = child.data.selectAll;
    if (selectAll) {
      // console.log(selectAll);
      selectAll.forEach(item => {
      selectAll.forEach((item) => {
        if (item.saleMethod != 0) {
          // console.log(item, 'item');
          selectAllId.push(item.saleMethod[0].Id)
          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: []
          })
        }
      })
      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');
      console.log(item, "sadsdasd");
      // 拿到id
      item.forEach(items => {
      item.forEach((items) => {
        if (items.saleMethod != 0) {
          saleMethodIds.push(items.saleMethod[0].Id)
          saleMethodIds.push(items.saleMethod[0].Id);
        }
      })
      console.log(saleMethodIds, 'saleMethodIds');
      });
      console.log(saleMethodIds, "saleMethodIds");
      app.MG.store.initOrder({
        requests: saleMethodIds.map(id => ({
          saleMethodId: id,
          count: 1,
        })),
      }).then(res => {
        if (res) {
          wx.navigateTo({
            url: '/pages/cart/paymentPage/index?orderNumber=' + res.orderNumber,
          })
      app.MG.store
        .initOrder({
          requests: saleMethodIds.map((id) => ({
            saleMethodId: id,
            count: 1,
          })),
        })
        .then((res) => {
          if (res) {
            wx.navigateTo({
              url:
                "/pages/cart/paymentPage/index?orderNumber=" + res.orderNumber,
            });
          child.setData({
            superiorPurchaseSaleMethodId: [] // 使用setData方法清空sonPurchaseSaleMethodId数据
          })
        }
      })
            child.setData({
              superiorPurchaseSaleMethodId: [], // 使用setData方法清空sonPurchaseSaleMethodId数据
            });
          }
        });
    }
    if (item.length == 0 && sonItem) {
      app.MG.store.initOrder({
        requests: sonItem.map(id => ({
          saleMethodId: id,
          count: 1,
        })),
      }).then(res => {
        if (res) {
          wx.navigateTo({
            url: '/pages/cart/paymentPage/index?orderNumber=' + res.orderNumber,
          })
          this.setData({
            paymentPage: true
          })
          child.setData({
            sonPurchaseSaleMethodId: [] // 使用setData方法清空sonPurchaseSaleMethodId数据
          })
        }
      })
      app.MG.store
        .initOrder({
          requests: sonItem.map((id) => ({
            saleMethodId: id,
            count: 1,
          })),
        })
        .then((res) => {
          if (res) {
            wx.navigateTo({
              url:
                "/pages/cart/paymentPage/index?orderNumber=" + res.orderNumber,
            });
            this.setData({
              paymentPage: true,
            });
            child.setData({
              sonPurchaseSaleMethodId: [], // 使用setData方法清空sonPurchaseSaleMethodId数据
            });
          }
        });
    }
  },
})
});
packageBookService/pages/bookServices/detail/buyResource/index.wxml
@@ -4,17 +4,31 @@
<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" />
      <t-icon
        name="chevron-left"
        size="30"
        data-name="{{item}}"
        bind:click="goBack"
      />
    </view>
    <view class="navbar-title">资源购买</view>
  </view>
  <view bind:tap="checkAll"> 全选 </view>
  <view bind:tap="checkAll"> {{checkAllState ? '取消' : '全选'}} </view>
</view>
<!-- 内容 -->
<view class="buy-resource" wx:if="{{!loading}}">
  <tree id="tree" paymentPage="{{paymentPage}}" superior="{{superior}}" treeList="{{learn}}" tab="{{'jsek_cloudLearning'}}" isShowCheck="{{true}}" openIds="{{openLearnids}}" />
  <tree
    id="tree"
    paymentPage="{{paymentPage}}"
    superior="{{superior}}"
    treeList="{{learn}}"
    tab="{{'jsek_cloudLearning'}}"
    isShowCheck="{{true}}"
    openIds="{{openLearnids}}"
    bind:changeCheckAll="changeCheckAll"
  />
</view>
<view class="noData" wx:if="{{loading}}">
@@ -22,5 +36,7 @@
</view>
<view class="page-bottom">
  <t-button theme="primary" size="large" class="btn-buy" bindtap="batchPurchase">批量购买</t-button>
</view>
  <t-button theme="primary" size="large" class="btn-buy" bindtap="batchPurchase"
    >批量购买</t-button
  >
</view>
packageBookService/pages/bookServices/detail/components/learnResource/learnResource.js
@@ -9,6 +9,9 @@
    },
    bookId: {
      type: Number
    },
    isshowDrawBtn:{
      type:Boolean
    }
  },
packageBookService/pages/bookServices/detail/components/learnResource/learnResource.wxml
@@ -1,6 +1,11 @@
<!--pages/bookServices/detail/components/learnResource/learnResource.wxml-->
<view class="learnResource" theme="primary">
<view
  class="learnResource"
  theme="primary"
  style="justify-content: {{!isshowDrawBtn ? 'flex-end' : ''}};"
>
  <t-button
    wx:if="{{isshowDrawBtn}}"
    loading="{{receive}}"
    class="btn"
    theme="primary"
@@ -19,6 +24,7 @@
    theme="primary"
    style="height: 72rpx; font-size: 28rpx"
    bind:tap="goBuyResource"
    style="margin: {{!isshowDrawBtn ? '0 30rpx' : ''}}"
  >
    <view slot="content" class="btn-content">
      <image src="/static/images/bookService/detail/yijiangoumai.png" />
packageBookService/pages/bookServices/detail/components/relatedBooks/index.js
New file
@@ -0,0 +1,22 @@
// packageBookService/pages/bookServices/detail/components/relatedBooks/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    relatedBookData: {
      type: Array,
      value:[]
    },
  },
  /**
   * 组件的初始数据
   */
  data: {},
  /**
   * 组件的方法列表
   */
  methods: {},
});
packageBookService/pages/bookServices/detail/components/relatedBooks/index.json
New file
@@ -0,0 +1,4 @@
{
  "component": true,
  "usingComponents": {}
}
packageBookService/pages/bookServices/detail/components/relatedBooks/index.wxml
New file
@@ -0,0 +1,8 @@
<!--packageBookService/pages/bookServices/detail/components/relatedBooks/index.wxml-->
<view class="reletedBooks">
  <!-- <view wx:for="{{relatedBookData}}" wx:key="id" class="book-box">
    <image src="{{item.icon}}" />
    <text>{{item.name}}</text>
  </view> -->
  相关图书
</view>
packageBookService/pages/bookServices/detail/components/relatedBooks/index.wxss
New file
@@ -0,0 +1 @@
/* packageBookService/pages/bookServices/detail/components/relatedBooks/index.wxss */
packageBookService/pages/bookServices/detail/components/testResource/testResource.wxml
@@ -66,12 +66,14 @@
    wx:for="{{list}}"
    wx:key="id"
    wx:if="{{radioItem == 'test'}}"
    bind:tap="goTest"
    data-value="{{item}}"
  >
    <view class="list-title">
      <image src="/static/images/bookService/detail/test-icon.png"></image>
      <text>{{item.name}}</text>
    </view>
    <view class="practice" bind:tap="goTest" data-value="{{item}}">
    <view class="practice">
      <image src="/static/images/bookService/detail/lianxi-icon.png"></image>
    </view>
  </view>
packageBookService/pages/bookServices/detail/components/tree/index.js
@@ -1,31 +1,29 @@
const util = require('./components/util') // 引入封装过的加载提示
import {
  loginInfo
} from '../../../../../../assets/js/login'
const app = getApp()
const util = require("./components/util"); // 引入封装过的加载提示
import { loginInfo } from "../../../../../../assets/js/login";
const app = getApp();
Component({
  // checked: false,
  properties: {
    treeList: {
      type: Array,
      value: []
      value: [],
    },
    bookInfo: {
      type: Object,
      value: {}
      value: {},
    },
    buyIds: {
      type: Array,
      value: []
      value: [],
    },
    tab: {
      type: String,
      value: ''
      value: "",
    },
    applyState: {
      type: String,
      value: ''
      value: "",
    },
    openIds: {
      type: Array,
@@ -42,33 +40,34 @@
    superior: {
      type: Boolean,
      value: false,
    }
    },
  },
  data: {
    sonPurchaseSaleMethodId: '',
    sonPurchaseSaleMethodId: "",
    superiorPurchaseSaleMethodId: [],
    activeValues: [1, 2],
    webpageSrc: '',
    webpageSrc: "",
    cloudShoppingCart: [],
    selectAll: [],
    shoppingCart: true,
    stop: false,
  },
  ready() {
    this.setData({
    })
    console.log('准备');
    this.setData({});
    console.log("准备");
  },
  onLoad() {
    this.setData({
      sonPurchaseSaleMethodId: []
    })
    console.log(this.data.sonPurchaseSaleMethodId, 'sonPurchaseSaleMethodId789');
      sonPurchaseSaleMethodId: [],
    });
    console.log(
      this.data.sonPurchaseSaleMethodId,
      "sonPurchaseSaleMethodId789"
    );
  },
  observers: {
    'openIds': function (newValue) {
    openIds: function (newValue) {
      // var myEventDetail = {
      // }
      // var myEventOption = {
@@ -76,18 +75,17 @@
      //   composed: true
      // }
      // this.triggerEvent('handleTree', myEventDetail, myEventOption)
    }
    },
  },
  methods: {
    handleList(tree) {
      for (let index = 0; index < tree.length; index++) {
        const item = tree[index];
        if (item.sysType == 'CmsItem' && !item.checked) {
        if (item.sysType == "CmsItem" && !item.checked) {
        }
        if (item.children && item.children.length > 0) {
          this.handleList(item.children)
          this.handleList(item.children);
        }
      }
    },
@@ -100,38 +98,39 @@
    handleCheck(data) {
      for (let index = 0; index < data.length; index++) {
        const element = data[index];
        element.checked = true
        element.checked = true;
        if (element.childrenCount && element.type == "productFolder") {
          handleCheck(element.children)
          handleCheck(element.children);
        }
      }
    },
    downloadTeach(e) {
      const value = e.currentTarget.dataset.value
      const value = e.currentTarget.dataset.value;
      var myEventDetail = {
        value,
      } // detail对象,提供给事件监听函数
      }; // detail对象,提供给事件监听函数
      var myEventOption = {
        bubbles: true,
        composed: true
      } // 触发事件的选项
      this.triggerEvent('downloadTeach', myEventDetail, myEventOption)
        composed: true,
      }; // 触发事件的选项
      this.triggerEvent("downloadTeach", myEventDetail, myEventOption);
    },
    // 判断资源是否购买
    resourceIsBuy(data) {
      if (data.saleMethod && data.saleMethod.length) {
        if (data.saleMethod[0].State == 'Disable') return false
        const isSHow = this.properties.buyIds.some((item) => item == data.saleMethod[0].Id)
        return !isSHow
        if (data.saleMethod[0].State == "Disable") return false;
        const isSHow = this.properties.buyIds.some(
          (item) => item == data.saleMethod[0].Id
        );
        return !isSHow;
      } else {
        return false
        return false;
      }
    },
    // 跳转音视频播放器
    goPlayer(e) {
      // 检查登录状态
      const token = wx.getStorageSync(app.config.tokenKey)
      const token = wx.getStorageSync(app.config.tokenKey);
      if (!token) {
        loginInfo(app, (data) => {
          // 如果不是第一次登录,会执行回调
@@ -140,68 +139,72 @@
          } else {
            // 出现错误,返回false
          }
        })
        });
      } else {
        const item = e.currentTarget.dataset.item
        const parent = e.currentTarget.dataset.parent
        let url
        const item = e.currentTarget.dataset.item;
        const parent = e.currentTarget.dataset.parent;
        let url;
        if (this.properties.isShowCheck && this.resourceIsBuy(item)) {
          return wx.showToast({
            icon: 'error',
            title: "请先购买资源"
          })
          return false;
        }
        if (item.selectType == 'video' || item.learnSelectType == 'video') {
          url = '/packageDomain/pages/resourceDetails/myVideo/index'
        } else if (item.selectType == 'audio' || item.learnSelectType == 'audio') {
          url = '/packageDomain/pages/resourceDetails/myAudio/index'
        } else if (item.selectType == 'picture' || item.selectType == 'zip') {
          url = '/packageDomain/pages/resourceDetails/document/index'
        if (item.selectType == "video" || item.learnSelectType == "video") {
          url = "/packageDomain/pages/resourceDetails/myVideo/index";
        } else if (
          item.selectType == "audio" ||
          item.learnSelectType == "audio"
        ) {
          url = "/packageDomain/pages/resourceDetails/myAudio/index";
        } else if (item.selectType == "picture" || item.selectType == "zip") {
          url = "/packageDomain/pages/resourceDetails/document/index";
        }
        if (this.properties.tab == 'jsek_cloudLearning' && this.resourceIsBuy(item)) {
        if (
          this.properties.tab == "jsek_cloudLearning" &&
          this.resourceIsBuy(item)
        ) {
          return wx.showToast({
            icon: 'error',
            title: '请先购买该资源',
          })
            icon: "error",
            title: "请先购买该资源",
          });
        }
        wx.navigateTo({
          url: `${url}?productLinkPath=${item.productLinkPath}&parentProductLinkPath=${parent.productLinkPath}&parentName=${parent.name}&activeId=${item.id}&bookId=${this.properties.bookInfo.id}&bookName=${this.properties.bookInfo.name}&cmsId=${this.properties.bookInfo.rootCmsItemId}`,
        })
        if (item.selectType == 'document' || item.selectType == 'pdf') {
          const fileLink = app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.file
          console.log(fileLink, 'fileLink');
        });
        if (item.selectType == "document" || item.selectType == "pdf") {
          const fileLink =
            app.config.requestCtx + "/file/api/ApiDownload?md5=" + item.file;
          console.log(fileLink, "fileLink");
          //提示加载中
          util.showLoading()
          util.showLoading();
          // 单次下载允许的最大文件为 200MB
          wx.downloadFile({
            url: fileLink, // 地址已打码,自己换个其他的地址("https://www.xxxxx.com/file/测试通知.pdf")
            success: function (res) {
              console.log(res, "wx.downloadFile success res")
              console.log(res, "wx.downloadFile success res");
              if (res.statusCode != 200) {
                util.hideLoadingWithErrorTips()
                return false
                util.hideLoadingWithErrorTips();
                return false;
              }
              var Path = res.tempFilePath //返回的文件临时地址,用于后面打开本地预览所用
              var Path = res.tempFilePath; //返回的文件临时地址,用于后面打开本地预览所用
              wx.openDocument({
                filePath: Path,
                showMenu: true,
                success: function (res) {
                  console.log('打开成功');
                  util.hideLoading()
                }
              })
                  console.log("打开成功");
                  util.hideLoading();
                },
              });
            },
            fail: function (err) {
              console.log(err, "wx.downloadFile fail err");
              util.hideLoadingWithErrorTips()
            }
          })
              util.hideLoadingWithErrorTips();
            },
          });
        }
        if (item.selectType == 'webpage') {
        if (item.selectType == "webpage") {
          this.setData({
            webpageSrc: item.jsek_link
          })
          console.log(this.data.webpageSrc, 'webpageSrc');
            webpageSrc: item.jsek_link,
          });
          console.log(this.data.webpageSrc, "webpageSrc");
        }
      }
    },
@@ -212,13 +215,13 @@
      function findChildren(item) {
        if (item.id === id) {
          if (item.children && item.children.length > 0) {
            item.children.forEach(child => {
            item.children.forEach((child) => {
              findChildren(child);
            });
          }
        } else {
          if (item.children && item.children.length > 0) {
            item.children.forEach(child => {
            item.children.forEach((child) => {
              findChildren(child);
            });
          }
@@ -227,8 +230,8 @@
          result.push(...item.children);
        }
      }
      console.log(this.properties.treeList, 'this.properties.treeList');
      this.properties.treeList.forEach(item => {
      console.log(this.properties.treeList, "this.properties.treeList");
      this.properties.treeList.forEach((item) => {
        findChildren(item);
      });
      return result;
@@ -240,16 +243,16 @@
      function flatten(node) {
        result.push(node);
        if (node.children && node.children.length > 0) {
          node.children.forEach(child => {
          node.children.forEach((child) => {
            flatten(child);
          });
        }
      }
      tree.forEach(node => {
      tree.forEach((node) => {
        flatten(node);
      });
      // console.log(result, 'result');
      return result
      return result;
    },
    // 变为true
@@ -257,7 +260,7 @@
      function findAndUpdate(node) {
        if (ids.includes(node.id)) {
          // console.log(node, 'node');
          node.checked = state // 将目标项的 check 属性设置为 true
          node.checked = state; // 将目标项的 check 属性设置为 true
        }
        if (node.children && node.children.length > 0) {
          for (let child of node.children) {
@@ -274,13 +277,13 @@
    checkResoucrceInfo(tree, id) {
      function findAndUpdate(node) {
        if (node.sysType == 'CmsFolder' && node.children.length > 0) {
        if (node.sysType == "CmsFolder" && node.children.length > 0) {
          for (let index = 0; index < node.children.length; index++) {
            const element = node.children[index];
            findAndUpdate(element)
            findAndUpdate(element);
          }
        } else if (id == node.id && node.sysType == "CmsItem") {
          node.checked = !node.checked // 将目标项的 check 属性设置为 true
          node.checked = !node.checked; // 将目标项的 check 属性设置为 true
        }
      }
      for (let node of tree) {
@@ -290,142 +293,162 @@
    },
    // 全选
    checkAll() {
      const ids = []
      const list = []
      let checked = ''
      this.properties.treeList.forEach(item => {
      const ids = [];
      const list = [];
      let checked = "";
      this.properties.treeList.forEach((item) => {
        if (item.children && item.children.length > 0) {
          list.push(...this.flattenTree([item]))
          list.push(...this.flattenTree([item]));
        }
      })
      list.forEach(item => {
        ids.push(item.id)
        checked = item.checked
      })
      const flag = list.findIndex(item => item.checked == false) > -1 ? true : false
      const updataList = this.findAndUpdateItemsByIds(this.properties.treeList, ids, flag);
      console.log(checked, 'list');
      });
      list.forEach((item) => {
        ids.push(item.id);
        checked = item.checked;
      });
      const flag =
        list.findIndex((item) => item.checked == false) > -1 ? true : false;
        var myEventDetail = {
          value:flag,
        }; // detail对象,提供给事件监听函数
        var myEventOption = {
          bubbles: true,
          composed: true,
        }; // 触发事件的选项
        this.triggerEvent('changeCheckAll',myEventDetail,myEventOption)
      const updataList = this.findAndUpdateItemsByIds(
        this.properties.treeList,
        ids,
        flag
      );
      console.log(checked, "list");
      if (!checked) {
        this.setData({
          selectAll: list
        })
          selectAll: list,
        });
      }
      this.setData({
        treeList: updataList
      })
        treeList: updataList,
      });
    },
    // 章节勾选
    checkResourceTitle(e) {
      const flag = e.detail.checked
      debugger
      const flag = e.detail.checked;
      debugger;
      // 这个时候checked的值是fals
      let checkResourceTitleList = []
      const item = e.currentTarget.dataset.item
      let checkResourceTitleList = [];
      const item = e.currentTarget.dataset.item;
      //
      let list = this.flattenTree([item])
      let ids = []
      list.forEach(item => {
        ids.push(item.id)
      })
      // console.log(list, 'list789');
      const updatedTreeList = this.findAndUpdateItemsByIds(this.properties.treeList, ids, flag);
      this.setData({
        treeList: updatedTreeList // 更新 treeList 数据
      let list = this.flattenTree([item]);
      let ids = [];
      list.forEach((item) => {
        ids.push(item.id);
      });
      console.log(list, 'list.checked');
      // console.log(list, 'list789');
      const updatedTreeList = this.findAndUpdateItemsByIds(
        this.properties.treeList,
        ids,
        flag
      );
      this.setData({
        treeList: updatedTreeList, // 更新 treeList 数据
      });
      console.log(list, "list.checked");
      if (!list.checked) {
        this.setData({
          superiorPurchaseSaleMethodId: list
        })
          superiorPurchaseSaleMethodId: list,
        });
      }
      // console.log(this.data.superiorPurchaseSaleMethodId, 'superiorPurchaseSaleMethodId');
      list.forEach(items => {
        console.log(items.checked, 'itesasd');
      list.forEach((items) => {
        console.log(items.checked, "itesasd");
        if (!items.checked) {
          this.setData({
            cloudShoppingCart: items
          })
            cloudShoppingCart: items,
          });
        }
      })
      });
      this.setData({
        openIds: this.data.openIds
      })
        openIds: this.data.openIds,
      });
    },
    // 子项勾选
    checkResource(e) {
      const citem = e.currentTarget.dataset.item
      console.log(citem, '5648');
      const updataList = this.checkResoucrceInfo(this.properties.treeList, citem.id)
      console.log(citem.checked, 'citem.checked');
      const citem = e.currentTarget.dataset.item;
      console.log(citem, "5648");
      const updataList = this.checkResoucrceInfo(
        this.properties.treeList,
        citem.id
      );
      console.log(citem.checked, "citem.checked");
      if (!citem.checked) {
        //选中的时候添加id
        let sonPurchaseSaleMethodId = this.data.sonPurchaseSaleMethodId || []
        console.log(this.properties.paymentPage, 'this.properties.paymentPage');
        let sonPurchaseSaleMethodId = this.data.sonPurchaseSaleMethodId || [];
        console.log(this.properties.paymentPage, "this.properties.paymentPage");
        if (this.properties.paymentPage) {
          console.log(789987);
          sonPurchaseSaleMethodId = []
          this.properties.paymentPage = false
          sonPurchaseSaleMethodId = [];
          this.properties.paymentPage = false;
        }
        if (!this.properties.paymentPage) {
          sonPurchaseSaleMethodId.push(citem.saleMethod[0].Id)
          sonPurchaseSaleMethodId.push(citem.saleMethod[0].Id);
        }
        this.setData({
          sonPurchaseSaleMethodId: sonPurchaseSaleMethodId
        })
          sonPurchaseSaleMethodId: sonPurchaseSaleMethodId,
        });
        console.log(this.data.sonPurchaseSaleMethodId);
      } else {
        // 取消选中的时候删除id
      }
      this.setData({
        treeList: updataList,
      })
      });
    },
    // 加入购物车
    async onCloudShoppingCart(e) {
      let shoppingCartGetId = []
      const saleMethodId = e.currentTarget.dataset.item.saleMethod[0].Id
      let shoppingCartGetId = [];
      const saleMethodId = e.currentTarget.dataset.item.saleMethod[0].Id;
      console.log(saleMethodId);
      let query = {
        start: 0,
        size: 999,
        filterList: [],
        searchList: []
      }
        searchList: [],
      };
      const res = await app.MG.store.getShoppingCartProductList(query)
      res.datas.forEach(item => {
        shoppingCartGetId.push(item.saleMethod.id)
      })
      const res = await app.MG.store.getShoppingCartProductList(query);
      res.datas.forEach((item) => {
        shoppingCartGetId.push(item.saleMethod.id);
      });
      if (shoppingCartGetId.includes(saleMethodId)) {
        console.log(111);
        wx.showToast({
          icon: 'error',
          title: '已添加',
        })
          icon: "error",
          title: "已添加",
        });
        this.setData({
          shoppingCart: false
        })
          shoppingCart: false,
        });
      } else {
        let query = {
          requests: [{
            saleMethodId: saleMethodId,
            storeEventId: null,
            // agentCode: '电子书'
          }]
        }
        const addRes = await app.MG.store.addShoppingCart(query)
        console.log(addRes, 'addRes');
          requests: [
            {
              saleMethodId: saleMethodId,
              storeEventId: null,
              // agentCode: '电子书'
            },
          ],
        };
        const addRes = await app.MG.store.addShoppingCart(query);
        console.log(addRes, "addRes");
        wx.showToast({
          icon: 'success',
          title: '添加成功',
        })
          icon: "success",
          title: "添加成功",
        });
      }
    },
  },
  catchtap() {}
})
  catchtap() {},
});
packageBookService/pages/bookServices/detail/components/tree/index.wxml
@@ -132,12 +132,12 @@
                wx:if="{{tab == 'jsek_teachingResources'}}"
              >
                <!--  下载按钮 -->
                <image
                <!-- <image
                  src="/static/images/bookService/detail/download-icon.png"
                  class="download-image"
                  data-value="{{citem}}"
                  catchtap="downloadTeach"
                ></image>
                ></image> -->
              </view>
              <view wx:if="{{tab == 'jsek_cloudLearning'}}">
                <!-- 云学习试看图标 -->
packageBookService/pages/bookServices/detail/index.js
@@ -1,31 +1,29 @@
// pages/bookServices/detail/index.js
import Toast from 'tdesign-miniprogram/toast';
import tool from '../../../../assets/js/toolClass';
import {
  loginInfo
} from '../../../../assets/js/login'
import Toast from "tdesign-miniprogram/toast";
import tool from "../../../../assets/js/toolClass";
import { loginInfo } from "../../../../assets/js/login";
const app = getApp();
Page({
  /**
   * 页面的初始数据
   */
  data: {
    bookId: '',
    barHeight: '',
    navBarHeight: '',
    bookId: "",
    barHeight: "",
    navBarHeight: "",
    options: {
      id: '',
      name: '',
      id: "",
      name: "",
    },
    bookDetail: {},
    bookItemDetail: {},
    link: {
      jd: '',
      tamll: '',
      dang: '',
      micro: '',
      jd: "",
      tamll: "",
      dang: "",
      micro: "",
    },
    tabValue: 'brief',
    tabValue: "brief",
    cmsDatas: [], // 资源refCode列表
    ids: [1],
    list: [],
@@ -39,7 +37,8 @@
    applyResourceState: false, // 申请教学资源按钮防抖
    resourceClassList: [], // 资源所属分类
    applyState: "", // 教学资源申请状态
    deadline: "", // 教学资源申请有效日期
    deadline: "", // 教学资源申请有效日期,
    isshowDrawBtn: true, // 云学习领取查看按钮是否显示
    rejectCause: "", // 下载拒绝原因
    buyIdList: [],
    shoppingCartGetId: [], // 已购买id列表
@@ -47,8 +46,8 @@
    loading: false,
    isShowTeachDownload: false, // 提示PC下载弹窗状态
    confirmBtn: {
      content: '我知道了',
      variant: 'base'
      content: "我知道了",
      variant: "base",
    },
    mockData: {
      id: 0, // 销售id
@@ -56,8 +55,10 @@
      count: 0, // 组卷已购买次数
      useCount: 0, // 组件已使用次数
      residue: 0, // 组卷剩余次数
      mockList: [] // 用户组卷提交信息
      mockList: [], // 用户组卷提交信息
    },
    relatedBookPath: "", // 相关图书path
    relatedBookData: [], // 相关图书列表
    flag: true,
    noResources: false,
    selectedIds: "", //商品或子商品销售方式
@@ -77,65 +78,69 @@
      bookName: "",
      fileType: "",
      md5: "",
      freePage: ""
      freePage: "",
    }, //阅读器数据
    buyResourceData: {
      productLinkPath: '',
      refCode: '',
      productLinkPath: "",
      refCode: "",
    },
    briefIcon: {
      name: "/static/images/bookService/detail/tushujianjie-g.png"
      name: "/static/images/bookService/detail/tushujianjie-g.png",
    },
    briefIconClick: {
      name: '/static/images/bookService/detail/tushujianjie-click.png'
      name: "/static/images/bookService/detail/tushujianjie-click.png",
    },
    eBookIcon: {
      name: '/static/images/bookService/detail/ebook-g.png'
      name: "/static/images/bookService/detail/ebook-g.png",
    },
    eBookClickIcon: {
      name: '/static/images/bookService/detail/ebook-click.png'
      name: "/static/images/bookService/detail/ebook-click.png",
    },
    teachResourcesIcon: {
      name: '/static/images/bookService/detail/jiaoxueziyuan.png'
      name: "/static/images/bookService/detail/jiaoxueziyuan.png",
    },
    teachResourcesClickIcon: {
      name: '/static/images/bookService/detail/jiaoxueziyuan-click.png'
      name: "/static/images/bookService/detail/jiaoxueziyuan-click.png",
    },
    learnResourceIcon: {
      name: '/static/images/bookService/detail/yunxuexi.png'
      name: "/static/images/bookService/detail/yunxuexi.png",
    },
    learnResourceClickIcon: {
      name: '/static/images/bookService/detail/yunxuexi-click.png'
      name: "/static/images/bookService/detail/yunxuexi-click.png",
    },
    testResourceIocn: {
      name: '/static/images/bookService/detail/test-icon-g.png'
      name: "/static/images/bookService/detail/test-icon-g.png",
    },
    testResourceClickIocn: {
      name: '/static/images/bookService/detail/test-click-icon.png'
      name: "/static/images/bookService/detail/test-click-icon.png",
    },
    noteIcon: {
      name: '/static/images/bookService/detail/biji-icon-g.png'
      name: "/static/images/bookService/detail/biji-icon-g.png",
    },
    noteClickIcon: {
      name: '/static/images/bookService/detail/biji-click-icon.png'
      name: "/static/images/bookService/detail/biji-click-icon.png",
    },
    linkIcon: {
      name: "/static/images/bookService/detail/link.png",
    },
    linkClickIcon: {
      name: "/static/images/bookService/detail/link-click.png",
    },
    icon1: {
      name: "/static/images/bookService/detail/dangdang.png"
    }
      name: "/static/images/bookService/detail/dangdang.png",
    },
  },
  resetTree: function (e) {
    this.setData({
      currentCheck: e.detail.checkedItem,
      list: e.detail.changeList
    })
      list: e.detail.changeList,
    });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    // 检查登录状态
    // const token = wx.getStorageSync(app.config.tokenKey)
    // if (!token) {
@@ -153,7 +158,8 @@
    const systInfo = wx.getSystemInfoSync();
    const menu = wx.getMenuButtonBoundingClientRect(); // 胶囊信息
    const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度
    const navBarHeight =
      (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度
    this.setData({
      bookId: options.id,
      barHeight: systInfo.statusBarHeight,
@@ -167,32 +173,29 @@
    });
    this.getBookInfo(options.id);
    this.getResourceClass() // 获取资源所属分类
    const token = wx.getStorageSync(app.config.tokenKey)
    this.getResourceClass(); // 获取资源所属分类
    const token = wx.getStorageSync(app.config.tokenKey);
    if (token) {
      this.getShoppingCartProductGet()
      this.getApplyInfo(options.id)
      this.getMockData()
      this.getAlreadyPBookList()
      this.getAlreadyEBookList()
      this.getShoppingCartProductGet();
      this.getApplyInfo(options.id);
      this.getMockData();
      this.getAlreadyPBookList();
      this.getAlreadyEBookList();
    }
    if (wx.getStorageSync(app.config.userInfoKey)) {
      this.setData({
        userInfo: JSON.parse(wx.getStorageSync(app.config.userInfoKey))
      })
        userInfo: JSON.parse(wx.getStorageSync(app.config.userInfoKey)),
      });
      // 获取申请次数
      this.getSelectPaperBookCount()
      this.getSelectBookCount()
      this.getSelectPaperBookCount();
      this.getSelectBookCount();
    }
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
  },
  onReady() {},
  /**
   * 生命周期函数--监听页面显示
@@ -201,16 +204,16 @@
    if (wx.getStorageSync("paperBookList")) {
      this.setData({
        paperBookList: wx.getStorageSync("paperBookList"),
      })
      });
    }
    if (wx.getStorageSync("electronicBookList")) {
      this.setData({
        electronicBookList: wx.getStorageSync("electronicBookList"),
      })
      });
    }
    this.setData({
      num: this.data.paperBookList.length + this.data.electronicBookList.length
    })
      num: this.data.paperBookList.length + this.data.electronicBookList.length,
    });
  },
  /**
@@ -226,18 +229,15 @@
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {
  },
  onPullDownRefresh() {},
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
    if (this.data.tabValue == 'jsek_note') {
      const child = this.selectComponent('#note')
      child.onReachBottom()
    if (this.data.tabValue == "jsek_note") {
      const child = this.selectComponent("#note");
      child.onReachBottom();
    }
  },
@@ -248,11 +248,13 @@
  // 格式化日期
  formatDate(dateString) {
    if (!dateString) {
      return '';
      return "";
    }
    const match = dateString.match(/^(\d{4})\/(\d{1,2})\/(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/);
    const match = dateString.match(
      /^(\d{4})\/(\d{1,2})\/(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/
    );
    if (!match) {
      throw new Error('Invalid date format');
      throw new Error("Invalid date format");
    }
    const [, year, month, day, hours, minutes, seconds] = match;
@@ -262,11 +264,11 @@
      parseInt(day, 10),
      parseInt(hours, 10),
      parseInt(minutes, 10),
      parseInt(seconds, 10),
      parseInt(seconds, 10)
    );
    if (isNaN(date.getTime())) {
      throw new Error('Invalid date');
      throw new Error("Invalid date");
    }
    // 由于小程序环境可能不支持 Intl.DateTimeFormat,我们使用简化的格式化方法
@@ -275,17 +277,32 @@
  },
  // 简化的月份格式化函数,返回月份的中文表达
  formatMonth(month) {
    const months = ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'];
    const months = [
      "1月",
      "2月",
      "3月",
      "4月",
      "5月",
      "6月",
      "7月",
      "8月",
      "9月",
      "10月",
      "11月",
      "12月",
    ];
    return months[parseInt(month, 10) - 1];
  },
  // 金额显示.00格式
  numFormat(value) {
    if (!value) return '0.00';
    if (!value) return "0.00";
    value = Number(value).toFixed(2);
    var intPart = Math.trunc(value); // 获取整数部分
    var intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,'); // 将整数部分逢三一断
    var floatPart = '.00'; // 预定义小数部分
    var value2Array = value.split('.');
    var intPartFormat = intPart
      .toString()
      .replace(/(\d)(?=(?:\d{3})+$)/g, "$1,"); // 将整数部分逢三一断
    var floatPart = ".00"; // 预定义小数部分
    var value2Array = value.split(".");
    // =2表示数据有小数位
    if (value2Array.length === 2) {
      floatPart = value2Array[1].toString(); // 拿到小数部分
@@ -306,14 +323,14 @@
      "mockData'.id": 0,
      "mockData.price": 0,
      "mockData.count": 0,
    })
    });
    const query = {
      path: '*',
      queryType: '*',
      path: "*",
      queryType: "*",
      productId: id,
      favoriteTypes: 'FavoriteBookCity',
      favoriteTypes: "FavoriteBookCity",
      itemFields: {
        'SysType=': 'CmsFolder',
        "SysType=": "CmsFolder",
      },
      coverSize: {
        height: 300,
@@ -345,62 +362,73 @@
      this.setData({
        bookDetail: res.datas,
        cmsDatas: res.datas.cmsDatas[0].datas,
        buyIdList: res.datas.purchasedSaleMethodIdList
        buyIdList: res.datas.purchasedSaleMethodIdList,
        relatedBookPath: JSON.parse(res.datas.datas.ProductLinkInfo)[0]
          .LinkPath,
      });
      this.getSubTtem();
      // 获取图书分类
      let className = ''
      if (Array.isArray(res.datas.bookClassification) && res.datas.bookClassification.length) {
      let className = "";
      if (
        Array.isArray(res.datas.bookClassification) &&
        res.datas.bookClassification.length
      ) {
        const iconType = JSON.parse(res.datas.bookClassification)[0][0];
        const classType = JSON.parse(res.datas.bookClassification)[0][1];
        className = await this.getBookClass(iconType, classType)
        className = await this.getBookClass(iconType, classType);
      }
      // 获取组卷销售id
      if (res.datas.saleMethod && res.datas.saleMethod.length) {
        res.datas.saleMethod.forEach((item) => {
          if (item.SaleType == 'combinationTestPaper') {
          if (item.SaleType == "combinationTestPaper") {
            this.setData({
              'mockData.id': item.Id,
              'mockData.price': item.Price
            })
              "mockData.id": item.Id,
              "mockData.price": item.Price,
            });
          }
        })
        });
      }
      // 获取组卷已购买次数
      if (res.datas.purchasedSaleMethodIdList && res.datas.purchasedSaleMethodIdList.length) {
      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
          ).length;
          this.setData({
            'mockData.count': count
          })
            "mockData.count": count,
          });
        }
      }
      this.setData({
        'bookDetail.publicationDate': this.formatDate(this.data.bookDetail.publicationDate),
        'bookDetail.class': className,
        'bookDetail.price': this.numFormat(this.data.bookDetail.price),
        'bookDetail.oldPrice': this.numFormat(this.data.bookDetail.oldPrice),
        'bookDetail.paperPrice': this.numFormat(this.data.bookDetail.paperPrice),
        pageLoading: false
        "bookDetail.publicationDate": this.formatDate(
          this.data.bookDetail.publicationDate
        ),
        "bookDetail.class": className,
        "bookDetail.price": this.numFormat(this.data.bookDetail.price),
        "bookDetail.oldPrice": this.numFormat(this.data.bookDetail.oldPrice),
        "bookDetail.paperPrice": this.numFormat(
          this.data.bookDetail.paperPrice
        ),
        pageLoading: false,
      });
      console.log('图书信息', this.data.bookDetail);
      console.log("图书信息", this.data.bookDetail);
    });
  },
  //请求子商品的文件
  getSubTtem() {
    const obj = {
      path: '*',
      queryType: 'SubProduct',
      path: "*",
      queryType: "SubProduct",
      sort: {
        type: 'Desc',
        field: 'CreateDate'
        type: "Desc",
        field: "CreateDate",
      },
      paging: {
        start: 0,
        size: 6
        size: 6,
      },
      mainProductId: this.data.bookDetail.id,
      fields: {
@@ -408,43 +436,51 @@
        bookshelf_pdf: [],
        bookshelf_protectedEpub: [],
        bookshelf_freeEpub: [], //epub试读百分比
        bookshelf_probationPage: [] //pdf试读页数
      }
    }
        bookshelf_probationPage: [], //pdf试读页数
      },
    };
    app.MG.store.getProductList(obj).then((res) => {
      if (res.datas && res.datas.length > 0) {
        this.setData({
          bookItemDetail: res.datas[0],
          selectedIds: res.datas[0].defaultSaleMethod.id,
          bookBuy: res.datas[0].purchasedSaleMethodIdList.indexOf(res.datas[0].defaultSaleMethodId) > -1
          bookBuy:
            res.datas[0].purchasedSaleMethodIdList.indexOf(
              res.datas[0].defaultSaleMethodId
            ) > -1,
        });
        let times = new Date(res.datas[0].defaultSaleMethod.endDate).getTime()
        let startTime = new Date(res.datas[0].defaultSaleMethod.beginDate).getTime()
        let times = new Date(res.datas[0].defaultSaleMethod.endDate).getTime();
        let startTime = new Date(
          res.datas[0].defaultSaleMethod.beginDate
        ).getTime();
        if (times < new Date().getTime() || new Date().getTime() < startTime) {
          this.setData({
            expire: true
            expire: true,
          });
        } else {
          this.setData({
            expire: false
            expire: false,
          });
        }
        if (res.datas[0].bookshelf_pdf || res.datas[0].bookshelf_protectedEpub) {
        if (
          res.datas[0].bookshelf_pdf ||
          res.datas[0].bookshelf_protectedEpub
        ) {
          this.setData({
            noFile: true
            noFile: true,
          });
          if (res.datas[0].bookshelf_pdf) {
            this.setData({
              "fileInfo.bookName": this.data.bookDetail.name,
              "fileInfo.fileType": 'pdf',
              "fileInfo.fileType": "pdf",
              "fileInfo.md5": res.datas[0].bookshelf_pdf,
              "fileInfo.freePage": res.datas[0].bookshelf_probationPage,
            });
          } else if (res.datas[0].bookshelf_protectedEpub) {
            this.setData({
              "fileInfo.bookName": this.data.bookDetail.name,
              "fileInfo.fileType": 'epub',
              "fileInfo.fileType": "epub",
              "fileInfo.md5": res.datas[0].bookshelf_protectedEpub,
              "fileInfo.freePage": res.datas[0].bookshelf_freeEpub,
            });
@@ -453,19 +489,19 @@
      } else {
        if (this.data.bookDetail.pdf || this.data.bookDetail.protectedEpub) {
          this.setData({
            noFile: true
            noFile: true,
          });
          if (this.data.bookDetail.pdf) {
            this.setData({
              "fileInfo.bookName": this.data.bookDetail.name,
              "fileInfo.fileType": 'pdf',
              "fileInfo.fileType": "pdf",
              "fileInfo.md5": this.data.bookDetail.pdf,
              "fileInfo.freePage": this.data.bookDetail.probationPage,
            });
          } else if (this.data.bookDetail.protectedEpub) {
            this.setData({
              "fileInfo.bookName": this.data.bookDetail.name,
              "fileInfo.fileType": 'epub',
              "fileInfo.fileType": "epub",
              "fileInfo.md5": this.data.bookDetail.protectedEpub,
              "fileInfo.freePage": this.data.bookDetail.freeEpubPage,
            });
@@ -473,27 +509,34 @@
        }
        this.setData({
          selectedIds: this.data.bookDetail.defaultSaleMethodId,
          bookBuy: this.data.bookDetail.purchasedSaleMethodIdList.indexOf(this.data.bookDetail.defaultSaleMethodId) > -1
          bookBuy:
            this.data.bookDetail.purchasedSaleMethodIdList.indexOf(
              this.data.bookDetail.defaultSaleMethodId
            ) > -1,
        });
        let times = new Date(this.data.bookDetail.defaultSaleMethod.endDate).getTime()
        let startTime = new Date(this.data.bookDetail.defaultSaleMethod.beginDate).getTime()
        let times = new Date(
          this.data.bookDetail.defaultSaleMethod.endDate
        ).getTime();
        let startTime = new Date(
          this.data.bookDetail.defaultSaleMethod.beginDate
        ).getTime();
        if (times < new Date().getTime() || new Date().getTime() < startTime) {
          this.setData({
            expire: true
            expire: true,
          });
        } else {
          this.setData({
            expire: false
            expire: false,
          });
        }
      }
    })
    });
  },
  // 获取图书分类
  async getBookClass(iconType, classType) {
    let name = '';
    let name = "";
    const query = {
      refCodes: ['bookClassification'],
      refCodes: ["bookClassification"],
    };
    await app.MG.store.getProductTypeField(query).then((res) => {
      JSON.parse(res[0].config).option.forEach((item) => {
@@ -510,140 +553,149 @@
  },
  // 收藏
  setCollect() {
    const token = wx.getStorageSync(app.config.tokenKey)
    const token = wx.getStorageSync(app.config.tokenKey);
    if (!token) {
      // 检查登录状态
      loginInfo(app, (data) => {
        // 如果不是第一次登录,会执行回调
        if (data) {
          // 登录成功,自动记录token和用户信息,并返回true
          this.getBookInfo(this.data.bookId)
          this.getBookInfo(this.data.bookId);
        } else {
          // 出现错误,返回false
        }
      })
      });
    } else {
      if (this.data.bookDetail.isFavourite) {
        app.MG.store
          .delProductLink({
            productIds: [this.data.bookDetail.id],
            linkType: 'FavoriteBookCity',
            linkType: "FavoriteBookCity",
          })
          .then(() => {
            this.setData({
              'bookDetail.isFavourite': false
            })
              "bookDetail.isFavourite": false,
            });
          });
      } else {
        const params = {
          productIds: [this.data.bookDetail.id],
          linkType: 'FavoriteBookCity',
          linkType: "FavoriteBookCity",
        };
        app.MG.store.addProductLink(params).then((res) => {
          this.setData({
            'bookDetail.isFavourite': true
          })
            "bookDetail.isFavourite": true,
          });
        });
      }
    }
  },
  // 我要建议
  suggestBtn() {
    // 检查登录状态
    const token = wx.getStorageSync(app.config.tokenKey)
    const child = this.selectComponent('#suggest-component')
    const token = wx.getStorageSync(app.config.tokenKey);
    const child = this.selectComponent("#suggest-component");
    if (!token) {
      wx.showLoading({
        title: '加载中',
      })
        title: "加载中",
      });
      loginInfo(app, (data) => {
        // 如果不是第一次登录,会执行回调
        if (data) {
          // 登录成功,自动记录token和用户信息,并返回true
          child.showDialog()
          wx.hideLoading()
          child.showDialog();
          wx.hideLoading();
        } else {
          // 出现错误,返回false
        }
      })
      });
    } else {
      // 如果是第一次登录,会跳转至绑定用户信息页面,填写完用户信息后进行登录并储存token和用户信息,结束后跳转回当前页面(携带页面参数)
      child.showDialog()
      child.showDialog();
    }
  },
  // 跳转网店
  goShop(e) {
    const {
      link
    } = e.currentTarget.dataset;
    const { link } = e.currentTarget.dataset;
    wx.navigateTo({
      url: `/packageBookService/pages/bookServices/webpage/index?url=${link}`,
    })
    });
  },
  // tag切换
  onTabsChange(e) {
    this.setData({
      tabValue: e.detail.value,
      noResources: false
    })
    if (e.detail.label == '教学资源' || e.detail.label == '云学习' || e.detail.label == '云测试') {
      const checkData = this.data.cmsDatas.find(item => item.refCode == e.detail.value)
      noResources: false,
    });
    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') {
        if (e.detail.value == "jsek_cloudLearning") {
          this.setData({
            'buyResourceData.productLinkPath': checkData.productLinkPath,
            'buyResourceData.refCode': checkData.refCode
          })
            "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)) {
          this.getResourceData(checkData)
        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)
        ) {
          this.getResourceData(checkData);
        }
      } else {
        this.setData({
          noResources: true
        })
          noResources: true,
        });
      }
    } else if (e.detail.label == '云笔记') {
      const token = wx.getStorageSync(app.config.tokenKey)
      const child = this.selectComponent('#note')
      child.handleSubmitTitle()
    } else if (e.detail.label == "云笔记") {
      const token = wx.getStorageSync(app.config.tokenKey);
      const child = this.selectComponent("#note");
      child.handleSubmitTitle();
      if (token) {
        child.changeLoading()
        child.getNoteList()
        child.changeLoading();
        child.getNoteList();
      }
    } else if (e.detail.label == '电子书') {
      const child = this.selectComponent('#eBook')
    } else if (e.detail.label == "电子书") {
      const child = this.selectComponent("#eBook");
      if (child) {
        child.getProgress()
        child.getProgress();
      }
    } else if (e.detail.label == "相关图书") {
      this.getAboutBook(this.data.relatedBookPath);
    }
  },
  // 获取资源所属分类
  getResourceClass() {
    let query = {
      refCodes: ['resourcesClassification']
    }
      refCodes: ["resourcesClassification"],
    };
    app.MG.store.getProductTypeField(query).then((res) => {
      this.setData({
        resourceClassList: JSON.parse(res[0].config).option
      })
    })
        resourceClassList: JSON.parse(res[0].config).option,
      });
    });
  },
  //  获取教学资源  云学习  云测试
  getResourceData(type) {
    this.setData({
      loading: true,
      noResources: false
    })
      noResources: false,
    });
    let query = {
      path: '*',
      queryType: '*',
      path: "*",
      queryType: "*",
      productId: this.data.bookDetail.id,
      cmsPath: type.productLinkPath,
      itemFields: {
        SysType: 'CmsFolder',
        SysType: "CmsFolder",
        // 资源类型,试读文件,是否允许下载等参数
        selectType: [],
        freeFile: [],
@@ -652,96 +704,106 @@
        isDownload: [],
        jsek_resourceBrief: [],
        jsek_link: [],
        jsek_questionBank: []
        jsek_questionBank: [],
      },
      pading: {
        start: 0,
        size: 999
        size: 999,
      },
    }
    };
    app.MG.store
      .getProductDetail(query)
      .then(async (res) => {
        if (!res.datas.cmsDatas[0].datas.length) {
          return this.setData({
            noResources: true,
            loading: false
          })
            loading: false,
          });
        }
        // 云测试,递归请求里层数据
        if (type.refCode == 'questionBank') {
        if (type.refCode == "questionBank") {
          const data = res.datas.cmsDatas[0].datas.filter(
            (item) => item.refCode == 'jsek_questionBank'
          )
          if (data.length) return this.getResourceData(data[0])
            (item) => item.refCode == "jsek_questionBank"
          );
          if (data.length) return this.getResourceData(data[0]);
        }
        //教学资源 云学习
        if (type.refCode == 'jsek_teachingResources' || type.refCode == 'jsek_cloudLearning') {
        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)
            let result = []
            if (type.refCode == 'jsek_teachingResources') {
              this.findChildIds(list, result)
            res.datas.cmsDatas[0].datas.forEach((item) => {
              item.checked = false;
            });
            const list = await this.getAllResource(res.datas.cmsDatas[0].datas);
            let result = [];
            if (type.refCode == "jsek_teachingResources") {
              console.log("教学资源", list);
              this.findChildIds(list, result);
              this.setData({
                teach: list,
                loading: false,
                openTeachids: result
              })
              console.log('教学资源', this.data.teach, this.data.applyState);
            } 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.findChildIds(list, result)
                openTeachids: result,
              });
            } else if (type.refCode == "jsek_cloudLearning") {
              let arr = this.handleTreeData(list).filter((item) =>
                this.resourceIsBuy(item)
              );
              let freeIds = arr.filter((item) => {
                return item.saleMethod[0].Price == 0;
              });
              if (!freeIds.length)
                this.setData({
                  isshowDrawBtn: false,
                });
              debugger;
              this.findChildIds(list, result);
              this.setData({
                learn: list,
                loading: false,
                openLearnids: result
              })
                openLearnids: result,
              });
            }
          } else {
            // 无数据
          }
        } else if (type.refCode == 'jsek_questionBank') {
        } 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
          })
            loading: false,
          });
        } else {
          console.log('其他');
          console.log("其他");
        }
      })
      .catch((e) => {
        console.log(e)
      })
        console.log(e);
      });
  },
  // 获取tag下所有资源
  async getAllResource(data) {
    if (!data.length) return false
    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)
      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
    return data;
  },
  // 获取资源接口
  async getFolderItem(path) {
    let query = {
      path: '*',
      queryType: '*',
      path: "*",
      queryType: "*",
      productId: this.data.bookDetail.id,
      cmsPath: path,
      itemFields: {
        SysType: 'CmsFolder',
        SysType: "CmsFolder",
        // 资源类型,试读文件,是否允许下载等参数
        selectType: [],
        freeFile: [],
@@ -752,68 +814,70 @@
        jsek_resourceBrief: [],
        jsek_link: [],
        accessType: [],
        learnSelectType: []
        learnSelectType: [],
      },
      pading: {
        start: 0,
        size: 999
        size: 999,
      },
    }
    const data = await app.MG.store.getProductDetail(query)
    };
    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 (type.value == item.resourcesClassification)
          item.resourceClass = type.name;
      });
      // 网页 不能下载 私有文件
      if (item.sysType == 'CmsItem') {
        if (item.selectType == 'webpage') {
          item.disabled = true
      if (item.sysType == "CmsItem") {
        if (item.selectType == "webpage") {
          item.disabled = true;
        } else {
          if (item.isDownload != 1) {
            item.disabled = true
            item.disabled = true;
          }
        }
        if (item.file) {
          if (item.fileMap[item.file].protectType == 'Private') item.disabled = true
          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)
    });
    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
    });
    return data.datas.cmsDatas[0].datas;
  },
  // 获取展开项
  findChildIds(data, result) {
    let index = 0
    let index = 0;
    for (let i = 0; i < data.length; i++) {
      if (index < 3) {
        const item = data[i]
        const item = data[i];
        if (item.children && item.children.length > 0) {
          result.push(item.id)
          result.push(item.id);
          for (let j = 0; j < item.children.length; j++) {
            if (index < 3) {
              const childrenItme = item.children[j]
              const childrenItme = item.children[j];
              if (item.children && item.children.length > 0) {
                result.push(childrenItme.id)
                index += 1
                result.push(childrenItme.id);
                index += 1;
              }
            } else {
              break
              break;
            }
          }
        } else if (item.children && item.children.length > 0) {
          result.push(item.id)
          index += 1
          result.push(item.id);
          index += 1;
        }
      } else {
        break
        break;
      }
    }
  },
@@ -821,281 +885,279 @@
  // 图书添加购物车
  async addBookShopcCar() {
    if (!this.data.expire) {
      const shoppingCartGetId = []
      const shoppingCartGetId = [];
      let query = {
        start: 0,
        size: 9999,
        filterList: [],
        searchList: []
      }
      const res = await app.MG.store.getShoppingCartProductList(query)
        searchList: [],
      };
      const res = await app.MG.store.getShoppingCartProductList(query);
      res.datas.forEach((item) => {
        shoppingCartGetId.push(item.saleMethod.id)
      })
      console.log(shoppingCartGetId, 'shoppingCartGetId');
      console.log(this.data.selectedIds, '销售方式id');
      const determine = shoppingCartGetId.some((item) => item == this.data.selectedIds)
        shoppingCartGetId.push(item.saleMethod.id);
      });
      console.log(shoppingCartGetId, "shoppingCartGetId");
      console.log(this.data.selectedIds, "销售方式id");
      const determine = shoppingCartGetId.some(
        (item) => item == this.data.selectedIds
      );
      console.log(determine);
      if (!determine) {
        let query = {
          requests: [{
            saleMethodId: this.data.selectedIds,
            storeEventId: null,
            agentCode: '电子书'
          }]
        }
        const addRes = app.MG.store.addShoppingCart(query)
        this.showSuccessToast()
        console.log(addRes, 'addRes');
        wx.switchTab({
          url: '/pages/cart/index',
        })
          requests: [
            {
              saleMethodId: this.data.selectedIds,
              storeEventId: null,
              agentCode: "电子书",
            },
          ],
        };
        const addRes = app.MG.store.addShoppingCart(query);
        this.showSuccessToast();
      } else {
        Toast({
          context: this,
          selector: '#t-toast',
          message: '该书已在购物车,请勿重复添加',
          theme: 'warning',
          direction: 'column',
          selector: "#t-toast",
          message: "该书已在购物车,请勿重复添加",
          theme: "warning",
          direction: "column",
        });
      }
    } else {
      wx.showToast({
        title: "商品不在有效期",
        icon: 'none',
        icon: "none",
        duration: 1000,
      })
      });
    }
  },
  showSuccessToast() {
    Toast({
      context: this,
      selector: '#t-toast',
      message: '添加成功',
      theme: 'success',
      direction: 'column',
      selector: "#t-toast",
      message: "添加成功",
      theme: "success",
      direction: "column",
    });
  },
  async buyBook() {
    console.log(this.data.bookItemDetail.defaultSaleMethodId, 'this.data.bookItemDetail.defaultSaleMethodId');
    console.log(
      this.data.bookItemDetail.defaultSaleMethodId,
      "this.data.bookItemDetail.defaultSaleMethodId"
    );
    if (!this.data.expire) {
      let bookOrdersId = ''
      let pBookInfo = {
        type: "电子书",
        pId: this.data.bookItemDetail ? this.data.bookDetail.id : ''
      }
      let bookOrdersId = "";
      let query = {
        remarks: JSON.stringify(pBookInfo),
        requests: [{
          saleMethodId: this.data.bookItemDetail.defaultSaleMethodId ? this.data.bookItemDetail.defaultSaleMethodId : this.data.bookDetail.defaultSaleMethodId,
          count: 1
        }]
      }
        remarks: "电子书",
        requests: [
          {
            saleMethodId: this.data.bookItemDetail.defaultSaleMethodId
              ? this.data.bookItemDetail.defaultSaleMethodId
              : this.data.bookDetail.defaultSaleMethodId,
            count: 1,
          },
        ],
      };
      // 发起订单初始化请求并等待结果
      const res = await app.MG.store.initOrder(query)
      const res = await app.MG.store.initOrder(query);
      // 获取订单号并赋值给 orderNumber.value
      bookOrdersId = res.orderNumber
      bookOrdersId = res.orderNumber;
      console.log(bookOrdersId);
      // 检查订单号是否存在
      if (bookOrdersId) {
        const url = '/pages/cart/paymentPage/index?orderNumber=' + bookOrdersId
        const url = "/pages/cart/paymentPage/index?orderNumber=" + bookOrdersId;
        wx.navigateTo({
          url
        })
          url,
        });
      } else {
        console.log(222);
      }
    } else {
      wx.showToast({
        title: "商品不在有效期",
        icon: 'none',
        icon: "none",
        duration: 1000,
      })
      });
    }
  },
  // 获取教学资源下载是否申请通过
  async getApplyInfo(id) {
    // 获取当前时间
    const currentDate = new Date()
    const currentDate = new Date();
    let query = {
      sort: {
        type: 'Desc',
        field: 'CreateDate'
        type: "Desc",
        field: "CreateDate",
      },
      start: 0,
      size: 99999,
      appRefCode: app.config.appRefCode,
      topicIdOrRefCode: 'productDownLoad'
    }
      topicIdOrRefCode: "productDownLoad",
    };
    await app.MG.ugc.getTopicMessageList(query).then((res) => {
      const applyResource = res.datas.find((item) => {
        let content = []
        let content = [];
        try {
          content = JSON.parse(item.content)
          content = JSON.parse(item.content);
        } catch (error) {
          content = []
          content = [];
        }
        if (Array.isArray(content)) return content.find((citem) => citem.id == id)
        return false
      })
        if (Array.isArray(content))
          return content.find((citem) => citem.id == id);
        return false;
      });
      // 有申请记录
      if (applyResource) {
        if (applyResource.state == 'Reject') {
        if (applyResource.state == "Reject") {
          this.setData({
            rejectCause: JSON.parse(applyResource.feedBack).reason,
            applyState: 'Reject'
          })
        } else if (applyResource.state == 'Normal') {
          const endDate = JSON.parse(applyResource.feedBack).endDate
            applyState: "Reject",
          });
        } else if (applyResource.state == "Normal") {
          const endDate = JSON.parse(applyResource.feedBack).endDate;
          // const endDate = new Date(JSON.parse(applyResource.feedBack).endDate + ' 23:59:59').getTime()
          if (endDate == '永久') {
          if (endDate == "永久") {
            this.setData({
              applyState: 'Normal',
              deadline: '永久',
            })
            console.log('有效日期', this.data.deadline);
              applyState: "Normal",
              deadline: "永久",
            });
            console.log("有效日期", this.data.deadline);
          } else {
            let endTime = new Date(endDate + ' 23:59:59').getTime()
            let endTime = new Date(endDate + " 23:59:59").getTime();
            this.setData({
              deadline: endDate + ' 23:59:59'
            })
              deadline: endDate + " 23:59:59",
            });
            if (currentDate.getTime() < endTime) {
              // 未超时
              this.setData({
                applyState: 'Normal'
              })
                applyState: "Normal",
              });
            } else {
              this.setData({
                applyState: 'none'
              })
                applyState: "none",
              });
            }
          }
        } else {
          this.setData({
            applyState: applyResource.state
          })
            applyState: applyResource.state,
          });
        }
      } else {
        this.setData({
          applyState: 'none'
        })
          applyState: "none",
        });
      }
    })
    });
    this.setData({
      applyResourceState: false,
    })
    wx.hideLoading()
    });
    wx.hideLoading();
  },
  // 申请教学资源
  applyResource() {
    if (this.data.applyResourceState) {
      return wx.showToast({
        icon: 'error',
        title: '请勿重复点击',
      })
        icon: "error",
        title: "请勿重复点击",
      });
    }
    this.setData({
      applyResourceState: true
    })
    let role = JSON.parse(wx.getStorageSync(app.config.userInfoKey)).role
      applyResourceState: true,
    });
    let role = JSON.parse(wx.getStorageSync(app.config.userInfoKey)).role;
    if (role) {
      if (role == 'Teacher') {
      if (role == "Teacher") {
        wx.showLoading({
          title: '加载中',
        })
          title: "加载中",
        });
        // 申请教学资源
        let query = {
          topicIdOrRefCode: 'productDownLoad',
          type: 'applyForDownload',
          state: 'WaitAudit',
          cmsTypeRefCode: '',
          topicIdOrRefCode: "productDownLoad",
          type: "applyForDownload",
          state: "WaitAudit",
          cmsTypeRefCode: "",
          newDataListRequest: [],
          name: this.data.bookDetail.name, // name为申请的书本名称
          content: JSON.stringify([{
            name: this.data.bookDetail.name,
            id: this.data.bookDetail.id,
            // defaultSaleMethodId: bookData.value.defaultSaleMethodId,
            icon: this.data.bookDetail.icon
          }])
        }
          content: JSON.stringify([
            {
              name: this.data.bookDetail.name,
              id: this.data.bookDetail.id,
              // defaultSaleMethodId: bookData.value.defaultSaleMethodId,
              icon: this.data.bookDetail.icon,
            },
          ]),
        };
        app.MG.ugc.newTopicMessage(query).then(async (res) => {
          if (res) {
            wx.showToast({
              title: '申请已提交',
              title: "申请已提交",
              duration: 2000,
            })
            });
          }
          await this.getApplyInfo(this.data.bookDetail.id)
        })
          await this.getApplyInfo(this.data.bookDetail.id);
        });
      } else {
        wx.showModal({
          title: '尊敬的用户,您好!',
          content: '请先进行教师认证!',
          title: "尊敬的用户,您好!",
          content: "请先进行教师认证!",
          complete: (res) => {
            if (res.cancel) {}
            if (res.cancel) {
            }
            if (res.confirm) {
              wx.navigateTo({
                url: '/packageDomain/pages/teacherCertification/index',
              })
                url: "/packageDomain/pages/teacherCertification/index",
              });
            }
          }
        })
          },
        });
      }
    } else {
      wx.showModal({
        title: '尊敬的用户,您好!',
        content: '请先进行教师认证!',
        title: "尊敬的用户,您好!",
        content: "请先进行教师认证!",
        complete: (res) => {
          if (res.cancel) {}
          if (res.cancel) {
          }
          if (res.confirm) {
            wx.navigateTo({
              url: '/packageDomain/pages/teacherCertification/index',
            })
              url: "/packageDomain/pages/teacherCertification/index",
            });
          }
        }
      })
        },
      });
    }
  },
  // 教学资源下载前往PC提示Diialog
  closeTeachDownload() {
    this.setData({
      isShowTeachDownload: false
    })
      isShowTeachDownload: false,
    });
  },
  // 下载功能
  downloadTeach(e) {
    let role = JSON.parse(wx.getStorageSync(app.config.userInfoKey)).role
    if (role && role == 'Teacher') {
    let role = JSON.parse(wx.getStorageSync(app.config.userInfoKey)).role;
    if (role && role == "Teacher") {
      this.setData({
        isShowTeachDownload: true
      })
        isShowTeachDownload: true,
      });
    } else {
      wx.showModal({
        title: '尊敬的用户,您好!',
        content: '请先进行教师认证!',
        title: "尊敬的用户,您好!",
        content: "请先进行教师认证!",
        complete: (res) => {
          if (res.cancel) {
          }
          if (res.confirm) {
            wx.navigateTo({
              url: '/packageDomain/pages/teacherCertification/index',
            })
              url: "/packageDomain/pages/teacherCertification/index",
            });
          }
        }
      })
        },
      });
    }
    //   const data = e.detail.value
    //   // const data
@@ -1191,33 +1253,35 @@
          tempFilePath: res.tempFilePath,
          success: function (res) {
            wx.showToast({
              title: '下载成功',
              icon: 'success'
            })
              title: "下载成功",
              icon: "success",
            });
          },
          fail: function (res) {
            wx.showToast({
              title: '下载失败',
              icon: 'none'
            })
          }
        })
              title: "下载失败",
              icon: "none",
            });
          },
        });
      },
      fail: function (res) {
        wx.showToast({
          title: '下载失败',
          icon: 'none'
        })
      }
    })
          title: "下载失败",
          icon: "none",
        });
      },
    });
  },
  // 判断资源是否购买
  resourceIsBuy(data) {
    if (data.saleMethod && data.saleMethod.length) {
      const isSHow = this.data.buyIdList.some((item) => item == data.saleMethod[0].Id)
      return !isSHow
      const isSHow = this.data.buyIdList.some(
        (item) => item == data.saleMethod[0].Id
      );
      return !isSHow;
    } else {
      return false
      return false;
    }
  },
  // 获取已购买商品
@@ -1226,55 +1290,59 @@
      start: 0,
      size: 999,
      filterList: [],
      searchList: []
    }
      searchList: [],
    };
    app.MG.store.getShoppingCartProductList(query).then((res) => {
      const list = []
      const list = [];
      res.datas.forEach((item) => {
        list.push(item.saleMethod.id)
      })
        list.push(item.saleMethod.id);
      });
      this.setData({
        shoppingList: res.datas,
        shoppingCartGetId: list
      })
    })
        shoppingCartGetId: list,
      });
    });
  },
  // 判断资源加入购物车按钮是否显示
  isShoppingCart(data) {
    if (data.saleMethod && data.saleMethod.length) {
      if (data.saleMethod[0].Price <= 0) return false
      if (data.saleMethod[0].Price <= 0) return false;
      // 再判断是否购买
      const isBuy = this.data.buyIdList.some((item) => item == data.saleMethod[0].Id)
      const isBuy = this.data.buyIdList.some(
        (item) => item == data.saleMethod[0].Id
      );
      if (isBuy) {
        // 购买了
        return false
        return false;
      } else {
        // 判断是否加入购物车
        const isSHow = this.data.shoppingCartGetId.some((item) => item == data.saleMethod[0].Id)
        return !isSHow
        const isSHow = this.data.shoppingCartGetId.some(
          (item) => item == data.saleMethod[0].Id
        );
        return !isSHow;
      }
    } else {
      return false
      return false;
    }
  },
  // 遍历树结构转换为数组方法
  handleTreeData(array) {
    const flattenedArray = []
    const flattenedArray = [];
    array.forEach((node) => {
      // 将当前节点添加到展开的数组中
      flattenedArray.push(node)
      flattenedArray.push(node);
      // 递归处理子节点
      if (node.children && node.children.length > 0) {
        const childrenArray = this.handleTreeData(node.children)
        flattenedArray.push(...childrenArray)
        const childrenArray = this.handleTreeData(node.children);
        flattenedArray.push(...childrenArray);
      }
    })
    return flattenedArray.filter((item) => item.sysType == 'CmsItem')
    });
    return flattenedArray.filter((item) => item.sysType == "CmsItem");
  },
  // 云学习一键领取
  async getFreeResource() {
    const child = this.selectComponent('#learn-resource')
    const token = wx.getStorageSync(app.config.tokenKey)
    const child = this.selectComponent("#learn-resource");
    const token = wx.getStorageSync(app.config.tokenKey);
    if (!token) {
      loginInfo(app, (data) => {
        // 如果不是第一次登录,会执行回调
@@ -1283,95 +1351,99 @@
        } else {
          // 出现错误,返回false
        }
      })
      });
    } else {
      let arr = this.handleTreeData(this.data.learn).filter((item) => this.resourceIsBuy(item))
      let arr = this.handleTreeData(this.data.learn).filter((item) =>
        this.resourceIsBuy(item)
      );
      let freeIds = arr.filter((item) => {
        return item.saleMethod[0].Price == 0
      })
      debugger
      if (!freeIds.length) return wx.showToast({
        icon: "error",
        title: '暂无免费资源',
      })
      child.changeReceive(true)
      let requests = []
        return item.saleMethod[0].Price == 0;
      });
      if (!freeIds.length)
        return wx.showToast({
          icon: "error",
          title: "暂无免费资源",
        });
      child.changeReceive(true);
      let requests = [];
      freeIds.forEach((item, index) => {
        if (this.resourceIsBuy(item)) {
          requests.push({
            saleMethodId: item.saleMethod[0].Id,
            count: 1
          })
            count: 1,
          });
        }
      })
      debugger
      });
      let query = {
        remarks: '云学习',
        remarks: "云学习",
        requests,
      }
      };
      try {
        const initOrderRes = await app.MG.store.initOrder(query)
        const initOrderRes = await app.MG.store.initOrder(query);
        let parameter = {
          orderNum: initOrderRes.orderNumber
        }
          orderNum: initOrderRes.orderNumber,
        };
        // 确认订单
        const confirmOrderRes = await app.MG.store.confirmOrder(parameter)
        const confirmOrderRes = await app.MG.store.confirmOrder(parameter);
        if (confirmOrderRes.orderNumber) {
          child.changeReceive(false)
          child.changeReceive(false);
          wx.showToast({
            title: '领取成功',
          })
          this.getBookInfo(this.data.bookId)
            title: "领取成功",
          });
          this.getBookInfo(this.data.bookId);
        }
      } catch (error) {
        console.log(error)
        console.log(error);
      }
    }
  },
  // 云学习一键购买
  async allAddShoppiingCar() {
    const child = this.selectComponent('#learn-resource')
    const token = wx.getStorageSync('jsek-token')
    const child = this.selectComponent("#learn-resource");
    const token = wx.getStorageSync("jsek-token");
    if (!token) {
      return wx.getUserProfile({
        desc: '用户登录',
        desc: "用户登录",
        success: (res) => {
          console.log(res);
        }
      })
        },
      });
    }
    let shopList = this.handleTreeData(this.data.learn).filter((item) => this.resourceIsBuy(item))
    this.getShoppingCartProductGet()
    if (!shopList.length) return wx.showToast({
      icon: "error",
      title: '已全部购买',
    })
    child.changeBuy(true)
    let requests = []
    let shopList = this.handleTreeData(this.data.learn).filter((item) =>
      this.resourceIsBuy(item)
    );
    this.getShoppingCartProductGet();
    if (!shopList.length)
      return wx.showToast({
        icon: "error",
        title: "已全部购买",
      });
    child.changeBuy(true);
    let requests = [];
    shopList.forEach((item) => {
      requests.push({
        saleMethodId: item.saleMethod[0].Id,
        count: 1,
      })
    })
      });
    });
    let query = {
      remarks: '云学习',
      remarks: "云学习",
      requests,
    }
    const initOrderRes = await app.MG.store.initOrder(query)
    child.changeBuy(false)
    };
    const initOrderRes = await app.MG.store.initOrder(query);
    child.changeBuy(false);
    // 检查订单号是否存在
    if (initOrderRes.orderNumber) {
      // bookService: orderNumber.value,  少传这个 ,暂时不知道有什么用
      wx.navigateTo({
        url: `/pages/cart/paymentPage/index?&bookId=${this.data.bookDetail.id}&bookName=${this.data.bookDetail.name}&orderNumber=${initOrderRes.orderNumber}`,
      })
      });
    } else {
      // 订单号不存在,显示警告消息
      wx.showToast({
        icon: "error",
        title: '请重试',
      })
        title: "请重试",
      });
    }
  },
  // 变为所有check   true
@@ -1398,145 +1470,196 @@
  // 组卷格式化日期显示
  DateFormat(date, fmt) {
    if (date && fmt) {
      let _date = new Date(date)
      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() //毫秒
      }
        "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))
        fmt = fmt.replace(
          RegExp.$1,
          (_date.getFullYear() + "").substr(4 - RegExp.$1.length)
        );
      }
      for (var k in o) {
        if (new RegExp('(' + k + ')').test(fmt)) {
        if (new RegExp("(" + k + ")").test(fmt)) {
          fmt = fmt.replace(
            RegExp.$1,
            RegExp.$1.length == 1 ?
            (o)[k] :
            ('00' + (o)[k]).substr(('' + (o)[k]).length)
          )
            RegExp.$1.length == 1
              ? o[k]
              : ("00" + o[k]).substr(("" + o[k]).length)
          );
        }
      }
      return fmt
      return fmt;
    } else {
      return ''
      return "";
    }
  },
  // 获取组卷答题数据
  getMockData() {
    this.setData({
      'mockData.useCount': 0,
      'mockData.mockList': []
    })
      "mockData.useCount": 0,
      "mockData.mockList": [],
    });
    app.MG.identity
      .getUserKey({
        domain: 'mockData',
        keys: [this.data.bookId]
        domain: "mockData",
        keys: [this.data.bookId],
      })
      .then((res) => {
        if (res && res.length) {
          const mock = JSON.parse(res[0].value)
          mock.forEach(item => {
            item.createDate = this.DateFormat(item.createDate, 'yyyy-MM-dd')
          })
          const mock = JSON.parse(res[0].value);
          mock.forEach((item) => {
            item.createDate = this.DateFormat(item.createDate, "yyyy-MM-dd");
          });
          this.setData({
            'mockData.mockList': mock
          })
            "mockData.mockList": mock,
          });
          // 组卷已使用次数
          res.forEach((item) => {
            // 已经有答题分数等数据,证明组卷已经使用完毕
            if (item.resultData) {
              this.setData({
                'mockData.useCount': this.data.mockData.useCount + 1
              })
                "mockData.useCount": this.data.mockData.useCount + 1,
              });
            }
          })
          });
        }
      })
      });
  },
  // 购买组卷
  async buyMock() {
    let res
    if (!this.data.mockData.id) return wx.showToast({
      icon: "error",
      title: '暂无组卷',
      mask: true
    })
    let res;
    if (!this.data.mockData.id)
      return wx.showToast({
        icon: "error",
        title: "暂无组卷",
        mask: true,
      });
    // 构建订单查询对象
    try {
      let query = {
        remarks: '组卷',
        requests: [{
          saleMethodId: this.data.mockData.id,
          count: 1
        }]
      }
        remarks: "组卷",
        requests: [
          {
            saleMethodId: this.data.mockData.id,
            count: 1,
          },
        ],
      };
      if (this.data.flag) {
        this.setData({
          flag: false
        })
        res = await app.MG.store.initOrder(query)
          flag: false,
        });
        res = await app.MG.store.initOrder(query);
      }
      if (res.orderNumber && this.data.mockData.price) {
        wx.navigateTo({
          url: `/pages/cart/paymentPage/index?orderNumber=${res.orderNumber}`,
        })
        });
      } else {
        // 0元直接领取
        // 确认订单
        const confirmOrderRes = await app.MG.store.confirmOrder({
          orderNum: res.orderNumber
        })
          orderNum: res.orderNumber,
        });
        if (confirmOrderRes) {
          wx.showToast({
            icon: "success",
            title: '领取成功',
          })
            title: "领取成功",
          });
          this.setData({
            flag: true
          })
          await this.recordBuyMock() // 记录购买时间
            flag: true,
          });
          await this.recordBuyMock(); // 记录购买时间
        }
      }
    } catch (error) {
      console.log(error)
      console.log(error);
    }
  },
  // 记录购买组卷时间
  recordBuyMock() {
    const num = this.data.mockData.mockList.length
    const id = tool.uuid(8)
    const createDate = this.DateFormat(new Date().getTime(), 'yyyy-MM-dd')
    const mockList = this.data.mockData.mockList
    const num = this.data.mockData.mockList.length;
    const id = tool.uuid(8);
    const createDate = this.DateFormat(new Date().getTime(), "yyyy-MM-dd");
    const mockList = this.data.mockData.mockList;
    mockList.push({
      id,
      createDate,
      name: `第${num + 1}套试卷`,
      state: '0'
    })
      state: "0",
    });
    this.setData({
      'mockData.mockList': mockList
    })
      "mockData.mockList": mockList,
    });
    // 记录购买时间,并设状态state为1,表示刚购买完成组卷
    app.MG.identity.setUserKey({
      setKeyRequests: [{
        domain: 'mockData',
        key: this.data.bookDetail.id + '',
        value: JSON.stringify(this.data.mockData.mockList)
      }]
    })
      setKeyRequests: [
        {
          domain: "mockData",
          key: this.data.bookDetail.id + "",
          value: JSON.stringify(this.data.mockData.mockList),
        },
      ],
    });
  },
  // 获取相关图书
  getAboutBook(path) {
    // loadings.value.aboutBook = true
    let query = {
      path,
      queryType: "*",
      coverSize: {
        height: 243,
      },
      paging: {
        start: 0,
        size: 99,
      },
      fields: {
        author: [],
        publicationDate: [],
      },
    };
    app.MG.store.getProductList(query).then((res) => {
      console.log("完整相关图书", res.datas);
      const Arr = res.datas.filter(
        (item) => item.id != this.data.bookDetail.id
      );
      let bookArr = [];
      if (Arr.length) {
        if (Arr.length > 3) {
          for (var i = 0; i < 3; i++) {
            var _num = Math.floor(Math.random() * Arr.length);
            var mm = Arr[_num];
            Arr.splice(_num, 1);
            bookArr.push(mm);
          }
        } else {
          bookArr = Arr;
        }
        this.setData({
          relatedBookData: bookArr,
        });
        console.log("相关图书", this.data.relatedBookData);
      }
    });
    // loadings.value.aboutBook = false
  },
  // 底部购买按钮
  buyBtn() {
    if (this.data.tabValue == 'brief' && !this.data.bookBuy) {
      this.buyBook()
    } else if (this.data.tabValue == 'jsek_cloudLearning') {
      const tree = this.selectComponent('#tree')
      tree.onCloudShoppingCart()
    if (this.data.tabValue == "brief" && !this.data.bookBuy) {
      this.buyBook();
    } else if (this.data.tabValue == "jsek_cloudLearning") {
      const tree = this.selectComponent("#tree");
      tree.onCloudShoppingCart();
    } else {
      console.log(this.data.tabValue);
    }
@@ -1545,16 +1668,27 @@
  goRead() {
    if (!this.data.noFile) {
      wx.showToast({
        title: '暂无阅读文件',
        icon: 'none',
        duration: 2000
      })
        title: "暂无阅读文件",
        icon: "none",
        duration: 2000,
      });
      return false;
    }
    wx.navigateTo({
      url: '/packageBookService/pages/components/webView/index?md5=' + this.data.fileInfo.md5 + '&fileName=' + this.data.fileInfo.bookName + '&fileType=' + this.data.fileInfo.fileType + '&freePage=' + this.data.fileInfo.freePage + '&bookBuy=' + this.data.bookBuy + '&bookId=' + this.data.bookDetail.id
    })
      url:
        "/packageBookService/pages/components/webView/index?md5=" +
        this.data.fileInfo.md5 +
        "&fileName=" +
        this.data.fileInfo.bookName +
        "&fileType=" +
        this.data.fileInfo.fileType +
        "&freePage=" +
        this.data.fileInfo.freePage +
        "&bookBuy=" +
        this.data.bookBuy +
        "&bookId=" +
        this.data.bookDetail.id,
    });
  },
  //样书申请
@@ -1563,114 +1697,119 @@
    const data = {
      start: 0,
      size: 9999,
      topicIdOrRefCode: 'applyEntityBook',
      topicIdOrRefCode: "applyEntityBook",
      appRefCode: app.config.appRefCode,
      sort: {
        type: 'Desc',
        field: 'CreateDate'
      }
    }
        type: "Desc",
        field: "CreateDate",
      },
    };
    app.MG.ugc.getTopicMessageList(data).then((res) => {
      let list = [];
      res.datas.map((item) => {
        if (item.content) {
          item.content = JSON.parse(item.content)
          item.content = JSON.parse(item.content);
        }
        list.push(item)
      })
        list.push(item);
      });
      this.setData({
        alreadyPaperBookList: list,
      });
    })
    });
  },
  //获取已申请电子样书
  getAlreadyEBookList() {
    const data = {
      start: 0,
      size: 9999,
      topicIdOrRefCode: 'applyBook',
      topicIdOrRefCode: "applyBook",
      appRefCode: app.config.appRefCode,
      sort: {
        type: 'Desc',
        field: 'CreateDate'
      }
    }
        type: "Desc",
        field: "CreateDate",
      },
    };
    app.MG.ugc.getTopicMessageList(data).then((res) => {
      let list = []
      let list = [];
      if (res.datas.length > 0) {
        res.datas.map((item) => {
          if (item.feedBack) {
            item.feedBack = JSON.parse(item.feedBack)
            item.feedBack = JSON.parse(item.feedBack);
            if (item.feedBack.endDate) {
              let times = new Date(item.feedBack.endDate + ' 23:59:59').getTime()
              let currentDate = new Date().getTime()
              let times = new Date(
                item.feedBack.endDate + " 23:59:59"
              ).getTime();
              let currentDate = new Date().getTime();
              if (times < currentDate) {
                item.isExpiry = true
                item.isExpiry = true;
              }
            }
          }
          if (item.content) {
            item.content = JSON.parse(item.content)
            item.content = JSON.parse(item.content);
          }
          if (item.state != 'Reject') {
            list.push(item)
          if (item.state != "Reject") {
            list.push(item);
          }
        })
        });
        this.setData({
          alreadyElectronicBookList: list,
        });
      }
    })
    });
  },
  //获取当前已申请次数(纸质)
  getSelectPaperBookCount() {
    app.MG.app
      .getTicketResult({
        ticketRefCodeOrGuid: 'paperSampleBookapplyNum',
        roleId: this.data.userInfo.roleId
        ticketRefCodeOrGuid: "paperSampleBookapplyNum",
        roleId: this.data.userInfo.roleId,
      })
      .then((res) => {
        this.setData({
          paperBookCount: res.totalCount - res.usedCount
        })
      })
          paperBookCount: res.totalCount - res.usedCount,
        });
      });
  },
  //获取当前已申请次数(电子)
  getSelectBookCount() {
    app.MG.app
      .getTicketResult({
        ticketRefCodeOrGuid: 'electronicSampleBookapplyNum',
        roleId: this.data.userInfo.roleId
        ticketRefCodeOrGuid: "electronicSampleBookapplyNum",
        roleId: this.data.userInfo.roleId,
      })
      .then((res) => {
        this.setData({
          ebookCount: res.totalCount - res.usedCount
        })
      })
          ebookCount: res.totalCount - res.usedCount,
        });
      });
  },
  //申请电子样书
  appplyElectronicBook() {
    console.log(this.data.bookDetail)
    if (this.data.bookDetail.isApplyBook == 2 || this.data.bookDetail.isApplyBook == 4) {
      let role = this.data.userInfo != null ? this.data.userInfo.role : null
    console.log(this.data.bookDetail);
    if (
      this.data.bookDetail.isApplyBook == 2 ||
      this.data.bookDetail.isApplyBook == 4
    ) {
      let role = this.data.userInfo != null ? this.data.userInfo.role : null;
      if (role) {
        if (role == 'Teacher') {
        if (role == "Teacher") {
          if (!this.data.noFile) {
            wx.showToast({
              title: "暂无电子书文件,请联系管理员!",
              icon: 'none',
              icon: "none",
              duration: 1000,
            })
            return
            });
            return;
          }
          if (this.data.ebookCount == 0) {
            wx.showToast({
              title: "您的电子样书申请次数已用尽,若要继续,请联系管理员!",
              icon: "none",
              duration: 1000,
            })
            });
            return false;
          }
          if (this.data.electronicBookList.length >= 2) {
@@ -1678,63 +1817,71 @@
              title: "每次最多只可申请2本样书",
              icon: "none",
              duration: 1000,
            })
            });
            return false;
          }
          let isHas = this.data.electronicBookList.find((eitem) => eitem.id == this.data.bookDetail.id)
          let isHas = this.data.electronicBookList.find(
            (eitem) => eitem.id == this.data.bookDetail.id
          );
          if (isHas) {
            wx.showToast({
              title: "该书已在清单列表中",
              icon: "none",
              duration: 1000,
            })
            });
            return false;
          }
          let isApply = this.data.alreadyElectronicBookList.find((eitem) => eitem.id == this.data.bookDetail.id)
          let isApply = this.data.alreadyElectronicBookList.find(
            (eitem) => eitem.id == this.data.bookDetail.id
          );
          if (isApply) {
            wx.showToast({
              title: "该书已申请!",
              icon: "none",
              duration: 1000,
            })
            });
            return false;
          }
          this.addBookFun(this.data.bookDetail, "eBook")
          this.addBookFun(this.data.bookDetail, "eBook");
        } else {
          wx.showModal({
            title: '尊敬的用户,您好!', //提示的标题
            content: '请先进行教师认证?', //提示的内容
            title: "尊敬的用户,您好!", //提示的标题
            content: "请先进行教师认证?", //提示的内容
            success: function (res) {
              if (res.confirm) {
                wx.navigateTo({
                  url: "/packageDomain/pages/teacherCertification/index",
                });
              } else if (res.cancel) {}
            }
          })
              } else if (res.cancel) {
              }
            },
          });
        }
      }
    } else {
      wx.showToast({
        title: "该书不能申请电子样书",
        icon: 'none',
        icon: "none",
        duration: 1000,
      })
      });
    }
  },
  //申请纸质样书
  appplyPaperBook() {
    if (this.data.bookDetail.isApplyBook == 3 || this.data.bookDetail.isApplyBook == 4) {
      let role = this.data.userInfo != null ? this.data.userInfo.role : null
    if (
      this.data.bookDetail.isApplyBook == 3 ||
      this.data.bookDetail.isApplyBook == 4
    ) {
      let role = this.data.userInfo != null ? this.data.userInfo.role : null;
      if (role) {
        if (role == 'Teacher') {
        if (role == "Teacher") {
          // 点击选中
          if (this.data.paperBookCount == 0) {
            wx.showToast({
              title: "您的纸质样书申请次数已用尽,若要继续,请联系管理员!",
              icon: "none",
              duration: 1000,
            })
            });
            return false;
          }
          if (this.data.paperBookList.length >= 2) {
@@ -1742,88 +1889,93 @@
              title: "每次最多只可申请2本样书",
              icon: "none",
              duration: 1000,
            })
            });
            return false;
          }
          let isHas = this.data.paperBookList.find((pitem) => pitem.id == this.data.bookDetail.id)
          let isHas = this.data.paperBookList.find(
            (pitem) => pitem.id == this.data.bookDetail.id
          );
          if (isHas) {
            wx.showToast({
              title: "该书已在清单列表中",
              icon: "none",
              duration: 1000,
            })
            });
            return false;
          }
          let isApply = this.data.alreadyPaperBookList.find((pitem) => pitem.id == this.data.bookDetail.id)
          let isApply = this.data.alreadyPaperBookList.find(
            (pitem) => pitem.id == this.data.bookDetail.id
          );
          if (isApply) {
            wx.showToast({
              title: "该书已申请!",
              icon: "none",
              duration: 1000,
            })
            });
            return false;
          }
          this.addBookFun(this.data.bookDetail, "pBook")
          this.addBookFun(this.data.bookDetail, "pBook");
        } else {
          wx.showModal({
            title: '尊敬的用户,您好!', //提示的标题
            content: '请先进行教师认证?', //提示的内容
            title: "尊敬的用户,您好!", //提示的标题
            content: "请先进行教师认证?", //提示的内容
            success: function (res) {
              if (res.confirm) {
                wx.navigateTo({
                  url: "/packageDomain/pages/teacherCertification/index",
                });
              } else if (res.cancel) {}
            }
          })
              } else if (res.cancel) {
              }
            },
          });
        }
      }
    } else {
      wx.showToast({
        title: "该书不能申请纸质样书",
        icon: 'none',
        icon: "none",
        duration: 1000,
      })
      });
    }
  },
  //  添加样书
  addBookFun(item, type) {
    let itemAttr = null
    let itemAttr = null;
    const eList = this.data.electronicBookList;
    const pList = this.data.paperBookList;
    itemAttr = {
      id: item.id,
      title: item.name || '-',
      title: item.name || "-",
      icon: item.icon,
      checked: false,
      defaultSaleMethodId: item.defaultSaleMethodId,
      md5: item.datas.Icon,
      author: item.author || '-',
      price: item.price || '-',
      isbn: item.isbn || '-',
      publicationDate: item.publicationDate
    }
    if (type == 'eBook') {
      eList.push(itemAttr)
      author: item.author || "-",
      price: item.price || "-",
      isbn: item.isbn || "-",
      publicationDate: item.publicationDate,
    };
    if (type == "eBook") {
      eList.push(itemAttr);
      this.setData({
        electronicBookList: eList,
      })
      });
      wx.setStorageSync("electronicBookList", eList);
    } else {
      pList.push(itemAttr)
      pList.push(itemAttr);
      this.setData({
        paperBookList: pList,
      })
      });
      wx.setStorageSync("paperBookList", pList);
    }
    this.setData({
      num: this.data.num + 1
    })
      num: this.data.num + 1,
    });
    wx.showToast({
      title: "添加成功,在样书申请单等您哦~",
      icon: "none",
      duration: 1000,
    })
    });
  },
  //去样书申请单
@@ -1834,28 +1986,29 @@
  },
  handleTree() {
    // const child = this.selectComponent('#teach-tree')
    let tree
    let tree;
    // let openIds = child.data.openIds
    if (this.data.tabValue == 'jsek_teachingResources') {
      tree = this.data.teach
    if (this.data.tabValue == "jsek_teachingResources") {
      tree = this.data.teach;
    } else {
      tree = this.data.learn
      tree = this.data.learn;
    }
    for (let index = 0; index < tree.length; index++) {
      const item = tree[index];
      if (item.children && item.children.length > 0) {
        const num = this.data.openTeachids.findIndex(citem => item.id == citem)
        const num = this.data.openTeachids.findIndex(
          (citem) => item.id == citem
        );
        if (num >= 0) {
          item.open = true
          item.open = true;
        } else {
          item.open = false
          item.open = false;
        }
        this.handleTree(item.children)
        this.handleTree(item.children);
      }
    }
    this.setData({
      teach: tree
    })
      teach: tree,
    });
  },
})
});
packageBookService/pages/bookServices/detail/index.json
@@ -10,6 +10,7 @@
    "teach-resource": "/packageBookService/pages/bookServices/detail/components/teachResource/index",
    "learn-resource": "/packageBookService/pages/bookServices/detail/components/learnResource/learnResource",
    "test-resource": "/packageBookService/pages/bookServices/detail/components/testResource/testResource",
    "related-books": "/packageBookService/pages/bookServices/detail/components/relatedBooks/index",
    "note": "/packageBookService/pages/bookServices/detail/components/note/note",
    "tree": "/packageBookService/pages/bookServices/detail/components/tree/index",
    "suggest": "/packageBookService/pages/bookServices/detail/components/suggest/suggest",
packageBookService/pages/bookServices/detail/index.wxml
@@ -4,30 +4,55 @@
  <view style="width: 100%; height: {{barHeight}}px; "></view>
  <view class="nacigationBar" style="width: 70%; height: {{navBarHeight}}px;">
    <view>
      <t-icon name="chevron-left" size="30" data-name="{{item}}" bind:click="goBack" />
      <t-icon
        name="chevron-left"
        size="30"
        data-name="{{item}}"
        bind:click="goBack"
      />
    </view>
    <view class="navbar-title">{{options.name}}</view>
  </view>
  <t-toast id="t-toast" />
  <scroll-view scroll-y="{{true}}" class="book" bindscrolltolower="onReachBottom">
  <scroll-view
    scroll-y="{{true}}"
    class="book"
    bindscrolltolower="onReachBottom"
  >
    <!-- 图书详情 -->
    <view class="book-box">
      <view class="book-detail">
        <view class="detail-left">
          <view class="book-img">
            <image loading="" src="{{bookDetail.icon ? bookDetail.icon : '/static/images/default-book-img.png'}}" mode="aspectFill" aria-label="{{bookDetail.name}}" />
            <image
              loading=""
              src="{{bookDetail.icon ? bookDetail.icon : '/static/images/default-book-img.png'}}"
              mode="aspectFill"
              aria-label="{{bookDetail.name}}"
            />
          </view>
          <view class="book-use">
            <view class="collect" bind:tap="setCollect">
              <view>
                <image loading="" src="/static/images/bookService/detail/collect.png" wx:if="{{!bookDetail.isFavourite}}" />
                <image loading="" src="/static/images/bookService/detail/collecting.png" wx:if="{{bookDetail.isFavourite}}" />
                <image
                  loading=""
                  src="/static/images/bookService/detail/collect.png"
                  wx:if="{{!bookDetail.isFavourite}}"
                />
                <image
                  loading=""
                  src="/static/images/bookService/detail/collecting.png"
                  wx:if="{{bookDetail.isFavourite}}"
                />
              </view>
              <view class="use-title">收藏</view>
            </view>
            <view class="suggest" bind:tap="suggestBtn">
              <view>
                <image loading="" src="/static/images/bookService/detail/suggest.png" />
                <image
                  loading=""
                  src="/static/images/bookService/detail/suggest.png"
                />
              </view>
              <view class="use-title">我要建议</view>
            </view>
@@ -49,15 +74,24 @@
              <view class="li-content">{{bookDetail.isbn}}</view>
            </view>
            <view class="message-li">
              <view class="li-title" wx:if="{{bookDetail.publicationDate}}">出版时间:</view>
              <view class="li-title" wx:if="{{bookDetail.publicationDate}}"
                >出版时间:</view
              >
              <view class="li-content">{{bookDetail.publicationDate}}</view>
            </view>
            <view class="message-li" wx:if="{{bookDetail.class}}" style="height: 80rpx">
            <view
              class="message-li"
              wx:if="{{bookDetail.class}}"
              style="height: 80rpx"
            >
              <view class="li-title">图书分类:</view>
              <view class="class-name showTow">{{bookDetail.class}}</view>
            </view>
          </view>
          <image src="/static/images/bookService/detail/square.png" class="right-background" />
          <image
            src="/static/images/bookService/detail/square.png"
            class="right-background"
          />
        </view>
      </view>
      <!-- 销售信息 -->
@@ -66,12 +100,17 @@
          <!-- 电子书售价 -->
          <view class="electron-price" wx:if="{{bookDetail.price}}">
            <view>
              <image src="/static/images/bookService/detail/electon-price.png" />
              <image
                src="/static/images/bookService/detail/electon-price.png"
              />
            </view>
            <view class="price">
              <view class="price-text">{{bookDetail.price == '0.00' ? '免费' : '¥'+
                bookDetail.price}}</view>
              <view class="price-old" wx:if="{{bookDetail.oldPrice != '0.00'}}">¥{{bookDetail.oldPrice}}
              <view class="price-text"
                >{{bookDetail.price == '0.00' ? '免费' : '¥'+
                bookDetail.price}}</view
              >
              <view class="price-old" wx:if="{{bookDetail.oldPrice != '0.00'}}"
                >¥{{bookDetail.oldPrice}}
              </view>
            </view>
            <view> </view>
@@ -81,24 +120,66 @@
            <view>
              <image src="/static/images/bookService/detail/paper-price.png" />
            </view>
            <view class="price">{{bookDetail.paperPrice == '0.00' ? '免费' :
              '¥'+bookDetail.paperPrice}}</view>
            <view class="price"
              >{{bookDetail.paperPrice == '0.00' ? '免费' :
              '¥'+bookDetail.paperPrice}}</view
            >
          </view>
        </view>
        <!-- 网店 -->
        <view class="book-web">
          <image src="/static/images/bookService/detail/jd.png" wx:if="{{bookDetail.JDLink}}" bind:tap="goShop" data-link="{{bookDetail.JDLink}}" data-type="jd" />
          <image class="tmall-image" src="/static/images/bookService/detail/tmall.png" bind:tap="goShop" data-link="{{bookDetail.tmallLink}}" wx:if="{{bookDetail.tmallLink}}" />
          <image src="/static/images/bookService/detail/dangdang.png" bind:tap="goShop" data-link="{{bookDetail.dangdangLink}}" wx:if="{{bookDetail.dangdangLink}}" />
          <image src="/static/images/bookService/detail/weidian.png" bind:tap="goShop" data-link="{{bookDetail.weidianLink}}" wx:if="{{bookDetail.weidianLink}}" />
          <image
            src="/static/images/bookService/detail/jd.png"
            wx:if="{{bookDetail.JDLink}}"
            bind:tap="goShop"
            data-link="{{bookDetail.JDLink}}"
            data-type="jd"
          />
          <image
            class="tmall-image"
            src="/static/images/bookService/detail/tmall.png"
            bind:tap="goShop"
            data-link="{{bookDetail.tmallLink}}"
            wx:if="{{bookDetail.tmallLink}}"
          />
          <image
            src="/static/images/bookService/detail/dangdang.png"
            bind:tap="goShop"
            data-link="{{bookDetail.dangdangLink}}"
            wx:if="{{bookDetail.dangdangLink}}"
          />
          <image
            src="/static/images/bookService/detail/weidian.png"
            bind:tap="goShop"
            data-link="{{bookDetail.weidianLink}}"
            wx:if="{{bookDetail.weidianLink}}"
          />
        </view>
      </view>
    </view>
    <view class="book-resource">
      <t-tabs defaultValue="{{tabValue}}" bind:change="onTabsChange" t-class="custom-tabs" t-class-content="custom-panel" class="tab-class">
        <t-tab-panel label="图书简介" icon="{{ tabValue == 'brief' ? briefIconClick : briefIcon}}" value="brief" style="{{tabPanelstyle}}">
          <book-brief content="{{bookDetail.content}}" authorIntroduction="{{bookDetail.authorIntroduction}}" wx:if="{{bookDetail.content || bookDetail.authorIntroduction}}"></book-brief>
          <view wx:if="{{!bookDetail.content && !bookDetail.authorIntroduction}}" class="noData">
      <t-tabs
        defaultValue="{{tabValue}}"
        bind:change="onTabsChange"
        t-class="custom-tabs"
        t-class-content="custom-panel"
        class="tab-class"
      >
        <t-tab-panel
          label="图书简介"
          icon="{{ tabValue == 'brief' ? briefIconClick : briefIcon}}"
          value="brief"
          style="{{tabPanelstyle}}"
        >
          <book-brief
            content="{{bookDetail.content}}"
            authorIntroduction="{{bookDetail.authorIntroduction}}"
            wx:if="{{bookDetail.content || bookDetail.authorIntroduction}}"
          ></book-brief>
          <view
            wx:if="{{!bookDetail.content && !bookDetail.authorIntroduction}}"
            class="noData"
          >
            <t-empty icon="folder-open" description="暂无数据" />
          </view>
        </t-tab-panel>
@@ -109,44 +190,132 @@
          style="{{tabPanelstyle}}"
        >
        </t-tab-panel> -->
        <t-tab-panel label="教学资源" icon="{{tabValue == 'jsek_teachingResources' ? teachResourcesClickIcon : teachResourcesIcon}}" value="jsek_teachingResources" class="{{loading ? 'loading': ''}}">
          <view wx:if="{{!loading && teach.length && !noResources && applyState}}">
            <teach-resource applyState="{{applyState}}" rejectCause="{{rejectCause}}" deadline="{{deadline}}" bind:applyResource="applyResource" applyResourceLoading="{{applyResourceLoading}}"></teach-resource>
            <tree id="teach-tree" openIds="{{openTeachids}}" bookInfo="{{bookDetail}}" treeList="{{teach}}" tab="{{tabValue}}" applyState="{{applyState}}" bind:downloadTeach="downloadTeach" bind:handleTree="handleTree" openTeachids="{{openTeachids}}" wx:if="{{teach.length}}"></tree>
        <t-tab-panel
          label="教学资源"
          icon="{{tabValue == 'jsek_teachingResources' ? teachResourcesClickIcon : teachResourcesIcon}}"
          value="jsek_teachingResources"
          class="{{loading ? 'loading': ''}}"
        >
          <view
            wx:if="{{!loading && teach.length && !noResources && applyState}}"
          >
            <teach-resource
              applyState="{{applyState}}"
              rejectCause="{{rejectCause}}"
              deadline="{{deadline}}"
              bind:applyResource="applyResource"
              applyResourceLoading="{{applyResourceLoading}}"
            ></teach-resource>
            <tree
              id="teach-tree"
              openIds="{{openTeachids}}"
              bookInfo="{{bookDetail}}"
              treeList="{{teach}}"
              tab="{{tabValue}}"
              applyState="{{applyState}}"
              bind:downloadTeach="downloadTeach"
              bind:handleTree="handleTree"
              openTeachids="{{openTeachids}}"
              wx:if="{{teach.length}}"
            ></tree>
          </view>
          <t-loading theme="circular" size="60rpx" class="loading" loading="{{loading }}" />
          <t-loading
            theme="circular"
            size="60rpx"
            class="loading"
            loading="{{loading }}"
          />
          <view wx:if="{{noResources}}" class="noData">
            <t-empty icon="folder-open" description="暂无数据" />
          </view>
        </t-tab-panel>
        <t-tab-panel label="云学习" icon="{{tabValue == 'jsek_cloudLearning' ? learnResourceClickIcon : learnResourceIcon}}" value="jsek_cloudLearning" style="{{tabPanelstyle}}">
        <t-tab-panel
          label="云学习"
          icon="{{tabValue == 'jsek_cloudLearning' ? learnResourceClickIcon : learnResourceIcon}}"
          value="jsek_cloudLearning"
          style="{{tabPanelstyle}}"
        >
          <view wx:if="{{!loading && learn.length}}">
            <learn-resource bind:getFreeResource="getFreeResource" bind:allAddShoppiingCar="allAddShoppiingCar" id="learn-resource" buyResourceData="{{buyResourceData}}" bookId="{{bookDetail.id}}"></learn-resource>
            <tree id="tree" openIds="{{openLearnids}}" bookInfo="{{bookDetail}}" tab="{{tabValue}}" treeList="{{learn}}" buyIds="{{buyIdList}}" openLearnids="{{openLearnids}}"></tree>
            <learn-resource
              bind:getFreeResource="getFreeResource"
              bind:allAddShoppiingCar="allAddShoppiingCar"
              id="learn-resource"
              buyResourceData="{{buyResourceData}}"
              bookId="{{bookDetail.id}}"
              isshowDrawBtn="{{isshowDrawBtn}}"
            ></learn-resource>
            <tree
              id="tree"
              openIds="{{openLearnids}}"
              bookInfo="{{bookDetail}}"
              tab="{{tabValue}}"
              treeList="{{learn}}"
              buyIds="{{buyIdList}}"
              openLearnids="{{openLearnids}}"
            ></tree>
          </view>
          <view wx:if="{{noResources}}" class="noData">
            <t-empty icon="folder-open" description="暂无数据" />
          </view>
        </t-tab-panel>
        <t-tab-panel label="云测试" icon="{{tabValue == 'questionBank' ? testResourceClickIocn : testResourceIocn}}" value="questionBank" style="{{tabPanelstyle}}">
        <t-tab-panel
          label="云测试"
          icon="{{tabValue == 'questionBank' ? testResourceClickIocn : testResourceIocn}}"
          value="questionBank"
          style="{{tabPanelstyle}}"
        >
          <view wx:if="{{!loading}}">
            <test-resource list="{{test}}" bookInfo="{{bookDetail}}" mockData="{{mockData}}" bind:buyMock="buyMock"></test-resource>
            <test-resource
              list="{{test}}"
              bookInfo="{{bookDetail}}"
              mockData="{{mockData}}"
              bind:buyMock="buyMock"
            ></test-resource>
          </view>
        </t-tab-panel>
        <t-tab-panel label="云笔记" icon="{{tabValue == 'jsek_note' ? noteClickIcon: noteIcon}}" value="jsek_note" style="{{tabPanelstyle}}">
        <t-tab-panel
          label="云笔记"
          icon="{{tabValue == 'jsek_note' ? noteClickIcon: noteIcon}}"
          value="jsek_note"
          style="{{tabPanelstyle}}"
        >
          <note bookInfo="{{bookDetail}}" id="note" class="note-list"></note>
        </t-tab-panel>
        <t-tab-panel
          label="相关图书"
          icon="{{tabValue == 'related_books' ? linkClickIcon: linkIcon}}"
          value="related_books"
          style="{{tabPanelstyle}}"
        >
          <related-books relatedBookData="{{relatedBookData}}"></related-books>
        </t-tab-panel>
      </t-tabs>
    </view>
  </scroll-view>
  <!-- 我要建议弹窗 -->
  <suggest class="suggest-component" id="suggest-component" bookIcon="{{bookDetail.icon}}" bookName="{{bookDetail.name}}"></suggest>
  <suggest
    class="suggest-component"
    id="suggest-component"
    bookIcon="{{bookDetail.icon}}"
    bookName="{{bookDetail.name}}"
  ></suggest>
  <!-- 教学资源下载提示弹窗 -->
  <t-dialog class="teachDownloadDialog" visible="{{isShowTeachDownload}}" title="提示" content="请前往PC端下载" confirm-btn="{{ confirmBtn }}" bind:confirm="closeTeachDownload" />
  <t-dialog
    class="teachDownloadDialog"
    visible="{{isShowTeachDownload}}"
    title="提示"
    content="请前往PC端下载"
    confirm-btn="{{ confirmBtn }}"
    bind:confirm="closeTeachDownload"
  />
  <view class="applyBox" bindtap="goApply">
    <view class="box">
      <t-image src="/static/images/home/yangshuForm1.png" mode="heightFix" class="img" />
      <t-image
        src="/static/images/home/yangshuForm1.png"
        mode="heightFix"
        class="img"
      />
      <view class="num" wx:if="{{num > 0}}">{{num}}</view>
    </view>
  </view>
@@ -154,13 +323,18 @@
  <view class="box-bottom">
    <view class="bottom-btn" bind:tap="appplyElectronicBook">
      <view>
        <t-image loading="" src="/static/images/bookService/detail/ebook.png"></t-image>
        <t-image
          loading=""
          src="/static/images/bookService/detail/ebook.png"
        ></t-image>
      </view>
      <view class="btn-text">电子样书申请</view>
    </view>
    <view class="bottom-btn" bind:tap="appplyPaperBook">
      <view>
        <t-image src="/static/images/bookService/detail/paper-book.png"></t-image>
        <t-image
          src="/static/images/bookService/detail/paper-book.png"
        ></t-image>
      </view>
      <view class="btn-text">纸质样书申请</view>
    </view>
@@ -171,12 +345,19 @@
      <view class="btn-text">试读</view>
    </view>
    <view class="shopCar shopCarColor" bind:tap="addBookShopcCar" wx:if="{{!bookBuy}}">加入购物车</view>
    <view class="buy buyColor" bind:tap="buyBtn" wx:if="{{!bookBuy}}">立即购买</view>
    <view class="buy read " bind:tap="goRead" wx:if="{{bookBuy}}">立即查看</view>
    <view
      class="shopCar shopCarColor"
      bind:tap="addBookShopcCar"
      wx:if="{{!bookBuy}}"
      >加入购物车</view
    >
    <view class="buy buyColor" bind:tap="buyBtn" wx:if="{{!bookBuy}}"
      >立即购买</view
    >
    <view class="buy read" bind:tap="goRead" wx:if="{{bookBuy}}">立即查看</view>
  </view>
</view>
<view class="loading" wx:if="{{pageLoading}}">
  <t-loading loading="{{pageLoading}}" size="40"></t-loading>
</view>
</view>
packageBookService/pages/bookServices/examination/examination.js
@@ -1,9 +1,6 @@
import {
  getPublicImage
} from '../../../../assets/js/middleGround/tool'
const app = getApp()
import { getPublicImage } from "../../../../assets/js/middleGround/tool";
const app = getApp();
Page({
  /**
   * 页面的初始数据
   */
@@ -22,7 +19,7 @@
    answerType: "", // 答题模式
    submitStatus: false, // 提交状态
    currentIndex: 0, // 当前显示的题号
    collectList: [], //  收藏题目列表
    collectList: [], //  收藏题目列表
    errorList: [], // 错题列表
    subjectiveTotal: 0, // 客观题总数
    subjectiveNum: 0, // 客观题得分
@@ -35,18 +32,18 @@
    uuid: 0,
    mockData: {
      // 组卷信息
      state: '0',
      state: "0",
      score: 0, // 总分
      sumTime: 0,
      time: 0, // 答题剩余时间
      datas: [], // 所有模考记录数据(题目列表,用户答题,考试报告)
      answer: []
      answer: [],
    },
    saveTime: 20,
    isNight: false,
    sliderValue: 0, // 字体滑块
    startTime: "", //进入页面当前时间
    pauseTime: 0 //暂停时间
    pauseTime: 0, //暂停时间
  },
  /**
@@ -64,25 +61,26 @@
    // });
    const systInfo = wx.getSystemInfoSync();
    const menu = wx.getMenuButtonBoundingClientRect(); // 胶囊信息
    const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度
    const navBarHeight =
      (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度
    this.setData({
      barHeight: systInfo.statusBarHeight,
      navBarHeight: navBarHeight,
      answerTitle: options.answerTitle,
      bookId: options.bookId,
      productLinkPath: options.productLinkPath ? options.productLinkPath : '',
      productLinkPath: options.productLinkPath ? options.productLinkPath : "",
      rootCmsItemId: options.rootCmsItemId,
      idPathList: options.idPathList ? JSON.parse(options.idPathList) : [],
      answerType: options.answerType,
    });
    if (this.data.answerType == 'mock') {
    if (this.data.answerType == "mock") {
      this.setData({
        uuid: options.uuid,
        mockid: options.mockid
      })
        mockid: options.mockid,
      });
    }
    this.init()
    console.log('传参', options);
    this.init();
    console.log("传参", options);
  },
  /**
@@ -94,27 +92,27 @@
   * 生命周期函数--监听页面显示
   */
  onShow() {
    if (this.data.answerType != 'mock') {
    if (this.data.answerType != "mock") {
      if (wx.timer) {
        clearInterval(wx.timer)
        clearInterval(wx.timer);
      }
    }
    if (this.data.answerType == 'mock') {
    if (this.data.answerType == "mock") {
      if (wx.timer) {
        clearInterval(wx.timer)
        clearInterval(wx.timer);
      }
      wx.timer = setInterval(() => {
        this.setData({
          saveTime: this.data.saveTime - 1
        })
          saveTime: this.data.saveTime - 1,
        });
        if (this.data.saveTime == 0) {
          this.saveMockData()
          this.saveMockData();
        }
      }, 1000)
      }, 1000);
    }
    this.setData({
      startTime: Date.now()
    })
      startTime: Date.now(),
    });
  },
  /**
@@ -122,14 +120,14 @@
   */
  onHide() {
    if (wx.timer) {
      clearInterval(wx.timer)
      clearInterval(wx.timer);
    }
    this.setData({
      pauseTime: Date.now()
    })
      pauseTime: Date.now(),
    });
    if (wx.getStorageSync(app.config.tokenKey)) {
      let duration = this.data.pauseTime - this.data.startTime
      this.count(duration)
      let duration = this.data.pauseTime - this.data.startTime;
      this.count(duration);
    }
  },
@@ -138,52 +136,48 @@
   */
  onUnload(e) {
    if (wx.timer) {
      clearInterval(wx.timer)
      clearInterval(wx.timer);
    }
    if (this.data.countdownInterval !== null) {
      clearInterval(this.data.countdownInterval)
      clearInterval(this.data.countdownInterval);
    }
    this.setData({
      pauseTime: Date.now()
    })
      pauseTime: Date.now(),
    });
    if (wx.getStorageSync(app.config.tokenKey)) {
      let duration = this.data.pauseTime - this.data.startTime
      this.count(duration)
      let duration = this.data.pauseTime - this.data.startTime;
      this.count(duration);
    }
  },
  count(timeStr) {
    const data = {
      appRefCode: app.config.appRefCode,
      type: 'LearningTime', //统计类型--阅读时长
      data: timeStr + '', //统计内容--时长毫秒
      event: 'LearningTime',
      sysType: 'App'
    }
      type: "LearningTime", //统计类型--阅读时长
      data: timeStr + "", //统计内容--时长毫秒
      event: "LearningTime",
      sysType: "App",
    };
    //阅读商品的id
    if (this.data.bookId) {
      data.productId = this.data.bookId
      data.productId = this.data.bookId;
    }
    //阅读资源的id
    // if (product.cmsItemId) {
    //   data.cmsItemId = product.cmsItemId
    // }
    app.MG.job.newJobWithApiNewEvent(data).then((res) => {})
    app.MG.job.newJobWithApiNewEvent(data).then((res) => {});
  },
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {
  },
  onPullDownRefresh() {},
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
  },
  onReachBottom() {},
  /**
   * 用户点击右上角分享
@@ -205,13 +199,13 @@
        const oldVal = value; // 记录属性的旧值
        value = newVal; // 更新属性的值
        callback.call(context, newVal, oldVal); // 调用回调函数,传递新值和旧值
      }
      },
    });
  },
  onChangeSlider(e) {
    this.setData({
      sliderValue: e.detail.value
    })
      sliderValue: e.detail.value,
    });
    console.log(e.detail.value);
  },
  // 返回
@@ -222,109 +216,122 @@
  //设置背景色
  changeBGColor(e) {
    this.setData({
      isNight: e.detail.value
    })
      isNight: e.detail.value,
    });
  },
  // 获取保存的倒计时时间
  getSavedTime() {
    const savedTime = wx.getStorageSync('countdownTime')
    return savedTime ? parseInt(savedTime) : null
    const savedTime = wx.getStorageSync("countdownTime");
    return savedTime ? parseInt(savedTime) : null;
  },
  // 保存倒计时时间到本地存储
  saveTime() {
    wx.setStorageSync('countdownTime', this.data.countdownTime.toString())
    wx.setStorageSync("countdownTime", this.data.countdownTime.toString());
  },
  clearTime() {
    this.setData({
      countdownTime: 2 * 60 * 60 * 1000
    })
      countdownTime: 2 * 60 * 60 * 1000,
    });
  },
  // 暂停或继续倒计时
  toggleCountdown() {
    if (this.data.countdownInterval) {
      clearInterval(this.data.countdownInterval)
      clearInterval(this.data.countdownInterval);
      this.setData({
        countdownInterval: null,
        isCountdownRunning: false
      })
        isCountdownRunning: false,
      });
    } else {
      this.startCountdown()
      this.startCountdown();
      this.setData({
        isCountdownRunning: true
      })
        isCountdownRunning: true,
      });
    }
  },
  // 开始倒计时
  startCountdown() {
    // 如果计时器已经存在,先清除之前的计时器
    if (this.data.countdownInterval) {
      clearInterval(this.data.countdownInterval)
      clearInterval(this.data.countdownInterval);
      this.setData({
        countdownInterval: null
      })
        countdownInterval: null,
      });
    }
    this.setData({
      countdownInterval: setInterval(() => {
        this.setData({
          countdownTime: this.data.countdownTime - 1000
        })
          countdownTime: this.data.countdownTime - 1000,
        });
        if (this.data.countdownTime <= 0) {
          clearInterval(this.data.countdownInterval)
          clearInterval(this.data.countdownInterval);
          this.setData({
            countdownTime: 0,
            isCountdownRunning: false
          })
            isCountdownRunning: false,
          });
        }
        this.saveTime()
      }, 1000)
    })
        this.saveTime();
      }, 1000),
    });
  },
  // 切换题目
  changeSwiper(e) {
    this.setData({
      currentIndex: e.detail.index
    })
    let index = e.detail.index - 1 >= 0 ? e.detail.index - 1 : 0
    const item = this.data.questionDataList[index]
    if ((this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') && !item.isComplete) {
      let flag = this.isHaveAnswer(item.userAnswer)
      if (flag) this.handleQuestion(index)
      currentIndex: e.detail.index,
    });
    let index = e.detail.index - 1 >= 0 ? e.detail.index - 1 : 0;
    const item = this.data.questionDataList[index];
    if (
      (this.data.answerType == "collectQuestion" ||
        this.data.answerType == "errorQuestion") &&
      !item.isComplete
    ) {
      let flag = this.isHaveAnswer(item.userAnswer);
      if (flag) this.handleQuestion(index);
    }
  },
  // 我的错题,收藏查看解析按钮
  viewParsing() {
    if (this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') {
      const item = this.data.questionDataList[this.data.currentIndex]
    if (
      this.data.answerType == "collectQuestion" ||
      this.data.answerType == "errorQuestion"
    ) {
      const item = this.data.questionDataList[this.data.currentIndex];
      if (!item.isComplete) {
        this.handleQuestion(this.data.currentIndex)
        this.handleQuestion(this.data.currentIndex);
      }
    }
  },
  // 点击答题卡跳转题目
  goQuestion(e) {
    const id = e.detail.id
    const id = e.detail.id;
    this.data.questionDataList.forEach((item, index) => {
      if (item.id == id) {
        this.setData({
          currentIndex: index
        })
          currentIndex: index,
        });
      }
    })
    });
  },
  // 单选 多选 触发
  onChangeRadio(e) {
    const radioData = e.detail.value.currentTarget.dataset.value
    const id = e.detail.value.currentTarget.dataset.id
    const radioChecked = e.detail.value.detail.value
    const questionList = this.data.questionDataList
    const radioData = e.detail.value.currentTarget.dataset.value;
    const id = e.detail.value.currentTarget.dataset.id;
    const radioChecked = e.detail.value.detail.value;
    const questionList = this.data.questionDataList;
    // 我的错题和我的收藏模式下,单选题选择了直接批改
    for (let index = 0; index < questionList.length; index++) {
      const item = questionList[index];
      if (item.id == id && !item.isComplete) {
        item.userAnswer = radioChecked
        item.isUserAnswer = this.isHaveAnswer(radioChecked)
        if ((item.questionType == 'singleChoice' || item.questionType == 'judge') && (this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') && !item.isComplete) {
          this.handleQuestion(this.data.currentIndex)
        item.userAnswer = radioChecked;
        item.isUserAnswer = this.isHaveAnswer(radioChecked);
        if (
          (item.questionType == "singleChoice" ||
            item.questionType == "judge") &&
          (this.data.answerType == "collectQuestion" ||
            this.data.answerType == "errorQuestion") &&
          !item.isComplete
        ) {
          this.handleQuestion(this.data.currentIndex);
        }
      }
    }
@@ -337,14 +344,14 @@
    //     }
    //   }
    // })
    const cardListUpdata = this.data.cardList
    const cardListUpdata = this.data.cardList;
    for (let index = 0; index < cardListUpdata.length; index++) {
      const item = cardListUpdata[index];
      for (let cindex = 0; cindex < item.infoList.length; cindex++) {
        const citem = item.infoList[cindex];
        if (citem.id == id && !citem.isComplete) {
          citem.userAnswer = radioChecked
          citem.isUserAnswer = this.isHaveAnswer(radioChecked)
          citem.userAnswer = radioChecked;
          citem.isUserAnswer = this.isHaveAnswer(radioChecked);
        }
      }
    }
@@ -358,44 +365,44 @@
    // })
    this.setData({
      questionDataList: questionList,
      cardList: cardListUpdata
    })
    if (this.data.answerType == 'mock') {
      cardList: cardListUpdata,
    });
    if (this.data.answerType == "mock") {
      this.setData({
        saveTime: 20
      })
        saveTime: 20,
      });
    }
  },
  // 输入框触发
  onChangeInput(e) {
    const inputData = e.detail.value.detail.value
    const id = e.detail.value.currentTarget.dataset.id
    const index = Number(e.detail.value.currentTarget.dataset.index)
    const inputData = e.detail.value.detail.value;
    const id = e.detail.value.currentTarget.dataset.id;
    const index = Number(e.detail.value.currentTarget.dataset.index);
    console.log(index);
    const questionList = this.data.questionDataList
    questionList.forEach(item => {
    const questionList = this.data.questionDataList;
    questionList.forEach((item) => {
      if (item.id == id) {
        item.userAnswer[index] = inputData
        return item.isUserAnswer = this.isHaveAnswer(inputData)
        item.userAnswer[index] = inputData;
        return (item.isUserAnswer = this.isHaveAnswer(inputData));
      }
    })
    const cardListUpdata = this.data.cardList
    cardListUpdata.forEach(item => {
      item.infoList.forEach(citem => {
    });
    const cardListUpdata = this.data.cardList;
    cardListUpdata.forEach((item) => {
      item.infoList.forEach((citem) => {
        if (citem.id == id) {
          citem.userAnswer[index] = inputData
          return citem.isUserAnswer = this.isHaveAnswer(inputData)
          citem.userAnswer[index] = inputData;
          return (citem.isUserAnswer = this.isHaveAnswer(inputData));
        }
      })
    })
      });
    });
    this.setData({
      questionDataList: questionList,
      cardList: cardListUpdata,
    })
    if (this.data.answerType == 'mock') {
    });
    if (this.data.answerType == "mock") {
      this.setData({
        saveTime: 20
      })
        saveTime: 20,
      });
    }
  },
  // 数组转为字符串方法
@@ -403,100 +410,109 @@
    // 检查是否为数组
    if (Array.isArray(data)) {
      // 使用 join 方法将数组转换为字符串,默认使用逗号分隔
      return data.join(',').replace(/<[^>]*>/g, '')
      return data.join(",").replace(/<[^>]*>/g, "");
    } else {
      // 如果不是数组,直接返回原始值
      return data.replace(/<[^>]*>/g, '')
      return data.replace(/<[^>]*>/g, "");
    }
  },
  // 判断是否有用户答案
  isHaveAnswer(data) {
    if (typeof data == 'string') {
    if (typeof data == "string") {
      data = data
        .replace(/<[^>]*>/g, '')
        .replace(/&nbsp;/g, '')
        .trim()
        .replace(/<[^>]*>/g, "")
        .replace(/&nbsp;/g, "")
        .trim();
      if (data.length) {
        return true
        return true;
      } else {
        return false
        return false;
      }
    } else if (typeof data == 'object') {
      const answer = data.find((item) => item.length > 0)
    } else if (typeof data == "object") {
      const answer = data.find((item) => item.length > 0);
      if (answer) {
        return true
        return true;
      } else {
        return false
        return false;
      }
    } else {
      return false
      return false;
    }
  },
  // 提交逻辑
  submitPaper() {
    // 关闭退出页面监听
    wx.disableAlertBeforeUnload()
    wx.disableAlertBeforeUnload();
    this.setData({
      submitStatus: true,
      loading: true
    })
    const child = this.selectComponent('#question-options')
    if (this.data.answerType == 'option' || this.data.answerType == 'errorQuestion' || this.data.answerType == 'mock') {
      loading: true,
    });
    const child = this.selectComponent("#question-options");
    if (
      this.data.answerType == "option" ||
      this.data.answerType == "errorQuestion" ||
      this.data.answerType == "mock"
    ) {
      // 先遍历所有题目,将未批改的题目批改
      const qustionList = this.data.questionDataList
      const qustionList = this.data.questionDataList;
      for (let index = 0; index < qustionList.length; index++) {
        const item = qustionList[index];
        if (!item.isComplete) this.handleQuestion(index)
        if (!item.isComplete) this.handleQuestion(index);
      }
    }
    if (this.data.answerType == 'option') {
      this.toggleCountdown()
      this.recordAnswerData()
      child.openTestReportDialog()
    } else if (this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') {
      this.goBack()
    } else if (this.data.answerType == 'mock') {
      this.toggleCountdown()
    if (this.data.answerType == "option") {
      this.toggleCountdown();
      this.recordAnswerData();
      child.openTestReportDialog();
    } else if (
      this.data.answerType == "collectQuestion" ||
      this.data.answerType == "errorQuestion"
    ) {
      this.goBack();
    } else if (this.data.answerType == "mock") {
      this.toggleCountdown();
      // 设置模考状态为已完成
      const mockData = this.data.mockData
      const mockData = this.data.mockData;
      mockData.datas.forEach((item) => {
        if (item.id == this.data.uuid) {
          item.state = '3'
          item.state = "3";
          item.report = {
            userScore: this.data.subjectiveNum
          }
            userScore: this.data.subjectiveNum,
          };
        }
      })
      });
      this.setData({
        mockData: mockData,
        submitStatus: true
      })
      this.setMockInfo(mockData.datas)
        submitStatus: true,
      });
      this.setMockInfo(mockData.datas);
      // 记录用户答题数据
      let saveData = []
      let saveData = [];
      for (let index = 0; index < this.data.questionDataList.length; index++) {
        const item = this.data.questionDataList[index];
        saveData.push({
          id: item.id,
          answer: item.userAnswer,
          isRight: item.isRight
        })
          isRight: item.isRight,
        });
      }
      app.MG.identity.setUserKey({
        setKeyRequests: [{
          domain: 'mockAnswerData',
          key: this.data.uuid,
          value: JSON.stringify({
            time: this.data.countdownTime,
            answerData: saveData
          })
        }]
      })
      child.openTestReportDialog()
        setKeyRequests: [
          {
            domain: "mockAnswerData",
            key: this.data.uuid,
            value: JSON.stringify({
              time: this.data.countdownTime,
              answerData: saveData,
            }),
          },
        ],
      });
      child.openTestReportDialog();
    }
    this.setData({
      loading: false
    })
      loading: false,
    });
  },
  // 初始化函数
  async init() {
@@ -504,77 +520,87 @@
      loading: true,
      subjectiveTotal: 0,
      subjectiveNum: 0,
      subjectiveGrade: 0
    })
    if (this.data.answerType == 'option') {
      subjectiveGrade: 0,
    });
    if (this.data.answerType == "option") {
      if (this.data)
        // this.startCountdown()
        this.setData({
          countdownTime: 2 * 60 * 60 * 1000
        })
          countdownTime: 2 * 60 * 60 * 1000,
        });
      // 测试答题
      await this.getCollectIdList() // 获取收藏id列表
      await this.getErrorList() // 获取错题id列表
    } else if (this.data.answerType == 'collectQuestion') {
      await this.getCollectIdList(); // 获取收藏id列表
      await this.getErrorList(); // 获取错题id列表
    } else if (this.data.answerType == "collectQuestion") {
      this.setData({
        submitStatus: true
      })
        submitStatus: true,
      });
      // 我的收藏
      await this.getcollectId() // 获取收藏题目
    } else if (this.data.answerType == 'errorQuestion') {
      await this.getcollectId(); // 获取收藏题目
    } else if (this.data.answerType == "errorQuestion") {
      this.setData({
        submitStatus: true
      })
        submitStatus: true,
      });
      // 我的错题
      // loadings.value = true
      await this.getErrorIdList()
      await this.getCollectIdList() // 获取收藏id列表
    } else if (this.data.answerType == 'mock') {
      this.getErrorList()
      this.getCollectIdList()
      await this.getErrorIdList();
      await this.getCollectIdList(); // 获取收藏id列表
    } else if (this.data.answerType == "mock") {
      this.getErrorList();
      this.getCollectIdList();
      this.getMockInfo(async (res) => {
        let mocklist
        let mocklist;
        try {
          mocklist = JSON.parse(res[0].value)
          mocklist = JSON.parse(res[0].value);
        } catch (error) {
          mocklist = []
          mocklist = [];
        }
        if (mocklist.length && this.data.uuid) {
          const oldMockData = mocklist.find((mockItem) => mockItem.id == this.data.uuid)
          const oldMockData = mocklist.find(
            (mockItem) => mockItem.id == this.data.uuid
          );
          this.setData({
            'mockData.state': oldMockData.state,
            'mockData.score': oldMockData.score,
            'mockData.datas': mocklist,
          })
          if (oldMockData.state == '0') {
            "mockData.state": oldMockData.state,
            "mockData.score": oldMockData.score,
            "mockData.datas": mocklist,
          });
          if (oldMockData.state == "0") {
            // 组卷购买了,但未进入页面
            await this.getEduQuizConfig()
          } else if (oldMockData.state == '1' || oldMockData.state == '2' || oldMockData.state == '3') {
            await this.getEduQuizConfig();
          } else if (
            oldMockData.state == "1" ||
            oldMockData.state == "2" ||
            oldMockData.state == "3"
          ) {
            // 组卷后进入过页面,但是未答过题
            let oldQuestionList = []
            oldQuestionList = await this.getMockQuestionList()
            const userAnswerList = await this.getMockAnswer()
            let oldQuestionList = [];
            oldQuestionList = await this.getMockQuestionList();
            const userAnswerList = await this.getMockAnswer();
            this.setData({
              'mockData.sumTime': oldMockData.time,
              cardList: oldQuestionList
            })
            await this.getMockDataList(oldQuestionList, userAnswerList)
              "mockData.sumTime": oldMockData.time,
              cardList: oldQuestionList,
            });
            await this.getMockDataList(oldQuestionList, userAnswerList);
          }
          if (oldMockData.state == '0' || oldMockData.state == '1' || oldMockData.state == '2') {
            this.startCountdown()
          if (
            oldMockData.state == "0" ||
            oldMockData.state == "1" ||
            oldMockData.state == "2"
          ) {
            this.startCountdown();
          }
          if (oldMockData.state == '3') {
          if (oldMockData.state == "3") {
            this.setData({
              submitStatus: true,
              subjectiveNum: oldMockData.report.userScore
            })
              subjectiveNum: oldMockData.report.userScore,
            });
          }
        }
      })
      });
    }
  },
  async restart() {
    const countDownRef = this.selectComponent('#countDownRef')
    const countDownRef = this.selectComponent("#countDownRef");
    this.setData({
      loading: true,
      total: 0,
@@ -582,38 +608,40 @@
      subjectiveTotal: 0,
      subjectiveNum: 0,
      currentIndex: 0,
      submitStatus: false
    })
    if (this.data.answerType == 'option') {
      submitStatus: false,
    });
    if (this.data.answerType == "option") {
      this.setData({
        countdownTime: 2 * 60 * 60 * 1000
      })
        countdownTime: 2 * 60 * 60 * 1000,
      });
      this.delAnswerInfo(() => {
        this.getQuestionList()
        this.clearTime()
      })
        this.getQuestionList();
        this.clearTime();
      });
      if (!this.data.submitStatus) {
        this.startCountdown()
        this.startCountdown();
      }
    } else if (this.data.answerType == 'mock') {
    } else if (this.data.answerType == "mock") {
      // 组卷模式
      // 清空答题记录
      await app.MG.identity.setUserKey({
        setKeyRequests: [{
          domain: 'mockAnswerData',
          key: this.data.uuid,
          value: JSON.stringify({
            time: this.data.countdownTime,
            answerData: []
          })
        }]
      })
      this.init()
        setKeyRequests: [
          {
            domain: "mockAnswerData",
            key: this.data.uuid,
            value: JSON.stringify({
              time: this.data.countdownTime,
              answerData: [],
            }),
          },
        ],
      });
      this.init();
    } else {
      this.init()
      this.clearTime()
      this.init();
      this.clearTime();
      if (submitStatus.value) {
        this.startCountdown()
        this.startCountdown();
      }
    }
  },
@@ -621,64 +649,67 @@
  getCollectIdList() {
    app.MG.identity
      .getUserKey({
        domain: 'collectData',
        keys: [this.data.rootCmsItemId]
        domain: "collectData",
        keys: [this.data.rootCmsItemId],
      })
      .then((res) => {
        try {
          this.setData({
            collectList: JSON.parse(res[0].value)
          })
            collectList: JSON.parse(res[0].value),
          });
        } catch (error) {}
        if (this.data.answerType == 'option') {
        if (this.data.answerType == "option") {
          // 先获取用户答题记录
          this.getAnswerInfo(async (res) => {
            if (res.length) {
              // 有记录,不能答题,状态设为已提交
              this.setData({
                submitStatus: true
              })
              let value = JSON.parse(res[0].value)
                submitStatus: true,
              });
              let value = JSON.parse(res[0].value);
              // 有答题记录,得分赋值
              if (value) {
                wx.disableAlertBeforeUnload()
                wx.disableAlertBeforeUnload();
                this.setData({
                  submitStatus: true
                })
                  submitStatus: true,
                });
                value.dataList.forEach((item) => {
                  if (item.name == '客观题得分' && item.path == this.data.productLinkPath)
                  if (
                    item.name == "客观题得分" &&
                    item.path == this.data.productLinkPath
                  )
                    this.setData({
                      subjectiveNum: item.score
                    })
                })
                      subjectiveNum: item.score,
                    });
                });
              }
              this.setData({
                currentIndex: value.currentIndex
              })
                currentIndex: value.currentIndex,
              });
              console.log(this.data.submitStatus);
              // 携带答题记录 获取题目
              await this.getQuestionList(value.dataList)
              await this.getQuestionList(value.dataList);
            } else {
              await this.getQuestionList() // 获取题库题目
              await this.getQuestionList(); // 获取题库题目
            }
          })
          });
        }
      })
      });
  },
  // 获取错题id列表
  getErrorList() {
    app.MG.identity
      .getUserKey({
        domain: 'errorData',
        keys: [this.data.rootCmsItemId]
        domain: "errorData",
        keys: [this.data.rootCmsItemId],
      })
      .then((res) => {
        try {
          this.setData({
            errorList: JSON.parse(res[0].value)
          })
            errorList: JSON.parse(res[0].value),
          });
        } catch (error) {}
      })
      });
  },
  // 获取题库题目
  async getQuestionList(oldData) {
@@ -686,23 +717,23 @@
    this.setData({
      cardList: [],
      correctNum: 0,
    })
    let flag = 0
    });
    let flag = 0;
    for (let index = 0; index < this.data.idPathList.length; index++) {
      const pathitem = this.data.idPathList[index];
      const pathList = this.data.cardList
      const pathList = this.data.cardList;
      pathList.push({
        path: pathitem.productLinkPath,
        catalogName: pathitem.name,
        infoList: []
      })
        infoList: [],
      });
      this.setData({
        cardList: pathList
      })
        cardList: pathList,
      });
      // 获取题目
      let query = {
        path: '*',
        queryType: '*',
        path: "*",
        queryType: "*",
        productId: this.data.bookId,
        cmsPath: pathitem.productLinkPath,
        itemFields: {
@@ -715,110 +746,150 @@
          Embedded_QuestionBank_StemStyle: [],
          Embedded_QuestionBank_OptionStyle: [],
          Embedded_QuestionBank_KnowledgePoint: [],
          Embedded_QuestionBank_Difficulty: []
          Embedded_QuestionBank_Difficulty: [],
        },
        pading: {
          start: 0,
          size: 999
        }
      }
          size: 999,
        },
      };
      await app.MG.store.getProductDetail(query).then((res) => {
        this.setData({
          total: res.datas.cmsDatas[0].datas.length
        })
          total: res.datas.cmsDatas[0].datas.length,
        });
        // total.value += res.datas.cmsDatas[0].datas.length
        let oldList
        let oldList;
        if (oldData) {
          // 提交过,存在答题记录
          oldList = oldData.find((item) => item.path == pathitem.productLinkPath).infoList
          oldList = oldData.find(
            (item) => item.path == pathitem.productLinkPath
          ).infoList;
          this.setData({
            submitStatus: true
          })
            submitStatus: true,
          });
        }
        res.datas.cmsDatas[0].datas.forEach((item, index) => {
          let oldObj = ''
          if (oldList) oldObj = oldList.find((oldItem) => oldItem.id == item.id)
          let oldObj = "";
          if (oldList)
            oldObj = oldList.find((oldItem) => oldItem.id == item.id);
          let questionObj = {
            // num: index, // 题号
            id: item.id,
            type: pathitem.name,
            stem: item.Embedded_QuestionBank_QuestionType == 'completion' ?
              JSON.parse(item.Embedded_QuestionBank_Stem)
              .stemTxt.replaceAll('<vacancy>', ',input,')
              .split(',') : JSON.parse(item.Embedded_QuestionBank_Stem), // 题干
            stem:
              item.Embedded_QuestionBank_QuestionType == "completion"
                ? JSON.parse(item.Embedded_QuestionBank_Stem)
                    .stemTxt.replaceAll("<vacancy>", ",input,")
                    .split(",")
                : JSON.parse(item.Embedded_QuestionBank_Stem), // 题干
            answer: item.Embedded_QuestionBank_Answer, // 答案
            option: item.Embedded_QuestionBank_Option ?
              JSON.parse(item.Embedded_QuestionBank_Option) : '', // 选择题选项
            option: item.Embedded_QuestionBank_Option
              ? JSON.parse(item.Embedded_QuestionBank_Option)
              : "", // 选择题选项
            analysisCon: item.Embedded_QuestionBank_AnalysisCon, // 解析
            questionType: item.Embedded_QuestionBank_QuestionType, // 题型
            optionStyle: item.Embedded_QuestionBank_OptionStyle, // 选项显示类型
            stemStyle: item.Embedded_QuestionBank_StemStyle, // 题干显示类型
            difficulty: item.Embedded_QuestionBank_Difficulty ?
              4 - item.Embedded_QuestionBank_Difficulty : 0, // 难度等级
            userAnswer: oldObj ?
              oldObj.userAnswer : item.Embedded_QuestionBank_QuestionType == 'completion' ||
              item.Embedded_QuestionBank_QuestionType == 'multipleChoice' ? [] : '',
            difficulty: item.Embedded_QuestionBank_Difficulty
              ? 4 - item.Embedded_QuestionBank_Difficulty
              : 0, // 难度等级
            userAnswer: oldObj
              ? oldObj.userAnswer
              : item.Embedded_QuestionBank_QuestionType == "completion" ||
                item.Embedded_QuestionBank_QuestionType == "multipleChoice"
              ? []
              : "",
            isUserAnswer: oldObj ? this.isHaveAnswer(oldObj.userAnswer) : false,
            isRight: oldObj ? oldObj.isRight : null,
            isComplete: oldObj ? oldObj.isComplete : false,
            isCollect: this.data.collectList.indexOf(item.id) > -1 ? true : false,
            isUnfold: '' // 控制解析的折叠面板是否展开
          }
            isCollect:
              this.data.collectList.indexOf(item.id) > -1 ? true : false,
            isUnfold: "", // 控制解析的折叠面板是否展开
          };
          // 多选和填空答案肯为数组,要转换JSON格式
          if (
            questionObj.questionType == 'completion' ||
            questionObj.questionType == 'multipleChoice'
            questionObj.questionType == "completion" ||
            questionObj.questionType == "multipleChoice"
          ) {
            try {
              questionObj.answer = JSON.parse(questionObj.answer).toString()
              questionObj.answer = JSON.parse(questionObj.answer).toString();
            } catch (error) {
              questionObj.answer = item.Embedded_QuestionBank_Answer
              questionObj.answer = item.Embedded_QuestionBank_Answer;
            }
          }
          // 填空题改造
          if (questionObj.questionType == 'completion') {
            let index = 0
          if (questionObj.questionType == "completion") {
            let index = 0;
            for (let i = 0; i < questionObj.stem.length; i++) {
              const item = questionObj.stem[i]
              if (item == 'input') {
              const item = questionObj.stem[i];
              if (item == "input") {
                questionObj.stem[i] = {
                  num: index,
                  data: 'input'
                }
                if (!oldObj) questionObj.userAnswer[index] = ''
                index++
                  data: "input",
                };
                if (!oldObj) questionObj.userAnswer[index] = "";
                index++;
              }
            }
          }
          // 题干富文本处理
          if (questionObj.stemStyle == 'RichText') {
          if (questionObj.stemStyle == "RichText") {
            // questionObj.option.txt = ''
            questionObj.stem.stemTxt = questionObj.stem.stemTxt.replace(/\<img/gi, '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" ').replace(/\<p/gi, '<p class="stem-rich-p"')
            questionObj.stem.stemTxt = questionObj.stem.stemTxt
              .replace(
                /\<img/gi,
                '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" '
              )
              .replace(/\<p/gi, '<p class="stem-rich-p"');
          }
          // 选项富文本处理
          if (questionObj.optionStyle == 'RichText' && (questionObj.questionType == 'singleChoice' || questionObj.questionType == 'judge' || questionObj.questionType == 'multipleChoice')) {
            questionObj.option.forEach(item => {
              if (item.txt) item.txt = item.txt.replace(/\<img/gi, '<img class="option-rich-img"').replace(/\<p/gi, '<p class="stem-rich-p"')
            })
          if (
            questionObj.optionStyle == "RichText" &&
            (questionObj.questionType == "singleChoice" ||
              questionObj.questionType == "judge" ||
              questionObj.questionType == "multipleChoice")
          ) {
            questionObj.option.forEach((item) => {
              if (item.txt)
                item.txt = item.txt
                  .replace(/\<img/gi, '<img class="option-rich-img"')
                  .replace(/\<p/gi, '<p class="stem-rich-p"');
            });
          }
          // 解析富文本处理
          if (questionObj.analysisCon && typeof questionObj.analysisCon == 'string') {
            questionObj.analysisCon = questionObj.analysisCon.replace(/\<img/gi, '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" ')
          // 解析富文本处理
          if (
            questionObj.analysisCon &&
            typeof questionObj.analysisCon == "string"
          ) {
            questionObj.analysisCon = questionObj.analysisCon.replace(
              /\<img/gi,
              '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" '
            );
          }
          // 获取图片
          if (questionObj.stemStyle == 'Image' || questionObj.stemStyle == 'TxtAndImage') {
            questionObj.stem.stemImage = getPublicImage(questionObj.stem.stemImage, 150)
          if (
            questionObj.stemStyle == "Image" ||
            questionObj.stemStyle == "TxtAndImage"
          ) {
            questionObj.stem.stemImage = getPublicImage(
              questionObj.stem.stemImage,
              150
            );
          }
          if (questionObj.optionStyle == 'Image' || questionObj.optionStyle == 'TxtAndImage') {
            questionObj.option.forEach(optionItem => {
              if (optionItem.img) optionItem.img = getPublicImage(optionItem.img, 150)
            })
          if (
            questionObj.optionStyle == "Image" ||
            questionObj.optionStyle == "TxtAndImage"
          ) {
            questionObj.option.forEach((optionItem) => {
              if (optionItem.img)
                optionItem.img = getPublicImage(optionItem.img, 150);
            });
          }
          // 客观题总分赋值
          if (questionObj.questionType !== 'shortAnswer') {
          if (questionObj.questionType !== "shortAnswer") {
            this.setData({
              subjectiveGrade: this.data.subjectiveGrade + 2
            })
              subjectiveGrade: this.data.subjectiveGrade + 2,
            });
          }
          // if (questionObj.optionStyle == 'RichText') {
          //   questionObj.option.forEach(optionItem => {
@@ -828,144 +899,164 @@
          // 旧数据里 题目正确 记录正确数量
          if (questionObj.isRight) {
            this.setData({
              correctNum: this.data.correctNum + 1
            })
              correctNum: this.data.correctNum + 1,
            });
          }
          if (pathitem.name == '判断题' || pathitem.name == '填空题' || pathitem.name == '多选题' || pathitem.name == '单选题' || pathitem.name == '听力题') {
          if (
            pathitem.name == "判断题" ||
            pathitem.name == "填空题" ||
            pathitem.name == "多选题" ||
            pathitem.name == "单选题" ||
            pathitem.name == "听力题"
          ) {
            if (oldObj) {
              this.setData({
                subjectiveTotal: this.data.subjectiveTotal + 1
              })
                subjectiveTotal: this.data.subjectiveTotal + 1,
              });
            }
          }
          // cardList赋值
          let cardIndex = this.data.cardList.findIndex((item) => item.path == pathitem.productLinkPath)
          let infoList = this.data.cardList[cardIndex].infoList
          infoList.push(questionObj)
          let cardIndex = this.data.cardList.findIndex(
            (item) => item.path == pathitem.productLinkPath
          );
          let infoList = this.data.cardList[cardIndex].infoList;
          infoList.push(questionObj);
          this.setData({
            [`cardList[${cardIndex}].infoList`]: infoList
          })
            [`cardList[${cardIndex}].infoList`]: infoList,
          });
          flag++;
          let questionList = []
          let grade = 0
          const cardUpdatedList = this.data.cardList
          let questionList = [];
          let grade = 0;
          const cardUpdatedList = this.data.cardList;
          // if (flag == this.data.idPathList.length) {
          cardUpdatedList.forEach(aitem => {
          cardUpdatedList.forEach((aitem) => {
            aitem.infoList.forEach((bitem, bindex) => {
              questionList.push(bitem)
              bitem.number = bindex + 1
              bitem.score = 2
            })
          })
              questionList.push(bitem);
              bitem.number = bindex + 1;
              bitem.score = 2;
            });
          });
          this.setData({
            questionDataList: questionList,
            cardList: cardUpdatedList,
          })
        })
      })
          });
        });
      });
    }
    // 有题目再开始倒计时
    if (this.data.questionDataList.length) this.startCountdown()
    if (this.data.questionDataList.length) this.startCountdown();
    this.setData({
      loading: false
    })
      loading: false,
    });
  },
  // 批改题目 (练习,我的错题,我的收藏,,组卷)
  handleQuestion(index) {
    const questionList = this.data.questionDataList
    const questionList = this.data.questionDataList;
    if (questionList[index].isComplete) {
      // 题目已完成,跳过
      return true
      return true;
    }
    questionList[index].isComplete = true
    const item = questionList[index]
    questionList[index].isComplete = true;
    const item = questionList[index];
    // 批改题目
    if (item.questionType == 'multipleChoice') {
    if (item.questionType == "multipleChoice") {
      // 多选题
      if (item.answer.length == item.userAnswer.length) {
        const sortedArr1 = item.answer.slice().sort()
        const sortedArr2 = item.userAnswer.slice().sort()
        const sortedArr1 = item.answer.slice().sort();
        const sortedArr2 = item.userAnswer.slice().sort();
        questionList[index].isRight = sortedArr1.every(
          (value, valueIndex) => value === sortedArr2[valueIndex]
        )
        );
      } else {
        questionList[index].isRight = false
        questionList[index].isRight = false;
      }
    } else if (item.questionType == 'singleChoice' || item.questionType == 'judge') {
    } else if (
      item.questionType == "singleChoice" ||
      item.questionType == "judge"
    ) {
      // 单选 判断
      questionList[index].isRight = item.answer == item.userAnswer
    } else if (item.questionType == 'shortAnswer') {
      questionList[index].isRight = item.answer == item.userAnswer;
    } else if (item.questionType == "shortAnswer") {
      // 简答 翻译
      questionList[index].isRight = null
    } else if (item.questionType == 'completion') {
      if (item.answer == 'string') {
        item.isRight = item.answer == item.userAnswer[0]
      questionList[index].isRight = null;
    } else if (item.questionType == "completion") {
      if (item.answer == "string") {
        item.isRight = item.answer == item.userAnswer[0];
      } else {
        if (item.answer.length != item.userAnswer.length) {
          item.isRight = false
          item.isRight = false;
        } else {
          item.isRight = item.answer.every(
            (value, index) => value === item.userAnswer[index]
          )
          );
        }
      }
      if (typeof item.answer == 'string') {
        questionList[index].isRight = item.answer == item.userAnswer[0]
      if (typeof item.answer == "string") {
        questionList[index].isRight = item.answer == item.userAnswer[0];
      } else {
        if (item.answer.length != item.userAnswer.length) {
          questionList[index].isRight = false
          questionList[index].isRight = false;
        } else {
          questionList[index].isRight = item.answer.every(
            (value, valueIndex) => value === item.userAnswer[valueIndex]
          )
          );
        }
      }
    }
    if (item.questionType != 'shortAnswer') {
    if (item.questionType != "shortAnswer") {
      this.setData({
        subjectiveTotal: this.data.subjectiveTotal + 1,
      })
      });
    }
    if (questionList[index].isRight && item.questionType != 'shortAnswer') {
    if (questionList[index].isRight && item.questionType != "shortAnswer") {
      // 客观题回答正确
      this.setData({
        subjectiveNum: this.data.subjectiveNum + item.score,
        correctNum: this.data.correctNum + 1
      })
        correctNum: this.data.correctNum + 1,
      });
    }
    if (!questionList[index].isRight && item.questionType != 'shortAnswer') {
    if (!questionList[index].isRight && item.questionType != "shortAnswer") {
      // 客观题回答错误 记录错题
      if (this.data.errorList.findIndex((errorItem) => errorItem == item.id) == -1) {
        this.data.errorList.push(item.id)
      if (
        this.data.errorList.findIndex((errorItem) => errorItem == item.id) == -1
      ) {
        this.data.errorList.push(item.id);
      }
    } else {
      if (this.data.answerType == 'errorQuestion' || this.data.answerType == 'option') {
      if (
        this.data.answerType == "errorQuestion" ||
        this.data.answerType == "option"
      ) {
        // 从错题集中移除
        let errorIndex = this.data.errorList.findIndex((erroritem) => erroritem == item.id)
        let errorIndex = this.data.errorList.findIndex(
          (erroritem) => erroritem == item.id
        );
        if (errorIndex > -1) {
          this.data.errorList.splice(errorIndex, 1)
          this.data.errorList.splice(errorIndex, 1);
        }
      }
    }
    if (this.data.answerType != 'collectQuestion') {
    if (this.data.answerType != "collectQuestion") {
      // 记录错题
      app.MG.identity
        .setUserKey({
          setKeyRequests: [{
            domain: 'errorData',
            key: this.data.rootCmsItemId,
            value: JSON.stringify(this.data.errorList)
          }]
          setKeyRequests: [
            {
              domain: "errorData",
              key: this.data.rootCmsItemId,
              value: JSON.stringify(this.data.errorList),
            },
          ],
        })
        .then((res) => {
          console.log(res)
        })
          console.log(res);
        });
    }
    this.setData({
      questionDataList: questionList
    })
    const cardUpdatedList = this.data.cardList
      questionDataList: questionList,
    });
    const cardUpdatedList = this.data.cardList;
    cardUpdatedList.forEach((item) => {
      item.infoList.forEach((citem) => {
        if (citem.id == questionList[index].id) {
@@ -974,188 +1065,199 @@
      });
    });
    this.setData({
      cardList: cardUpdatedList
    })
      cardList: cardUpdatedList,
    });
  },
  // 题目收藏按钮,收藏和取消同一接口,取消数组减去该项id
  setCollect() {
    const citem = this.data.questionDataList[this.data.currentIndex]
    const questionList = this.data.questionDataList
    const citem = this.data.questionDataList[this.data.currentIndex];
    const questionList = this.data.questionDataList;
    for (let index = 0; index < questionList.length; index++) {
      const item = questionList[index];
      if (item.id == citem.id) {
        item.isCollect = !item.isCollect
        item.isCollect = !item.isCollect;
      }
    }
    this.setData({
      questionDataList: questionList
    })
      questionDataList: questionList,
    });
    if (this.data.collectList.length == 0) {
      this.setData({
        collectList: [citem.id]
      })
        collectList: [citem.id],
      });
    } else {
      const collectItme = this.data.collectList.filter((item) => item == citem.id)
      const collectItme = this.data.collectList.filter(
        (item) => item == citem.id
      );
      if (collectItme.length) {
        const arr = this.data.collectList.filter((item) => item != citem.id)
        const arr = this.data.collectList.filter((item) => item != citem.id);
        this.setData({
          collectList: arr
        })
          collectList: arr,
        });
      } else {
        const collectArr = this.data.collectList
        collectArr.push(citem.id)
        const collectArr = this.data.collectList;
        collectArr.push(citem.id);
        this.setData({
          collectList: collectArr
        })
          collectList: collectArr,
        });
      }
    }
    app.MG.identity
      .setUserKey({
        setKeyRequests: [{
          domain: 'collectData',
          key: this.data.rootCmsItemId,
          value: JSON.stringify(this.data.collectList)
        }]
        setKeyRequests: [
          {
            domain: "collectData",
            key: this.data.rootCmsItemId,
            value: JSON.stringify(this.data.collectList),
          },
        ],
      })
      .then((res) => {})
      .then((res) => {});
  },
  // 处理答题数据
  recordAnswerData() {
    this.data.cardList.push({
      name: '客观题得分',
      name: "客观题得分",
      score: this.data.subjectiveNum,
      path: this.data.productLinkPath,
      // infoList: [],
      // catalogName: ''
    })
    });
    let setInfoData = {
      currentIndex: this.data.currentIndex,
      dataList: JSON.parse(JSON.stringify(this.data.cardList))
    }
      dataList: JSON.parse(JSON.stringify(this.data.cardList)),
    };
    for (let i = 0; i < setInfoData.dataList.length; i++) {
      const item = setInfoData.dataList[i]
      if (!item.name && !item.name == '客观题得分') {
      const item = setInfoData.dataList[i];
      if (!item.name && !item.name == "客观题得分") {
        for (let j = 0; j < item.infoList.length; j++) {
          let obj = {
            id: item.infoList[j].id,
            userAnswer: item.infoList[j].userAnswer,
            isComplete: item.infoList[j].isComplete,
            isRight: item.infoList[j].isRight,
            isCollect: item.infoList[j].isCollect
          }
          item.infoList[j] = obj
            isCollect: item.infoList[j].isCollect,
          };
          item.infoList[j] = obj;
        }
      }
    }
    this.setAnswerInfo(setInfoData)
    this.setAnswerInfo(setInfoData);
  },
  // 提交答题数据
  setAnswerInfo(data) {
    app.MG.identity
      .setUserKey({
        setKeyRequests: [{
          domain: 'answerData',
          key: this.data.productLinkPath,
          value: JSON.stringify(data)
        }]
        setKeyRequests: [
          {
            domain: "answerData",
            key: this.data.productLinkPath,
            value: JSON.stringify(data),
          },
        ],
      })
      .then((res) => {})
      .then((res) => {});
  },
  // 获取答题数据
  getAnswerInfo(callback) {
    app.MG.identity
      .getUserKey({
        domain: 'answerData',
        keys: [this.data.productLinkPath]
        domain: "answerData",
        keys: [this.data.productLinkPath],
      })
      .then((res) => {
        if (callback) callback(res)
      })
        if (callback) callback(res);
      });
  },
  // 删除答题数据
  delAnswerInfo(callback) {
    app.MG.identity
      .delUserKey({
        domain: 'answerData',
        keys: [this.data.productLinkPath]
        domain: "answerData",
        keys: [this.data.productLinkPath],
      })
      .then((res) => {
        if (callback) callback()
      })
        if (callback) callback();
      });
  },
  // 我的收藏模式下获取收藏题目id
  async getcollectId() {
    app.MG.identity
      .getUserKey({
        domain: 'collectData',
        keys: [this.data.rootCmsItemId]
        domain: "collectData",
        keys: [this.data.rootCmsItemId],
      })
      .then(async (res) => {
        try {
          this.setData({
            collectList: JSON.parse(res[0].value)
          })
            collectList: JSON.parse(res[0].value),
          });
        } catch (error) {}
        if (this.data.collectList && this.data.collectList.length) {
          await this.getCollectDataList()
          await this.getCollectDataList();
        } else {
          this.setData({
            loading: false
          })
            loading: false,
          });
          wx.showModal({
            title: '提示',
            content: '收藏夹暂无数据', //editable如果为true,这就是输入框的内容
            title: "提示",
            content: "收藏夹暂无数据", //editable如果为true,这就是输入框的内容
            editable: false, //是否显示输入框
            showCancel: false,
            success: (res) => {
              if (res.confirm) {
                this.setData({
                  submitStatus: true
                })
                this.goBack()
                  submitStatus: true,
                });
                this.goBack();
              }
            }
          })
            },
          });
        }
      })
      });
  },
  // 获取收藏夹
  async getCollectDataList() {
    let questionArr = []
    let questionArr = [];
    this.setData({
      cardList: [{
        catalogName: '单选题',
        infoList: []
      }, {
        catalogName: '判断题',
        infoList: []
      }, {
        catalogName: '多选题',
        infoList: []
      }, {
        catalogName: '填空题',
        infoList: []
      }, {
        catalogName: '简答题',
        infoList: []
      }]
    })
    let singleChoiceArr = [] // 单选
    let judgeArr = [] // 判断
    let shortArr = [] // 简答
    let multipleChoiceArr = [] // 多选
    let completionArr = [] // 填空
      cardList: [
        {
          catalogName: "单选题",
          infoList: [],
        },
        {
          catalogName: "判断题",
          infoList: [],
        },
        {
          catalogName: "多选题",
          infoList: [],
        },
        {
          catalogName: "填空题",
          infoList: [],
        },
        {
          catalogName: "简答题",
          infoList: [],
        },
      ],
    });
    let singleChoiceArr = []; // 单选
    let judgeArr = []; // 判断
    let shortArr = []; // 简答
    let multipleChoiceArr = []; // 多选
    let completionArr = []; // 填空
    for (let qindex = 0; qindex < this.data.collectList.length; qindex++) {
      const qitem = this.data.collectList[qindex];
      let query = {
        path: '*',
        path: "*",
        cmsPath: this.data.rootCmsItemId,
        cmsType: '*',
        cmsType: "*",
        productId: this.data.bookId,
        queryType: '*',
        itemIds: qitem + '',
        queryType: "*",
        itemIds: qitem + "",
        itemFields: {
          Embedded_QuestionBank_Stem: [],
          Embedded_QuestionBank_AnalysisCon: [],
@@ -1165,191 +1267,230 @@
          Embedded_QuestionBank_StemStyle: [],
          Embedded_QuestionBank_OptionStyle: [],
          Embedded_QuestionBank_KnowledgePoint: [],
          Embedded_QuestionBank_Difficulty: []
        }
      }
          Embedded_QuestionBank_Difficulty: [],
        },
      };
      await app.MG.store.getProductDetail(query).then((res) => {
        let questionArr = []
        let questionArr = [];
        res.datas.cmsDatas[0].datas.forEach((item, index) => {
          const questionObj = {
            number: index + 1, // 题号
            id: item.id,
            stem: item.Embedded_QuestionBank_QuestionType == 'completion' ?
              JSON.parse(item.Embedded_QuestionBank_Stem)
              .stemTxt.replaceAll('<vacancy>', ',input,')
              .split(',') : JSON.parse(item.Embedded_QuestionBank_Stem), // 题干
            stem:
              item.Embedded_QuestionBank_QuestionType == "completion"
                ? JSON.parse(item.Embedded_QuestionBank_Stem)
                    .stemTxt.replaceAll("<vacancy>", ",input,")
                    .split(",")
                : JSON.parse(item.Embedded_QuestionBank_Stem), // 题干
            answer: item.Embedded_QuestionBank_Answer, // 答案
            option: item.Embedded_QuestionBank_Option ?
              JSON.parse(item.Embedded_QuestionBank_Option) : '', // 选择题选项
            option: item.Embedded_QuestionBank_Option
              ? JSON.parse(item.Embedded_QuestionBank_Option)
              : "", // 选择题选项
            analysisCon: item.Embedded_QuestionBank_AnalysisCon, // 解析
            questionType: item.Embedded_QuestionBank_QuestionType, // 题型
            optionStyle: item.Embedded_QuestionBank_OptionStyle, // 选项显示类型
            stemStyle: item.Embedded_QuestionBank_StemStyle, // 题干显示类型
            difficulty: item.Embedded_QuestionBank_Difficulty ?
              4 - item.Embedded_QuestionBank_Difficulty : 0, // 难度等级
            userAnswer: item.Embedded_QuestionBank_QuestionType == 'completion' ||
              item.Embedded_QuestionBank_QuestionType == 'multipleChoice' ? [] : '',
            difficulty: item.Embedded_QuestionBank_Difficulty
              ? 4 - item.Embedded_QuestionBank_Difficulty
              : 0, // 难度等级
            userAnswer:
              item.Embedded_QuestionBank_QuestionType == "completion" ||
              item.Embedded_QuestionBank_QuestionType == "multipleChoice"
                ? []
                : "",
            isSubmit: false, // 查看解析
            isRight: null, // 是否正确
            isComplete: false,
            isCollect: true
          }
            isCollect: true,
          };
          // 多选和填空答案肯为数组,要转换JSON格式
          if (
            questionObj.questionType == 'completion' ||
            questionObj.questionType == 'multipleChoice'
            questionObj.questionType == "completion" ||
            questionObj.questionType == "multipleChoice"
          ) {
            try {
              questionObj.answer = JSON.parse(questionObj.answer).toString()
              questionObj.answer = JSON.parse(questionObj.answer).toString();
            } catch (error) {
              questionObj.answer = item.Embedded_QuestionBank_Answer
              questionObj.answer = item.Embedded_QuestionBank_Answer;
            }
          }
          // 填空题改造
          if (questionObj.questionType == 'completion') {
            let index = 0
          if (questionObj.questionType == "completion") {
            let index = 0;
            for (let i = 0; i < questionObj.stem.length; i++) {
              const item = questionObj.stem[i]
              if (item == 'input') {
              const item = questionObj.stem[i];
              if (item == "input") {
                questionObj.stem[i] = {
                  num: index,
                  data: 'input'
                }
                questionObj.userAnswer[index] = ''
                index++
                  data: "input",
                };
                questionObj.userAnswer[index] = "";
                index++;
              }
            }
          }
          // 获取图片
          if (questionObj.stemStyle == 'Image' || questionObj.stemStyle == 'TxtAndImage') {
            questionObj.stem.stemImage = getPublicImage(questionObj.stem.stemImage, 150)
          if (
            questionObj.stemStyle == "Image" ||
            questionObj.stemStyle == "TxtAndImage"
          ) {
            questionObj.stem.stemImage = getPublicImage(
              questionObj.stem.stemImage,
              150
            );
          }
          if (questionObj.optionStyle == 'Image' || questionObj.optionStyle == 'TxtAndImage') {
            questionObj.option.forEach(optionItem => {
              if (optionItem.img) optionItem.img = getPublicImage(optionItem.img, 150)
            })
          if (
            questionObj.optionStyle == "Image" ||
            questionObj.optionStyle == "TxtAndImage"
          ) {
            questionObj.option.forEach((optionItem) => {
              if (optionItem.img)
                optionItem.img = getPublicImage(optionItem.img, 150);
            });
          }
          // 题干富文本处理
          if (questionObj.stemStyle == 'RichText') {
          if (questionObj.stemStyle == "RichText") {
            // questionObj.option.txt = ''
            questionObj.stem.stemTxt = questionObj.stem.stemTxt.replace(/\<img/gi, '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" ').replace(/\<p/gi, '<p class="stem-rich-p"')
            questionObj.stem.stemTxt = questionObj.stem.stemTxt
              .replace(
                /\<img/gi,
                '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" '
              )
              .replace(/\<p/gi, '<p class="stem-rich-p"');
          }
          // 选项富文本处理
          if (questionObj.optionStyle == 'RichText' && (questionObj.questionType == 'singleChoice' || questionObj.questionType == 'judge' || questionObj.questionType == 'multipleChoice')) {
            questionObj.option.forEach(item => {
              if (item.txt) item.txt = item.txt.replace(/\<img/gi, '<img class="option-rich-img"').replace(/\<p/gi, '<p class="stem-rich-p"')
            })
          if (
            questionObj.optionStyle == "RichText" &&
            (questionObj.questionType == "singleChoice" ||
              questionObj.questionType == "judge" ||
              questionObj.questionType == "multipleChoice")
          ) {
            questionObj.option.forEach((item) => {
              if (item.txt)
                item.txt = item.txt
                  .replace(/\<img/gi, '<img class="option-rich-img"')
                  .replace(/\<p/gi, '<p class="stem-rich-p"');
            });
          }
          if (item.Embedded_QuestionBank_QuestionType == 'judge') {
            questionObj.type = '判断题'
            judgeArr.push(questionObj)
          } else if (item.Embedded_QuestionBank_QuestionType == 'singleChoice') {
            questionObj.type = '单选题'
            singleChoiceArr.push(questionObj)
          } else if (item.Embedded_QuestionBank_QuestionType == 'multipleChoice') {
            questionObj.type = '多选题'
            multipleChoiceArr.push(questionObj)
          } else if (item.Embedded_QuestionBank_QuestionType == 'completion') {
            questionObj.type = '填空题'
            completionArr.push(questionObj)
          } else if (item.Embedded_QuestionBank_QuestionType == 'shortAnswer') {
            questionObj.type = '简答题'
            shortArr.push(questionObj)
          if (item.Embedded_QuestionBank_QuestionType == "judge") {
            questionObj.type = "判断题";
            judgeArr.push(questionObj);
          } else if (
            item.Embedded_QuestionBank_QuestionType == "singleChoice"
          ) {
            questionObj.type = "单选题";
            singleChoiceArr.push(questionObj);
          } else if (
            item.Embedded_QuestionBank_QuestionType == "multipleChoice"
          ) {
            questionObj.type = "多选题";
            multipleChoiceArr.push(questionObj);
          } else if (item.Embedded_QuestionBank_QuestionType == "completion") {
            questionObj.type = "填空题";
            completionArr.push(questionObj);
          } else if (item.Embedded_QuestionBank_QuestionType == "shortAnswer") {
            questionObj.type = "简答题";
            shortArr.push(questionObj);
          }
        })
      })
        });
      });
    }
    this.setData({
      ['cardList[0].infoList']: singleChoiceArr,
      ['cardList[1].infoList']: judgeArr,
      ['cardList[2].infoList']: multipleChoiceArr,
      ['cardList[3].infoList']: completionArr,
      ['cardList[3].infoList']: shortArr,
    })
    const cardList = this.data.cardList
      ["cardList[0].infoList"]: singleChoiceArr,
      ["cardList[1].infoList"]: judgeArr,
      ["cardList[2].infoList"]: multipleChoiceArr,
      ["cardList[3].infoList"]: completionArr,
      ["cardList[4].infoList"]: shortArr,
    });
    const cardList = this.data.cardList;
    for (let index = 0; index < cardList.length; index++) {
      const item = cardList[index];
      for (let cindex = 0; cindex < item.infoList.length; cindex++) {
        const citem = item.infoList[cindex]
        citem.number = cindex + 1
        questionArr.push(citem)
        const citem = item.infoList[cindex];
        citem.number = cindex + 1;
        questionArr.push(citem);
      }
    }
    this.setData({
      questionDataList: questionArr,
      cardList: cardList,
      loading: false
    })
      loading: false,
    });
  },
  // 我的错题模式下获取错题id列表
  async getErrorIdList() {
    await app.MG.identity
      .getUserKey({
        domain: 'errorData',
        keys: [this.data.rootCmsItemId]
        domain: "errorData",
        keys: [this.data.rootCmsItemId],
      })
      .then((res) => {
        try {
          this.setData({
            errorList: JSON.parse(res[0].value)
          })
            errorList: JSON.parse(res[0].value),
          });
        } catch (error) {}
        if (this.data.errorList && this.data.errorList.length) {
          this.getErrorDataList()
          this.getErrorDataList();
        } else {
          this.setData({
            loading: true
          })
            loading: true,
          });
          wx.showModal({
            title: '提示',
            content: '错题集暂无数据', //editable如果为true,这就是输入框的内容
            title: "提示",
            content: "错题集暂无数据", //editable如果为true,这就是输入框的内容
            editable: false, //是否显示输入框
            showCancel: false,
            success: (res) => {
              if (res.confirm) {
                this.setData({
                  submitStatus: true
                })
                this.goBack()
                  submitStatus: true,
                });
                this.goBack();
              }
            }
          })
            },
          });
        }
      })
      });
  },
  // 获取错题集
  async getErrorDataList() {
    this.setData({
      cardList: [{
        catalogName: '单选题',
        infoList: []
      }, {
        catalogName: '判断题',
        infoList: []
      }, {
        catalogName: '多选题',
        infoList: []
      }, {
        catalogName: '填空题',
        infoList: []
      }, {
        catalogName: '简答题',
        infoList: []
      }]
    })
    let singleChoiceArr = [] // 单选
    let judgeArr = [] // 判断
    let shortArr = [] // 简答
    let multipleChoiceArr = [] // 多选
    let completionArr = [] // 填空
      cardList: [
        {
          catalogName: "单选题",
          infoList: [],
        },
        {
          catalogName: "判断题",
          infoList: [],
        },
        {
          catalogName: "多选题",
          infoList: [],
        },
        {
          catalogName: "填空题",
          infoList: [],
        },
        {
          catalogName: "简答题",
          infoList: [],
        },
      ],
    });
    let singleChoiceArr = []; // 单选
    let judgeArr = []; // 判断
    let shortArr = []; // 简答
    let multipleChoiceArr = []; // 多选
    let completionArr = []; // 填空
    let query = {
      path: '*',
      path: "*",
      cmsPath: this.data.rootCmsItemId,
      cmsType: '*',
      cmsType: "*",
      productId: this.data.bookId,
      queryType: '*',
      itemIds: this.data.errorList.map((item) => item + ''),
      queryType: "*",
      itemIds: this.data.errorList.map((item) => item + ""),
      itemFields: {
        Embedded_QuestionBank_Stem: [],
        Embedded_QuestionBank_AnalysisCon: [],
@@ -1359,234 +1500,269 @@
        Embedded_QuestionBank_StemStyle: [],
        Embedded_QuestionBank_OptionStyle: [],
        Embedded_QuestionBank_KnowledgePoint: [],
        Embedded_QuestionBank_Difficulty: []
      }
    }
        Embedded_QuestionBank_Difficulty: [],
      },
    };
    await app.MG.store.getProductDetail(query).then((res) => {
      let questionArr = []
      let questionArr = [];
      res.datas.cmsDatas[0].datas.forEach((item, index) => {
        const questionObj = {
          number: index + 1, // 题号
          id: item.id,
          stem: item.Embedded_QuestionBank_QuestionType == 'completion' ?
            JSON.parse(item.Embedded_QuestionBank_Stem)
            .stemTxt.replaceAll('<vacancy>', ',input,')
            .split(',') : JSON.parse(item.Embedded_QuestionBank_Stem), // 题干
          stem:
            item.Embedded_QuestionBank_QuestionType == "completion"
              ? JSON.parse(item.Embedded_QuestionBank_Stem)
                  .stemTxt.replaceAll("<vacancy>", ",input,")
                  .split(",")
              : JSON.parse(item.Embedded_QuestionBank_Stem), // 题干
          answer: item.Embedded_QuestionBank_Answer, // 答案
          option: item.Embedded_QuestionBank_Option ?
            JSON.parse(item.Embedded_QuestionBank_Option) : '', // 选择题选项
          option: item.Embedded_QuestionBank_Option
            ? JSON.parse(item.Embedded_QuestionBank_Option)
            : "", // 选择题选项
          analysisCon: item.Embedded_QuestionBank_AnalysisCon, // 解析
          questionType: item.Embedded_QuestionBank_QuestionType, // 题型
          optionStyle: item.Embedded_QuestionBank_OptionStyle, // 选项显示类型
          stemStyle: item.Embedded_QuestionBank_StemStyle, // 题干显示类型
          difficulty: item.Embedded_QuestionBank_Difficulty ?
            4 - item.Embedded_QuestionBank_Difficulty : 0, // 难度等级
          userAnswer: item.Embedded_QuestionBank_QuestionType == 'completion' ||
            item.Embedded_QuestionBank_QuestionType == 'multipleChoice' ? [] : '',
          difficulty: item.Embedded_QuestionBank_Difficulty
            ? 4 - item.Embedded_QuestionBank_Difficulty
            : 0, // 难度等级
          userAnswer:
            item.Embedded_QuestionBank_QuestionType == "completion" ||
            item.Embedded_QuestionBank_QuestionType == "multipleChoice"
              ? []
              : "",
          isSubmit: false, // 查看解析
          isRight: null, // 是否正确
          isComplete: false,
          isCollect: this.data.collectList.some((collectItem) => collectItem == item.id)
        }
          isCollect: this.data.collectList.some(
            (collectItem) => collectItem == item.id
          ),
        };
        // 多选和填空答案肯为数组,要转换JSON格式
        if (
          questionObj.questionType == 'completion' ||
          questionObj.questionType == 'multipleChoice'
          questionObj.questionType == "completion" ||
          questionObj.questionType == "multipleChoice"
        ) {
          try {
            questionObj.answer = JSON.parse(questionObj.answer).toString()
            questionObj.answer = JSON.parse(questionObj.answer).toString();
          } catch (error) {
            questionObj.answer = item.Embedded_QuestionBank_Answer
            questionObj.answer = item.Embedded_QuestionBank_Answer;
          }
        }
        // 填空题改造
        if (questionObj.questionType == 'completion') {
          let index = 0
        if (questionObj.questionType == "completion") {
          let index = 0;
          for (let i = 0; i < questionObj.stem.length; i++) {
            const item = questionObj.stem[i]
            if (item == 'input') {
            const item = questionObj.stem[i];
            if (item == "input") {
              questionObj.stem[i] = {
                num: index,
                data: 'input'
              }
              questionObj.userAnswer[index] = ''
              index++
                data: "input",
              };
              questionObj.userAnswer[index] = "";
              index++;
            }
          }
        }
        // 获取图片
        if (questionObj.stemStyle == 'Image' || questionObj.stemStyle == 'TxtAndImage') {
          questionObj.stem.stemImage = getPublicImage(questionObj.stem.stemImage, 150)
        if (
          questionObj.stemStyle == "Image" ||
          questionObj.stemStyle == "TxtAndImage"
        ) {
          questionObj.stem.stemImage = getPublicImage(
            questionObj.stem.stemImage,
            150
          );
        }
        if (questionObj.optionStyle == 'Image' || questionObj.optionStyle == 'TxtAndImage') {
          questionObj.option.forEach(optionItem => {
            if (optionItem.img) optionItem.img = getPublicImage(optionItem.img, 150)
          })
        if (
          questionObj.optionStyle == "Image" ||
          questionObj.optionStyle == "TxtAndImage"
        ) {
          questionObj.option.forEach((optionItem) => {
            if (optionItem.img)
              optionItem.img = getPublicImage(optionItem.img, 150);
          });
        }
        // 题干富文本处理
        if (questionObj.stemStyle == 'RichText') {
        if (questionObj.stemStyle == "RichText") {
          // questionObj.option.txt = ''
          questionObj.stem.stemTxt = questionObj.stem.stemTxt.replace(/\<img/gi, '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" ').replace(/\<p/gi, '<p class="stem-rich-p"')
          questionObj.stem.stemTxt = questionObj.stem.stemTxt
            .replace(
              /\<img/gi,
              '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img" '
            )
            .replace(/\<p/gi, '<p class="stem-rich-p"');
        }
        // 选项富文本处理
        if (questionObj.optionStyle == 'RichText' && (questionObj.questionType == 'singleChoice' || questionObj.questionType == 'judge' || questionObj.questionType == 'multipleChoice')) {
          questionObj.option.forEach(item => {
            if (item.txt) item.txt = item.txt.replace(/\<img/gi, '<img class="option-rich-img"').replace(/\<p/gi, '<p class="stem-rich-p"')
          })
        if (
          questionObj.optionStyle == "RichText" &&
          (questionObj.questionType == "singleChoice" ||
            questionObj.questionType == "judge" ||
            questionObj.questionType == "multipleChoice")
        ) {
          questionObj.option.forEach((item) => {
            if (item.txt)
              item.txt = item.txt
                .replace(/\<img/gi, '<img class="option-rich-img"')
                .replace(/\<p/gi, '<p class="stem-rich-p"');
          });
        }
        if (item.Embedded_QuestionBank_QuestionType == 'judge') {
          questionObj.type = '判断题'
          judgeArr.push(questionObj)
        } else if (item.Embedded_QuestionBank_QuestionType == 'singleChoice') {
          questionObj.type = '单选题'
          singleChoiceArr.push(questionObj)
        } else if (item.Embedded_QuestionBank_QuestionType == 'multipleChoice') {
          questionObj.type = '多选题'
          multipleChoiceArr.push(questionObj)
        } else if (item.Embedded_QuestionBank_QuestionType == 'completion') {
          questionObj.type = '填空题'
          completionArr.push(questionObj)
        } else if (item.Embedded_QuestionBank_QuestionType == 'shortAnswer') {
          questionObj.type = '简答题'
          shortArr.push(questionObj)
        if (item.Embedded_QuestionBank_QuestionType == "judge") {
          questionObj.type = "判断题";
          judgeArr.push(questionObj);
        } else if (item.Embedded_QuestionBank_QuestionType == "singleChoice") {
          questionObj.type = "单选题";
          singleChoiceArr.push(questionObj);
        } else if (
          item.Embedded_QuestionBank_QuestionType == "multipleChoice"
        ) {
          questionObj.type = "多选题";
          multipleChoiceArr.push(questionObj);
        } else if (item.Embedded_QuestionBank_QuestionType == "completion") {
          questionObj.type = "填空题";
          completionArr.push(questionObj);
        } else if (item.Embedded_QuestionBank_QuestionType == "shortAnswer") {
          questionObj.type = "简答题";
          shortArr.push(questionObj);
        }
        // questionArr.push(questionObj)
      })
      });
      this.setData({
        // questionDataList: questionArr,
        ['cardList[0].infoList']: singleChoiceArr,
        ['cardList[1].infoList']: judgeArr,
        ['cardList[2].infoList']: multipleChoiceArr,
        ['cardList[3].infoList']: completionArr,
        ['cardList[3].infoList']: shortArr,
        ["cardList[0].infoList"]: singleChoiceArr,
        ["cardList[1].infoList"]: judgeArr,
        ["cardList[2].infoList"]: multipleChoiceArr,
        ["cardList[3].infoList"]: completionArr,
        ["cardList[4].infoList"]: shortArr,
        // loading: false
      })
      const cardList = this.data.cardList
      });
      const cardList = this.data.cardList;
      for (let index = 0; index < cardList.length; index++) {
        const item = cardList[index];
        for (let cindex = 0; cindex < item.infoList.length; cindex++) {
          const citem = item.infoList[cindex]
          citem.number = cindex + 1
          questionArr.push(citem)
          const citem = item.infoList[cindex];
          citem.number = cindex + 1;
          questionArr.push(citem);
        }
      }
      this.setData({
        questionDataList: questionArr,
        cardList: cardList,
        loading: false
      })
    })
        loading: false,
      });
    });
    // loadings.value = false
  },
  // 获取组卷结果
  async getEduQuizConfig() {
    await app.MG.edu
      .getEduQuizConfigResult({
        idOrRefCode: this.data.mockid
        idOrRefCode: this.data.mockid,
      })
      .then(async (configRes) => {
        // 获取 分数 时间
        this.setData({
          'mockData.score': configRes.score
        })
          "mockData.score": configRes.score,
        });
        try {
          this.setData({
            'mockData.time': JSON.parse(configRes.config).time * 1000,
            countdownTime: JSON.parse(configRes.config).time * 1000
          })
            "mockData.time": JSON.parse(configRes.config).time * 1000,
            countdownTime: JSON.parse(configRes.config).time * 1000,
          });
        } catch (error) {
          this.setData({
            'mockData.time': 3600 * 1000,
            "mockData.time": 3600 * 1000,
            countdownTime: 3600 * 1000,
          })
          });
        }
        this.setData({
          'mockData.sumTime': this.data.mockData.time
        })
        let itemIds = []
        let numberIndex = 1
          "mockData.sumTime": this.data.mockData.time,
        });
        let itemIds = [];
        let numberIndex = 1;
        // 获取抽题结果
        const cardList = configRes.eduQuizConfigStageResultList.map((item) => {
          let questionIds = []
          let questionIds = [];
          // 获取必含题目
          let list = item.cmsItemList.map((idItem) => {
            itemIds.push(idItem.id + '')
            itemIds.push(idItem.id + "");
            questionIds.push({
              id: idItem.id + '',
              score: idItem.score
            })
            numberIndex++
              id: idItem.id + "",
              score: idItem.score,
            });
            numberIndex++;
            return {
              number: numberIndex,
              id: idItem.id,
              score: idItem.score
            }
          })
              score: idItem.score,
            };
          });
          // 获取抽题题目
          let extractList = []
          let extractList = [];
          for (let i = 0; i < item.generatorResultList.length; i++) {
            const extractItem = item.generatorResultList[i]
            let extractItemList = extractItem.cmsItemList.map((extractCmsItem) => {
              itemIds.push(extractCmsItem.id + '')
              questionIds.push({
                id: extractCmsItem.id + '',
                score: extractCmsItem.score
              })
              numberIndex++
              return {
                number: numberIndex,
                id: extractCmsItem.id,
                score: extractCmsItem.score
            const extractItem = item.generatorResultList[i];
            let extractItemList = extractItem.cmsItemList.map(
              (extractCmsItem) => {
                itemIds.push(extractCmsItem.id + "");
                questionIds.push({
                  id: extractCmsItem.id + "",
                  score: extractCmsItem.score,
                });
                numberIndex++;
                return {
                  number: numberIndex,
                  id: extractCmsItem.id,
                  score: extractCmsItem.score,
                };
              }
            })
            extractList = extractList.concat(extractItemList)
            );
            extractList = extractList.concat(extractItemList);
          }
          return {
            path: item.id,
            catalogName: item.name,
            infoList: list.concat(extractList)
          }
        })
            infoList: list.concat(extractList),
          };
        });
        this.setData({
          cardList: cardList
        })
          cardList: cardList,
        });
        // 更新该条组卷的数据状态,包括记录改试卷总分,更改组卷状态state为1,表示已经抽题完成,并要将抽屉数据记录下来
        if (this.data.mockData.datas && this.data.mockData.datas.length) {
          const mockData = this.data.mockData
          const mockData = this.data.mockData;
          mockData.datas.forEach((item, index) => {
            if (item.id == this.data.uuid) {
              item.state = '1'
              item.time = mockData.time
              item.score = configRes.score
              mockData.state = '1'
              item.state = "1";
              item.time = mockData.time;
              item.score = configRes.score;
              mockData.state = "1";
            }
          })
          });
          this.setData({
            mockData: mockData
          })
            mockData: mockData,
          });
        }
        this.setMockInfo(this.data.mockData.datas) // 记录试卷总分 时长,修改state为 1
        this.setMockInfo(this.data.mockData.datas); // 记录试卷总分 时长,修改state为 1
        // 更新本地mockData
        this.saveMockQuestionList(this.data.cardList) // 记录题目列表
        await this.getMockDataList(this.data.cardList) // 请求题目数据
      })
        this.saveMockQuestionList(this.data.cardList); // 记录题目列表
        await this.getMockDataList(this.data.cardList); // 请求题目数据
      });
  },
  // 获取组卷题目列表
  async getMockDataList(questionList, oldList) {
    const questionDataList = this.data.questionDataList
    const questionDataList = this.data.questionDataList;
    for (let pathindex = 0; pathindex < questionList.length; pathindex++) {
      const pathitem = questionList[pathindex];
      let itemIds = []
      pathitem.infoList.forEach(item => {
        itemIds.push(item.id + '')
      })
      let itemIds = [];
      pathitem.infoList.forEach((item) => {
        itemIds.push(item.id + "");
      });
      let query = {
        path: '*',
        path: "*",
        cmsPath: this.data.rootCmsItemId,
        cmsType: '*',
        cmsType: "*",
        productId: this.data.bookId,
        queryType: '*',
        queryType: "*",
        itemIds,
        itemFields: {
          Embedded_QuestionBank_Stem: [],
@@ -1597,272 +1773,330 @@
          Embedded_QuestionBank_StemStyle: [],
          Embedded_QuestionBank_OptionStyle: [],
          Embedded_QuestionBank_KnowledgePoint: [],
          Embedded_QuestionBank_Difficulty: []
        }
      }
          Embedded_QuestionBank_Difficulty: [],
        },
      };
      await app.MG.store.getProductDetail(query).then((res) => {
        res.datas.cmsDatas[0].datas.forEach((item, index) => {
          // 循环questionList,给每题赋值分数
          let oldObj
          if (oldList) oldObj = oldList.find((oldItem) => oldItem.id == item.id)
          let oldObj;
          if (oldList)
            oldObj = oldList.find((oldItem) => oldItem.id == item.id);
          let questionObj = {
            // number: pathitem.infoList.find(infoItem => infoItem.itemId == item.id).number,
            id: item.id,
            score: pathitem.infoList.find(infoItem => infoItem.id == item.id).score,
            stem: item.Embedded_QuestionBank_QuestionType == 'completion' ?
              JSON.parse(item.Embedded_QuestionBank_Stem)
              .stemTxt.replaceAll('<vacancy>', ',input,')
              .split(',') : JSON.parse(item.Embedded_QuestionBank_Stem), // 题干
            score: pathitem.infoList.find((infoItem) => infoItem.id == item.id)
              .score,
            stem:
              item.Embedded_QuestionBank_QuestionType == "completion"
                ? JSON.parse(item.Embedded_QuestionBank_Stem)
                    .stemTxt.replaceAll("<vacancy>", ",input,")
                    .split(",")
                : JSON.parse(item.Embedded_QuestionBank_Stem), // 题干
            answer: item.Embedded_QuestionBank_Answer, // 答案
            option: item.Embedded_QuestionBank_Option ?
              JSON.parse(item.Embedded_QuestionBank_Option) : '', // 选择题选项
            option: item.Embedded_QuestionBank_Option
              ? JSON.parse(item.Embedded_QuestionBank_Option)
              : "", // 选择题选项
            analysisCon: item.Embedded_QuestionBank_AnalysisCon, // 解析
            questionType: item.Embedded_QuestionBank_QuestionType, // 题型
            optionStyle: item.Embedded_QuestionBank_OptionStyle, // 选项显示类型
            stemStyle: item.Embedded_QuestionBank_StemStyle, // 题干显示类型
            difficulty: item.Embedded_QuestionBank_Difficulty ?
              4 - item.Embedded_QuestionBank_Difficulty : 0, // 难度等级
            userAnswer: oldObj ?
              oldObj.answer : item.Embedded_QuestionBank_QuestionType == 'completion' ||
              item.Embedded_QuestionBank_QuestionType == 'multipleChoice' ? [] : '',
            difficulty: item.Embedded_QuestionBank_Difficulty
              ? 4 - item.Embedded_QuestionBank_Difficulty
              : 0, // 难度等级
            userAnswer: oldObj
              ? oldObj.answer
              : item.Embedded_QuestionBank_QuestionType == "completion" ||
                item.Embedded_QuestionBank_QuestionType == "multipleChoice"
              ? []
              : "",
            isUserAnswer: oldObj ? this.isHaveAnswer(oldObj.userAnswer) : false,
            isRight: oldObj ? oldObj.isRight : null,
            // isComplete: oldObj ? oldObj.isComplete : false,
            isComplete: this.data.mockData.state == '3' ? true : false,
            isCollect: this.data.collectList.indexOf(item.id) > -1 ? true : false,
            isUnfold: '' // 控制解析的折叠面板是否展开
          }
            isComplete: this.data.mockData.state == "3" ? true : false,
            isCollect:
              this.data.collectList.indexOf(item.id) > -1 ? true : false,
            isUnfold: "", // 控制解析的折叠面板是否展开
          };
          // 多选和填空答案肯为数组,要转换JSON格式
          if (
            questionObj.questionType == 'completion' ||
            questionObj.questionType == 'multipleChoice'
            questionObj.questionType == "completion" ||
            questionObj.questionType == "multipleChoice"
          ) {
            try {
              questionObj.answer = JSON.parse(questionObj.answer).toString()
              questionObj.answer = JSON.parse(questionObj.answer).toString();
            } catch (error) {
              questionObj.answer = item.Embedded_QuestionBank_Answer
              questionObj.answer = item.Embedded_QuestionBank_Answer;
            }
          }
          // 填空题改造
          if (questionObj.questionType == 'completion') {
            let index = 0
          if (questionObj.questionType == "completion") {
            let index = 0;
            for (let i = 0; i < questionObj.stem.length; i++) {
              const item = questionObj.stem[i]
              if (item == 'input') {
              const item = questionObj.stem[i];
              if (item == "input") {
                questionObj.stem[i] = {
                  num: index,
                  data: 'input'
                }
                if (!oldObj) questionObj.userAnswer[index] = ''
                index++
                  data: "input",
                };
                if (!oldObj) questionObj.userAnswer[index] = "";
                index++;
              }
            }
          }
          // 题干富文本处理
          if (questionObj.stemStyle == 'RichText') {
          if (questionObj.stemStyle == "RichText") {
            // questionObj.option.txt = ''
            questionObj.stem.stemTxt = questionObj.stem.stemTxt.replace(/\<img/gi, '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img"')
            questionObj.stem.stemTxt = questionObj.stem.stemTxt.replace(
              /\<img/gi,
              '<img style="max-width: 300rpx !important;object-fit: contain;" class="stem-rich-img"'
            );
          }
          // 选项富文本处理
          if (questionObj.optionStyle == 'RichText' && (questionObj.questionType == 'singleChoice' || questionObj.questionType == 'judge' || questionObj.questionType == 'multipleChoice')) {
            questionObj.option.forEach(item => {
              if (item.txt) item.txt = item.txt.replace(/\<img/gi, '<img class="option-rich-img"')
            })
          if (
            questionObj.optionStyle == "RichText" &&
            (questionObj.questionType == "singleChoice" ||
              questionObj.questionType == "judge" ||
              questionObj.questionType == "multipleChoice")
          ) {
            questionObj.option.forEach((item) => {
              if (item.txt)
                item.txt = item.txt.replace(
                  /\<img/gi,
                  '<img class="option-rich-img"'
                );
            });
          }
          // 获取图片
          if (questionObj.stemStyle == 'Image' || questionObj.stemStyle == 'TxtAndImage') {
            questionObj.stem.stemImage = getPublicImage(questionObj.stem.stemImage, 150)
          if (
            questionObj.stemStyle == "Image" ||
            questionObj.stemStyle == "TxtAndImage"
          ) {
            questionObj.stem.stemImage = getPublicImage(
              questionObj.stem.stemImage,
              150
            );
          }
          if (questionObj.optionStyle == 'Image' || questionObj.optionStyle == 'TxtAndImage') {
            questionObj.option.forEach(optionItem => {
              if (optionItem.img) optionItem.img = getPublicImage(optionItem.img, 150)
            })
          if (
            questionObj.optionStyle == "Image" ||
            questionObj.optionStyle == "TxtAndImage"
          ) {
            questionObj.option.forEach((optionItem) => {
              if (optionItem.img)
                optionItem.img = getPublicImage(optionItem.img, 150);
            });
          }
          // 客观题总分赋值
          if (questionObj.questionType !== 'shortAnswer') {
          if (questionObj.questionType !== "shortAnswer") {
            this.setData({
              subjectiveGrade: this.data.subjectiveGrade + questionObj.score
            })
              subjectiveGrade: this.data.subjectiveGrade + questionObj.score,
            });
          }
          if (oldObj && oldObj.isRight) {
            this.setData({
              correctNum: this.data.correctNum + 1
            })
              correctNum: this.data.correctNum + 1,
            });
          }
          if (item.questionType != 'shortAnswer' && item.isComplete) {
          if (item.questionType != "shortAnswer" && item.isComplete) {
            this.setData({
              subjectiveTotal: this.data.subjectiveTotal + 1
            })
              subjectiveTotal: this.data.subjectiveTotal + 1,
            });
          }
          // if (oldObj && isHaveAnswer(oldObj.answer)) countDownRef.value.changeAlready()
          // cardList赋值
          let cardIndex = this.data.cardList.findIndex((item) => item.catalogName == pathitem.catalogName)
          let infoIndex = this.data.cardList[cardIndex].infoList.findIndex(infoItem => infoItem.id == item.id)
          let cardIndex = this.data.cardList.findIndex(
            (item) => item.catalogName == pathitem.catalogName
          );
          let infoIndex = this.data.cardList[cardIndex].infoList.findIndex(
            (infoItem) => infoItem.id == item.id
          );
          this.setData({
            [`cardList[${cardIndex}].infoList[${infoIndex}]`]: questionObj
          })
          let questionList = []
          const cardUpdatedList = this.data.cardList
          cardUpdatedList.forEach(aitem => {
            [`cardList[${cardIndex}].infoList[${infoIndex}]`]: questionObj,
          });
          let questionList = [];
          const cardUpdatedList = this.data.cardList;
          cardUpdatedList.forEach((aitem) => {
            aitem.infoList.forEach((bitem, bindex) => {
              questionList.push(bitem)
              bitem.number = bindex + 1
            })
          })
              questionList.push(bitem);
              bitem.number = bindex + 1;
            });
          });
          this.setData({
            questionDataList: questionList,
            cardList: cardUpdatedList
          })
        })
      })
            cardList: cardUpdatedList,
          });
        });
      });
    }
    this.setData({
      loading: false
    })
      loading: false,
    });
  },
  // 获取组卷数据
  getMockInfo(callback) {
    app.MG.identity
      .getUserKey({
        domain: 'mockData',
        keys: [this.data.bookId]
        domain: "mockData",
        keys: [this.data.bookId],
      })
      .then((res) => {
        if (callback) callback(res)
      })
        if (callback) callback(res);
      });
  },
  // 记录购买组卷时间
  setMockInfo(data) {
    app.MG.identity.setUserKey({
      setKeyRequests: [{
        domain: 'mockData',
        key: this.data.bookId + '',
        value: JSON.stringify(data)
      }]
    })
      setKeyRequests: [
        {
          domain: "mockData",
          key: this.data.bookId + "",
          value: JSON.stringify(data),
        },
      ],
    });
  },
  // 记录组卷题目列表
  saveMockQuestionList(data) {
    app.MG.identity
      .setUserKey({
        setKeyRequests: [{
          domain: 'mockQuestionData',
          key: this.data.uuid,
          value: JSON.stringify(data)
        }]
        setKeyRequests: [
          {
            domain: "mockQuestionData",
            key: this.data.uuid,
            value: JSON.stringify(data),
          },
        ],
      })
      .then((res) => {
        console.log('模考题目列表已记录')
      })
        console.log("模考题目列表已记录");
      });
  },
  // 获取记录组卷题目列表
  async getMockQuestionList() {
    let list = []
    let list = [];
    await app.MG.identity
      .getUserKey({
        domain: 'mockQuestionData',
        keys: [this.data.uuid]
        domain: "mockQuestionData",
        keys: [this.data.uuid],
      })
      .then((res) => {
        list = JSON.parse(res[0].value)
      })
    return list
        list = JSON.parse(res[0].value);
      });
    return list;
  },
  // 获取模考用户答题数据
  async getMockAnswer() {
    let data
    let data;
    await app.MG.identity
      .getUserKey({
        domain: 'mockAnswerData',
        keys: [this.data.uuid]
        domain: "mockAnswerData",
        keys: [this.data.uuid],
      })
      .then((res) => {
        if (res[0]) {
          this.setData({
            currentIndex: JSON.parse(res[0].value).currentIndex,
            'mockData.time': JSON.parse(res[0].value).time,
            countdownTime: JSON.parse(res[0].value).time ? JSON.parse(res[0].value).time : this.data.mockData.sumTime,
            'mockData.answer': JSON.parse(res[0].value).answerData
          })
            "mockData.time": JSON.parse(res[0].value).time,
            countdownTime: JSON.parse(res[0].value).time
              ? JSON.parse(res[0].value).time
              : this.data.mockData.sumTime,
            "mockData.answer": JSON.parse(res[0].value).answerData,
          });
          console.log(JSON.parse(res[0].value));
          data = JSON.parse(res[0].value).answerData
          data = JSON.parse(res[0].value).answerData;
        }
      })
    return data
      });
    return data;
  },
  // 记录模考答题数据
  saveMockData() {
    const data = this.data.mockData.datas.find((itme) => itme.id == this.data.uuid)
    if (data.state == '3') return true
    const saveData = this.data.mockData.answer
    const data = this.data.mockData.datas.find(
      (itme) => itme.id == this.data.uuid
    );
    if (data.state == "3") return true;
    const saveData = this.data.mockData.answer;
    for (let i = 0; i < this.data.questionDataList.length; i++) {
      const item = this.data.questionDataList[i]
      const item = this.data.questionDataList[i];
      if (this.isHaveAnswer(item.userAnswer)) {
        const index = saveData.findIndex((saveitem) => saveitem.id == item.id)
        if (index + '' != '-1') {
          saveData[index].answer = item.userAnswer
        const index = saveData.findIndex((saveitem) => saveitem.id == item.id);
        if (index + "" != "-1") {
          saveData[index].answer = item.userAnswer;
        } else {
          saveData.push({
            id: item.id,
            answer: item.userAnswer
          })
            answer: item.userAnswer,
          });
        }
      }
    }
    //
    if (this.data.mockData.state == '1') {
      const datas = this.data.mockData.datas
    //
    if (this.data.mockData.state == "1") {
      const datas = this.data.mockData.datas;
      datas.forEach((item) => {
        if (item.id == this.data.uuid) {
          item.state = '2'
          item.state = "2";
        }
      })
      this.setMockInfo(datas)
      });
      this.setMockInfo(datas);
    }
    //
    //
    app.MG.identity
      .setUserKey({
        setKeyRequests: [{
          domain: 'mockAnswerData',
          key: this.data.uuid,
          value: JSON.stringify({
            currentIndex: this.data.currentIndex,
            time: this.data.countdownTime,
            answerData: saveData
          })
        }]
        setKeyRequests: [
          {
            domain: "mockAnswerData",
            key: this.data.uuid,
            value: JSON.stringify({
              currentIndex: this.data.currentIndex,
              time: this.data.countdownTime,
              answerData: saveData,
            }),
          },
        ],
      })
      .then((res) => {
        this.setData({
          saveTime: 20
        })
        console.log('模考答题数据已记录')
      })
          saveTime: 20,
        });
        console.log("模考答题数据已记录");
      });
  },
  // 富文本处理
  formatRichText(html) {
    console.log(html);
    let newContent = html.replace(/<img[^>]*>/gi, function (match, capture) {
      match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
      match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
      match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
      return match;
    });
    newContent = newContent.replace(/style="[^"]+"/gi, function (match, capture) {
      match = match
        .replace(/<p>/gi, '<p class="p_class">')
        .replace(/width:[^;]+;/gi, 'max-width:100%;')
        .replace(/width:[^;]+;/gi, 'max-width:100%;');
        .replace(/style="[^"]+"/gi, "")
        .replace(/style='[^']+'/gi, "");
      match = match
        .replace(/width="[^"]+"/gi, "")
        .replace(/width='[^']+'/gi, "");
      match = match
        .replace(/height="[^"]+"/gi, "")
        .replace(/height='[^']+'/gi, "");
      return match;
    });
    newContent = newContent.replace(
      /style="[^"]+"/gi,
      function (match, capture) {
        match = match
          .replace(/<p>/gi, '<p class="p_class">')
          .replace(/width:[^;]+;/gi, "max-width:100%;")
          .replace(/width:[^;]+;/gi, "max-width:100%;");
        return match;
      }
    );
    newContent = newContent.replace(/<br[^>]*\/>/gi, "");
    newContent = newContent.replace(/<a>/gi, '<a class="p_class "');
    newContent = newContent.replace(/<li>/gi, '<li class="p_class "');
    newContent = newContent.replace(/\<p/gi, '<p class="p_class "');
    newContent = newContent.replace(/\<span/gi, '<span class="p_class "');
    newContent = newContent.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block;margin-top:0;margin-bottom:0;"');
    newContent = newContent.replace(
      /\<img/gi,
      '<img style="max-width:100%;height:auto;display:block;margin-top:0;margin-bottom:0;"'
    );
    return newContent;
  }
})
  },
});
packageBookService/pages/bookServices/examination/questionList/index.wxml
@@ -155,7 +155,6 @@
        </t-radio-group>
        <!-- 多选题 -->
        <t-checkbox-group
          disabled="{{item.isComplete}}"
          class="checkbox-group"
          wx:elif="{{item.questionType == 'multipleChoice'}}"
          t-class="box"
@@ -172,6 +171,7 @@
            wx:key="contentIndex"
          >
            <t-checkbox
              disabled="{{item.isComplete}}"
              icon="rectangle"
              block="{{false}}"
              value="{{contentItem.value}}"
packageBookService/pages/bookServices/examination/questionOptions/index.wxml
@@ -75,6 +75,26 @@
        <text class="un-answered explain-color-box"></text>
        <text>未答</text>
      </view>
      <view
        class="error-box"
        wx:if="{{((answerType == 'option' || answerType == 'mock') && submitStatus) || answerType == 'collectQuestion' || answerType == 'errorQuestion'}}"
      >
        <text
          class="explain-color-box"
          style="background-color: #ee1818"
        ></text>
        <text>错误</text>
      </view>
      <view
        class="correct-box"
        wx:if="{{((answerType == 'option' || answerType == 'mock') && submitStatus) || answerType == 'collectQuestion' || answerType == 'errorQuestion'}}"
      >
        <text
          class="explain-color-box"
          style="background-color: #1fbc1f"
        ></text>
        <text>正确</text>
      </view>
    </view>
    <view class="question-card-list">
      <view wx:for="{{cardList}}" wx:key="index" class="card-box">
@@ -91,7 +111,7 @@
            wx:for-item="citem"
            wx:for-index="cindex"
            wx:key="cindex"
            class="question-box {{citem.isUserAnswer ? 'answered' : 'un-answered'}}"
            class="question-box {{ citem.isUserAnswer ? 'answered' : 'un-answered' }} {{ ( ((answerType == 'option' || answerType == 'mock') && submitStatus || answerType == 'collectQuestion' || answerType == 'errorQuestion')  && citem.questionType !== 'shortAnswer' )  ? citem.isRight ? 'correct-box-color' : 'error-box-color' : ''}} "
          >
            {{citem.number}}
          </view>
packageBookService/pages/bookServices/examination/questionOptions/index.wxss
@@ -71,12 +71,16 @@
  justify-content: flex-end;
}
.explain-un-answered {
.explain-un-answered,
.correct-box,
.error-box {
  margin-left: 80rpx;
}
.explain-answered,
.explain-un-answered {
.explain-un-answered,
.correct-box,
.error-box {
  display: flex;
  align-items: center;
}
@@ -132,6 +136,16 @@
  color: #fff;
}
.error-box-color {
  background-color: #EE1818;
  color: #fff;
}
.correct-box-color {
  background-color: #1FBC1F;
  color: #fff;
}
.un-answered {
  background-color: #F1F3F8;
  color: #B4B6BD;
static/images/bookService/detail/link-click.png
static/images/bookService/detail/link.png