userHomepage.vue 15 KB

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