doctorHall.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  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/image/hall/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/image/hall/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('./famousHall?type=0')">
  27. <text>更多讲堂</text>
  28. <image class="right-arrow" src="@/static/image/home/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="navTo('./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('./famousHall?type=1')">
  50. <text>更多讲堂</text>
  51. <image class="right-arrow" src="@/static/image/home/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('./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. console.log("qxj findIdx:"+findIdx);
  140. if(findIdx==-1){
  141. let dictItem={"dictValue":0,"dictLabel": "精选"};
  142. this.mtabs.unshift(dictItem);
  143. }
  144. this.isBest=true;
  145. if(this.mtabs.length>0){
  146. this.mtabs = this.mtabs.splice(0,4)
  147. this.cateId=this.mtabs[0].dictValue;
  148. for (let i = 0; i < this.mtabs.length; i++) {
  149. if(i<=4){
  150. this.tabChange(i);
  151. }
  152. }
  153. this.tabChange(0);
  154. }
  155. }
  156. },
  157. rej => {}
  158. );
  159. },
  160. getFamousCourseList:function(index){
  161. let that=this;
  162. let params={};
  163. if(this.isBest){
  164. params={"isBest":1};
  165. }else{
  166. params={"cateId":this.cateId};
  167. }
  168. if(this.dataList.hasOwnProperty(index+"")){
  169. this.updateSwiperHeight(index);
  170. return;
  171. }
  172. getCourseList(params,1,4).then(res => {
  173. if(res.code==200){
  174. if(index==0){
  175. console.log("----qxj getCourseList:");
  176. console.log(res.data.list);
  177. }
  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. // 修改当前页
  201. tabChange(index){
  202. //if(this.tabIndex === index) return;
  203. this.tabIndex = index;
  204. this.scrollViewId = 'scrollView'+index;
  205. const item=this.mtabs[index];
  206. if(item){
  207. if(item.dictLabel=='精选'){
  208. this.isBest=true;
  209. }else{
  210. this.isBest=false;
  211. }
  212. this.cateId=item.dictValue;
  213. this.getFamousCourseList(index);
  214. }
  215. },
  216. // SWIPER划动
  217. swiperChange(e){
  218. // this.tabIndex = e.detail.current;
  219. // this.scrollViewId = 'scrollView'+this.tabIndex;
  220. this.tabChange(e.detail.current);
  221. },
  222. onTransition(){
  223. //console.log("qxj onTransition");
  224. },
  225. animationfinish(){
  226. //console.log("qxj animationfinish");
  227. // this.updateSwiperHeight();
  228. },
  229. onSwiperResize() {
  230. //console.log("qxj onSwiperResize");
  231. },
  232. updateSwiperHeight() {
  233. let dataArr=this.dataList[this.tabIndex.toString()];
  234. if(dataArr==undefined || dataArr.length==0){
  235. this.swHeight=150;
  236. }else{
  237. uni.createSelectorQuery().in(this).select('#swiper-content').boundingClientRect(rect => {
  238. //console.log("qxj swHeight:"+this.swHeight);
  239. if(rect!=null){
  240. this.swHeight = rect.height+20;
  241. }
  242. if(this.swHeight<=100){
  243. //所以(total + pagesize -1) / pagesize就得到总页数
  244. // console.log("qxj famousItemHei:"+this.famousItemHei);
  245. this.swHeight=(dataArr.length+1)/2*this.famousItemHei;
  246. return;
  247. }
  248. }).exec();
  249. }
  250. },
  251. handleAdvClick(index){
  252. var ad=this.advs[index];
  253. if(ad.showType==1){
  254. uni.setStorageSync('url',ad.appAdvUrl);
  255. uni.navigateTo({
  256. url:"h5"
  257. })
  258. }
  259. else if(ad.showType==3){
  260. uni.setStorageSync('content',ad.content);
  261. uni.navigateTo({
  262. url:"content"
  263. })
  264. }
  265. else{
  266. uni.navigateTo({
  267. url:ad.appAdvUrl
  268. })
  269. }
  270. },
  271. navTo(url) {
  272. uni.navigateTo({
  273. url: url
  274. })
  275. },
  276. goToMsg(){
  277. // 切换到视图1 tab
  278. uni.switchTab({
  279. url: '/pages/TUIKit/TUIPages/TUIConversation/index'
  280. });
  281. }
  282. }
  283. }
  284. </script>
  285. <style lang="scss" scoped>
  286. @mixin u-flex($flexD, $alignI, $justifyC) {
  287. display: flex;
  288. flex-direction: $flexD;
  289. align-items: $alignI;
  290. justify-content: $justifyC;
  291. }
  292. .content {
  293. padding: 0 24rpx;
  294. font-family: PingFang SC, PingFang SC;
  295. font-weight: 400;
  296. font-size: 24rpx;
  297. color: #999999;
  298. }
  299. .title {
  300. font-family: PingFang SC, PingFang SC;
  301. font-weight: 500;
  302. font-size: 32rpx;
  303. color: #222222;
  304. line-height: 44rpx;
  305. }
  306. .search-box {
  307. @include u-flex(row, center, space-between);
  308. padding-bottom: 22rpx;
  309. }
  310. .search {
  311. padding: 0;
  312. flex: 1;
  313. image {
  314. width: 24rpx;
  315. height: 24rpx;
  316. padding-left: 16rpx;
  317. }
  318. }
  319. .msg {
  320. image {
  321. width: 48rpx;
  322. height: 48rpx;
  323. margin-left: 26rpx;
  324. margin-right: 4rpx;
  325. position: relative;
  326. }
  327. .badge::after {
  328. content: "";
  329. width: 16rpx;
  330. height: 16rpx;
  331. background: #FF5C03;
  332. border-radius: 50%;
  333. position: absolute;
  334. right: 0;
  335. top: 0;
  336. }
  337. }
  338. .swiper {
  339. width: 694rpx;
  340. height: 390rpx;
  341. margin: 0 auto 16rpx auto;
  342. background: #fff;
  343. border-radius: 20rpx;
  344. overflow: hidden;
  345. .swiper-item {
  346. width: 694rpx;
  347. height: 390rpx;
  348. }
  349. }
  350. ::v-deep {
  351. .uni-swiper-dot {
  352. width: 10rpx;
  353. height: 10rpx;
  354. background: rgba(255, 255, 255, 0.5);
  355. }
  356. .uni-swiper-dot-active {
  357. width: 24rpx;
  358. height: 10rpx;
  359. background-color: #FFFFFF;
  360. border-radius: 5rpx 5rpx 5rpx 5rpx;
  361. }
  362. }
  363. .cate-scroll{
  364. width: 100%;
  365. min-height: 64rpx;
  366. white-space: nowrap;
  367. margin-bottom: 24rpx;
  368. &-item{
  369. display: inline-block;
  370. font-weight: 400;
  371. font-size: 28rpx;
  372. color: #222222;
  373. padding: 0 43rpx;
  374. line-height: 64rpx;
  375. margin-right: 20rpx;
  376. border-radius: 32rpx;
  377. background: #fff;
  378. &-active{
  379. font-weight: 600;
  380. font-size: 28rpx;
  381. color: #FF5C03;
  382. }
  383. }
  384. }
  385. .box-nav {
  386. width: 100%;
  387. padding: 16rpx 0;
  388. box-sizing: border-box;
  389. display: flex;
  390. justify-content: space-between;
  391. &-right {
  392. @include u-flex(row, center, flex-start);
  393. }
  394. .right-arrow {
  395. height: 48rpx;
  396. width: 48rpx;
  397. }
  398. }
  399. .hall-box {
  400. @include u-flex(row, center, flex-start);
  401. flex-wrap: wrap;
  402. margin: 0 -18rpx -18rpx 0;
  403. .gapitem {
  404. margin: 0 18rpx 18rpx 0;
  405. }
  406. }
  407. .hothall {
  408. width: 702rpx;
  409. margin-bottom: 20rpx;
  410. background: #FFFFFF;
  411. border-radius: 16rpx 16rpx 16rpx 16rpx;
  412. overflow: hidden;
  413. position: relative;
  414. .video-img {
  415. width: 702rpx;
  416. height: 400rpx;
  417. background: rgba(0, 0, 0, 0.15);
  418. border-radius: 16rpx 16rpx 0rpx 0rpx;
  419. }
  420. .vip{
  421. position: absolute;
  422. min-width: 54rpx;
  423. min-height: 20rpx;
  424. line-height: 20rpx;
  425. background: linear-gradient(94deg, #FFE9D0 0%, #E9BD97 100%);
  426. border-radius: 16rpx 0 16rpx 0;
  427. top:0;
  428. left: 0;
  429. color:#333;
  430. font-size:18rpx ;
  431. text-align: center;
  432. font-weight: 500;
  433. font-style: italic;
  434. }
  435. &-infobox {
  436. padding: 24rpx;
  437. image {
  438. width: 88rpx;
  439. height: 128rpx;
  440. background: #ECECEC;
  441. border-radius: 8rpx 8rpx 8rpx 8rpx;
  442. border: 2rpx solid #ECECEC;
  443. flex-shrink: 0;
  444. margin-right: 28rpx;
  445. }
  446. }
  447. &-info {
  448. @include u-flex(row, center, flex-start);
  449. }
  450. &-title {
  451. font-weight: 500;
  452. font-size: 28rpx;
  453. color: #222222;
  454. overflow: hidden;
  455. white-space: nowrap;
  456. text-overflow: ellipsis;
  457. }
  458. &-desc {
  459. font-weight: 400;
  460. font-size: 24rpx;
  461. color: #757575;
  462. line-height: 28rpx;
  463. margin-top: 10rpx;
  464. overflow: hidden;
  465. text-overflow: ellipsis;
  466. display: -webkit-box;
  467. -webkit-line-clamp: 2;
  468. -webkit-box-orient: vertical;
  469. }
  470. .tagbox {
  471. @include u-flex(row, center, flex-start);
  472. flex-wrap: wrap;
  473. margin: 0 -12rpx -12rpx 0;
  474. }
  475. .tag {
  476. min-height: 40rpx;
  477. margin: 16rpx 12rpx 12rpx 0;
  478. background: #FEFAF3;
  479. border-radius: 20rpx 20rpx 20rpx 20rpx;
  480. border: 1rpx solid #FBEDD1;
  481. padding: 0 16rpx;
  482. font-weight: 400;
  483. font-size: 22rpx;
  484. color: #A97125;
  485. line-height: 40rpx;
  486. }
  487. }
  488. </style>