From 8e3ee81b6ed824866734b7034604121f370f4201 Mon Sep 17 00:00:00 2001 From: QYF-GitLab1 <1940665526@qq.com> Date: 星期三, 09 七月 2025 17:55:14 +0800 Subject: [PATCH] 登录、购书码、申请阅读 --- src/views/bookList/bookDetail.vue | 257 ++++++++++++++++++++++++++++++++------------------ 1 files changed, 164 insertions(+), 93 deletions(-) diff --git a/src/views/bookList/bookDetail.vue b/src/views/bookList/bookDetail.vue index 947e30a..cabbd95 100644 --- a/src/views/bookList/bookDetail.vue +++ b/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; -- Gitblit v1.9.1