index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. <template>
  2. <view class="container" :data-theme="theme">
  3. <!-- :style="userInfo.avatar?{ backgroundImage: `url(${userInfo.avatar})` }: ''" -->
  4. <!-- #ifdef MP || APP -->
  5. <NavBar navTitle="个人主页" :isBackgroundColor="false" iconColor='#fff'></NavBar>
  6. <!-- #endif -->
  7. <view class="header">
  8. <view class="header-bg" :style="{'background-image': userInfo.avatar}">
  9. <img :src="userInfo.avatar" alt="">
  10. <view class="header-bg-mc"></view>
  11. </view>
  12. <view class="user_wrapper acea-row">
  13. <image v-if="userInfo.userLevelIcon" class="level_icon" :src="userInfo.userLevelIcon" alt="">
  14. <view class="acea-row row-middle">
  15. <image :src="userInfo.avatar || urlDomain+'crmebimage/presets/morenT.png'" class="picture">
  16. </image>
  17. <view class="user_text">
  18. <view class="name acea-row">
  19. <text>{{userInfo.isLogoff ? "用户已注销": (userInfo.nickname || '')}}</text>
  20. </view>
  21. <view v-if="userInfo.id" class="user_id">ID: {{userInfo.id || ''}}</view>
  22. </view>
  23. </view>
  24. <view v-if="id && id!=uid" @click.stop="followAuthor">
  25. <button v-if="!userInfo.isConcerned" class="follow_btn focus">
  26. <text class="iconfont icon-jiahao2"></text>关注
  27. </button>
  28. <button v-else class="follow_btn focused">已关注</button>
  29. </view>
  30. <view v-if="userInfo.id==uid">
  31. <navigator hover-class="none" url="/pages/discover/discover_release/index"
  32. class="follow_btn focus bg-color">
  33. 去发布
  34. </navigator>
  35. </view>
  36. </view>
  37. <view class="acea-row plant_info" @click="onEdit">
  38. <view v-if="!userInfo.signature && userInfo.id==uid">点击可编辑个性签名</view>
  39. <view class="" v-if="userInfo.signature" style="width: 92%;">
  40. <view class="acea-row" v-if="userInfo.isMore || userInfo.signature.length<=30">
  41. <text class="signature">{{userInfo.signature}}</text>
  42. <text v-if="userInfo.isMore" class="more" @click.stop="moreTap">收起</text>
  43. </view>
  44. <view v-else class="acea-row">
  45. <text class="info signature">{{userInfo.signature.slice(0,23)}}...</text>
  46. <text class="more" @click.stop="moreTap"> 展开</text>
  47. </view>
  48. </view>
  49. <text v-show="userInfo.id==uid" class="ml10 iconfont icon-fabuzhongcao"></text>
  50. </view>
  51. <view class="plant_info" style="padding-bottom: 30rpx;">
  52. <view class="count_wrapper acea-row">
  53. <navigator :url="!id ? '/pages/discover/discover_follow/index?type=follow' : ''" class="item"
  54. hover-class="none">
  55. <text class="mr10">{{userInfo.concernedNum}}</text> 关注
  56. </navigator>
  57. <navigator :url="!id ? '/pages/discover/discover_follow/index?type=fans' : ''" class="item"
  58. hover-class="none">
  59. <text class="mr10">{{userInfo.fansNum}}</text> 粉丝
  60. </navigator>
  61. <view class="item">
  62. <text class="mr10">{{userInfo.likeNum}}</text> 获赞
  63. </view>
  64. </view>
  65. </view>
  66. <view v-if="!id && isShow" class="tab_count relative">
  67. <text @click.stop="changeTab(0)" :class="tab==0 ? 'on' : ''">作品</text>
  68. <text @click.stop="changeTab(1)" :class="tab==1 ? 'on' : ''">赞过</text>
  69. </view>
  70. </view>
  71. <view class="main">
  72. <view class="tab-conts">
  73. <view v-if="list.length > 0" class="goods-wrap flex-1">
  74. <view class="goods">
  75. <WaterfallsFlow v-if="list.length" :wfList="list" :fromType="1" fromTo="home">
  76. </WaterfallsFlow>
  77. </view>
  78. </view>
  79. <view class="empty-boxs noContent" v-if="list.length == 0 && !loading">
  80. <emptyPage title="暂无更多内容~" mTop="13%" :imgSrc="urlDomain+'crmebimage/presets/noguanzhu.png'">
  81. </emptyPage>
  82. </view>
  83. <view class='loadingicon acea-row row-center-wrapper'>
  84. <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>
  85. <view class="end" :hidden="loading || list.length == 0"><text
  86. :class="loaded ? 'loaded' : ''">{{loadTitle}}</text>
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. <uni-popup ref="inputDialog" type="dialog">
  92. <view v-if="isShowSignature" class="tui-modal-custom">
  93. <view class="fs-32 fw-500 lh-44rpx text-center">编辑简介</view>
  94. <view class="mt-24 bg--w111-f5f5f5 rd-16rpx p-24 h-342">
  95. <textarea class="w-full fs-26" ref="myTextarea" v-model="signature" :focus="focus"
  96. :always-embed="true" :adjust-position="true" cursor-spacing="85rpx"
  97. placeholder="请输入内容" :maxlength="100" name="desc" />
  98. </view>
  99. <view class="flex-between-center mt-40">
  100. <view class="w-244 h-72 rd-36rpx flex-center fs-26 font-color close-btn" @tap="handleInputClose">取消
  101. </view>
  102. <view class="w-244 h-72 rd-36rpx flex-center bg-color text--w111-fff fs-26"
  103. @tap="handleInputConfirm">保存
  104. </view>
  105. </view>
  106. </view>
  107. </uni-popup>
  108. </view>
  109. </template>
  110. <script>
  111. // +----------------------------------------------------------------------
  112. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  113. // +----------------------------------------------------------------------
  114. // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
  115. // +----------------------------------------------------------------------
  116. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  117. // +----------------------------------------------------------------------
  118. // | Author: CRMEB Team <admin@crmeb.com>
  119. // +----------------------------------------------------------------------
  120. import WaterfallsFlow from '@/components/WaterfallsFlow/WaterfallsFlow.vue'
  121. import WaterfallsFlowItem from '@/components/discoverFlowItem/discoverFlowItem.vue'
  122. import emptyPage from '@/components/emptyPage.vue';
  123. import NavBar from '@/components/navBar.vue';
  124. import {
  125. userHomeApi,
  126. myHomeApi,
  127. authorNoteApi,
  128. myNoteApi,
  129. myLikeListApi,
  130. editSignatureApi
  131. } from '@/api/discover.js';
  132. import {
  133. toLogin
  134. } from '@/libs/login.js';
  135. import {
  136. mapGetters
  137. } from "vuex";
  138. import {
  139. discoverFollowAuthor
  140. } from '@/libs/follow.js';
  141. const app = getApp();
  142. let sysHeight = uni.getSystemInfoSync().statusBarHeight;
  143. export default {
  144. components: {
  145. WaterfallsFlow,
  146. WaterfallsFlowItem,
  147. emptyPage,
  148. NavBar
  149. },
  150. data() {
  151. return {
  152. sysHeight: sysHeight,
  153. urlDomain: this.$Cache.get("imgHost"),
  154. theme: app.globalData.theme,
  155. list: [], // 内容列表
  156. loadTitle: '加载更多',
  157. loading: false,
  158. loaded: false,
  159. isShowAuth: false, //是否隐藏授权
  160. isAuto: false, //没有授权的不会自动授权
  161. userInfo: {},
  162. where: {
  163. page: 1,
  164. limit: 10
  165. },
  166. tab: 0,
  167. id: '', //作者id
  168. isShow: false,
  169. focus: false,
  170. isShowSignature: false, // 是否显示简介编辑内容
  171. signature: '' //弹窗中的签名
  172. }
  173. },
  174. created() {},
  175. computed: {
  176. ...mapGetters(['isLogin', 'uid']),
  177. },
  178. watch: {},
  179. onLoad: function(options) {
  180. this.id = options.id ? options.id : '';
  181. },
  182. onShow() {
  183. if (this.id) {
  184. this.isShow = false
  185. this.getUserHome(this.id);
  186. this.authorNoteList();
  187. } else {
  188. this.isShow = true
  189. this.getMyHome();
  190. this.myNoteList();
  191. }
  192. },
  193. onReady() {},
  194. mounted: function() {},
  195. methods: {
  196. moreTap() {
  197. this.$set(this.userInfo, 'isMore', !this.userInfo.isMore)
  198. },
  199. //个性签名取消
  200. handleInputClose() {
  201. this.$refs.inputDialog.close()
  202. this.isShowSignature = false;
  203. },
  204. //个性签名保存
  205. handleInputConfirm() {
  206. editSignatureApi({
  207. signature: this.signature
  208. }).then(res => {
  209. uni.showToast({
  210. title: res.data,
  211. icon: 'none'
  212. })
  213. this.getMyHome();
  214. }).catch(err => {
  215. uni.showToast({
  216. title: err,
  217. icon: 'none'
  218. })
  219. });
  220. // 关闭窗口后,恢复默认内容
  221. this.$refs.inputDialog.close()
  222. this.isShowSignature = false;
  223. },
  224. //编辑个性签名
  225. onEdit() {
  226. if (this.userInfo.id == this.uid) {
  227. this.isShowSignature = true;
  228. this.signature = this.userInfo.signature;
  229. this.$refs.inputDialog.open();
  230. }
  231. },
  232. //回退页面之后重新加载页面
  233. reFresh() {
  234. this.loading = false;
  235. this.loaded = false;
  236. this.where = {
  237. page: 1,
  238. limit: 10
  239. }
  240. this.list = []
  241. if (this.id) {
  242. this.getUserHome(this.id);
  243. this.authorNoteList();
  244. } else {
  245. this.getMyHome();
  246. this.myNoteList();
  247. }
  248. },
  249. //获取我的用户信息
  250. getMyHome() {
  251. myHomeApi().then(res => {
  252. this.userInfo = res.data;
  253. this.signature = this.userInfo.signature
  254. this.isMore = false;
  255. }).catch(err => {
  256. uni.showToast({
  257. title: err,
  258. icon: 'none'
  259. })
  260. });
  261. },
  262. //逛逛用户主页
  263. getUserHome(id) {
  264. userHomeApi(id).then(res => {
  265. this.userInfo = res.data
  266. }).catch(err => {
  267. uni.showToast({
  268. title: err,
  269. icon: 'none'
  270. })
  271. });
  272. },
  273. // 关注作者
  274. followAuthor: function() {
  275. if (this.isLogin) {
  276. if (this.userInfo.isLogoff) return;
  277. discoverFollowAuthor(this.id).then(() => {
  278. this.$set(this.userInfo, 'isConcerned', !this.userInfo.isConcerned);
  279. });
  280. } else {
  281. toLogin();
  282. }
  283. },
  284. changeTab(tab) {
  285. this.tab = tab
  286. this.where.page = 1
  287. this.loaded = this.loading = false
  288. this.list = []
  289. if (tab === 0) {
  290. this.myNoteList();
  291. } else {
  292. this.myLikeList();
  293. }
  294. },
  295. // 获取我的点赞作品
  296. myLikeList: function() {
  297. let that = this;
  298. if (that.loaded || that.loading) return;
  299. that.loading = true;
  300. that.loadTitle = '';
  301. myLikeListApi(that.where).then(res => {
  302. let list = res.data.list;
  303. let goods = that.$util.SplitArray(list, that.list);
  304. that.loaded = list.length < that.where.limit;
  305. that.loading = false;
  306. that.loadTitle = that.loaded ? '到底了' : '加载更多';
  307. that.$set(that, 'list', goods);
  308. that.$set(that.where, 'page', that.where.page + 1);
  309. }).catch(err => {
  310. that.loading = false;
  311. uni.showToast({
  312. title: err,
  313. icon: 'none'
  314. })
  315. })
  316. },
  317. // 获取我的的作品
  318. myNoteList: function() {
  319. let that = this;
  320. if (that.loaded || that.loading) return;
  321. that.loading = true;
  322. that.loadTitle = '';
  323. myNoteApi(that.where).then(res => {
  324. let list = res.data.list;
  325. let goods = that.$util.SplitArray(list, that.list);
  326. that.loaded = list.length < that.where.limit;
  327. that.loading = false;
  328. that.loadTitle = that.loaded ? '到底了' : '加载更多';
  329. that.$set(that, 'list', goods);
  330. that.$set(that.where, 'page', that.where.page + 1);
  331. }).catch(err => {
  332. that.loading = false;
  333. uni.showToast({
  334. title: err,
  335. icon: 'none'
  336. })
  337. })
  338. },
  339. // 作者的作品
  340. authorNoteList: function() {
  341. let that = this;
  342. if (that.loaded || that.loading) return;
  343. that.loading = true;
  344. that.loadTitle = '';
  345. this.where.authorId = this.id
  346. authorNoteApi(this.where.authorId, that.where).then(res => {
  347. let list = res.data.list;
  348. let goods = that.$util.SplitArray(list, that.list);
  349. that.loaded = list.length < that.where.limit;
  350. that.loading = false;
  351. that.loadTitle = that.loaded ? '到底了' : '加载更多';
  352. that.$set(that, 'list', goods);
  353. that.$set(that.where, 'page', that.where.page + 1);
  354. }).catch(err => {
  355. that.loading = false;
  356. uni.showToast({
  357. title: err,
  358. icon: 'none'
  359. })
  360. })
  361. }
  362. },
  363. onReachBottom() {
  364. if (this.id) {
  365. this.authorNoteList();
  366. } else {
  367. if (this.tab === 0) {
  368. this.myNoteList();
  369. } else {
  370. this.myLikeList();
  371. }
  372. }
  373. },
  374. onPullDownRefresh() {},
  375. // 滚动监听
  376. onPageScroll(e) {
  377. // 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件
  378. uni.$emit('scroll');
  379. }
  380. }
  381. </script>
  382. <style lang="scss" scoped>
  383. .close-btn {
  384. @include coupons_border_color(theme);
  385. }
  386. .tui-modal-custom {
  387. width: 600rpx;
  388. position: relative;
  389. box-sizing: border-box;
  390. padding: 40rpx;
  391. border-radius: 16px;
  392. background-color: #fff;
  393. z-index: 9999;
  394. .h-342 {
  395. min-height: 268rpx;
  396. max-height: 268rpx;
  397. ;
  398. overflow-y: scroll;
  399. }
  400. }
  401. .signature {
  402. overflow: hidden;
  403. display: -webkit-box;
  404. -webkit-line-clamp: 5;
  405. -webkit-box-orient: vertical;
  406. text-overflow: ellipsis;
  407. width: 88%;
  408. }
  409. .goods-wrap {
  410. padding-top: 24rpx;
  411. }
  412. .more {
  413. font-weight: 600;
  414. margin-left: 8rpx;
  415. }
  416. .container {
  417. background: #ffffff;
  418. min-height: 100vh;
  419. }
  420. .header-bg {
  421. position: absolute;
  422. width: 100%;
  423. height: 650rpx;
  424. top: 0;
  425. /* #ifdef MP || APP-PLUS */
  426. z-index: -1;
  427. /* #endif */
  428. /* #ifdef H5 */
  429. z-index: 0;
  430. /* #endif */
  431. z-index: 0;
  432. filter: blur(0);
  433. overflow: hidden;
  434. img {
  435. width: 100%;
  436. height: 100%;
  437. filter: blur(16rpx);
  438. transform: scale(1.5);
  439. }
  440. .header-bg-mc {
  441. position: absolute;
  442. top: 0;
  443. width: 100%;
  444. height: 100%;
  445. background-image: linear-gradient(180deg, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.1) 39%, rgba(0, 0, 0, 0.7) 100%);
  446. }
  447. }
  448. .header {
  449. width: 750rpx;
  450. padding: 20rpx 0 0;
  451. box-sizing: border-box;
  452. background: linear-gradient(360deg, #72798E 0%, #384857 99%);
  453. opacity: 1;
  454. .tab_count {
  455. text-align: center;
  456. background: #ffffff;
  457. padding: 30rpx 0 15rpx 0;
  458. border-radius: 12px 12px 0 0;
  459. text {
  460. font-size: 28rpx;
  461. color: #999999;
  462. margin: 0 30rpx;
  463. position: relative;
  464. padding-bottom: 14rpx;
  465. &.on {
  466. font-size: 32rpx;
  467. color: #282828;
  468. font-weight: bold;
  469. &::after {
  470. content: "";
  471. width: 40rpx;
  472. height: 5rpx;
  473. @include main_bg_color(theme);
  474. position: absolute;
  475. bottom: 0;
  476. left: 10rpx;
  477. }
  478. .underline {
  479. opacity: 1;
  480. }
  481. }
  482. }
  483. }
  484. .user_wrapper {
  485. align-items: center;
  486. justify-content: space-between;
  487. padding: 0 34rpx;
  488. position: relative;
  489. .level_icon {
  490. position: absolute;
  491. width: 38rpx;
  492. height: 38rpx;
  493. margin: 4rpx 0 0 6rpx;
  494. border: none;
  495. z-index: 11;
  496. bottom: 2rpx;
  497. left: 124rpx;
  498. }
  499. .image,
  500. uni-image,
  501. image {
  502. width: 140rpx;
  503. height: 140rpx;
  504. border-radius: 100%;
  505. border: 4rpx solid #ffffff;
  506. }
  507. .user_text {
  508. margin-left: 30rpx;
  509. color: #FFFFFF;
  510. .name {
  511. font-size: 34rpx;
  512. font-weight: bold;
  513. align-items: center;
  514. }
  515. .user_id {
  516. margin-top: 16rpx;
  517. font-size: 24rpx;
  518. }
  519. }
  520. }
  521. .plant_info {
  522. position: relative;
  523. padding: 0 34rpx;
  524. margin-top: 30rpx;
  525. justify-content: space-between;
  526. color: #ffffff;
  527. font-size: 24rpx;
  528. .count_wrapper {
  529. color: #FFFFFF;
  530. font-size: 24rpx;
  531. .item {
  532. text-align: center;
  533. margin-right: 60rpx;
  534. &:last-child {
  535. margin-right: 0;
  536. }
  537. text {
  538. font-size: 30rpx;
  539. margin-top: 10rpx;
  540. }
  541. }
  542. }
  543. }
  544. .iconfont {
  545. font-size: 24rpx;
  546. margin-right: 12rpx;
  547. }
  548. .follow_btn {
  549. color: #ffffff;
  550. font-size: 26rpx;
  551. display: flex;
  552. align-items: center;
  553. justify-content: center;
  554. width: 146rpx;
  555. height: 62rpx;
  556. @include linear-gradient(theme);
  557. border-radius: 33rpx;
  558. .icon-fabu {
  559. font-size: 24rpx;
  560. }
  561. &.focused {
  562. background: transparent;
  563. color: #FFFFFF;
  564. border: 1px solid #FFFFFF;
  565. }
  566. }
  567. }
  568. .main {
  569. background: #ffffff;
  570. position: relative;
  571. }
  572. .goods {
  573. // display: flex;
  574. // flex-wrap: wrap;
  575. // justify-content: space-between;
  576. // width: 750rpx;
  577. padding: 0 24rpx;
  578. }
  579. .empty {
  580. margin: 130rpx 0 150rpx;
  581. text-align: center;
  582. image,
  583. uni-image {
  584. display: inline-block;
  585. width: 414rpx;
  586. height: 305rpx;
  587. }
  588. text {
  589. display: block;
  590. color: #999999;
  591. font-size: 26rpx;
  592. }
  593. }
  594. .end {
  595. margin-top: 50rpx 0;
  596. text-align: center;
  597. text {
  598. color: #999999;
  599. font-size: 22rpx;
  600. position: relative;
  601. &.loaded {
  602. &::before,
  603. &::after {
  604. content: "";
  605. display: inline-block;
  606. width: 22rpx;
  607. height: 1rpx;
  608. background: #999999;
  609. position: absolute;
  610. top: 18rpx;
  611. opacity: .5;
  612. }
  613. &::before {
  614. left: -30rpx;
  615. }
  616. &::after {
  617. right: -30rpx;
  618. }
  619. }
  620. }
  621. }
  622. </style>