userHomepage.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  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. @import url("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css");
  359. page {
  360. background-color: #fff;
  361. }
  362. .page {
  363. background-color: #fff;
  364. width: 100%;
  365. min-height: 100vh;
  366. }
  367. .reserveASeat {
  368. width: 100%;
  369. height: calc(var(--status-bar-height));
  370. }
  371. .topBody {
  372. width: 750rpx;
  373. background: transparent;
  374. }
  375. .header {
  376. padding: 20rpx;
  377. padding-top: 48rpx;
  378. background: linear-gradient(225deg, #cdff9f 0%, #acff5f 30%, #d0ffa5 100%);
  379. min-height: calc(520rpx + var(--status-bar-height));
  380. margin-bottom: calc(-40rpx );
  381. .card-box {
  382. width: 100%;
  383. min-height: 410rpx;
  384. position: relative;
  385. left: 0;
  386. top: 0%;
  387. overflow: hidden;
  388. .card-top {
  389. height: 410rpx;
  390. width: 100%;
  391. background: url("../../static/me/my-card-bg.png") top center / 100% auto,
  392. #fff;
  393. position: absolute;
  394. top: 0%;
  395. left: 0;
  396. z-index: 5;
  397. padding: 24rpx 0;
  398. padding-top: 16rpx;
  399. box-sizing: border-box;
  400. border-radius: 25rpx;
  401. .top-box {
  402. display: flex;
  403. justify-content: space-between;
  404. align-items: center;
  405. // padding-top: 8rpx;
  406. background: url("../../static/me/car-top-bg-center.png") top center/
  407. 146rpx 50rpx no-repeat;
  408. padding-right: 24rpx;
  409. padding-left: 24rpx;
  410. .hello-box {
  411. font-family: "CustomFont" !important;
  412. font-size: 36rpx;
  413. font-weight: 700;
  414. }
  415. .settingBtn-box {
  416. width: 148rpx;
  417. display: flex;
  418. align-items: center;
  419. justify-content: flex-end;
  420. image {
  421. width: 64rpx;
  422. height: 64rpx;
  423. }
  424. }
  425. }
  426. .userinfo-box {
  427. min-height: 120rpx;
  428. width: 100%;
  429. display: flex;
  430. padding-right: 24rpx;
  431. padding-left: 24rpx;
  432. padding-top: 18rpx;
  433. .avator {
  434. width: 120rpx;
  435. height: 120rpx;
  436. margin-right: 16rpx;
  437. }
  438. .userinfo-right {
  439. .nickname {
  440. font-weight: bold;
  441. margin-bottom: 0rpx;
  442. display: flex;
  443. flex-direction: row;
  444. justify-content: flex-start;
  445. align-items: center;
  446. display: flex;
  447. padding-bottom: 12rpx;
  448. > text {
  449. max-width: 380rpx;
  450. font-family: "PingFang SC-Bold";
  451. font-weight: 400;
  452. font-size: 36rpx;
  453. }
  454. image {
  455. width: 36rpx;
  456. margin-left: 8rpx;
  457. margin-right: 10rpx;
  458. }
  459. .level {
  460. font-weight: 400;
  461. font-size: 22rpx;
  462. font-family: "PingFang SC-Bold";
  463. background: linear-gradient(360deg, #acf934 0%, #ffe439 100%);
  464. border-radius: 8rpx;
  465. padding: 2rpx 8rpx;
  466. }
  467. }
  468. .label {
  469. height: 40rpx;
  470. // height: 110rpx;
  471. overflow: hidden;
  472. > view {
  473. color: #acf934;
  474. font-family: "PingFang SC-Medium";
  475. font-weight: 400;
  476. font-size: 24rpx;
  477. background: #1f1f1f;
  478. border-radius: 6px 6px 6px 6px;
  479. display: inline-block;
  480. margin-right: 10rpx;
  481. margin-bottom: 10rpx;
  482. padding: 6rpx 16rpx;
  483. }
  484. }
  485. }
  486. }
  487. .intro_row {
  488. width: 100%;
  489. display: flex;
  490. align-items: center;
  491. padding-right: 24rpx;
  492. padding-left: 24rpx;
  493. padding-top: 12rpx;
  494. padding-bottom: 12rpx;
  495. .intro_text {
  496. color: #1f1f1f;
  497. font-size: 24rpx;
  498. font-family: "PingFang SC-Bold";
  499. font-weight: 400;
  500. padding-right: 0rpx;
  501. ::v-deep.uv-text__value{
  502. font-size: 26rpx !important;
  503. }
  504. }
  505. .add_icon {
  506. width: 28rpx;
  507. margin-left: 10rpx;
  508. }
  509. }
  510. .line{
  511. width: 100%;
  512. height: 2rpx;
  513. background-color: #F2F6F2;
  514. margin:10rpx 0;
  515. margin-bottom: 20rpx;
  516. }
  517. .bom {
  518. display: flex;
  519. align-items: center;
  520. justify-content: space-between;
  521. padding-right: 24rpx;
  522. padding-left: 24rpx;
  523. .follow_info {
  524. display: flex;
  525. align-items: center;
  526. justify-content: space-between;
  527. max-width: 300rpx;
  528. .follow-box {
  529. display: flex;
  530. flex-direction: column;
  531. align-items: center;
  532. justify-content: center;
  533. text-align: center;
  534. }
  535. .num {
  536. width: 100%;
  537. font-size: 36rpx;
  538. font-weight: bold;
  539. color: #333;
  540. }
  541. .label {
  542. width: 100%;
  543. font-size: 24rpx;
  544. color: #999;
  545. }
  546. .separator {
  547. width: 2rpx;
  548. height: 24rpx;
  549. background-color: #e5e5e5;
  550. margin: 0 30rpx;
  551. }
  552. }
  553. .points-box {
  554. display: flex;
  555. justify-content: space-between;
  556. .followTheAuthor {
  557. padding: 6rpx 40rpx 8rpx 35rpx;
  558. border-radius: 26rpx;
  559. margin-right: 16rpx;
  560. transition: all 0.6s;
  561. border: 2rpx solid transparent;
  562. &.followTheAuthor1 {
  563. color: #acf934;
  564. background: #1f1f1f;
  565. }
  566. &.followTheAuthor0 {
  567. border: 2rpx solid #1f1f1f;
  568. background: #fff;
  569. }
  570. }
  571. }
  572. }
  573. .follow_info {
  574. // display: none;
  575. }
  576. }
  577. }
  578. }
  579. .thread {
  580. height: 210rpx;
  581. padding: 50rpx;
  582. font-size: 52rpx;
  583. color: #6e6a6a;
  584. padding-top: 80rpx;
  585. }
  586. .myinfo {
  587. width: 100%;
  588. display: flex;
  589. flex-direction: column;
  590. border-radius: 28rpx 28rpx 0 0;
  591. padding: 24rpx 20rpx;
  592. padding-top: 14rpx;
  593. justify-content: flex-start;
  594. box-sizing: border-box;
  595. background: #fff;
  596. overflow: hidden;
  597. .line {
  598. width: 100%;
  599. height: 2rpx;
  600. background: #f2f6f2;
  601. margin-bottom: 8rpx;
  602. margin-top: 32rpx;
  603. }
  604. .subtitle {
  605. display: flex;
  606. .item {
  607. padding: 0 43rpx;
  608. font-weight: 400;
  609. font-size: 28rpx;
  610. color: #999999;
  611. font-family: "PingFang SC-Medium";
  612. &.active {
  613. font-family: "PingFang SC-Bold";
  614. font-weight: 400;
  615. font-size: 28rpx;
  616. color: #1f1f1f;
  617. }
  618. }
  619. }
  620. .tablist {
  621. display: flex;
  622. justify-content: flex-start;
  623. box-sizing: border-box;
  624. background: #ffffff;
  625. .item {
  626. padding: 15rpx 38rpx;
  627. color: #1f1f1f;
  628. font-size: 28rpx;
  629. background: #f2f6f2;
  630. margin-right: 20rpx;
  631. border-radius: 30rpx;
  632. position: relative;
  633. left: 0;
  634. top: 0;
  635. line-height: 1;
  636. transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  637. // box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
  638. &:active {
  639. transform: scale(0.95);
  640. // box-shadow: 0 1rpx 4rpx rgba(0, 0, 0, 0.05);
  641. }
  642. .indicator-triangle {
  643. position: absolute;
  644. bottom: -10rpx;
  645. left: 50%;
  646. transform: translateX(-50%);
  647. width: 0;
  648. height: 0;
  649. border-left: 10rpx solid transparent;
  650. border-right: 10rpx solid transparent;
  651. border-top: 10rpx solid #acf934;
  652. display: none;
  653. transition: all 0.3s ease;
  654. }
  655. &.active {
  656. background: #acf934;
  657. font-family: "CustomFont" !important;
  658. box-shadow: 0 4rpx 12rpx rgba(172, 249, 52, 0.3);
  659. .indicator-triangle {
  660. display: block;
  661. transform: translateX(-50%) scale(1.2);
  662. }
  663. }
  664. }
  665. }
  666. .numlist {
  667. display: grid;
  668. grid-template-columns: repeat(2, 1fr);
  669. margin-top: 30rpx
  670. }
  671. }
  672. .empty-state {
  673. display: flex;
  674. flex-direction: column;
  675. align-items: center;
  676. justify-content: center;
  677. padding: 60rpx 0;
  678. margin-top: 40rpx;
  679. background: #FFFFFF;
  680. border-radius: 20rpx;
  681. width: 710rpx;
  682. .empty-image {
  683. width: 240rpx;
  684. height: 240rpx;
  685. margin-bottom: 30rpx;
  686. }
  687. .empty-text {
  688. font-size: 32rpx;
  689. color: #333333;
  690. margin-bottom: 16rpx;
  691. font-weight: 500;
  692. }
  693. .empty-subtext {
  694. font-size: 28rpx;
  695. color: #999999;
  696. }
  697. }
  698. </style>