userHomepage.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  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 class="intro_text two-omit">
  38. {{ myinfo.content }}
  39. </uv-text>
  40. </view>
  41. <view class="bom">
  42. <view class="follow_info">
  43. <view class="follow-box">
  44. <view class="num">{{ myinfo.num_attention }}</view>
  45. <view class="label">关注</view>
  46. </view>
  47. <view class="separator"></view>
  48. <view class="follow-box">
  49. <view class="num">{{ myinfo.num_fans }}</view>
  50. <view class="label">粉丝</view>
  51. </view>
  52. <view class="separator"></view>
  53. <view class="follow-box">
  54. <view class="num">{{ myinfo.num_like }}</view>
  55. <view class="label">获赞</view>
  56. </view>
  57. </view>
  58. <view class="points-box">
  59. <text class="followTheAuthor followTheAuthor1" v-if="!myinfo.is_attention" @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" :share-url="shareUrl" :share-title="shareTitle" :share-desc="shareDesc"
  80. :share-img="shareImg" @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. shareUrl: "https://your-share-url.com",
  121. shareTitle: "分享标题",
  122. shareDesc: "分享描述",
  123. shareImg: "https://your-share-image.com/image.jpg",
  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. if (res.data.need_login == "yes") {
  235. uni.removeStorageSync("wapptoken");
  236. uni.redirectTo({
  237. url: "/pages/login/login",
  238. });
  239. return;
  240. }
  241. if (res.data.aihao) {
  242. this.aihao_tags = res.data.aihao.split(",");
  243. }
  244. this.myinfo = res.data;
  245. },
  246. complete: (com) => {
  247. // uni.hideLoading();
  248. },
  249. fail: (e) => {
  250. console.log("----e:", e);
  251. },
  252. });
  253. },
  254. switchTab(index) {
  255. this.activeTab = index;
  256. this.offset = 0;
  257. this.hasMore = true;
  258. this.worksList = [];
  259. this.loadWorksList();
  260. },
  261. loadWorksList() {
  262. if (this.isLoading) return;
  263. this.isLoading = true;
  264. // 根据activeTab选择不同的API
  265. uni.request({
  266. url: this.$apiHost + '/Work/getlist',
  267. data: {
  268. uuid: getApp().globalData.uuid,
  269. skey: getApp().globalData.skey,
  270. type: "other", // 固定为my,表示获取自己的作品
  271. offset: this.offset,
  272. user_id:this.id
  273. },
  274. header: {
  275. "content-type": "application/json",
  276. sign: getApp().globalData.headerSign,
  277. },
  278. success: (res) => {
  279. console.log("列表数据:", JSON.parse(JSON.stringify(res.data)));
  280. if (res.data.success == "yes" && res.data.list) {
  281. if (res.data.list.length > 0) {
  282. this.worksList = [...this.worksList, ...res.data.list];
  283. this.offset += res.data.list.length;
  284. }
  285. if (res.data.list.length < 20) {
  286. this.hasMore = false;
  287. }
  288. } else {
  289. this.hasMore = false;
  290. }
  291. },
  292. complete: () => {
  293. this.isLoading = false;
  294. },
  295. fail: (e) => {
  296. console.log("请求列表失败:", e);
  297. this.isLoading = false;
  298. },
  299. });
  300. },
  301. firstLevelNavActiveSwitch(n) {
  302. this.firstLevelNavActive = n;
  303. this.offset = 0;
  304. this.hasMore = true;
  305. this.worksList = [];
  306. if (this.firstLevelNavActive == 0) {
  307. this.activeTab = 0;
  308. }
  309. this.loadWorksList();
  310. },
  311. loadMoreWorks() {
  312. if (this.hasMore && !this.isLoading) {
  313. this.loadWorksList();
  314. }
  315. },
  316. updateDataList() {
  317. this.data_list = this.worksList.map((item) => {
  318. return {
  319. url:
  320. item.images || item.img_url || item.url || "../../static/logo.png",
  321. title: item.title || item.description || "作品",
  322. id: item.id,
  323. };
  324. });
  325. },
  326. goWork(item) {
  327. uni.$emit("check_login", () => { });
  328. uni.navigateTo({
  329. url: "/pages/index/workDetail?id=" + item.id,
  330. });
  331. },
  332. navigateToFollow() {
  333. uni.navigateTo({
  334. url: "/pages/my/follow",
  335. });
  336. },
  337. },
  338. };
  339. </script>
  340. <style scoped lang="scss">
  341. // 导入FontAwesome
  342. @import url("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css");
  343. page {
  344. background-color: #fff;
  345. padding-top: var(--status-bar-height);
  346. padding-bottom: 144rpx;
  347. }
  348. .page {
  349. background-color: #fff;
  350. width: 100%;
  351. min-height: 100vh;
  352. }
  353. .topBody {
  354. width: 750rpx;
  355. }
  356. .header {
  357. padding: 20rpx;
  358. padding-top: 48rpx;
  359. background: linear-gradient(225deg, #cdff9f 0%, #acff5f 30%, #d0ffa5 100%);
  360. min-height: 720rpx;
  361. margin-bottom: -210rpx;
  362. .card-box {
  363. width: 100%;
  364. min-height: 440rpx;
  365. position: relative;
  366. left: 0;
  367. top: 0%;
  368. overflow: hidden;
  369. .card-top {
  370. height: 435rpx;
  371. width: 100%;
  372. background: url("../../static/me/my-card-bg.png") top center / 100% auto,
  373. #fff;
  374. position: absolute;
  375. top: 0%;
  376. left: 0;
  377. z-index: 5;
  378. padding: 24rpx;
  379. padding-top: 16rpx;
  380. box-sizing: border-box;
  381. border-radius: 25rpx;
  382. .top-box {
  383. display: flex;
  384. justify-content: space-between;
  385. padding-top: 8rpx;
  386. background: url("../../static/me/car-top-bg-center.png") top center/ 146rpx 50rpx no-repeat;
  387. .hello-box {
  388. font-family: "CustomFont" !important;
  389. font-size: 36rpx;
  390. font-weight: 700;
  391. }
  392. .settingBtn-box {
  393. width: 74rpx;
  394. display: flex;
  395. align-items: center;
  396. justify-content: space-between;
  397. image {
  398. width: 64rpx;
  399. height: 64rpx;
  400. }
  401. }
  402. }
  403. .userinfo-box {
  404. min-height: 120rpx;
  405. width: 100%;
  406. display: flex;
  407. .avator {
  408. width: 120rpx;
  409. height: 120rpx;
  410. margin-right: 16rpx;
  411. }
  412. .userinfo-right {
  413. .nickname {
  414. font-weight: bold;
  415. margin-bottom: 0rpx;
  416. display: flex;
  417. flex-direction: row;
  418. justify-content: flex-start;
  419. align-items: center;
  420. display: flex;
  421. >text {
  422. max-width: 380rpx;
  423. font-family: "PingFang SC-Bold";
  424. font-weight: 400;
  425. font-size: 36rpx;
  426. }
  427. image {
  428. width: 36rpx;
  429. margin-left: 8rpx;
  430. margin-right: 10rpx;
  431. }
  432. .level {
  433. font-weight: 400;
  434. font-size: 20rpx;
  435. font-family: "PingFang SC-Bold";
  436. background: linear-gradient(360deg, #acf934 0%, #ffe439 100%);
  437. border-radius: 8rpx;
  438. padding: 2rpx 8rpx;
  439. }
  440. }
  441. .label {
  442. height: 55rpx;
  443. height: 110rpx;
  444. overflow: hidden;
  445. >view {
  446. color: #acf934;
  447. font-family: "PingFang SC-Medium";
  448. font-weight: 400;
  449. font-size: 20rpx;
  450. background: #1f1f1f;
  451. border-radius: 6px 6px 6px 6px;
  452. display: inline-block;
  453. margin-left: 10rpx;
  454. margin-bottom: 10rpx;
  455. padding: 6rpx 16rpx;
  456. }
  457. }
  458. }
  459. }
  460. .intro_row {
  461. width: 100%;
  462. margin-bottom: 20rpx;
  463. display: flex;
  464. align-items: center;
  465. .intro_text {
  466. color: #1f1f1f;
  467. font-size: 28rpx;
  468. font-family: "PingFang SC-Bold";
  469. font-weight: 400;
  470. padding-right: 0rpx;
  471. }
  472. .add_icon {
  473. width: 28rpx;
  474. margin-left: 10rpx;
  475. }
  476. }
  477. .bom {
  478. display: flex;
  479. align-items: center;
  480. justify-content: space-between;
  481. .follow_info {
  482. display: flex;
  483. align-items: center;
  484. justify-content: space-between;
  485. width: 340rpx;
  486. .follow-box {
  487. display: flex;
  488. flex-direction: column;
  489. align-items: center;
  490. justify-content: center;
  491. text-align: center;
  492. }
  493. .num {
  494. width: 100%;
  495. font-size: 36rpx;
  496. font-weight: bold;
  497. color: #333;
  498. }
  499. .label {
  500. width: 100%;
  501. font-size: 28rpx;
  502. color: #999;
  503. }
  504. .separator {
  505. width: 2rpx;
  506. height: 24rpx;
  507. background-color: #e5e5e5;
  508. margin: 0 30rpx;
  509. }
  510. }
  511. .points-box {
  512. display: flex;
  513. justify-content: space-between;
  514. .followTheAuthor {
  515. padding: 6rpx 40rpx 8rpx 35rpx;
  516. border-radius: 26rpx;
  517. margin-right: 16rpx;
  518. transition: all 0.6s;
  519. border: 2rpx solid transparent;
  520. &.followTheAuthor1 {
  521. color: #acf934;
  522. background: #1f1f1f;
  523. }
  524. &.followTheAuthor0 {
  525. border: 2rpx solid #1f1f1f;
  526. background: #fff;
  527. }
  528. }
  529. }
  530. }
  531. }
  532. }
  533. }
  534. .myinfo {
  535. width: 100%;
  536. display: flex;
  537. flex-direction: column;
  538. border-radius: 28rpx 28rpx 0 0;
  539. padding: 24rpx 20rpx;
  540. justify-content: flex-start;
  541. box-sizing: border-box;
  542. background: #fff;
  543. .numlist1 {
  544. display: grid;
  545. grid-template-columns: repeat(2, 1fr);
  546. }
  547. }
  548. </style>