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