expert.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. <template>
  2. <view class="content">
  3. <!-- 达人信息 -->
  4. <view class="info">
  5. <image class="info-bg" src="https://cdn.his.cdwjyyh.com/images/expert_top_bg.png"></image>
  6. <view class="status_bar" :style="{height: statusBarHeight}"></view>
  7. <view class="back-box">
  8. <image class="img" @click="goBack" src="https://cdn.his.cdwjyyh.com/images/back_white_icon.png"></image>
  9. </view>
  10. <view class="info-block">
  11. <image class="head" :src="expert.avatar"></image>
  12. <view class="right">
  13. <view class="user">
  14. <text class="name">{{expert.nickname}}</text>
  15. <view class="level">
  16. <image class="icon" src="https://cdn.his.cdwjyyh.com/images/intelligent_icon.png"></image>LV.2
  17. </view>
  18. </view>
  19. <view class="txt">{{expert.introduction}}</view>
  20. <view class="card">
  21. <view class="card-item">
  22. <image class="img" src="https://cdn.his.cdwjyyh.com/images/jinbang_font.png"></image>
  23. <text class="ranking">达人榜 第15名</text>
  24. </view>
  25. <image class="go" src="https://cdn.his.cdwjyyh.com/images/jb_arrow_right_icon.png"></image>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="data-block">
  30. <view class="number-block">
  31. <view class="item">
  32. <text class="number-item">{{expert.fansNum}}</text>
  33. <text class="txt-item">粉丝</text>
  34. </view>
  35. <view class="item">
  36. <text class="number-item">{{expert.followNum}}</text>
  37. <text class="txt-item">关注</text>
  38. </view>
  39. <view class="item">
  40. <text class="number-item">{{expert.likes}}</text>
  41. <text class="txt-item">获赞</text>
  42. </view>
  43. </view>
  44. <!-- 关注 -->
  45. <view class="button" :class="isFollow ? 'follow' : ''" @click="toFollow">
  46. <image v-if="!isFollow" class="icon" src="https://cdn.his.cdwjyyh.com/images/guanzhu_green_icon.png" />
  47. <text>{{ isFollow ? '已关注' : '关注' }}</text>
  48. </view>
  49. </view>
  50. </view>
  51. <view class="vedio-block">
  52. <view class="tab-wrapper">
  53. <!-- 生活号标签 -->
  54. <view class="tab-item" :class="{ active: activeTab === 0 }" @click="switchTab(0)">
  55. <text class="tab-text">生活号(22)</text>
  56. <view v-if="activeTab === 0" class="underline"></view>
  57. </view>
  58. <!-- 直播标签 -->
  59. <view class="tab-item" :class="{ active: activeTab === 1 }" @click="switchTab(1)">
  60. <text class="tab-text">直播</text>
  61. <view v-if="activeTab === 1" class="underline"></view>
  62. </view>
  63. </view>
  64. <!-- 视频文章列表 -->
  65. <mescroll-body bottom="0" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
  66. :down="downOption" :up="upOption">
  67. <view class="list">
  68. <view class="list-item" @click="goLive(item)" v-for="(item,index) in list" :key="index">
  69. <image class="img" v-if="item.liveImgUrl" :src="item.liveImgUrl" mode="widthFix"></image>
  70. <image class="video-icon" src="https://cdn.his.cdwjyyh.com/images/video_icon.png"></image>
  71. <image class="suspension-icon" @click="onTask" src="https://cdn.his.cdwjyyh.com/images/suspension.png"></image>
  72. <view class="info-block">
  73. <view class="title">冰乳绿豆糕 冰冰凉凉谁吃谁迷糊! 谁懂,...</view>
  74. <view class="item">
  75. <view class="flex">
  76. <image class="head" src="https://cdn.his.cdwjyyh.com/images/img.png"></image>
  77. <text class="name">崔医生</text>
  78. </view>
  79. <view class="flex">
  80. <image class="icon" src="https://cdn.his.cdwjyyh.com/images/zan_icon.png"></image>
  81. <text>141</text>
  82. </view>
  83. </view>
  84. <view class="card">
  85. <view class="card-item">
  86. <image class="img" src="https://cdn.his.cdwjyyh.com/images/jinbang_font.png"></image>
  87. <text class="ranking">达人榜 第15名</text>
  88. </view>
  89. <image class="go" src="https://cdn.his.cdwjyyh.com/images/jb_arrow_right_icon.png"></image>
  90. </view>
  91. </view>
  92. </view>
  93. </view>
  94. </mescroll-body>
  95. </view>
  96. <Task :show="showTask" @close="handleCloseTask"></Task>
  97. </view>
  98. </template>
  99. <script>
  100. import Task from '@/components/task.vue'
  101. import {
  102. expertHomePage, // 达人主页
  103. follow, // 关注用户
  104. listCreatorRank, //达人排行榜
  105. } from '@/api/life.js'
  106. // import {
  107. // liveList
  108. // } from '@/api/living.js'
  109. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  110. // 点赞/取消点赞常量
  111. const LIKE = 'LIKE';
  112. const UNLIKE = 'UNLIKE';
  113. export default {
  114. components: {
  115. Task
  116. },
  117. mixins: [MescrollMixin],
  118. data() {
  119. return {
  120. expert:{},//达人的数据
  121. showTask: false,
  122. isFollow: false,
  123. expertId: 5, //达人id
  124. activeTab: 0,
  125. // 状态栏的高度
  126. statusBarHeight: uni.getStorageSync('menuInfo').statusBarHeight,
  127. list: [],
  128. downOption: {
  129. offset: 80,
  130. use: true,
  131. auto: false
  132. },
  133. upOption: {
  134. use: true,
  135. auto: true,
  136. page: {
  137. num: 0,
  138. size: 10
  139. }
  140. },
  141. mescroll: null,
  142. }
  143. },
  144. onLoad(option) {
  145. if(option.expertId){
  146. this.expertId=option.expertId;
  147. }
  148. this.getExpertHomePage();
  149. this.getListCreatorRank();
  150. },
  151. onUnload() {
  152. },
  153. methods: {// 返回上一页,无则返回首页
  154. goBack() {
  155. // 获取页面栈
  156. const pages = getCurrentPages();
  157. // 如果页面栈长度大于1,说明有上一页
  158. if (pages.length > 1) {
  159. // 返回上一页
  160. uni.navigateBack({
  161. delta: 1
  162. });
  163. } else {
  164. // 否则返回首页
  165. uni.reLaunch({
  166. url: '/pages/home/index'
  167. });
  168. }
  169. },
  170. //达人排行榜
  171. getListCreatorRank() {
  172. listCreatorRank().then(res => {
  173. if (res.code == 200) {
  174. console.log("达人排行榜", res)
  175. } else {
  176. uni.showToast({
  177. title: res.msg,
  178. icon: 'none'
  179. });
  180. }
  181. }).catch(err => {});
  182. },
  183. // 达人主页
  184. getExpertHomePage() {
  185. console.log("达人id",this.expertId)
  186. if(!this.expertId) return;
  187. expertHomePage(this.expertId).then(res => {
  188. if (res.code == 200 && res.data) {
  189. console.log("达人主页", res)
  190. this.expert=res.data
  191. // 同步关注状态
  192. this.isFollow = res.data.isFollow || false;
  193. } else {
  194. uni.showToast({
  195. title: res.msg || '获取达人信息失败',
  196. icon: 'none'
  197. });
  198. }
  199. }).catch(err => {});
  200. },
  201. // 关注用户
  202. toFollow() {
  203. console.log("关注取消用户")
  204. const action = this.isFollow ? UNLIKE : LIKE;
  205. const data = {
  206. expertId: this.expertId,
  207. action: action
  208. };
  209. follow(data).then(res => {
  210. if (res.code == 200) {
  211. this.isFollow = !this.isFollow;
  212. this.getExpertHomePage();
  213. console.log(action + "用户", res)
  214. } else {
  215. uni.showToast({
  216. title: res.msg,
  217. icon: 'none'
  218. });
  219. }
  220. }).catch(err => {});
  221. },
  222. onTask() {
  223. this.showTask = true;
  224. },
  225. handleCloseTask() {
  226. this.showTask = false;
  227. },
  228. switchTab(tab) {
  229. if (this.activeTab === tab) return;
  230. this.activeTab = tab;
  231. this.$emit('change', tab);
  232. },
  233. mescrollInit(mescroll) {
  234. this.mescroll = mescroll;
  235. },
  236. // 下拉刷新回调
  237. downCallback(mescroll) {
  238. this.list = [];
  239. mescroll.resetUpScroll();
  240. },
  241. // 上拉加载回调
  242. // upCallback(mescroll) {
  243. // const pageNum = mescroll.num;
  244. // const pageSize = mescroll.size;
  245. // let data = {
  246. // pageSize: pageSize,
  247. // pageNum: pageNum,
  248. // }
  249. // liveList(data).then(res => {
  250. // if (!res) {
  251. // mescroll.endErr();
  252. // return;
  253. // }
  254. // if (res.code == 200) {
  255. // let curPageData = Array.isArray(res.data.list) ? res.data.list : [];
  256. // let totalSize = Number(res.data.total) || 0;
  257. // if (pageNum === 1) {
  258. // this.list = [];
  259. // }
  260. // this.list = this.list.concat(curPageData);
  261. // mescroll.endBySize(curPageData.length, totalSize);
  262. // } else {
  263. // mescroll.endErr();
  264. // uni.showToast({
  265. // title: res.msg,
  266. // icon: 'none'
  267. // });
  268. // }
  269. // }).catch(err => {
  270. // mescroll.endErr();
  271. // });
  272. // },
  273. goLive(item) {
  274. uni.navigateTo({
  275. // &immediate=true
  276. url: `./living?liveId=${item.liveId}`
  277. });
  278. }
  279. }
  280. }
  281. </script>
  282. <style lang="scss" scoped>
  283. .content {
  284. background-color: #111;
  285. min-height: 100vh;
  286. // padding: 24rpx;
  287. // 达人信息
  288. .info {
  289. width: 100%;
  290. height: 600rpx;
  291. position: relative;
  292. z-index: 0;
  293. .info-bg {
  294. position: absolute;
  295. z-index: -1;
  296. width: 100%;
  297. height: 100%;
  298. }
  299. .back-box {
  300. display: flex;
  301. align-items: center;
  302. height: 88rpx;
  303. margin-left: 24rpx;
  304. .img {
  305. width: 48rpx;
  306. height: 48rpx;
  307. }
  308. }
  309. .info-block {
  310. margin-top: 32rpx;
  311. padding: 0 20rpx;
  312. display: flex;
  313. align-items: center;
  314. .head {
  315. width: 160rpx;
  316. height: 160rpx;
  317. margin-right: 20rpx;
  318. border-radius: 50%;
  319. }
  320. .right {
  321. .user {
  322. display: flex;
  323. .name {
  324. font-weight: 500;
  325. font-size: 40rpx;
  326. color: #FFFFFF;
  327. margin-right: 16rpx;
  328. }
  329. .level {
  330. width: 118rpx;
  331. height: 40rpx;
  332. display: flex;
  333. align-items: center;
  334. font-weight: 500;
  335. font-size: 22rpx;
  336. color: #FEF5EA;
  337. background: linear-gradient(90deg, #F5CE3C 0%, #E39414 100%);
  338. border-radius: 20rpx 20rpx 20rpx 20rpx;
  339. padding: 4rpx 12rpx;
  340. box-sizing: border-box;
  341. .icon {
  342. width: 32rpx;
  343. height: 32rpx;
  344. margin-right: 8rpx;
  345. }
  346. }
  347. }
  348. .txt {
  349. font-weight: 400;
  350. font-size: 22rpx;
  351. color: #FFFFFF;
  352. margin: 8rpx 0 16rpx;
  353. }
  354. .card {
  355. display: flex;
  356. justify-content: space-between;
  357. align-items: center;
  358. background: #FFF5EB;
  359. width: 302rpx;
  360. height: 40rpx;
  361. border-radius: 8rpx 8rpx 8rpx 8rpx;
  362. border: 1rpx solid #F3E2D0;
  363. padding: 8rpx;
  364. box-sizing: border-box;
  365. .card-item {
  366. display: flex;
  367. align-items: center;
  368. .img {
  369. width: 48rpx;
  370. height: 24rpx;
  371. margin-right: 8rpx;
  372. }
  373. .ranking {
  374. font-size: 22rpx;
  375. color: #D46C0D;
  376. }
  377. }
  378. .go {
  379. width: 16rpx;
  380. height: 16rpx;
  381. }
  382. }
  383. }
  384. }
  385. .data-block {
  386. padding: 0 20rpx;
  387. margin-top: 30rpx;
  388. display: flex;
  389. justify-content: space-between;
  390. align-items: center;
  391. .number-block {
  392. display: flex;
  393. .item {
  394. margin-right: 32rpx;
  395. display: flex;
  396. flex-direction: column;
  397. align-items: center;
  398. .number-item {
  399. font-family: Roboto, Roboto;
  400. font-weight: 600;
  401. font-size: 36rpx;
  402. color: #FFFFFF;
  403. }
  404. .txt-item {
  405. margin-top: 6rpx;
  406. font-size: 26rpx;
  407. color: rgba(255, 255, 255, 0.7);
  408. }
  409. }
  410. }
  411. .button {
  412. width: 144rpx;
  413. height: 56rpx;
  414. background: #FFFFFF;
  415. border-radius: 28rpx 28rpx 28rpx 28rpx;
  416. display: flex;
  417. align-items: center;
  418. justify-content: center;
  419. font-size: 24rpx;
  420. color: #02B176;
  421. &.follow {
  422. background: #F0F0F0;
  423. color: #666666;
  424. }
  425. .icon {
  426. width: 24rpx;
  427. height: 24rpx;
  428. margin-right: 4rpx;
  429. }
  430. }
  431. }
  432. }
  433. //达人视频
  434. .vedio-block {
  435. position: relative;
  436. z-index: 1;
  437. background-color: #FFFFFF;
  438. margin-top: -74rpx;
  439. border-radius: 32rpx 32rpx 0rpx 0rpx;
  440. padding: 26rpx 0;
  441. .tab-wrapper {
  442. display: flex;
  443. height: 88rpx;
  444. padding: 0 40rpx;
  445. position: relative;
  446. .tab-item {
  447. flex: 1;
  448. display: flex;
  449. flex-direction: column;
  450. align-items: center;
  451. justify-content: center;
  452. position: relative;
  453. color: #666666;
  454. &.active {
  455. font-weight: 600;
  456. font-size: 32rpx;
  457. color: #02B176;
  458. }
  459. .tab-text {
  460. font-size: 32rpx;
  461. transition: all 0.3s ease;
  462. }
  463. .underline {
  464. position: absolute;
  465. bottom: 0;
  466. left: 50%;
  467. transform: translateX(-50%);
  468. width: 48rpx;
  469. height: 6rpx;
  470. background: #02B176;
  471. border-radius: 3rpx 3rpx 3rpx 3rpx;
  472. animation: slideIn 0.3s ease;
  473. }
  474. }
  475. }
  476. @keyframes slideIn {
  477. from {
  478. opacity: 0;
  479. transform: translateX(-50%) scaleX(0.5);
  480. }
  481. to {
  482. opacity: 1;
  483. transform: translateX(-50%) scaleX(1);
  484. }
  485. }
  486. .list {
  487. background: #F5F7FA;
  488. padding: 24rpx 24rpx;
  489. display: flex;
  490. justify-content: space-between;
  491. flex-wrap: wrap;
  492. .list-item {
  493. width: 342rpx;
  494. margin-bottom: 18rpx;
  495. position: relative;
  496. display: flex;
  497. flex-direction: column;
  498. .img {
  499. width: 100%;
  500. border-radius: 16rpx 16rpx 0rpx 0rpx;
  501. }
  502. .video-icon {
  503. width: 40rpx;
  504. height: 40rpx;
  505. position: absolute;
  506. top: 20rpx;
  507. right: 20rpx;
  508. }
  509. .suspension-icon {
  510. width: 144rpx;
  511. height: 144rpx;
  512. position: absolute;
  513. top: -14rpx;
  514. right: 0rpx;
  515. }
  516. .info-block {
  517. border-radius: 0rpx 0rpx 16rpx 16rpx;
  518. padding: 12rpx 20rpx 20rpx;
  519. box-sizing: border-box;
  520. width: 100%;
  521. background: #FFFFFF;
  522. display: flex;
  523. flex-direction: column;
  524. .title {
  525. font-weight: 500;
  526. font-size: 28rpx;
  527. color: #333333;
  528. margin-bottom: 20rpx;
  529. }
  530. .item {
  531. display: flex;
  532. justify-content: space-between;
  533. align-items: center;
  534. margin-bottom: 20rpx;
  535. .flex {
  536. display: flex;
  537. align-items: center;
  538. font-size: 22rpx;
  539. color: #999999;
  540. }
  541. .icon {
  542. width: 32rpx;
  543. height: 32rpx;
  544. margin-right: 4rpx;
  545. }
  546. .head {
  547. width: 32rpx;
  548. height: 32rpx;
  549. border-radius: 50%;
  550. margin-right: 8rpx;
  551. }
  552. .name {
  553. color: #757575;
  554. }
  555. }
  556. text {
  557. white-space: nowrap;
  558. overflow: hidden;
  559. text-overflow: ellipsis;
  560. }
  561. .card {
  562. display: flex;
  563. justify-content: space-between;
  564. align-items: center;
  565. background: #FFF5EB;
  566. width: 302rpx;
  567. height: 40rpx;
  568. border-radius: 8rpx 8rpx 8rpx 8rpx;
  569. border: 1rpx solid #F3E2D0;
  570. padding: 8rpx;
  571. box-sizing: border-box;
  572. .card-item {
  573. display: flex;
  574. align-items: center;
  575. .img {
  576. width: 48rpx;
  577. height: 24rpx;
  578. margin-right: 8rpx;
  579. }
  580. .ranking {
  581. font-size: 22rpx;
  582. color: #D46C0D;
  583. }
  584. }
  585. .go {
  586. width: 16rpx;
  587. height: 16rpx;
  588. }
  589. }
  590. }
  591. }
  592. .list-item:nth-child(2n) {
  593. margin-right: 0;
  594. }
  595. }
  596. }
  597. }
  598. </style>