doctorHall.vue 13 KB

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