doctorHall.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. <template>
  2. <view class="content">
  3. <!-- 搜索 -->
  4. <!-- <view class="search-box">
  5. <uni-search-bar class="search" radius="34" placeholder="请输入关键字搜索" clearButton="auto" cancelButton="none"
  6. @confirm="search">
  7. <template v-slot:searchIcon>
  8. <image src="@/static/images/course/search_gray_icon.png" mode="aspectFill"></image>
  9. </template>
  10. </uni-search-bar>
  11. <view class="msg" @click="goToMsg()">
  12. <image :class="isNew ? 'badge':''" src="@/static/images/course/new_hall_icon.png" mode="aspectFill"></image>
  13. </view>
  14. </view> -->
  15. <!-- banner -->
  16. <swiper class="swiper" style="height: 390rpx;" circular :indicator-dots="indicatorDots" :autoplay="autoplay"
  17. :interval="interval" :duration="duration">
  18. <swiper-item v-for="(url,index) in advImgs" :key="index" class="swiper-item" @click="handleAdvClick(index)">
  19. <image style="width: 100%;height: 100%;" :src="url" mode="aspectFill"></image>
  20. </swiper-item>
  21. </swiper>
  22. <!-- 名医讲堂 -->
  23. <view id="guide3">
  24. <view class="box-nav">
  25. <view class="title">名医讲堂</view>
  26. <view class="box-nav-right" @click="navTo('/pages_course/famousHall?type=0')">
  27. <text>更多讲堂</text>
  28. <image class="right-arrow" src="@/static/images/course/my_right_arrow.png" mode="aspectFill"></image>
  29. </view>
  30. </view>
  31. <scroll-view scroll-x="true" class="cate-scroll" :scroll-into-view="scrollViewId" scroll-with-animation="true"
  32. overflow-anchor="none">
  33. <view :id="'scrollView' + index" class="cate-scroll-item" v-for="(item, index) in mtabs"
  34. :key="index" @click="tabChange(index)" :class="tabIndex == index ? 'cate-scroll-item-active' : ''">
  35. {{ item.dictLabel }}
  36. </view>
  37. </scroll-view>
  38. </view>
  39. <swiper :style="{'height': swHeight+'px'}" @transition="onTransition" @animationfinish="animationfinish" circular :autoplay="swiperAutoplay" interval="5000" duration="1000" :current="tabIndex" @change="swiperChange" v-if="mtabs.length>0">
  40. <swiper-item v-for="(tab,i) in mtabs" :key="i">
  41. <view id="swiper-content" class="hall-box">
  42. <hallItem class="gapitem guide3item" v-for="(item, index) in dataList[i] " :key="index" :item="item" @click.native="navTo('/pages_course/info?courseId='+item.courseId)" />
  43. </view>
  44. </swiper-item>
  45. </swiper>
  46. <!-- 热门推荐 -->
  47. <view class="box-nav">
  48. <view class="title">热门推荐</view>
  49. <view class="box-nav-right" @click="navTo('/pages_course/famousHall?type=1')">
  50. <text>更多讲堂</text>
  51. <image class="right-arrow" src="@/static/images/course/my_right_arrow.png" mode="aspectFill" :lazy-load="true"></image>
  52. </view>
  53. </view>
  54. <view class="hothall" v-for="(item, index) in recommendList" :key="index" @click="navTo('/pages_course/info?courseId='+item.courseId)">
  55. <image class="video-img" :src="item.imgUrl"></image>
  56. <view class="hothall-infobox">
  57. <view class="hothall-info">
  58. <image :src="item.secondImg" mode="aspectFit"></image>
  59. <view>
  60. <view class="hothall-title">{{item.courseName}}</view>
  61. <view class="hothall-desc">{{item.description}}
  62. </view>
  63. </view>
  64. <view v-if="item.isIntegral!=1" class="vip">VIP</view>
  65. </view>
  66. <view class="tagbox">
  67. <block v-if="item.tags!=null">
  68. <view class="tag" v-for="(item, index) in item.tags.split(',')" :key="index" >{{item}}</view>
  69. </block>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. </template>
  75. <script>
  76. import hallItem from "./hallItem.vue";
  77. import {getAdvList} from '@/api/adv.js'
  78. import { getDictByKey } from '@/api/common'
  79. import { getCourseCate,getCourseList } from '@/api/course'
  80. export default {
  81. components: {
  82. hallItem
  83. },
  84. props: ['swiperAutoplay'],
  85. data() {
  86. return {
  87. keyword: "",
  88. isNew: false,
  89. background: ['color1', 'color2', 'color3'],
  90. indicatorDots: true,
  91. autoplay: true,
  92. interval: 3000,
  93. duration: 1000,
  94. cateId:0,
  95. scrollViewId:'scrollView0',
  96. tabIndex: 0,
  97. advImgs:[],
  98. advs:[],
  99. mtabs:[],
  100. dataList:[],
  101. swHeight: 400,
  102. recommendList:[],
  103. isBest:false,
  104. famousItemHei:0,
  105. }
  106. },
  107. mounted() {
  108. this.famousItemHei=uni.upx2px(192);
  109. this.getAdvList();
  110. this.getCourseCate();
  111. this.getRecommendList();
  112. },
  113. methods: {
  114. getAdvList() {
  115. //联网加载数据
  116. var that = this;
  117. var data = { advType:12,status:1}
  118. getAdvList(data).then(res => {
  119. if(res.code==200){
  120. that.advImgs=[];
  121. that.advs=[];
  122. res.data.forEach(function(element) {
  123. if(element.imageUrl!=null&&element.imageUrl!=""){
  124. that.advs.push(element);
  125. that.advImgs.push(element.imageUrl);
  126. }
  127. });
  128. }else{
  129. uni.showToast({icon:'none',title: "请求失败"});
  130. }
  131. });
  132. },
  133. getCourseCate:function(){
  134. let that=this;
  135. getCourseCate().then(res => {
  136. if(res.code==200){
  137. this.mtabs=res.data;
  138. let findIdx=this.mtabs.findIndex(item=>item.dictLabel=='精选');
  139. if(findIdx==-1){
  140. let dictItem={"dictValue":0,"dictLabel": "精选"};
  141. this.mtabs.unshift(dictItem);
  142. }
  143. this.isBest=true;
  144. if(this.mtabs.length>0){
  145. this.mtabs = this.mtabs.splice(0,4)
  146. this.cateId=this.mtabs[0].dictValue;
  147. for (let i = 0; i < this.mtabs.length; i++) {
  148. if(i<=4){
  149. this.tabChange(i);
  150. }
  151. }
  152. this.tabChange(0);
  153. }
  154. }
  155. },
  156. rej => {}
  157. );
  158. },
  159. getFamousCourseList:function(index){
  160. let that=this;
  161. let params={};
  162. if(this.isBest){
  163. params={"isBest":1};
  164. }else{
  165. params={"cateId":this.cateId};
  166. }
  167. if(this.dataList.hasOwnProperty(index+"")){
  168. this.updateSwiperHeight(index);
  169. return;
  170. }
  171. getCourseList(params,1,4).then(res => {
  172. if(res.code==200){
  173. this.dataList[index+""]=res.data.list;
  174. this.$emit("loadFamousCourse",0);
  175. //this.$nextTick(() => {
  176. this.updateSwiperHeight(index);
  177. //});
  178. }
  179. },
  180. rej => {}
  181. );
  182. },
  183. getRecommendList(){
  184. let that=this;
  185. const params={"isTui":1};
  186. getCourseList(params,1,10).then(res => {
  187. if(res.code==200){
  188. this.recommendList=res.data.list;
  189. }
  190. },
  191. rej => {}
  192. );
  193. },
  194. search() {},
  195. // 修改当前页
  196. tabChange(index){
  197. //if(this.tabIndex === index) return;
  198. this.tabIndex = index;
  199. this.scrollViewId = 'scrollView'+index;
  200. const item=this.mtabs[index];
  201. if(item){
  202. if(item.dictLabel=='精选'){
  203. this.isBest=true;
  204. }else{
  205. this.isBest=false;
  206. }
  207. this.cateId=item.dictValue;
  208. this.getFamousCourseList(index);
  209. }
  210. },
  211. // SWIPER划动
  212. swiperChange(e){
  213. // this.tabIndex = e.detail.current;
  214. // this.scrollViewId = 'scrollView'+this.tabIndex;
  215. this.tabChange(e.detail.current);
  216. },
  217. onTransition(){
  218. //console.log("qxj onTransition");
  219. },
  220. animationfinish(){
  221. //console.log("qxj animationfinish");
  222. // this.updateSwiperHeight();
  223. },
  224. onSwiperResize() {
  225. //console.log("qxj onSwiperResize");
  226. },
  227. updateSwiperHeight() {
  228. let dataArr=this.dataList[this.tabIndex.toString()];
  229. if(dataArr==undefined || dataArr.length==0){
  230. this.swHeight=150;
  231. }else{
  232. uni.createSelectorQuery().in(this).select('#swiper-content').boundingClientRect(rect => {
  233. //console.log("qxj swHeight:"+this.swHeight);
  234. if(rect!=null){
  235. this.swHeight = rect.height+20;
  236. }
  237. if(this.swHeight<=100){
  238. //所以(total + pagesize -1) / pagesize就得到总页数
  239. // console.log("qxj famousItemHei:"+this.famousItemHei);
  240. this.swHeight=(dataArr.length+1)/2*this.famousItemHei;
  241. return;
  242. }
  243. }).exec();
  244. }
  245. },
  246. handleAdvClick(index){
  247. var ad=this.advs[index];
  248. if(ad.showType==1){
  249. uni.setStorageSync('url',ad.appAdvUrl);
  250. uni.navigateTo({
  251. url:"h5"
  252. })
  253. }
  254. else if(ad.showType==3){
  255. uni.setStorageSync('content',ad.content);
  256. uni.navigateTo({
  257. url:"content"
  258. })
  259. }
  260. else{
  261. uni.navigateTo({
  262. url:ad.appAdvUrl
  263. })
  264. }
  265. },
  266. navTo(url) {
  267. uni.navigateTo({
  268. url: url
  269. })
  270. },
  271. goToMsg(){
  272. // 切换到视图1 tab
  273. uni.switchTab({
  274. url: '/pages/TUIKit/TUIPages/TUIConversation/index'
  275. });
  276. }
  277. }
  278. }
  279. </script>
  280. <style lang="scss" scoped>
  281. @mixin u-flex($flexD, $alignI, $justifyC) {
  282. display: flex;
  283. flex-direction: $flexD;
  284. align-items: $alignI;
  285. justify-content: $justifyC;
  286. }
  287. .content {
  288. padding: 0 24rpx;
  289. font-family: PingFang SC, PingFang SC;
  290. font-weight: 400;
  291. font-size: 24rpx;
  292. color: #999999;
  293. }
  294. .title {
  295. font-family: PingFang SC, PingFang SC;
  296. font-weight: 500;
  297. font-size: 32rpx;
  298. color: #222222;
  299. line-height: 44rpx;
  300. }
  301. .search-box {
  302. @include u-flex(row, center, space-between);
  303. padding-bottom: 22rpx;
  304. }
  305. .search {
  306. padding: 0;
  307. flex: 1;
  308. image {
  309. width: 24rpx;
  310. height: 24rpx;
  311. padding-left: 16rpx;
  312. }
  313. }
  314. .msg {
  315. image {
  316. width: 48rpx;
  317. height: 48rpx;
  318. margin-left: 26rpx;
  319. margin-right: 4rpx;
  320. position: relative;
  321. }
  322. .badge::after {
  323. content: "";
  324. width: 16rpx;
  325. height: 16rpx;
  326. background: #018C39;
  327. border-radius: 50%;
  328. position: absolute;
  329. right: 0;
  330. top: 0;
  331. }
  332. }
  333. .swiper {
  334. width: 694rpx;
  335. height: 390rpx;
  336. margin: 0 auto 16rpx auto;
  337. background: #fff;
  338. border-radius: 20rpx;
  339. overflow: hidden;
  340. .swiper-item {
  341. width: 694rpx;
  342. height: 390rpx;
  343. }
  344. }
  345. ::v-deep {
  346. .uni-swiper-dot {
  347. width: 10rpx;
  348. height: 10rpx;
  349. background: rgba(255, 255, 255, 0.5);
  350. }
  351. .uni-swiper-dot-active {
  352. width: 24rpx;
  353. height: 10rpx;
  354. background-color: #FFFFFF;
  355. border-radius: 5rpx 5rpx 5rpx 5rpx;
  356. }
  357. }
  358. .cate-scroll{
  359. width: 100%;
  360. min-height: 64rpx;
  361. white-space: nowrap;
  362. margin-bottom: 24rpx;
  363. &-item{
  364. display: inline-block;
  365. font-weight: 400;
  366. font-size: 28rpx;
  367. color: #222222;
  368. padding: 0 43rpx;
  369. line-height: 64rpx;
  370. margin-right: 20rpx;
  371. border-radius: 32rpx;
  372. background: #fff;
  373. &-active{
  374. font-weight: 600;
  375. font-size: 28rpx;
  376. color: #018C39;
  377. }
  378. }
  379. }
  380. .box-nav {
  381. width: 100%;
  382. padding: 16rpx 0;
  383. box-sizing: border-box;
  384. display: flex;
  385. justify-content: space-between;
  386. &-right {
  387. @include u-flex(row, center, flex-start);
  388. }
  389. .right-arrow {
  390. height: 48rpx;
  391. width: 48rpx;
  392. }
  393. }
  394. .hall-box {
  395. @include u-flex(row, center, flex-start);
  396. flex-wrap: wrap;
  397. margin: 0 -18rpx -18rpx 0;
  398. .gapitem {
  399. margin: 0 18rpx 18rpx 0;
  400. }
  401. }
  402. .hothall {
  403. width: 702rpx;
  404. margin-bottom: 20rpx;
  405. background: #FFFFFF;
  406. border-radius: 16rpx 16rpx 16rpx 16rpx;
  407. overflow: hidden;
  408. position: relative;
  409. .video-img {
  410. width: 702rpx;
  411. height: 400rpx;
  412. background: rgba(0, 0, 0, 0.15);
  413. border-radius: 16rpx 16rpx 0rpx 0rpx;
  414. }
  415. .vip{
  416. position: absolute;
  417. min-width: 54rpx;
  418. min-height: 20rpx;
  419. line-height: 20rpx;
  420. background: linear-gradient(94deg, #FFE9D0 0%, #E9BD97 100%);
  421. border-radius: 16rpx 0 16rpx 0;
  422. top:0;
  423. left: 0;
  424. color:#333;
  425. font-size:18rpx ;
  426. text-align: center;
  427. font-weight: 500;
  428. font-style: italic;
  429. }
  430. &-infobox {
  431. padding: 24rpx;
  432. image {
  433. width: 88rpx;
  434. height: 128rpx;
  435. background: #ECECEC;
  436. border-radius: 8rpx 8rpx 8rpx 8rpx;
  437. border: 2rpx solid #ECECEC;
  438. flex-shrink: 0;
  439. margin-right: 28rpx;
  440. }
  441. }
  442. &-info {
  443. @include u-flex(row, center, flex-start);
  444. }
  445. &-title {
  446. font-weight: 500;
  447. font-size: 28rpx;
  448. color: #222222;
  449. overflow: hidden;
  450. white-space: nowrap;
  451. text-overflow: ellipsis;
  452. }
  453. &-desc {
  454. font-weight: 400;
  455. font-size: 24rpx;
  456. color: #757575;
  457. line-height: 28rpx;
  458. margin-top: 10rpx;
  459. overflow: hidden;
  460. text-overflow: ellipsis;
  461. display: -webkit-box;
  462. -webkit-line-clamp: 2;
  463. -webkit-box-orient: vertical;
  464. }
  465. .tagbox {
  466. @include u-flex(row, center, flex-start);
  467. flex-wrap: wrap;
  468. margin: 0 -12rpx -12rpx 0;
  469. }
  470. .tag {
  471. min-height: 40rpx;
  472. margin: 16rpx 12rpx 12rpx 0;
  473. background: #FEFAF3;
  474. border-radius: 20rpx 20rpx 20rpx 20rpx;
  475. border: 1rpx solid #FBEDD1;
  476. padding: 0 16rpx;
  477. font-weight: 400;
  478. font-size: 22rpx;
  479. color: #A97125;
  480. line-height: 40rpx;
  481. }
  482. }
  483. </style>