userHomepage.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731
  1. <template>
  2. <view class="page">
  3. <view class="topBody">
  4. <view class="header">
  5. <view class="reserveASeat"></view>
  6. <view class="card-box">
  7. <view class="card-top">
  8. <view class="top-box">
  9. <view class="hello-box" @click="goBack">
  10. <text class="fa fa-angle-left" style="color: #000; font-size: 55rpx;"></text>
  11. </view>
  12. <view class="settingBtn-box">
  13. <image @click="clickShare()" src="@/static/me/wd_icon_fenxian.png" mode=""></image>
  14. </view>
  15. </view>
  16. <view class="userinfo-box">
  17. <view class="userinfo-left">
  18. <CircleAvatar class="avator" :src="myinfo.avator"></CircleAvatar>
  19. </view>
  20. <view class="userinfo-right">
  21. <view class="nickname">
  22. <text class="one-omit">{{ myinfo.nickname }}</text>
  23. <image src="../../static/icon/wd_icon_nan.png" mode="widthFix" v-if="myinfo.sex_id == 1"></image>
  24. <image src="../../static/icon/wd_icon_nv.png" mode="widthFix" v-else-if="myinfo.sex_id == 2"></image>
  25. <view class="level">Lv{{ myinfo.my_level }}</view>
  26. </view>
  27. <view class="label">
  28. <view v-for="(item, index) in aihao_tags" :key="index + item">
  29. {{ item }}
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. <view class="intro_row">
  35. <block v-if="myinfo.content == ''">
  36. <text class="intro_text two-omit">简介</text>
  37. </block>
  38. <uv-text v-else :text="myinfo.content" class="intro_text two-omit">
  39. </uv-text>
  40. </view>
  41. <view class="line"></view>
  42. <view class="bom">
  43. <view class="follow_info">
  44. <view class="follow-box">
  45. <view class="num">{{ myinfo.num_attention }}</view>
  46. <view class="label">关注</view>
  47. </view>
  48. <view class="separator"></view>
  49. <view class="follow-box">
  50. <view class="num">{{ myinfo.num_fans }}</view>
  51. <view class="label">粉丝</view>
  52. </view>
  53. <view class="separator"></view>
  54. <view class="follow-box">
  55. <view class="num">{{ myinfo.num_like }}</view>
  56. <view class="label">获赞</view>
  57. </view>
  58. </view>
  59. <view class="points-box">
  60. <text class="followTheAuthor followTheAuthor1" v-if="!myinfo.is_attention"
  61. @click="followTheAuthor(1)">+关注</text>
  62. <text class="followTheAuthor followTheAuthor0" v-else @click="followTheAuthor(0)">已关注</text>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. <view class="myinfo" >
  69. <!-- 作品列表 -->
  70. <view class="numlist" >
  71. <WorkItem v-for="(item, index) in worksList" :subtitle="true" :key="index" :item="item"
  72. @click="goWork(item)" />
  73. <view v-if="isDataLoaded && worksList.length === 0" class="empty-state">
  74. <image src="@/static/icon/xx_img_zanwuxiaoxi.png" mode="aspectFit" class="empty-image">
  75. </image>
  76. <text class="empty-text">暂无作品</text>
  77. <text class="empty-subtext">他还没有开始创作作品~</text>
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. <!-- 确认框 -->
  83. <CustomConfirm ref="customConfirm"></CustomConfirm>
  84. <!-- 提示框 -->
  85. <DialogBox ref="DialogBox"></DialogBox>
  86. <!-- SharePopup组件 -->
  87. <SharePopup :visible="showShare" :userId="userId" :share-title="shareTitle" :share-desc="shareDesc" :share-img="shareImg" view="userHomepage"
  88. @close="showShare = false" />
  89. </view>
  90. </template>
  91. <script>
  92. import tabbar from "@/mixins/tabbar";
  93. import CustomConfirm from "@/components/custome-confirm/customeConfirm.vue";
  94. import CircleAvatar from "@/components/CircleAvatar/CircleAvatar.vue";
  95. import WorkItem from "@/components/WorkItem/WorkItem.vue";
  96. import SharePopup from "@/components/SharePopup/SharePopup.vue";
  97. import DialogBox from "@/components/DialogBox/DialogBox.vue";
  98. export default {
  99. components: {
  100. CustomConfirm,
  101. CircleAvatar,
  102. WorkItem,
  103. SharePopup,
  104. DialogBox
  105. },
  106. mixins: [tabbar],
  107. data() {
  108. return {
  109. firstLevelNavActive: 0,
  110. myinfo: {
  111. avator: "../../static/logo.png",
  112. nickname: "",
  113. content: "",
  114. sex_id: 1,
  115. my_level: 1,
  116. num_attention: 0,
  117. num_fans: 0,
  118. num_like: 0,
  119. wxkf: ""
  120. },
  121. aihao_tags: [],
  122. activeTab: 0,
  123. offset: 0,
  124. hasMore: true,
  125. isLoading: false,
  126. worksList: [],
  127. showShare: false,
  128. shareTitle: "",
  129. shareDesc: "",
  130. shareImg: "",
  131. userId: 0,
  132. id: 0,
  133. isDataLoaded: false,
  134. };
  135. },
  136. onLoad(e) {
  137. if (e.id) {
  138. this.id = e.id
  139. }
  140. },
  141. onShow() {
  142. uni.$emit("check_login", () => { });
  143. this.offset = 0;
  144. this.hasMore = true;
  145. this.worksList = [];
  146. this.loadInfo();
  147. this.loadWorksList();
  148. },
  149. onReachBottom() {
  150. if (this.hasMore && !this.isLoading) {
  151. this.loadMoreWorks();
  152. }
  153. },
  154. methods: {
  155. // 关注作者
  156. followTheAuthor(n) {
  157. uni.request({
  158. url: this.$apiHost + "/Member/attention",
  159. data: {
  160. uuid: getApp().globalData.uuid,
  161. id: this.id,
  162. },
  163. header: {
  164. "content-type": "application/json",
  165. sign: getApp().globalData.headerSign,
  166. },
  167. success: (res) => {
  168. console.log("点赞结果:", res.data);
  169. uni.showToast({
  170. title: res.data.str,
  171. icon: "none",
  172. });
  173. this.loadInfo();
  174. },
  175. fail: (e) => {
  176. console.log("关注失败:", e);
  177. uni.showToast({
  178. title: "网络请求失败",
  179. icon: "none",
  180. });
  181. },
  182. });
  183. },
  184. goBack() {
  185. uni.navigateBack({
  186. delta: 1,
  187. });
  188. },
  189. clickShare(item) {
  190. this.showShare = true;
  191. },
  192. goPage(page) {
  193. if (page == "kefu") {
  194. let that = this;
  195. // #ifdef APP-PLUS
  196. plus.share.getServices((res) => {
  197. const wechat = res.find((i) => i.id === "weixin");
  198. if (wechat) {
  199. wechat.openCustomerServiceChat(
  200. {
  201. corpid: "wwbc06aa8311b6ac08",
  202. url: that.myinfo.wxkf,
  203. },
  204. (src) => {
  205. console.log("success:");
  206. },
  207. (err) => {
  208. console.log("error:");
  209. }
  210. );
  211. } else {
  212. uni.showToast({
  213. title: "没有检测到微信,请先安装",
  214. icon: "error",
  215. });
  216. }
  217. });
  218. // #endif
  219. } else if (page != "") {
  220. uni.navigateTo({
  221. url: page,
  222. });
  223. }
  224. },
  225. loadInfo() {
  226. console.log({
  227. uuid: getApp().globalData.uuid,
  228. skey: getApp().globalData.skey,
  229. });
  230. uni.request({
  231. url: this.$apiHost + "/Member/getHomeInfo",
  232. data: {
  233. uuid: getApp().globalData.uuid,
  234. skey: getApp().globalData.skey,
  235. user_id: this.id,
  236. },
  237. header: {
  238. "content-type": "application/json",
  239. sign: getApp().globalData.headerSign,
  240. },
  241. success: (res) => {
  242. console.log("----:", JSON.parse(JSON.stringify(res.data)));
  243. this.shareTitle = res.data.nickname
  244. this.shareDesc = res.data.content
  245. this.shareImg = res.data.avator
  246. this.userId = res.data.user_id
  247. if (res.data.need_login == "yes") {
  248. uni.removeStorageSync("wapptoken");
  249. uni.redirectTo({
  250. url: "/pages/login/login",
  251. });
  252. return;
  253. }
  254. if (res.data.aihao) {
  255. this.aihao_tags = res.data.aihao.split(",");
  256. }
  257. this.myinfo = res.data;
  258. },
  259. complete: (com) => {
  260. // uni.hideLoading();
  261. },
  262. fail: (e) => {
  263. console.log("----e:", e);
  264. },
  265. });
  266. },
  267. switchTab(index) {
  268. this.activeTab = index;
  269. this.offset = 0;
  270. this.hasMore = true;
  271. this.worksList = [];
  272. this.loadWorksList();
  273. },
  274. loadWorksList() {
  275. if (this.isLoading) return;
  276. this.isLoading = true;
  277. this.isDataLoaded = false;
  278. uni.request({
  279. url: this.$apiHost + '/Work/getlist',
  280. data: {
  281. uuid: getApp().globalData.uuid,
  282. skey: getApp().globalData.skey,
  283. type: "other", // 固定为my,表示获取自己的作品
  284. offset: this.offset,
  285. user_id: this.id
  286. },
  287. header: {
  288. "content-type": "application/json",
  289. sign: getApp().globalData.headerSign,
  290. },
  291. success: (res) => {
  292. console.log("列表数据:", JSON.parse(JSON.stringify(res.data)));
  293. if (res.data.success == "yes" && res.data.list) {
  294. if (res.data.list.length > 0) {
  295. this.worksList = [...this.worksList, ...res.data.list];
  296. this.offset += res.data.list.length;
  297. }
  298. if (res.data.list.length < 20) {
  299. this.hasMore = false;
  300. }
  301. } else {
  302. this.hasMore = false;
  303. this.worksList = [];
  304. }
  305. },
  306. complete: () => {
  307. this.isLoading = false;
  308. this.isDataLoaded = true;
  309. },
  310. fail: (e) => {
  311. console.log("请求列表失败:", e);
  312. this.isLoading = false;
  313. this.isDataLoaded = true;
  314. this.worksList = [];
  315. },
  316. });
  317. },
  318. firstLevelNavActiveSwitch(n) {
  319. this.firstLevelNavActive = n;
  320. this.offset = 0;
  321. this.hasMore = true;
  322. this.worksList = [];
  323. if (this.firstLevelNavActive == 0) {
  324. this.activeTab = 0;
  325. }
  326. this.loadWorksList();
  327. },
  328. loadMoreWorks() {
  329. if (this.hasMore && !this.isLoading) {
  330. this.loadWorksList();
  331. }
  332. },
  333. updateDataList() {
  334. this.data_list = this.worksList.map((item) => {
  335. return {
  336. url:
  337. item.images || item.img_url || item.url || "../../static/logo.png",
  338. title: item.title || item.description || "作品",
  339. id: item.id,
  340. };
  341. });
  342. },
  343. goWork(item) {
  344. uni.$emit("check_login", () => { });
  345. uni.navigateTo({
  346. url: "/pages/index/workDetail?id=" + item.id,
  347. });
  348. },
  349. navigateToFollow() {
  350. uni.navigateTo({
  351. url: "/pages/my/follow",
  352. });
  353. },
  354. },
  355. };
  356. </script>
  357. <style scoped lang="scss">
  358. page {
  359. background-color: #fff;
  360. }
  361. .page {
  362. background-color: #fff;
  363. width: 100%;
  364. min-height: 100vh;
  365. }
  366. .reserveASeat {
  367. width: 100%;
  368. height: calc(var(--status-bar-height));
  369. }
  370. .topBody {
  371. width: 750rpx;
  372. background: transparent;
  373. }
  374. .header {
  375. padding: 20rpx;
  376. padding-top: 48rpx;
  377. background: linear-gradient(225deg, #cdff9f 0%, #acff5f 30%, #d0ffa5 100%);
  378. min-height: calc(520rpx + var(--status-bar-height));
  379. margin-bottom: calc(-40rpx );
  380. .card-box {
  381. width: 100%;
  382. min-height: 410rpx;
  383. position: relative;
  384. left: 0;
  385. top: 0%;
  386. overflow: hidden;
  387. .card-top {
  388. height: 410rpx;
  389. width: 100%;
  390. background: url("../../static/me/my-card-bg.png") top center / 100% auto,
  391. #fff;
  392. position: absolute;
  393. top: 0%;
  394. left: 0;
  395. z-index: 5;
  396. padding: 24rpx 0;
  397. padding-top: 16rpx;
  398. box-sizing: border-box;
  399. border-radius: 25rpx;
  400. .top-box {
  401. display: flex;
  402. justify-content: space-between;
  403. align-items: center;
  404. // padding-top: 8rpx;
  405. background: url("../../static/me/car-top-bg-center.png") top center/
  406. 146rpx 50rpx no-repeat;
  407. padding-right: 24rpx;
  408. padding-left: 24rpx;
  409. .hello-box {
  410. font-family: "CustomFont" !important;
  411. font-size: 36rpx;
  412. font-weight: 700;
  413. }
  414. .settingBtn-box {
  415. width: 148rpx;
  416. display: flex;
  417. align-items: center;
  418. justify-content: flex-end;
  419. image {
  420. width: 64rpx;
  421. height: 64rpx;
  422. }
  423. }
  424. }
  425. .userinfo-box {
  426. min-height: 120rpx;
  427. width: 100%;
  428. display: flex;
  429. padding-right: 24rpx;
  430. padding-left: 24rpx;
  431. padding-top: 18rpx;
  432. .avator {
  433. width: 120rpx;
  434. height: 120rpx;
  435. margin-right: 16rpx;
  436. }
  437. .userinfo-right {
  438. .nickname {
  439. font-weight: bold;
  440. margin-bottom: 0rpx;
  441. display: flex;
  442. flex-direction: row;
  443. justify-content: flex-start;
  444. align-items: center;
  445. display: flex;
  446. padding-bottom: 12rpx;
  447. > text {
  448. max-width: 380rpx;
  449. font-family: "PingFang SC-Bold";
  450. font-weight: 400;
  451. font-size: 36rpx;
  452. }
  453. image {
  454. width: 36rpx;
  455. margin-left: 8rpx;
  456. margin-right: 10rpx;
  457. }
  458. .level {
  459. font-weight: 400;
  460. font-size: 22rpx;
  461. font-family: "PingFang SC-Bold";
  462. background: linear-gradient(360deg, #acf934 0%, #ffe439 100%);
  463. border-radius: 8rpx;
  464. padding: 2rpx 8rpx;
  465. }
  466. }
  467. .label {
  468. height: 40rpx;
  469. // height: 110rpx;
  470. overflow: hidden;
  471. > view {
  472. color: #acf934;
  473. font-family: "PingFang SC-Medium";
  474. font-weight: 400;
  475. font-size: 24rpx;
  476. background: #1f1f1f;
  477. border-radius: 6px 6px 6px 6px;
  478. display: inline-block;
  479. margin-right: 10rpx;
  480. margin-bottom: 10rpx;
  481. padding: 6rpx 16rpx;
  482. }
  483. }
  484. }
  485. }
  486. .intro_row {
  487. width: 100%;
  488. display: flex;
  489. align-items: center;
  490. padding-right: 24rpx;
  491. padding-left: 24rpx;
  492. padding-top: 12rpx;
  493. padding-bottom: 12rpx;
  494. .intro_text {
  495. color: #1f1f1f;
  496. font-size: 24rpx;
  497. font-family: "PingFang SC-Bold";
  498. font-weight: 400;
  499. padding-right: 0rpx;
  500. ::v-deep.uv-text__value{
  501. font-size: 26rpx !important;
  502. }
  503. }
  504. .add_icon {
  505. width: 28rpx;
  506. margin-left: 10rpx;
  507. }
  508. }
  509. .line{
  510. width: 100%;
  511. height: 2rpx;
  512. background-color: #F2F6F2;
  513. margin:10rpx 0;
  514. margin-bottom: 20rpx;
  515. }
  516. .bom {
  517. display: flex;
  518. align-items: center;
  519. justify-content: space-between;
  520. padding-right: 24rpx;
  521. padding-left: 24rpx;
  522. .follow_info {
  523. display: flex;
  524. align-items: center;
  525. justify-content: space-between;
  526. max-width: 300rpx;
  527. .follow-box {
  528. display: flex;
  529. flex-direction: column;
  530. align-items: center;
  531. justify-content: center;
  532. text-align: center;
  533. }
  534. .num {
  535. width: 100%;
  536. font-size: 36rpx;
  537. font-weight: bold;
  538. color: #333;
  539. }
  540. .label {
  541. width: 100%;
  542. font-size: 24rpx;
  543. color: #999;
  544. }
  545. .separator {
  546. width: 2rpx;
  547. height: 24rpx;
  548. background-color: #e5e5e5;
  549. margin: 0 30rpx;
  550. }
  551. }
  552. .points-box {
  553. display: flex;
  554. justify-content: space-between;
  555. .followTheAuthor {
  556. padding: 6rpx 40rpx 8rpx 35rpx;
  557. border-radius: 26rpx;
  558. margin-right: 16rpx;
  559. transition: all 0.6s;
  560. border: 2rpx solid transparent;
  561. &.followTheAuthor1 {
  562. color: #acf934;
  563. background: #1f1f1f;
  564. }
  565. &.followTheAuthor0 {
  566. border: 2rpx solid #1f1f1f;
  567. background: #fff;
  568. }
  569. }
  570. }
  571. }
  572. .follow_info {
  573. // display: none;
  574. }
  575. }
  576. }
  577. }
  578. .thread {
  579. height: 210rpx;
  580. padding: 50rpx;
  581. font-size: 52rpx;
  582. color: #6e6a6a;
  583. padding-top: 80rpx;
  584. }
  585. .myinfo {
  586. width: 100%;
  587. display: flex;
  588. flex-direction: column;
  589. border-radius: 28rpx 28rpx 0 0;
  590. padding: 24rpx 20rpx;
  591. padding-top: 14rpx;
  592. justify-content: flex-start;
  593. box-sizing: border-box;
  594. background: #fff;
  595. overflow: hidden;
  596. .line {
  597. width: 100%;
  598. height: 2rpx;
  599. background: #f2f6f2;
  600. margin-bottom: 8rpx;
  601. margin-top: 32rpx;
  602. }
  603. .subtitle {
  604. display: flex;
  605. .item {
  606. padding: 0 43rpx;
  607. font-weight: 400;
  608. font-size: 28rpx;
  609. color: #999999;
  610. font-family: "PingFang SC-Medium";
  611. &.active {
  612. font-family: "PingFang SC-Bold";
  613. font-weight: 400;
  614. font-size: 28rpx;
  615. color: #1f1f1f;
  616. }
  617. }
  618. }
  619. .tablist {
  620. display: flex;
  621. justify-content: flex-start;
  622. box-sizing: border-box;
  623. background: #ffffff;
  624. .item {
  625. padding: 15rpx 38rpx;
  626. color: #1f1f1f;
  627. font-size: 28rpx;
  628. background: #f2f6f2;
  629. margin-right: 20rpx;
  630. border-radius: 30rpx;
  631. position: relative;
  632. left: 0;
  633. top: 0;
  634. line-height: 1;
  635. transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  636. // box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
  637. &:active {
  638. transform: scale(0.95);
  639. // box-shadow: 0 1rpx 4rpx rgba(0, 0, 0, 0.05);
  640. }
  641. .indicator-triangle {
  642. position: absolute;
  643. bottom: -10rpx;
  644. left: 50%;
  645. transform: translateX(-50%);
  646. width: 0;
  647. height: 0;
  648. border-left: 10rpx solid transparent;
  649. border-right: 10rpx solid transparent;
  650. border-top: 10rpx solid #acf934;
  651. display: none;
  652. transition: all 0.3s ease;
  653. }
  654. &.active {
  655. background: #acf934;
  656. font-family: "CustomFont" !important;
  657. box-shadow: 0 4rpx 12rpx rgba(172, 249, 52, 0.3);
  658. .indicator-triangle {
  659. display: block;
  660. transform: translateX(-50%) scale(1.2);
  661. }
  662. }
  663. }
  664. }
  665. .numlist {
  666. display: grid;
  667. grid-template-columns: repeat(2, 1fr);
  668. margin-top: 30rpx
  669. }
  670. }
  671. .empty-state {
  672. display: flex;
  673. flex-direction: column;
  674. align-items: center;
  675. justify-content: center;
  676. padding: 60rpx 0;
  677. margin-top: 40rpx;
  678. background: #FFFFFF;
  679. border-radius: 20rpx;
  680. width: 710rpx;
  681. .empty-image {
  682. width: 240rpx;
  683. height: 240rpx;
  684. margin-bottom: 30rpx;
  685. }
  686. .empty-text {
  687. font-size: 32rpx;
  688. color: #333333;
  689. margin-bottom: 16rpx;
  690. font-weight: 500;
  691. }
  692. .empty-subtext {
  693. font-size: 28rpx;
  694. color: #999999;
  695. }
  696. }
  697. </style>