旅游教育出版社-数字教材移动端
QYF-GitLab1
14 小时以前 8e3ee81b6ed824866734b7034604121f370f4201
src/views/bookList/bookDetail.vue
@@ -86,7 +86,7 @@
            class="detailBox"
            v-if="
              detailsInfo.tourism_catalog &&
                detailsInfo.tourism_catalog !== '<p></p>'
              detailsInfo.tourism_catalog !== '<p></p>'
            "
            v-html="detailsInfo.tourism_catalog"
          ></div>
@@ -99,7 +99,7 @@
            class="detailBox"
            v-if="
              detailsInfo.tourism_content &&
                detailsInfo.tourism_content !== '<p></p>'
              detailsInfo.tourism_content !== '<p></p>'
            "
            v-html="detailsInfo.tourism_content"
          ></div>
@@ -112,7 +112,7 @@
            class="detailBox"
            v-if="
              detailsInfo.tourism_authorBrief &&
                detailsInfo.tourism_authorBrief !== '<p></p>'
              detailsInfo.tourism_authorBrief !== '<p></p>'
            "
            v-html="detailsInfo.tourism_authorBrief"
          ></div>
@@ -132,9 +132,7 @@
                style="width: 100%; height: 300px"
              ></div>
            </div>
            <div class="title" v-if="resourceData.length > 0">
              资源明细
            </div>
            <div class="title" v-if="resourceData.length > 0">资源明细</div>
            <div class="resourceList" v-if="resourceData.length > 0">
              <div
                v-for="(item, index) in resourceData"
@@ -177,7 +175,11 @@
          <p v-else class="disable">申请试用</p>
        </li>
        <li class="btmBottom1">
          <img src="@/assets/images/textBook/shidu3.png" alt="" class="btnImg" />
          <img
            src="@/assets/images/textBook/shidu3.png"
            alt=""
            class="btnImg"
          />
          <p v-if="isBuy" @click="readBook()">阅读</p>
          <p v-if="!isBuy" @click="readBook()">试读</p>
        </li>
@@ -203,11 +205,7 @@
      show-cancel-button
      @confirm="onConfirm"
    >
      <van-field
        v-model="code"
        placeholder="请输入购书码"
        class="message"
      />
      <van-field v-model="code" placeholder="请输入购书码" class="message" />
    </van-dialog>
  </div>
</template>
@@ -218,6 +216,7 @@
import { mapState } from "vuex";
import toolClass from "@/assets/js/toolClass";
import myConfig from "@/assets/js/config";
import WeChat from "@/assets/js/weChat/weChat";
import axios from "axios";
var echarts = require("echarts");
// 全局注册
@@ -239,7 +238,7 @@
      // 收藏图片
      collectIcon: {
        star: require("@/assets/images/textBook/shoucang3.png"),
        selected_star: require("@/assets/images/tab_collection_pre.png")
        selected_star: require("@/assets/images/tab_collection_pre.png"),
      },
      isBuy: false,
      tabActive: 0,
@@ -258,11 +257,11 @@
      teacherState: "",
      shoppingCartGetId: [],
      dialogCode: false,
      code: ""
      code: "",
    };
  },
  computed: {
    ...mapState(["userInfo"])
    ...mapState(["userInfo"]),
  },
  created() {
    var that = this;
@@ -294,13 +293,13 @@
            tourism_teachingLevel: [],
            tourism_professionalCategory: [],
            tourism_zone: [],
            viewCount: []
            viewCount: [],
          },
          coverSize: {
            width: 880
          }
            width: 880,
          },
        })
        .then(res => {
        .then((res) => {
          console.log(res.datas);
          this.isBuy = res.datas.alreadyBuy;
          that.detailsInfo = res.datas;
@@ -312,15 +311,15 @@
                  requests: [
                    {
                      saleMethodId: this.detailsInfo.defaultSaleMethodId,
                      count: 1
                    }
                  ]
                      count: 1,
                    },
                  ],
                })
                .then(initRes => {
                .then((initRes) => {
                  if (initRes.orderNumber) {
                    this.MG.store
                      .confirmOrder({ orderNum: initRes.orderNumber })
                      .then(aRes => {
                      .then((aRes) => {
                        if (aRes) {
                          Toast.success("免费领取成功!");
                          this.getDetail(id);
@@ -334,6 +333,7 @@
          this.getBookResource();
        });
    },
    getProductType() {
      var that = this;
      this.MG.store
@@ -341,22 +341,22 @@
          refCodes: [
            "tourism_teachingLevel",
            "tourism_professionalCategory",
            "tourism_zone"
          ]
            "tourism_zone",
          ],
        })
        .then(res => {
        .then((res) => {
          if (res.length > 0) {
            res.forEach(element => {
            res.forEach((element) => {
              let optionList = JSON.parse(element.config).option;
              if (element.refCode == "tourism_teachingLevel") {
                optionList.forEach(item => {
                optionList.forEach((item) => {
                  if (that.detailsInfo.tourism_teachingLevel == item.value) {
                    that.teachingLevel = item.name;
                  }
                });
              }
              if (element.refCode == "tourism_professionalCategory") {
                optionList.forEach(item => {
                optionList.forEach((item) => {
                  if (
                    that.detailsInfo.tourism_professionalCategory == item.value
                  ) {
@@ -365,7 +365,7 @@
                });
              }
              if (element.refCode == "tourism_zone") {
                optionList.forEach(item => {
                optionList.forEach((item) => {
                  if (that.detailsInfo.tourism_zone == item.value) {
                    that.zone = item.name;
                  }
@@ -382,7 +382,7 @@
        this.MG.store
          .delProductLink({
            productIds: [this.detailsInfo.id],
            linkType: this.config.refCodes.LinkType.FavoriteTextBook
            linkType: this.config.refCodes.LinkType.FavoriteTextBook,
          })
          .then(() => {
            this.detailsInfo.isFavourite = false;
@@ -390,20 +390,20 @@
      } else {
        let params = {
          productIds: [this.detailsInfo.id],
          linkType: this.config.refCodes.LinkType.FavoriteTextBook
          linkType: this.config.refCodes.LinkType.FavoriteTextBook,
        };
        this.MG.store.addProductLink(params).then(res => {
        this.MG.store.addProductLink(params).then((res) => {
          this.detailsInfo.isFavourite = true;
        });
      }
    },
    //获取教材资源信息
    getBookResource() {
      console.log(
        this.config.textBookResourceUrl +
          this.detailsInfo.refCode +
          "/resource.json"
      );
      // console.log(
      //   this.config.textBookResourceUrl +
      //     this.detailsInfo.refCode +
      //     "/resource.json"
      // );
      try {
        axios
          .get(
@@ -411,9 +411,9 @@
              this.detailsInfo.refCode +
              "/resource.json"
          )
          .then(async res => {
          .then(async (res) => {
            if (res.data.length > 0) {
              res.data.forEach(item => {
              res.data.forEach((item) => {
                if (item.resourceTypeShow == "图片") {
                  item.icon = this.imgIcon;
                } else if (item.resourceTypeShow == "视频") {
@@ -445,12 +445,14 @@
            }
            if (this.resourceData.length > 0) {
              this.resourceHave = true;
              this.initChart(this.resourceData);
              if (this.$refs.resourcesChart) {
                this.initChart(this.resourceData);
              }
            } else {
              this.resourceHave = false;
            }
          })
          .catch(error => {
          .catch((error) => {
            console.log(error);
            this.resourceData = [];
            this.resourceHave = false;
@@ -460,13 +462,14 @@
        this.resourceHave = false;
      }
    },
    groupByResourceTypeShow(resources) {
      const grouped = resources.reduce((acc, item) => {
        const key = item.resourceTypeShow;
        if (!acc[key]) {
          acc[key] = {
            resourceTypeShow: key,
            list: []
            list: [],
          };
        }
        acc[key].list.push(item);
@@ -480,7 +483,7 @@
      // 基于准备好的dom,初始化echarts实例
      let dataList = [];
      let num = [];
      data.forEach(item => {
      data.forEach((item) => {
        dataList.push(item.resourceTypeShow);
        num.push(item.list.length);
      });
@@ -489,7 +492,7 @@
      myChart.setOption({
        tooltip: {},
        xAxis: {
          data: dataList
          data: dataList,
        },
        yAxis: {},
        series: [
@@ -498,7 +501,7 @@
            type: "bar",
            data: num,
            itemStyle: {
              color: function(params) {
              color: function (params) {
                // params.dataIndex是数据项的索引,你可以根据这个索引来设置不同的颜色
                const colors = [
                  "#5EA1FF",
@@ -510,15 +513,16 @@
                  "#3DB0BF",
                  "#FBBB3B",
                  "#3B5EFB",
                  "#B1FB3B"
                  "#B1FB3B",
                ];
                return colors[params.dataIndex % colors.length];
              }
            }
          }
        ]
              },
            },
          },
        ],
      });
    },
    tabChange(val) {
      console.log(val, 1);
      if (val == 3) {
@@ -529,9 +533,32 @@
    //使用购书码
    useBookCode() {
      this.code = "";
      this.dialogCode = true;
      if (this.token == "" || this.token == undefined || this.token == null) {
        Dialog.confirm({
          title: "温馨提示",
          message: "请您登录后使用购书码",
          showCancelButton: true,
          cancelButtonText: "取消",
          confirmButtonText: "确定",
          inputType: "text",
          inputPlaceholder: "请输入购书码",
        })
          .then((res) => {
            if (res == "confirm") {
              toolClass.delCookie(myConfig.tokenKey);
              WeChat.getCode("weChatLogin");
              return false;
            }
          })
          .catch((err) => {
            console.log(err);
          });
      } else {
        this.code = "";
        this.dialogCode = true;
      }
    },
    onConfirm() {
      var that = this;
      let lock = true;
@@ -542,9 +569,9 @@
          lock = false;
          that.MG.store
            .getActiveCode({
              code: that.code
              code: that.code,
            })
            .then(res => {
            .then((res) => {
              console.log(res);
              if (res && res.saleMethodList) {
                if (
@@ -553,9 +580,9 @@
                ) {
                  that.MG.store
                    .userActiveCode({
                      code: that.code
                      code: that.code,
                    })
                    .then(res => {
                    .then((res) => {
                      Toast.success(res == "激活成功" ? "够买成功" : res);
                      lock = true;
                      that.dialogCode = false;
@@ -571,6 +598,7 @@
        }
      }
    },
    //到购买页面
    payNow() {
      this.MG.store
@@ -578,17 +606,17 @@
          requests: [
            {
              saleMethodId: this.detailsInfo.defaultSaleMethodId,
              count: 1
            }
          ]
              count: 1,
            },
          ],
        })
        .then(res => {
        .then((res) => {
          this.$router.push({
            path: "/pay",
            query: {
              orderNum: res.orderNumber,
              shopId: this.id
            }
              shopId: this.id,
            },
          });
        });
    },
@@ -613,10 +641,10 @@
        start: 0,
        size: 999,
        filterList: [],
        searchList: []
        searchList: [],
      };
      const res = await this.MG.store.getShoppingCartProductList(query);
      res.datas.forEach(item => {
      res.datas.forEach((item) => {
        that.shoppingCartGetId.push(item.saleMethod.id);
      });
@@ -630,11 +658,11 @@
            {
              saleMethodId: this.detailsInfo.defaultSaleMethodId,
              storeEventId: null,
              agentCode: ""
            }
          ]
              agentCode: "",
            },
          ],
        };
        this.MG.store.addShoppingCart(data).then(res => {
        this.MG.store.addShoppingCart(data).then((res) => {
          if (res) {
            Toast.success("加入购物车成功");
          }
@@ -644,13 +672,50 @@
    //申请试用
    applyBook() {
      const role = this.userInfo.role;
      if (role == "Teacher") {
        this.getAlreadyBookList(this.detailsInfo);
      if (this.token == "" || this.token == undefined || this.token == null) {
        Dialog.confirm({
          title: "温馨提示",
          message: "请您登录后申请试用",
          showCancelButton: true,
          cancelButtonText: "关闭",
          confirmButtonText: "确定",
          inputType: "text",
        }).then((res) => {
          if (res == "confirm") {
            toolClass.delCookie(myConfig.tokenKey);
            WeChat.getCode("weChatLogin");
            return false;
          }
        });
      } else {
        Toast.fail("您还未通过教师审核");
        const role = this.userInfo.role;
        if (role == "Teacher") {
          this.getAlreadyBookList(this.detailsInfo);
        } else {
          Dialog.confirm({
            title: "温馨提示",
            message: "您不是教师用户,请进行教师认证后申请试用。",
            messageAlign: "left",
            showCancelButton: true,
            cancelButtonText: "关闭",
            confirmButtonText: "教师认证",
            inputType: "text",
          })
            .then((res) => {
              if (res == "confirm") {
                this.$router.replace({
                  path: "/teacherCertificate",
                  query: { from: "bookDetail", ...this.$route.query },
                });
              }
            })
            .catch((err) => {
              console.log(err);
            });
        }
      }
    },
    //获取已申请试用列表
    getAlreadyBookList(bookData) {
      const data = {
@@ -660,12 +725,12 @@
        appRefCode: this.config.appRefCode,
        sort: {
          type: "Desc",
          field: "CreateDate"
        }
          field: "CreateDate",
        },
      };
      this.MG.ugc.getTopicMessageList(data).then(res => {
      this.MG.ugc.getTopicMessageList(data).then((res) => {
        if (res.datas.length > 0) {
          res.datas.map(item => {
          res.datas.map((item) => {
            if (item.feedBack) {
              item.feedBack = JSON.parse(item.feedBack);
              if (item.feedBack.endDate) {
@@ -683,7 +748,7 @@
            }
          });
          let objVal = res.datas.find(
            i =>
            (i) =>
              i.productId == bookData.id &&
              i.state != "Reject" &&
              i.state == "WaitAudit"
@@ -693,39 +758,40 @@
              title: "提示",
              message: "您已申请试用该书,是否前往查看",
              confirmButtonText: "确定",
              cancelButtonText: "取消"
              cancelButtonText: "取消",
            }).then(() => {
              this.$router.push({
                name: "myApplyBook"
                name: "myApplyBook",
              });
            });
          } else {
            this.$router.push({
              name: "bookApply",
              query: {
                bookInfo: JSON.stringify(this.detailsInfo)
              }
                bookInfo: JSON.stringify(this.detailsInfo),
              },
            });
          }
        } else {
          this.$router.push({
            name: "bookApply",
            query: {
              bookInfo: JSON.stringify(this.detailsInfo)
            }
              bookInfo: JSON.stringify(this.detailsInfo),
            },
          });
        }
      });
    },
    contactUs() {
      this.$router.push({
        name: "aboutUs"
        name: "aboutUs",
      });
    },
    onClickLeft() {
      this.$router.go(-1);
    }
    },
  },
  mounted() {
    //挂载成功后给pop事件绑定一个方法
@@ -741,7 +807,7 @@
  //组件销毁后清除事件
  destroyed() {
    window.removeEventListener("popstate", this.onClickLeft, false); //false阻止默认事件
  }
  },
};
</script>
@@ -860,6 +926,11 @@
  overflow: auto;
}
.detailBox {
  font-size: none;
  font-family: none;
}
.noData {
  font-size: 16px;
  font-weight: bold;
@@ -887,9 +958,9 @@
  width: 60px;
  height: 60px;
}
.autoImg{
  width:40px;
  height:40px;
.autoImg {
  width: 40px;
  height: 40px;
}
.titleCount {
@@ -933,8 +1004,8 @@
}
.btnImg {
  margin-top: 5px;
  height:20px;
  width:20px;
  height: 20px;
  width: 20px;
}
.disable {
  color: #999;