doctorHall.vue 12 KB

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