litian
2024-04-03 b212136f20cc7f98c3616c97936978b1d1065b36
购买
4个文件已修改
129 ■■■■■ 已修改文件
packageBookService/pages/bookServices/detail/index.js 92 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/detail/index.wxml 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/detail/index.wxss 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packagePersonal/pages/myOrder/index.js 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packageBookService/pages/bookServices/detail/index.js
@@ -1,7 +1,9 @@
// pages/bookServices/detail/index.js
import Toast from "tdesign-miniprogram/toast";
import tool from "../../../../assets/js/toolClass";
import { loginInfo } from "../../../../assets/js/login";
import {
  loginInfo
} from "../../../../assets/js/login";
const app = getApp();
Page({
  /**
@@ -427,13 +429,14 @@
    };
    app.MG.store.getProductList(obj).then((res) => {
      if (res.datas && res.datas.length > 0) {
        console.log(res.datas[0], 2)
        this.setData({
          bookItemDetail: res.datas[0],
          selectedIds: res.datas[0].defaultSaleMethod.id,
          bookBuy:
            res.datas[0].purchasedSaleMethodIdList.indexOf(
          bookBuy: res.datas[0].purchasedSaleMethodIdList.indexOf(
              res.datas[0].defaultSaleMethodId
            ) > -1,
          "bookDetail.price": this.numFormat(res.datas[0].price),
        });
        let times = new Date(res.datas[0].defaultSaleMethod.endDate).getTime();
        let startTime = new Date(
@@ -495,8 +498,7 @@
        }
        this.setData({
          selectedIds: this.data.bookDetail.defaultSaleMethodId,
          bookBuy:
            this.data.bookDetail.purchasedSaleMethodIdList.indexOf(
          bookBuy: this.data.bookDetail.purchasedSaleMethodIdList.indexOf(
              this.data.bookDetail.defaultSaleMethodId
            ) > -1,
        });
@@ -602,7 +604,9 @@
  },
  // 跳转网店
  goShop(e) {
    const { link } = e.currentTarget.dataset;
    const {
      link
    } = e.currentTarget.dataset;
    wx.navigateTo({
      url: `/packageBookService/pages/bookServices/webpage/index?url=${link}`,
    });
@@ -902,13 +906,11 @@
      console.log(determine);
      if (!determine) {
        let query = {
          requests: [
            {
          requests: [{
              saleMethodId: this.data.selectedIds,
              storeEventId: null,
              agentCode: "电子书",
            },
          ],
          }, ],
        };
        const addRes = app.MG.store.addShoppingCart(query);
        this.showSuccessToast();
@@ -949,14 +951,12 @@
      let bookOrdersId = "";
      let query = {
        remarks: "电子书",
        requests: [
          {
            saleMethodId: this.data.bookItemDetail.defaultSaleMethodId
              ? this.data.bookItemDetail.defaultSaleMethodId
              : this.data.bookDetail.defaultSaleMethodId,
        requests: [{
          saleMethodId: this.data.bookItemDetail.defaultSaleMethodId ?
            this.data.bookItemDetail.defaultSaleMethodId :
            this.data.bookDetail.defaultSaleMethodId,
            count: 1,
          },
        ],
        }, ],
      };
      // 发起订单初始化请求并等待结果
      const res = await app.MG.store.initOrder(query);
@@ -965,13 +965,29 @@
      console.log(bookOrdersId);
      // 检查订单号是否存在
      if (bookOrdersId) {
        if (this.data.bookDetail.price == "0.00") {
          app.MG.store.confirmOrder({
            orderNum: bookOrdersId
          }).then(res => {
            if (res) {
              wx.showToast({
                title: "领取成功",
                icon: "none",
                duration: 1000,
              });
              this.getBookInfo(this.data.bookDetail.id);
            }
          })
        } else {
        const url = "/pages/cart/paymentPage/index?orderNumber=" + bookOrdersId;
        wx.navigateTo({
          url,
        });
        }
      } else {
        console.log(222);
      }
    } else {
      wx.showToast({
        title: "商品不在有效期",
@@ -1080,14 +1096,12 @@
          cmsTypeRefCode: "",
          newDataListRequest: [],
          name: this.data.bookDetail.name, // name为申请的书本名称
          content: JSON.stringify([
            {
          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) {
@@ -1103,8 +1117,7 @@
          title: "尊敬的用户,您好!",
          content: "请先进行教师认证!",
          complete: (res) => {
            if (res.cancel) {
            }
            if (res.cancel) {}
            if (res.confirm) {
              wx.navigateTo({
                url: "/packageDomain/pages/teacherCertification/index",
@@ -1118,8 +1131,7 @@
        title: "尊敬的用户,您好!",
        content: "请先进行教师认证!",
        complete: (res) => {
          if (res.cancel) {
          }
          if (res.cancel) {}
          if (res.confirm) {
            wx.navigateTo({
              url: "/packageDomain/pages/teacherCertification/index",
@@ -1147,8 +1159,7 @@
        title: "尊敬的用户,您好!",
        content: "请先进行教师认证!",
        complete: (res) => {
          if (res.cancel) {
          }
          if (res.cancel) {}
          if (res.confirm) {
            wx.navigateTo({
              url: "/packageDomain/pages/teacherCertification/index",
@@ -1504,9 +1515,9 @@
        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)
          );
        }
      }
@@ -1560,12 +1571,10 @@
    try {
      let query = {
        remarks: "组卷",
        requests: [
          {
        requests: [{
            saleMethodId: this.data.mockData.id,
            count: 1,
          },
        ],
        }, ],
      };
      if (this.data.flag) {
        this.setData({
@@ -1615,13 +1624,11 @@
    });
    // 记录购买时间,并设状态state为1,表示刚购买完成组卷
    app.MG.identity.setUserKey({
      setKeyRequests: [
        {
      setKeyRequests: [{
          domain: "mockData",
          key: this.data.bookDetail.id + "",
          value: JSON.stringify(this.data.mockData.mockList),
        },
      ],
      }, ],
    });
  },
  // 获取相关图书
@@ -1705,8 +1712,7 @@
      return false;
    }
    wx.navigateTo({
      url:
        "/packageBookService/pages/components/webView/index?md5=" +
      url: "/packageBookService/pages/components/webView/index?md5=" +
        this.data.fileInfo.md5 +
        "&fileName=" +
        this.data.fileInfo.bookName +
@@ -1881,8 +1887,7 @@
              wx.navigateTo({
                url: "/packageDomain/pages/teacherCertification/index",
              });
            } else if (res.cancel) {
            }
            } else if (res.cancel) {}
          },
        });
      }
@@ -1951,8 +1956,7 @@
              wx.navigateTo({
                url: "/packageDomain/pages/teacherCertification/index",
              });
            } else if (res.cancel) {
            }
            } else if (res.cancel) {}
          },
        });
      }
packageBookService/pages/bookServices/detail/index.wxml
@@ -168,15 +168,16 @@
      </view>
      <view class="btn-text">纸质样书申请</view>
    </view>
    <view class="bottom-btn tryRead" bind:tap="goRead" wx:if="{{!bookBuy}}">
    <view class="{{!bookBuy && bookDetail.isSell ? 'bottom-btn tryRead' : 'bottom-btn try'}}" bind:tap="goRead" wx:if="{{!bookBuy}}">
      <view>
        <t-image src="/static/images/bookService/detail/shidu.png"></t-image>
      </view>
      <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="shopCar shopCarColor" bind:tap="addBookShopcCar" wx:if="{{!bookBuy && bookDetail.price !== '0.00' && bookDetail.isSell}}">加入购物车</view>
    <view class="buy buyColor" bind:tap="buyBtn" wx:if="{{!bookBuy && bookDetail.price !== '0.00' && bookDetail.isSell}}">立即购买</view>
    <view class="buy receiveColor" bind:tap="buyBtn" wx:if="{{!bookBuy && bookDetail.price == '0.00' && bookDetail.isSell}}">免费领取</view>
    <view class="buy read" bind:tap="goRead" wx:if="{{bookBuy}}">立即查看</view>
  </view>
</view>
packageBookService/pages/bookServices/detail/index.wxss
@@ -242,8 +242,9 @@
.bottom-btn {
  background-color: #fff;
  width: 25%;
  /* width: 25%; */
  display: flex;
  flex: 2;
  align-items: center;
  justify-content: center;
  flex-direction: column;
@@ -251,7 +252,11 @@
}
.tryRead {
  width: 120rpx;
  flex: 1 !important;
}
.try {
  flex: 2 !important;
}
.btn-text {
@@ -276,6 +281,7 @@
  align-items: center;
  justify-content: center;
  color: #fff;
  flex: 2;
}
.read {
@@ -295,6 +301,11 @@
  background-color: #F14B3B;
}
.receiveColor {
  background-color: #F14B3B;
  width: 50% !important;
}
.disabledColor {
  background-color: #d9d9d9;
}
packagePersonal/pages/myOrder/index.js
@@ -173,14 +173,23 @@
    })
    this.getDataList(false);
  },
  goBookDetails(e) {
  async goBookDetails(e) {
    const {
      book,
      remarks
    } = e.currentTarget.dataset;
    let id = remarks != null && JSON.stringify(remarks).slice(1, -1) == 'object' && JSON.parse(remarks).pId ? JSON.parse(remarks).pId : book.orderSaleMethod.product.id;
    let parentData = null;
    let bookId = book.orderSaleMethod.product.id;
    if (remarks == null) {
      parentData = await app.MG.store.getProductBySaleMethod({
        'saleMethodId': book.orderSaleMethod.id
      })
      bookId = parentData.parentProduct[parentData.parentProduct.length - 1].id;
    } else if (remarks != null && JSON.stringify(remarks).slice(1, -1) == 'object' && JSON.parse(remarks).pId) {
      bookId = JSON.parse(remarks).pId
    }
    wx.navigateTo({
      url: `/packageBookService/pages/bookServices/detail/index?id=${id}&name=${book.name}`,
      url: `/packageBookService/pages/bookServices/detail/index?id=${bookId}&name=${book.name}`,
    });
  },