index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760
  1. <template>
  2. <view class="container" >
  3. <view class="swiper">
  4. <view class="swiper-box">
  5. <swiper circular="true" autoplay="true" @change="swiperChange">
  6. <swiper-item v-for="swiper in banner" :key="swiper.id">
  7. <image :src="swiper.pic"></image>
  8. </swiper-item>
  9. </swiper>
  10. <view class="indicator">
  11. <view class="dots" v-for="(swiper, index) in banner" :class="[swiperCurrent >= index ? 'on' : '']"
  12. :key="index"></view>
  13. </view>
  14. </view>
  15. </view>
  16. <view class="Live-list">
  17. <view class="list-name flex" @click="ToLive">
  18. <view class="list-tip">
  19. <view class="tip"></view>
  20. 正在直播
  21. </view>
  22. <view class="list-more">
  23. 更多
  24. <text class="iconfont iconenter"></text>
  25. </view>
  26. </view>
  27. <scroll-view class="floor-list" scroll-x>
  28. <view class="scoll-wrapper position-relative">
  29. <view class="floor-item" v-for="ls in broadList" @click="ToLiveDetails(ls)">
  30. <view class="img-box">
  31. <image class="list-image" :src="ls.image"></image>
  32. <view class="tip">好评</view>
  33. </view>
  34. <view class="title clamp">{{ls.title}}</view>
  35. <view class="tip-box flex_item">
  36. <view v-for="item in ls.label" class="tip">{{item}}</view>
  37. </view>
  38. <view class="info ellipsis">{{ls.abstract}}</view>
  39. </view>
  40. </view>
  41. </scroll-view>
  42. </view>
  43. <view class="Live-list">
  44. <view class="list-name flex" @click="ToCourse">
  45. <view class="list-tip">
  46. <view class="tip"></view>
  47. 精选好课
  48. </view>
  49. <view class="list-more">
  50. 更多
  51. <text class="iconfont iconenter"></text>
  52. </view>
  53. </view>
  54. <view id="list-box" class="list-box">
  55. <view class="guess-section flex">
  56. <view class="guess-item" v-for="ls in courseList" @click="ToCourseDetails(ls)">
  57. <view class="imagewrapper">
  58. <image :src="ls.image"></image>
  59. </view>
  60. <text class="title clamp">{{ls.title}}</text>
  61. <view class="tip-box flex_item">
  62. <view v-for="item in ls.label" class="tip">{{item}}</view>
  63. </view>
  64. <view class="info clamp">¥{{ls.money}}</view>
  65. </view>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </template>
  71. <script>
  72. import {
  73. mapState,
  74. mapMutations
  75. } from 'vuex';
  76. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  77. import {
  78. getDoctorList
  79. } from '@/api/doctor.js';
  80. import {
  81. course_list
  82. } from '@/api/course.js';
  83. import {
  84. saveUrl,
  85. interceptor
  86. } from '@/utils/loginUtils.js';
  87. export default {
  88. onPageScroll(e) {
  89. this.navP = e.scrollTop / 200;
  90. if (e.scrollTop > 10) {
  91. this.addr_color = '#333333';
  92. } else {
  93. this.addr_color = '#ffffff';
  94. }
  95. },
  96. data() {
  97. return {
  98. header_color: 'linear-gradient(52deg, rgba(151,143,250,1) 0%, rgba(126,153,254,1) 100%)', //轮播图背景色渐变
  99. navP: 0, // 导航栏透明度
  100. DoctorList: [],
  101. limit: 10, //每次加载数据条数
  102. page: 1, //当前页数
  103. loadingType: 'more', //加载更多状态
  104. loading: 0, //判断是否为点击搜索按钮跳转加载
  105. addr_color: '',
  106. swiperCurrent: 0, //轮播图
  107. swiperHeight: 300,
  108. banner: '', //轮播图
  109. recommend: '', //列表数据
  110. courseList: '', //专题列表
  111. broadList: '', //直播列表
  112. };
  113. },
  114. onLoad(option) {
  115. if (option.spread) {
  116. // 存储邀请人
  117. this.spread = option.spread;
  118. uni.setStorageSync('spread', option.spread);
  119. }
  120. this.getDoctorList();
  121. this.loadData();
  122. },
  123. computed: {
  124. ...mapState(['userInfo', 'hasLogin'])
  125. },
  126. onShow() {
  127. let obj = this
  128. saveUrl()
  129. console.log(this.userInfo, 55);
  130. // 1是病人 2是医生 3是机构
  131. if (obj.userInfo.type == 2) {
  132. uni.setTabBarItem({
  133. index: 0,
  134. text: '首页',
  135. iconPath: 'static/tabBar/tab-home.png',
  136. selectedIconPath: 'static/tabBar/tab-home-current.png'
  137. });
  138. uni.setTabBarItem({
  139. index: 1,
  140. text: '我的病人',
  141. iconPath: 'static/tabBar/tab-cate.png',
  142. selectedIconPath: 'static/tabBar/tab-cate-current.png',
  143. visible: true
  144. });
  145. uni.setTabBarItem({
  146. index: 2,
  147. text: '科普学习',
  148. iconPath: 'static/tabBar/tab-study.png',
  149. selectedIconPath: 'static/tabBar/tab-study-current.png',
  150. visible: false
  151. });
  152. uni.setTabBarItem({
  153. index: 3,
  154. text: '接单',
  155. iconPath: 'static/tabBar/jd.png',
  156. selectedIconPath: 'static/tabBar/jd-act.png',
  157. pagePath: '/pages/dd/dd'
  158. })
  159. uni.setTabBarItem({
  160. index: 4,
  161. text: '我的',
  162. iconPath: 'static/tabBar/tab-my.png',
  163. selectedIconPath: 'static/tabBar/tab-my-current.png'
  164. });
  165. }
  166. if (obj.userInfo.type == 1) {
  167. uni.setTabBarItem({
  168. index: 0,
  169. text: '首页',
  170. iconPath: 'static/tabBar/tab-home.png',
  171. selectedIconPath: 'static/tabBar/tab-home-current.png'
  172. });
  173. uni.setTabBarItem({
  174. index: 1,
  175. text: '咨询记录',
  176. iconPath: 'static/tabBar/tab-cate.png',
  177. selectedIconPath: 'static/tabBar/tab-cate-current.png',
  178. visible: true
  179. });
  180. uni.setTabBarItem({
  181. index: 2,
  182. text: '科普学习',
  183. iconPath: 'static/tabBar/tab-study.png',
  184. selectedIconPath: 'static/tabBar/tab-study-current.png',
  185. visible: true
  186. });
  187. uni.setTabBarItem({
  188. index: 3,
  189. text: '接单',
  190. iconPath: 'static/tabBar/jd.png',
  191. selectedIconPath: 'static/tabBar/jd-act.png',
  192. visible: false
  193. })
  194. uni.setTabBarItem({
  195. index: 4,
  196. text: '我的',
  197. iconPath: 'static/tabBar/tab-my.png',
  198. selectedIconPath: 'static/tabBar/tab-my-current.png'
  199. });
  200. }
  201. if (obj.userInfo.type == 3) {
  202. uni.setTabBarItem({
  203. index: 0,
  204. text: '首页',
  205. iconPath: 'static/tabBar/tab-home.png',
  206. selectedIconPath: 'static/tabBar/tab-home-current.png'
  207. });
  208. uni.setTabBarItem({
  209. index: 1,
  210. text: '咨询记录',
  211. iconPath: 'static/tabBar/tab-cate.png',
  212. selectedIconPath: 'static/tabBar/tab-cate-current.png'
  213. });
  214. uni.setTabBarItem({
  215. index: 2,
  216. text: '科普学习',
  217. iconPath: 'static/tabBar/tab-study.png',
  218. selectedIconPath: 'static/tabBar/tab-study-current.png',
  219. visible: false
  220. });
  221. uni.setTabBarItem({
  222. index: 3,
  223. text: '发布订单',
  224. iconPath: 'static/tabBar/jd.png',
  225. selectedIconPath: 'static/tabBar/jd-act.png',
  226. pagePath: '/pages/dd/dd'
  227. })
  228. uni.setTabBarItem({
  229. index: 4,
  230. text: '我的',
  231. iconPath: 'static/tabBar/tab-my.png',
  232. selectedIconPath: 'static/tabBar/tab-my-current.png'
  233. });
  234. }
  235. },
  236. //下拉刷新
  237. onPullDownRefresh() {
  238. this.page = 1;
  239. this.getDoctorList('refresh');
  240. },
  241. methods: {
  242. // onShowLog(){
  243. // this.$log.showLog()
  244. // },
  245. //加载专题列表
  246. loadData() {
  247. let obj = this;
  248. course_list({
  249. page: obj.page,
  250. limit: obj.limit
  251. })
  252. .then(data => {
  253. obj.banner = data.data.banner;
  254. obj.recommend = data.data.recommend;
  255. obj.courseList = data.data.recommend['精品课程排行'].list;
  256. if (data.data.recommend['在线直播'].list) {
  257. obj.broadList = data.data.recommend['在线直播'].list;
  258. }
  259. })
  260. .catch(e => {
  261. console.log(e.message);
  262. });
  263. },
  264. //获取医生列表
  265. getDoctorList(type) {
  266. let obj = this;
  267. //这里是将订单挂载到tab列表下
  268. if (type !== 'refresh') {
  269. //没有更多数据直接跳出方法
  270. if (obj.loadingType === 'nomore') {
  271. return;
  272. } else {
  273. // 设置当前为数据载入中
  274. obj.loadingType = 'loading';
  275. }
  276. } else {
  277. //当重新加载数据时更新状态为可继续添加数据
  278. obj.loadingType = 'more';
  279. }
  280. getDoctorList({
  281. hospital: '',
  282. keyword: '',
  283. sort: '',
  284. page: obj.page,
  285. limit: obj.limit
  286. })
  287. .then(data => {
  288. if (type === 'refresh') {
  289. obj.DoctorList = [];
  290. }
  291. obj.DoctorList = obj.DoctorList.concat(data.data.list);
  292. //判断是否还有下一页,有是more 没有是nomore
  293. if (obj.limit == obj.DoctorList.length) {
  294. obj.page++;
  295. obj.loadingType = 'more';
  296. } else {
  297. obj.loadingType = 'nomore';
  298. }
  299. // 判断是否为刷新数据
  300. if (type === 'refresh') {
  301. // 判断是否为点击搜索按钮跳转加载
  302. if (obj.loading == 1) {
  303. uni.hideLoading();
  304. } else {
  305. uni.stopPullDownRefresh();
  306. }
  307. }
  308. })
  309. .catch(e => {
  310. console.log(e.message);
  311. if (e.message == '请登录') {
  312. uni.showModal({
  313. title: '提示',
  314. content: '您未登录,是否马上登陆',
  315. success: function(res) {
  316. if (res.confirm) {
  317. interceptor();
  318. } else if (res.cancel) {
  319. console.log('用户点击取消');
  320. }
  321. }
  322. });
  323. }
  324. obj.loadingType = 'nomore';
  325. // obj.$api.msg(e.message);
  326. uni.hideLoading();
  327. });
  328. },
  329. //专题列表
  330. ToCourse() {
  331. let recommend = this.recommend['精品课程排行'];
  332. uni.navigateTo({
  333. url: '/pages/course/course?recommend_id=' + recommend.id + '&type=' + recommend.type +
  334. '&title=' + recommend.title + '&typesetting=' + recommend.typesetting
  335. });
  336. },
  337. //专题详情
  338. ToCourseDetails(item) {
  339. console.log(item)
  340. let id = item.link_id;
  341. uni.navigateTo({
  342. url: '/pages/course/detail?id=' + id
  343. });
  344. },
  345. //医生详情
  346. ToExpert(item) {
  347. uni.navigateTo({
  348. url: '/pages/doctor/expert?id=' + item
  349. });
  350. },
  351. //医生列表
  352. ToDoclist() {
  353. uni.navigateTo({
  354. url: '/pages/doctor/doclist'
  355. });
  356. },
  357. //直播列表
  358. ToLive() {
  359. console.log(this.recommend)
  360. let recommend = this.recommend['在线直播'];
  361. uni.navigateTo({
  362. url: '/pages/live/list?recommend_id=' + recommend.id + '&type=' + recommend.type +
  363. '&title=' +
  364. recommend.title + '&typesetting=' + recommend.typesetting
  365. });
  366. },
  367. //直播详情
  368. ToLiveDetails(ls) {
  369. console.log(ls)
  370. uni.navigateTo({
  371. url: '/pages/live/details?id=' + ls.link_id
  372. });
  373. },
  374. //轮播图
  375. swiperChange(e) {
  376. const index = e.detail.current;
  377. this.swiperCurrent = index;
  378. }
  379. }
  380. };
  381. </script>
  382. <style lang="scss">
  383. page {
  384. background: #f5f5f5;
  385. }
  386. .top_header {
  387. padding: 25rpx 0rpx;
  388. .top-address {
  389. position: fixed;
  390. top: 0;
  391. width: 100% !important;
  392. z-index: 999;
  393. padding-bottom: 25rpx;
  394. //地址
  395. .header {
  396. width: 100%;
  397. padding: 0 4%;
  398. height: 100rpx;
  399. display: flex;
  400. align-items: center;
  401. .addr {
  402. height: 60rpx;
  403. flex-shrink: 0;
  404. display: flex;
  405. align-items: center;
  406. font-size: 36rpx;
  407. font-weight: bold;
  408. width: 90%;
  409. color: #ffffff;
  410. .icon {
  411. height: 60rpx;
  412. margin-right: 15rpx;
  413. display: flex;
  414. align-items: center;
  415. font-size: 42rpx;
  416. color: #ffffff;
  417. }
  418. }
  419. .config {
  420. width: 120rpx;
  421. height: 60rpx;
  422. flex-shrink: 0;
  423. display: flex;
  424. .message {
  425. width: 65rpx;
  426. height: 65rpx;
  427. display: flex;
  428. justify-content: flex-end;
  429. align-items: center;
  430. font-size: 42rpx;
  431. color: #ffffff;
  432. }
  433. }
  434. }
  435. }
  436. .zhanwei {
  437. width: 100% !important;
  438. height: 60rpx;
  439. }
  440. }
  441. .search-box {
  442. height: 120rpx;
  443. }
  444. //搜索框
  445. .input-box {
  446. width: 80%;
  447. margin-left: 25rpx;
  448. height: 70rpx;
  449. background-color: #ffffff;
  450. border-radius: 50rpx;
  451. position: relative;
  452. display: flex;
  453. align-items: center;
  454. .icon {
  455. display: flex;
  456. align-items: center;
  457. position: absolute;
  458. top: 0;
  459. left: 35rpx;
  460. width: 60rpx;
  461. height: 70rpx;
  462. font-size: 34rpx;
  463. color: #c0c0c0;
  464. }
  465. input {
  466. padding-left: 100rpx;
  467. height: 28rpx;
  468. font-size: 28rpx;
  469. }
  470. }
  471. .queding {
  472. color: #ffffff;
  473. font-size: 35rpx;
  474. padding: 25rpx 25rpx;
  475. }
  476. //轮播图
  477. .swiper {
  478. width: 100%;
  479. display: flex;
  480. justify-content: center;
  481. .swiper-box {
  482. width: 100%;
  483. height: 346rpx;
  484. overflow: hidden;
  485. // box-shadow: 0upx 8upx 25upx rgba(0, 0, 0, 0.2);
  486. //兼容ios,微信小程序
  487. position: relative;
  488. z-index: 1;
  489. swiper {
  490. width: 100%;
  491. height: 346rpx;
  492. swiper-item {
  493. image {
  494. width: 100%;
  495. height: 346rpx;
  496. }
  497. }
  498. }
  499. .indicator {
  500. position: absolute;
  501. bottom: 20upx;
  502. left: 20upx;
  503. background-color: rgba(255, 255, 255, 0.4);
  504. width: 150upx;
  505. height: 5upx;
  506. border-radius: 3upx;
  507. overflow: hidden;
  508. display: flex;
  509. .dots {
  510. width: 0upx;
  511. background-color: rgba(255, 255, 255, 1);
  512. transition: all 0.3s ease-out;
  513. &.on {
  514. width: (100%/3);
  515. }
  516. }
  517. }
  518. }
  519. }
  520. //正在直播
  521. .Live-list {
  522. margin-top: 25rpx;
  523. width: 100%;
  524. background-color: #ffffff;
  525. font-size: 24rpx;
  526. padding: 35rpx 35rpx;
  527. .list-name {
  528. padding-bottom: 35rpx;
  529. .list-tip {
  530. position: relative;
  531. padding-left: 25rpx;
  532. color: #6786fb;
  533. font-size: 32rpx;
  534. .tip {
  535. position: absolute;
  536. left: 0rpx;
  537. width: 10rpx;
  538. height: 45rpx;
  539. background-color: #6786fb;
  540. border-radius: 25rpx;
  541. }
  542. }
  543. .list-more {
  544. color: #999999;
  545. font-size: 24rpx;
  546. }
  547. }
  548. }
  549. .scoll-wrapper {
  550. display: flex;
  551. align-items: flex-start;
  552. .floor-item {
  553. width: 220rpx;
  554. font-size: $font-sm + 2rpx;
  555. margin-right: 25rpx;
  556. .img-box {
  557. position: relative;
  558. .list-image {
  559. width: 220rpx;
  560. height: 144rpx;
  561. border-radius: 15rpx;
  562. box-shadow: 0px 6px 10px 0px rgba(0, 0, 0, 0.04);
  563. }
  564. .tip {
  565. position: absolute;
  566. right: 15rpx;
  567. top: 0rpx;
  568. background: #ff6700;
  569. width: 45rpx;
  570. text-align: center;
  571. font-size: 18rpx;
  572. color: #ffffff;
  573. padding: 10rpx 0rpx;
  574. border-bottom-left-radius: 25rpx;
  575. border-bottom-right-radius: 25rpx;
  576. }
  577. }
  578. .tip-box {
  579. display: flex;
  580. flex-wrap: wrap;
  581. padding-top: 5rpx;
  582. .tip {
  583. background: rgba(103, 134, 251, 0.18);
  584. color: #6786FB;
  585. margin-right: 15rpx;
  586. margin-top: 10rpx;
  587. padding: 2rpx 10rpx;
  588. }
  589. }
  590. .title {
  591. font-size: 26rpx !important;
  592. font-weight: 500;
  593. }
  594. .info {
  595. color: #999999;
  596. font-size: 24rpx;
  597. padding-top: 15rpx;
  598. }
  599. }
  600. }
  601. /*公用边框样式*/
  602. %icon {
  603. margin-right: 10rpx;
  604. display: inline-block;
  605. padding: 2rpx 10rpx;
  606. border: 1rpx solid $color-yellow;
  607. color: $color-yellow;
  608. line-height: 1;
  609. font-size: $font-base;
  610. border-radius: 10rpx;
  611. }
  612. //精选好课
  613. .guess-section {
  614. display: flex;
  615. flex-wrap: wrap;
  616. .guess-item {
  617. position: relative;
  618. overflow: hidden;
  619. display: flex;
  620. flex-direction: column;
  621. width: 47%;
  622. margin-bottom: 2%;
  623. background-color: white;
  624. padding-bottom: 30rpx;
  625. // &:nth-child(2n + 1) {
  626. // margin-right: 15rpx;
  627. // }
  628. }
  629. .tip-box {
  630. display: flex;
  631. flex-wrap: wrap;
  632. padding-top: 5rpx;
  633. .tip {
  634. background: rgba(103, 134, 251, 0.18);
  635. color: #6786FB;
  636. margin-right: 15rpx;
  637. margin-top: 10rpx;
  638. padding: 2rpx 10rpx;
  639. }
  640. }
  641. .imagewrapper {
  642. width: 100%;
  643. height: 204rpx;
  644. margin-bottom: 15rpx;
  645. image {
  646. border-radius: 15rpx;
  647. width: 100%;
  648. height: 100%;
  649. }
  650. }
  651. .title {
  652. font-size: 30rpx;
  653. color: $font-color-dark;
  654. }
  655. .info {
  656. color: #e73932;
  657. padding-top: 15rpx;
  658. font-size: 30rpx;
  659. }
  660. }
  661. .preferred_centent {
  662. width: 100%;
  663. .preferred_item {
  664. width: 100%;
  665. height: 100%;
  666. border-top: 1px solid #f0f0f0;
  667. padding: 35rpx 0rpx;
  668. .goods_image image {
  669. width: 140rpx;
  670. height: 140rpx;
  671. border-radius: 100%;
  672. }
  673. .goods_name {
  674. padding-left: 25rpx;
  675. width: 50%;
  676. .goods_title {
  677. white-space: nowrap;
  678. overflow: hidden;
  679. text-overflow: ellipsis;
  680. font-size: 30rpx;
  681. font-weight: 400;
  682. }
  683. .goods_info {
  684. padding-top: 15rpx;
  685. font-size: 24rpx;
  686. color: #999999;
  687. }
  688. }
  689. .btn-tpl {
  690. margin-left: 10rpx;
  691. border: 2rpx solid #305cec;
  692. padding: 13rpx 20rpx;
  693. color: #6786fb;
  694. border-radius: 15rpx;
  695. .tpl-img {
  696. padding-right: 10rpx;
  697. image {
  698. margin-top: 8rpx;
  699. width: 35rpx;
  700. height: 35rpx;
  701. }
  702. }
  703. }
  704. }
  705. }
  706. </style>