index.vue 17 KB

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