BaseDetail.vue 13.2 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594
<template>
  <div class="baseDetail">
    <div class="videoBox">
      <van-swipe class="my-swipe" indicator-color="white" v-if="detailData.coverList && detailData.coverList.length > 0">
        <van-swipe-item v-for="n in detailData.coverList" :key="n.id">
          <video
            v-if="n.cover_url.indexOf('.mp4') > -1"
            id="video"
            :src="n.cover_url"
            poster=""
            controls="controls"
            windowlessvideo="true"
            playsinline="true"
            webkit-playsinline="true"
            x5-playsinline="true"
            x-webkit-airplay="allow"
            width="100%"
            height="260px"
            type="video/mp4"
          ></video>
          <img v-if="n.cover_url.indexOf('.mp4') == -1" :src="n.cover_url" />
        </van-swipe-item>
      </van-swipe>
      <img v-else src="../assets/def.png" alt="" />
    </div>
    <div class="content">
      <div class="title">
        <h3>{{ detailData.baseName }}</h3>
        <div class="rightCorse">
          <p>
            <b>{{ detailData.baseScore == 0 ? '0.0' : detailData.baseScore }}</b
            ><b>分</b>
          </p>
          <p><van-rate v-model="detailData.baseScore" readonly allow-half void-icon="star" void-color="#eee" /></p>
        </div>
      </div>
      <div class="labels oh">
        <div class="fl">
          <template>
            <span v-for="(n, i) in detailData.baseLabels" :key="i">{{ n }}</span>
          </template>
        </div>
        <div class="fr">
          <span>{{ detailData.evaluationCount }}条评论</span>
          <van-icon name="arrow" />
        </div>
      </div>
      <div class="popularity">
        <van-icon name="medal" />
        <span>基地人气榜第{{ detailData.rank }}名</span>
        <van-icon name="arrow" />
      </div>
      <div class="area">
        <van-icon name="location" />
        <span>{{ getNull(detailData.province) + getNull(detailData.city) + getNull(detailData.area) + getNull(detailData.address) }}</span>
        <van-icon name="arrow" />
      </div>
      <div class="phone">
        <van-icon name="phone" />
        <template>
          <span v-for="(n, i) in detailData.mobiles" :key="i"
            ><a :href="'tel:' + n">{{ n }}</a></span
          >
        </template>
      </div>
      <hr />
      <van-tabs v-model="tabActive" @click="tabClick">
        <van-tab title="基地介绍" name="jdjs"></van-tab>
        <van-tab title="课程一览" name="kcyl"></van-tab>
        <van-tab title="当地故事" name="ddgs"></van-tab>
      </van-tabs>
      <h3 class="positionTitle" id="jdjs"><b>基地介绍</b><u></u></h3>
      <div class="cont" v-html="detailData.detail"></div>
      <h3 class="positionTitle" id="kcyl"><b>课程一览</b><u></u></h3>
      <ul class="classList">
        <li v-for="(n, i) in detailData.courseList" :key="i" @click="goCourseDetail(n.id)">
          <img :src="n.coverUrl" alt="" />
          <h3>{{ n.course_name }}</h3>
          <p>{{ n.course_info }}</p>
        </li>
      </ul>
      <h3 class="positionTitle" id="ddgs"><b>当地故事</b><u></u></h3>
      <div class="gushi">
        <div class="gslabel">
          <span>全部</span>
          <span>最新</span>
          <span>优质故事</span>
        </div>
        <ul>
          <li v-for="(n, i) in storyList" :key="i">
            <img :src="n.coverUrl" alt="" />
            <h3>{{ n.title }}</h3>
            <div>
              <img :src="n.faceUrl ? n.faceUrl : require('../assets/boy.png')" alt="" />
              <span class="name">{{ n.name }}</span>
              <div class="zan">
                <van-icon name="good-job-o" />
                <span>{{ n.likeCount }}</span>
              </div>
            </div>
          </li>
          <p v-if="storyList.length == storyCount" class="noMove">没有更多了</p>
          <van-empty
            class="custom-image"
            image="https://img.yzcdn.cn/vant/custom-empty-image.png"
            description="暂无故事"
            v-if="storyList.length == 0"
          />
        </ul>
      </div>
    </div>
    <div class="Collection oh" v-if="isWeb">
      <div class="box">
        <div class="icon">
          <p><van-icon name="service-o" /></p>
          <p>电话咨询</p>
        </div>
      </div>
      <div class="box">
        <span @click="addCollect"
          ><van-icon
            :style="detailData.isCollect == 0 ? 'color:#fff;' : 'color:red;'"
            :name="detailData.isCollect == 0 ? 'like-o' : 'like'"
          /><b>{{ detailData.isCollect == 0 ? '加入收藏' : '已收藏' }}</b></span
        >
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      userInfo: '',
      id: '',
      starsValue: 3.5,
      tabActive: 0,
      detailData: '',
      storyCount: '',
      storyList: [],
      storyPage: 1,
      isWeb: true,
    }
  },
  created() {
    if (window.innerWidth > 900) {
      this.isWeb = false
    }
  },
  mounted() {
    localStorage.setItem('prePage', 'BaseDetail')
    var id = this.$route.query.id
    if (id) {
      this.id = id
    }
      this.GetStudyBaseDetail()
  },

  methods: {

    goCourseDetail(id) {
      this.$router.push({ path: '/CourseDetail', query: { id: id } })
    },
    handleScroll() {
      var that = this //变量scrollTop是滚动条滚动时,距离顶部的距离
      //window.onscroll = function(){
      var scrollTop = document.documentElement.scrollTop || document.body.scrollTop //变量windowHeight是可视区的高度
      var windowHeight = document.documentElement.clientHeight || document.body.clientHeight //变量scrollHeight是滚动条的总高度
      var scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight //滚动条到底部的条件
      if (scrollTop + windowHeight == scrollHeight) {
        if (that.storyList.length < that.storyCount) {
          storyPage++
          that.GetStoryList(storyPage, detailData.city)
        } //写后台加载数据的函数 //console.log("距顶部"+scrollTop+"可视区高度"+windowHeight+"滚动条总高度"+scrollHeight);
      } // }
    },
    addCollect() {
      if (this.detailData.isCollect == 0) {
        var that = this
        this.$toast.loading({
          message: '请求中...',
        })
        this.http
          .AddMyCollect({
            baseId: this.detailData.id,
            userId: this.userInfo.centerNo,
          })
          .then(function (res) {
            that.$toast.clear()
            if (res.status == 1) {
              that.$toast.success('收藏成功')
              that.detailData.isCollect = 1
            }
          })
      }
    },
    tabClick(name, title) {
      // 找到锚点
      let anchorElement = document.getElementById(name)
      // 如果对应id的锚点存在,就跳转到锚点
      if (anchorElement) {
        anchorElement.scrollIntoView()
      }
    },
    GetStudyBaseDetail(id) {
      var that = this
      this.http
        .GetStudyBaseDetail({
          id: this.id,
          userId: this.userInfo.centerNo,
          cs: this.projectCity,
        })
        .then(function (res) {
          if (res.status == 1) {
            var mobiles = res.data.mobiles
            if (mobiles) {
              mobiles = mobiles.split(',')
              res.data.mobiles = mobiles
            } else {
              res.data.mobiles = []
            }
            var baseLabels = res.data.baseLabels
            if (baseLabels) {
              baseLabels = baseLabels.split(',')
              res.data.baseLabels = baseLabels
            } else {
              res.data.baseLabels = []
            }
            that.detailData = res.data
            that.GetStoryList(1, res.data.city)
          }
        })
    },
    GetStoryList(page, city) {
      var that = this
      this.http
        .GetStoryList({
          pageIndex: page,
          city: city,
          pageSize: 6,
        })
        .then(function (res) {
          if (res.status == 1) {
            that.storyCount = res.data.count
            that.storyList = that.storyList.concat(res.data.items)
          }
        })
    },
    getNull(t) {
      return t ? t : ''
    },
  },
}
</script>

<style lang="stylus" scoped>
.videoBox{
	img{
		width 100%
	}
}
.noMove{
	text-align center
	padding 20px 0
	color #ccc
}
.content{
	padding 40px
	box-sizing border-box
	.title{
		padding-right 160px
		box-sizing border-box
		position relative
		h3{
			font-size 2rem
			word-break: break-all;
			text-overflow: ellipsis;
			display: -webkit-box;
			-webkit-box-orient: vertical;
			-webkit-line-clamp: 2;
			overflow: hidden;
			margin 0
			min-height 90px
		}
		.rightCorse{
			position absolute
			text-align center
			right 0
			top 0
			p{
				margin 0
			}
			p:first-child{
				color #0EDBA1
				font-size 1.8rem
				b{
					display inline-block
					vertical-align middle
				}
				b:first-child{
					font-size 2.4rem
				}
			}
			p:last-child{
				font-size 1.2rem !important
			}

		}
	}
	.labels{
		margin-top 20px
		.fl{
			span{
				display inline-block
				margin-right 10px
				background-color #D0F8ED
				border-radius 6px
				padding 6px 10px
				color #00C08A
			}
		}
		.fr{
			color #0EDBA1
			padding-right 10px
		}
	}
	.popularity{
		margin-top 20px
		padding 10px 40px
		background-color #FBF7F1
		box-sizing border-box
		position relative
		color #B78E4E
		font-size 1.4rem
		border-radius 6px
		i{
			position absolute
			top 16px
		}
		i:first-child{
			left 10px
		}
		i:last-child{
			right 10px
		}
	}
	.area{
		margin-top 20px
		padding 10px 40px
		box-sizing border-box
		position relative
		font-size 1.4rem
		i{
			position absolute
			top 16px
		}
		i:first-child{
			left 10px
			color #06CB67
		}
		i:last-child{
			right 10px
		}
	}
	.phone{
		margin-top 20px
		padding 10px 40px
		box-sizing border-box
		position relative
		font-size 1.4rem
		min-height 40px
		span{
			margin-right 20px
			a{
				color #000000
			}
		}
		i{
			position absolute
			top 16px
		}
		i:first-child{
			left 10px
			color #41A8FF
		}
	}
	hr{
		height 20px
		background-color #EEEEEE
		border none
	}
	.cont{
		padding 40px 0
		font-size 1.4rem
		color #222222
		width 100%
		img {
			width 100% !important
		}
	}
	.classList{
		li{
			margin-top 40px
			padding-left 290px
			position relative
			min-height 270px
			img{
				width 270px
				height 270px
				position absolute
				left 0
				top 0
				border-radius 10px
			}
			h3{
				font-size 1.8rem
				word-break: break-all;
				text-overflow: ellipsis;
				display: -webkit-box;
				-webkit-box-orient: vertical;
				-webkit-line-clamp: 2;
				overflow: hidden;
				margin 0
			}
			p{
				margin 0
				margin-top 10px
				font-size 1.4rem
				color #919191
				word-break: break-all;
				text-overflow: ellipsis;
				display: -webkit-box;
				-webkit-box-orient: vertical;
				-webkit-line-clamp: 25;
				overflow: hidden;
			}
		}
	}
	.gushi{
		.gslabel{
			margin-top 40px
			span{
				display inline-block
				margin-right 20px
				padding 6px 10px
				background-color #D2FCED
				font-size 1.2rem
				border-radius 6px
			}
		}
		ul{
			overflow hidden
			li{
				float left
				width 50%
				margin-top 40px
				box-sizing border-box
				img{
					width 100%
					border-radius 20px
				}
				h3{
					font-size 1.6rem
					word-break: break-all;
					text-overflow: ellipsis;
					display: -webkit-box;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 2;
					overflow: hidden;
					margin 0
				}
				div{
					position relative
					padding 10px 0
					img{
						width 40px
						height 40px
						border-radius 50%
						display inline-block
						vertical-align middle
						margin-right 10px
					}
					span.name{
						display inline-block
						vertical-align middle
						color #7E7F81
						font-size 1.2rem
					}
					div.zan{
						position absolute
						right 20px
						bottom 6px
						font-size 1.2rem
						color #7E7F81
						i{
							font-size 1.4rem
							vertical-align top
						}
						span{
							display inline-block
							vertical-align top
						}
					}
				}
			}
			li:nth-child(2n){
				padding-left 20px
			}
			li:nth-child(2n+1){
				padding-right 20px
			}
		}
	}
	.positionTitle{
		margin 0
		margin-top 60px
		font-size 2rem
		position relative
		b{
			position relative
			z-index 100
		}
		u{
			width 180px
			height 16px
			border-radius 100px
			background-image linear-gradient(to right,#3FCC95,#ffffff)
			position absolute
			bottom 0
			left 0
		}
	}
}
.Collection{
	background-color white
	position fixed
	bottom 0
	left 0
	width 100%
	padding 20px 0
	z-index 500
	.box:last-child{
		width 69%
	}
	.box{
		display inline-block
		vertical-align middle
		width 30%
		text-align center
		color #666666
		.icon{
			display inline-block
			width 49%
			text-align center
			font-size 1.2rem
			p{
				margin 0
			}
			i{
				font-size 2.4rem
				color #000000
				font-weight bold
			}
		}
		.icon.active{
			color #0CE39D
			i{
				color #0CE39D
			}
		}
		span{
			display inline-block
			padding 20px 40px
			width 80%
			border-radius 100px
			color white
			font-size 2rem
			background:linear-gradient(307deg,rgba(51,233,172,1) 0%,rgba(6,203,103,1) 100%);
			b{
				display inline-block
				vertical-align middle
				margin-left 20px
				color white
			}
			i{
				vertical-align middle
				font-size 2.2rem
				font-weight bold
			}
		}
	}
}
</style>