index.vue 17 KB

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