| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457 |
- <template>
- <view style="height: 100%; background: #F8F9FA;">
- <!-- <van-image-->
- <!-- class="huodongText2-img"-->
- <!-- height="360rpx"-->
- <!-- :src="courseInfo.cover"-->
- <!-- width="100%"-->
- <!-- style="display: flex;align-items: center;"-->
- <!-- />-->
- <u-swiper :list="bannerList||[]" keyName="url"
- :indicatorStyle="{right: '20rpx', bottom: '20rpx', width: '100px',marginLeft: 'auto'}" indicator
- indicatorMode="number" :height="'360rpx'" imgMode="scaleToFill">
- </u-swiper>
- <view class="huodong-ccontent" >
- <view class="course-content">
- <view class="course-title">{{ courseInfo.goods_name }}</view>
- <view class="course-date">
- <view style="padding-top: 7rpx;width:28rpx;height: 28rpx ">
- <van-image
- class="huodongText2-img"
- height="28rpx"
- src="/static/miaoshu.png"
- width="28rpx"
- style="display: flex;"
- />
- </view>
- <span style="padding: 0 16rpx">{{courseInfo.remark}}</span>
- </view>
- <view class="course-price" style="position: relative;">
- <span style="font-size: 24rpx; color: #C29556;">¥ </span><span style="font-size: 36rpx;color: #C29556;">{{courseInfo.price_selling}}</span>
- <view style="position: absolute;right:0rpx;font-size: 22rpx;color:#888888; display: flex;">
- <view style="padding-top: 7rpx;width:28rpx;height: 28rpx ">
- <van-image
- class="huodongText2-img"
- height="28rpx"
- src="/static/baoming.png"
- width="28rpx"
- style="display: flex;"
- />
- </view>
- <span style="padding-left: 20rpx;"> {{courseInfo.stock_sales}} 人已学习</span>
- </view>
- </view>
- </view>
- </view>
- <view class="course-content-title">
- 课程介绍
- </view>
- <view id="course-content" ref="courseContent" style="width: 95%;margin: 0 auto;" v-html="courseInfo.content">
- </view>
- <view style="width: 100%;height: 165rpx" > </view>
- <van-toast id="van-toast"/>
- <view class="bottom-navigation">
- <view class="bottom-navigation-div">
- <view style="width: 40rpx;margin-right: 30rpx" @click="toJump( 1)" >
- <van-image
- height="36rpx"
- src="/static/hd-icon-a.png"
- width="36rpx"
- style="display: flex;align-items: center; justify-content: center;"
- />
- <span>
- 首页
- </span>
- </view>
- <view style="width: 40rpx;position:relative" open-type="contact">
- <van-image
- height="36rpx"
- src="/static/hd-icon-c.png"
- width="36rpx"
- style="display: flex;align-items: center; justify-content: center;"
- />
- <span>
- 咨询
- </span>
- <button style="position: absolute;width: 100%;height: 100%;z-index: 999;opacity: 0;top:0;"
- open-type="contact" ></button>
- </view>
- </view>
- <button class="course-button" @click="handleRegister">报名学习</button>
- </view>
- </view>
- </template>
- <script>
- import {getConfigData} from '@/common/api/common.js';
- import Toast from "../../wxcomponents/vant/dist/toast/toast";
- import {getGoodsDetail} from "../../common/api";
- export default {
- components: {},
- data() {
- return {
- bannerList: [],
- page: 1,
- pageSize: 10,
- courseTypeList: [],
- goods_code: 0,
- courseInfo: {},
- entry_end: 0,
- remainingImages: [],
- entry_num:0,
- entry_max:0,
- entry_balance:0,
- is_entry:false,
- suitNum:1,
- };
- },
- onLoad: function (option) {
- this.goods_code = option.goods_code
- this.getCourseDetail()
- this.setImgWidth()
- },
- onShow() {
- this.$nextTick(() => {
- });
- },
- onReachBottom() {
- },
- onShareAppMessage(res) {
- let params = {};
- params = {
- goods_code: this.goods_code
- };
- let configs = uni.getStorageSync('configs') || {};
- return {
- title: configs.shop_share_title,
- imageUrl: configs.shop_share_img,
- path: `/subPages/courseDetail/courseDetail${this.$stringPageOptions(params)}`
- };
- },
- onShareTimeline(res) {
- let params = {};
- params = {
- goods_code: this.goods_code
- };
- let configs = uni.getStorageSync('configs') || {};
- return {
- title: configs.shop_share_title,
- imageUrl: configs.shop_share_img,
- path: `/subPages/courseDetail/courseDetail${this.$stringPageOptions(params)}`
- };
- },
- computed: {},
- watch: {},
- methods: {
- getConfigDatalist() {
- getConfigData({dict_id: 36}).then(({data}) => {
- this.courseTypeList = data.reverse();
- });
- },
- handleRegister() {
- // Toast('敬请期待');
- let tempList = this.courseInfo.data_specs[0].list
- tempList = tempList.map(item => {
- return {
- group_name: item.group,
- spec_name: item.name
- }
- })
- let specText = tempList.map(item => {
- return `${item.group_name}::${item.spec_name}`
- })
- // 准备发送的数据结构,包含商品代码、套件数量和规格文本
- const sendData = {
- items: [{
- code: this.courseInfo.code, // 商品代码
- count: this.suitNum, // 套件数量
- // 将规格文本数组用“;;”连接成单个字符串
- spec: specText.join(';;')
- }]
- }
- // 调用API创建订单
- this.$api.createOrder(sendData).then(res => {
- // 成功创建订单后,显示成功提示
- uni.showToast({
- title: '订单创建成功'
- })
- // 导航到结算中心页面,并传递订单号作为查询参数
- uni.navigateTo({
- url: `/subPages/settleCenter/courseSettleCenter?orderNo=${res.data.order_no}`
- })
- })
- },
- getCourseDetail() {
- getGoodsDetail({goods_code: this.goods_code}).then(({data}) => {
- console.log(data)
- this.courseInfo = data.goods
- this.bannerList=this.courseInfo.slider||[]
- console.log('this.courseInfo.content', this.bannerList)
- // 修正 courseInfo.content 中的 src 属性值
- if (this.courseInfo.content) {
- this.courseInfo.content = this.courseInfo.content.replace(/\/apihttps:/g, 'https:');
- // 使用正则表达式匹配和修改 img 标签的 style 属性
- this.courseInfo.content = this.courseInfo.content.replace(/<img([^>]*)>/gi, (match, attributes) => {
- // 检查是否已经存在 style 属性
- if (attributes.includes('style')) {
- // 如果存在 style 属性,添加 width: 100%;
- return match.replace(/style="([^"]*)"/i, (styleMatch, styleContent) => {
- if (!styleContent.includes('width: 100%')) {
- return `style="${styleContent}; width: 100%;"`;
- }
- return styleMatch;
- });
- } else {
- // 如果不存在 style 属性,添加 style="width: 100%;"
- return match.replace(/<img/i, '<img style="width: 100%;"');
- }
- });
- // 使用正则表达式匹配和修改 p 标签的 style 属性
- this.courseInfo.content = this.courseInfo.content.replace(/<p([^>]*)>/gi, (match, attributes) => {
- // 检查是否已经存在 style 属性
- if (attributes.includes('style')) {
- // 如果存在 style 属性,添加新的样式
- return match.replace(/style="([^"]*)"/i, (styleMatch, styleContent) => {
- const newStyles = 'font-weight: 400; font-size: 24rpx; color: #666666; line-height: 36rpx;';
- if (!styleContent.includes(newStyles)) {
- return `style="${styleContent}; ${newStyles}"`;
- }
- return styleMatch;
- });
- } else {
- // 如果不存在 style 属性,添加 style 属性
- const newStyles = 'font-weight: 400; font-size: 24rpx; color: #666666; line-height: 36rpx;';
- return match.replace(/<p/i, `<p style="${newStyles}"`);
- }
- });
- }
- // 确保在数据更新后调用 setImgWidth
- this.$nextTick(() => {
- this.setImgWidth();
- });
- });
- },
- setImgWidth() {
- this.$nextTick(() => {
- if (this.$refs.courseContent) {
- const imgElements = this.$refs.courseContent.querySelectorAll('img');
- imgElements.forEach(img => {
- img.style.width = '100%';
- });
- } else {
- console.log(this.$refs)
- }
- });
- },
- getStyles(index=0) {
- let le =28
- let py=30
- if (this.entry_num%2==1){
- py+= 224/2-(84/2)-(le*Math.floor(this.entry_num / 2 ))-le/2
- }else{
- py+=224/2-(84/2)-(le*this.entry_num/2)
- }
- let right= index*le+py
- var newVar = {
- position: 'absolute',
- width: '84rpx',
- height: '84rpx',
- borderRadius: '84rpx',
- top: '30rpx',
- right: right+'rpx',
- };
- return newVar
- },
- toJump( index) {
- if(index==1){
- uni.switchTab({
- url:'/pages/home/index'
- });
- }else if(index==2){
- }
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .common-page {
- height: 100%;
- padding: 30rpx;
- }
- .huodong-ccontent {
- position: relative; /* 相对定位 */
- width: 650rpx;
- padding: 0rpx;
- margin: 30rpx auto;
- margin-bottom: 0;
- padding: 30rpx;
- background: #FFFFFF;
- border-radius: 16rpx 16rpx 16rpx 16rpx;
- }
- .course-content {
- margin-top: 30 rp;
- .course-title {
- font-family: PingFang SC, PingFang SC;
- font-weight: 400;
- font-size: 32rpx;
- color: #333333;
- line-height: 40rpx;
- text-align: left;
- font-style: normal;
- text-transform: none;
- font-weight: bold;
- margin-bottom: 16rpx;
- }
- .course-date {
- font-family: 苹方, 苹方;
- font-size: 26rpx;
- color: #666666;
- line-height: 40rpx;
- text-align: left;
- font-style: normal;
- text-transform: none;
- font-weight: 400;
- margin-bottom: 10rpx;
- display: flex;
- }
- .course-price {
- font-family: 苹方, 苹方;
- font-weight: 400;
- font-size: 24rpx;
- color: #666666;
- line-height: 40rpx;
- text-align: justify;
- font-style: normal;
- text-transform: none;
- display: flex;
- }
- }
- .bottom-navigation{
- position: fixed;
- // 文字垂直居中
- display: flex;
- align-items: center;
- justify-content: center;
- bottom: 0;
- height: 100rpx;
- width: calc(100% - 40rpx);
- background: #FFFFFF;
- box-shadow: 0rpx -2rpx 0rpx 0rpx #F1F3F6;
- border-radius: 24rpx 24rpx 0rpx 0rpx;
- border: 0rpx solid #979797;
- padding: 20rpx 20rpx 68rpx 20rpx ;
- &-div{
- height: 76rpx;
- width: 404rpx;
- padding-top: 10rpx;
- // 文字垂直居中
- display: flex;
- align-items: center;
- padding-left: 30rpx;
- span{
- font-family: PingFang SC, PingFang SC;
- font-weight: 400;
- font-size: 20rpx;
- color: #333333;
- line-height: 32rpx;
- text-align: left;
- font-style: normal;
- text-transform: none;
- }
- }
- .course-button {
- width: 264rpx;
- height: 80rpx;
- background: linear-gradient(315deg, #CA9359 0%, #E2B98E 100%);
- border-radius: 292rpx 292rpx 292rpx 292rpx;
- font-family: PingFang SC, PingFang SC;
- font-weight: 400;
- font-size: 28rpx;
- color: #FFFFFF;
- line-height: 36rpx;
- text-align: center;
- font-style: normal;
- text-transform: none;
- // 文字垂直居中
- display: flex;
- align-items: center;
- justify-content: center;
- }
- }
- /* 设置 v-html 渲染的内容中的 img 标签宽度为 100% */
- [v-html] img {
- width: 100%!important;
- }
- /* 定义 CSS 变量 */
- :root {
- --nav-bar-icon-color: black;
- --nav-bar-arrow-size: 16px;
- --tab-font-size: 28rpx;
- }
- .course-content-title {
- margin: 30rpx auto;
- width: 680rpx;
- // 垂直居中
- font-family: PingFang SC, PingFang SC;
- font-weight: 400;
- font-size: 28rpx;
- color: #333333;
- line-height: 40rpx;
- font-style: normal;
- text-transform: none;
- margin-bottom: 20rpx;
- // 加粗
- font-weight: bold;
- }
- /* 确保 van-nav-bar 内部的内容能够正确适应新的高度 */
- /deep/ .van-nav-bar__title {
- font-family: PingFang SC, PingFang SC !important;
- font-weight: 400 !important;
- font-size: 36rpx !important;
- color: #333333 !important;
- text-align: center;
- // 加粗
- // font-weight: bold;
- }
- /deep/ .van-nav-bar__content {
- text-align: center;
- }
- #course-content img{
- width: 100%!important;
- }
- /* 添加 van-tab 标题的字体大小样式 */
- /deep/ .van-tab__text {
- font-family: PingFang SC, PingFang SC;
- font-weight: 400;
- font-size: 28rpx;
- }
- </style>
|