userHomepage.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  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="1" @click="followTheAuthor(1)">+关注</text>
  60. <text class="followTheAuthor followTheAuthor0" v-if="0" @click="followTheAuthor(0)">已关注</text>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. <view class="myinfo">
  67. <!-- 作品列表 -->
  68. <view class="numlist1" v-if="activeTab === 0" style="margin-top: 30rpx">
  69. <WorkItem v-for="(item, index) in worksList" :secrecy="true" :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. };
  125. },
  126. onShow() {
  127. uni.$emit("check_login", () => { });
  128. this.offset = 0;
  129. this.hasMore = true;
  130. this.worksList = [];
  131. this.loadInfo();
  132. this.loadWorksList();
  133. },
  134. onReachBottom() {
  135. if (this.hasMore && !this.isLoading) {
  136. this.loadMoreWorks();
  137. }
  138. },
  139. methods: {
  140. // 关注作者
  141. followTheAuthor(n) {
  142. return
  143. uni.request({
  144. url: this.$apiHost + "/Member/attention",
  145. data: {
  146. uuid: getApp().globalData.uuid,
  147. id: this.author.id,
  148. },
  149. header: {
  150. "content-type": "application/json",
  151. sign: getApp().globalData.headerSign,
  152. },
  153. success: (res) => {
  154. console.log("点赞结果:", res.data);
  155. uni.showToast({
  156. title: res.data.str,
  157. icon: "none",
  158. });
  159. if (res.data.success === "yes") {
  160. console.log("关注结果:", res.data, n);
  161. this.author.is_attention = n;
  162. }
  163. },
  164. fail: (e) => {
  165. console.log("关注失败:", e);
  166. uni.showToast({
  167. title: "网络请求失败",
  168. icon: "none",
  169. });
  170. },
  171. });
  172. },
  173. goBack() {
  174. uni.navigateBack({
  175. delta: 1,
  176. });
  177. },
  178. clickShare(item) {
  179. this.showShare = true;
  180. },
  181. goPage(page) {
  182. if (page == "kefu") {
  183. let that = this;
  184. // #ifdef APP-PLUS
  185. plus.share.getServices((res) => {
  186. const wechat = res.find((i) => i.id === "weixin");
  187. if (wechat) {
  188. wechat.openCustomerServiceChat(
  189. {
  190. corpid: "wwbc06aa8311b6ac08",
  191. url: that.myinfo.wxkf,
  192. },
  193. (src) => {
  194. console.log("success:");
  195. },
  196. (err) => {
  197. console.log("error:");
  198. }
  199. );
  200. } else {
  201. uni.showToast({
  202. title: "没有检测到微信,请先安装",
  203. icon: "error",
  204. });
  205. }
  206. });
  207. // #endif
  208. } else if (page != "") {
  209. uni.navigateTo({
  210. url: page,
  211. });
  212. }
  213. },
  214. loadInfo() {
  215. console.log({
  216. uuid: getApp().globalData.uuid,
  217. skey: getApp().globalData.skey,
  218. });
  219. uni.request({
  220. url: this.$apiHost + "/User/getinfo",
  221. data: {
  222. uuid: getApp().globalData.uuid,
  223. skey: getApp().globalData.skey,
  224. },
  225. header: {
  226. "content-type": "application/json",
  227. sign: getApp().globalData.headerSign,
  228. },
  229. success: (res) => {
  230. console.log("----:", JSON.parse(JSON.stringify(res.data)));
  231. if (res.data.need_login == "yes") {
  232. uni.removeStorageSync("wapptoken");
  233. uni.redirectTo({
  234. url: "/pages/login/login",
  235. });
  236. return;
  237. }
  238. if (res.data.aihao) {
  239. this.aihao_tags = res.data.aihao.split(",");
  240. }
  241. this.myinfo = res.data;
  242. },
  243. complete: (com) => {
  244. // uni.hideLoading();
  245. },
  246. fail: (e) => {
  247. console.log("----e:", e);
  248. },
  249. });
  250. },
  251. switchTab(index) {
  252. this.activeTab = index;
  253. this.offset = 0;
  254. this.hasMore = true;
  255. this.worksList = [];
  256. this.loadWorksList();
  257. },
  258. loadWorksList() {
  259. if (this.isLoading) return;
  260. this.isLoading = true;
  261. // 根据activeTab选择不同的API
  262. let apiUrl = "";
  263. if (this.firstLevelNavActive == 0) {
  264. if (this.activeTab === 0) {
  265. apiUrl = "/Work/getlist";
  266. } else {
  267. apiUrl = "/WorkAI/getMyQueueList";
  268. }
  269. } else if (this.firstLevelNavActive == 1) {
  270. apiUrl = "/Article/getlist";
  271. }
  272. uni.request({
  273. url: this.$apiHost + apiUrl,
  274. data: {
  275. uuid: getApp().globalData.uuid,
  276. skey: getApp().globalData.skey,
  277. type: "my", // 固定为my,表示获取自己的作品
  278. offset: this.offset,
  279. status: this.activeTab === 0 ? 1 : undefined, // 只有我的作品需要status参数
  280. },
  281. header: {
  282. "content-type": "application/json",
  283. sign: getApp().globalData.headerSign,
  284. },
  285. success: (res) => {
  286. console.log("列表数据:", JSON.parse(JSON.stringify(res.data)));
  287. if (res.data.success == "yes" && res.data.list) {
  288. if (res.data.list.length > 0) {
  289. this.worksList = [...this.worksList, ...res.data.list];
  290. this.offset += res.data.list.length;
  291. }
  292. if (res.data.list.length < 20) {
  293. this.hasMore = false;
  294. }
  295. } else {
  296. this.hasMore = false;
  297. }
  298. // 只有在"我的作品"标签下才更新data_list
  299. if (this.activeTab === 0) {
  300. this.updateDataList();
  301. }
  302. console.log("作品列表数据:", this.worksList);
  303. },
  304. complete: () => {
  305. this.isLoading = false;
  306. },
  307. fail: (e) => {
  308. console.log("请求列表失败:", e);
  309. this.isLoading = false;
  310. },
  311. });
  312. },
  313. firstLevelNavActiveSwitch(n) {
  314. this.firstLevelNavActive = n;
  315. this.offset = 0;
  316. this.hasMore = true;
  317. this.worksList = [];
  318. if (this.firstLevelNavActive == 0) {
  319. this.activeTab = 0;
  320. }
  321. this.loadWorksList();
  322. },
  323. loadMoreWorks() {
  324. if (this.hasMore && !this.isLoading) {
  325. this.loadWorksList();
  326. }
  327. },
  328. updateDataList() {
  329. this.data_list = this.worksList.map((item) => {
  330. return {
  331. url:
  332. item.images || item.img_url || item.url || "../../static/logo.png",
  333. title: item.title || item.description || "作品",
  334. id: item.id,
  335. };
  336. });
  337. },
  338. goWork(item) {
  339. uni.$emit("check_login", () => { });
  340. // , //任务状态(1:排队中,3:生成失败,4:生成失败,9:创作完成)
  341. if (this.activeTab == 0) {
  342. uni.navigateTo({
  343. url:
  344. "/pages/makedetail/makeDetail?id=" +
  345. item.queue_id +
  346. "&queueId=" +
  347. item.id,
  348. });
  349. } else {
  350. if (item.status >= 9) {
  351. uni.navigateTo({
  352. url: "/pages/makedetail/makeDetail?id=" + item.id,
  353. });
  354. }
  355. if (item.status < 9 && item.status != 3 && item.status != 4) {
  356. var url = "";
  357. if (item.task_type === 1) {
  358. url = "/makedetail/makeImgDetail";
  359. }
  360. if (item.task_type === 2) {
  361. url = "/makedetail/makeMusicDetail";
  362. }
  363. if (url) {
  364. uni.navigateTo({
  365. url: "/pages" + url + "?id=" + item.id,
  366. });
  367. }
  368. }
  369. }
  370. },
  371. navigateToFollow() {
  372. uni.navigateTo({
  373. url: "/pages/my/follow",
  374. });
  375. },
  376. },
  377. };
  378. </script>
  379. <style scoped lang="scss">
  380. // 导入FontAwesome
  381. @import url("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css");
  382. page {
  383. background-color: #fff;
  384. padding-top: var(--status-bar-height);
  385. padding-bottom: 144rpx;
  386. }
  387. .page {
  388. background-color: #fff;
  389. width: 100%;
  390. min-height: 100vh;
  391. }
  392. .topBody {
  393. width: 750rpx;
  394. }
  395. .header {
  396. padding: 20rpx;
  397. padding-top: 48rpx;
  398. background: linear-gradient(225deg, #cdff9f 0%, #acff5f 30%, #d0ffa5 100%);
  399. min-height: 720rpx;
  400. margin-bottom: -210rpx;
  401. .card-box {
  402. width: 100%;
  403. min-height: 440rpx;
  404. position: relative;
  405. left: 0;
  406. top: 0%;
  407. overflow: hidden;
  408. .card-top {
  409. height: 435rpx;
  410. width: 100%;
  411. background: url("../../static/me/my-card-bg.png") top center / 100% auto,
  412. #fff;
  413. position: absolute;
  414. top: 0%;
  415. left: 0;
  416. z-index: 5;
  417. padding: 24rpx;
  418. padding-top: 16rpx;
  419. box-sizing: border-box;
  420. border-radius: 25rpx;
  421. .top-box {
  422. display: flex;
  423. justify-content: space-between;
  424. padding-top: 8rpx;
  425. background: url("../../static/me/car-top-bg-center.png") top center/ 146rpx 50rpx no-repeat;
  426. .hello-box {
  427. font-family: "CustomFont" !important;
  428. font-size: 36rpx;
  429. font-weight: 700;
  430. }
  431. .settingBtn-box {
  432. width: 74rpx;
  433. display: flex;
  434. align-items: center;
  435. justify-content: space-between;
  436. image {
  437. width: 64rpx;
  438. height: 64rpx;
  439. }
  440. }
  441. }
  442. .userinfo-box {
  443. min-height: 120rpx;
  444. width: 100%;
  445. display: flex;
  446. .avator {
  447. width: 120rpx;
  448. height: 120rpx;
  449. margin-right: 16rpx;
  450. }
  451. .userinfo-right {
  452. .nickname {
  453. font-weight: bold;
  454. margin-bottom: 0rpx;
  455. display: flex;
  456. flex-direction: row;
  457. justify-content: flex-start;
  458. align-items: center;
  459. display: flex;
  460. >text {
  461. max-width: 380rpx;
  462. font-family: "PingFang SC-Bold";
  463. font-weight: 400;
  464. font-size: 36rpx;
  465. }
  466. image {
  467. width: 36rpx;
  468. margin-left: 8rpx;
  469. margin-right: 10rpx;
  470. }
  471. .level {
  472. font-weight: 400;
  473. font-size: 20rpx;
  474. font-family: "PingFang SC-Bold";
  475. background: linear-gradient(360deg, #acf934 0%, #ffe439 100%);
  476. border-radius: 8rpx;
  477. padding: 2rpx 8rpx;
  478. }
  479. }
  480. .label {
  481. height: 55rpx;
  482. height: 110rpx;
  483. overflow: hidden;
  484. >view {
  485. color: #acf934;
  486. font-family: "PingFang SC-Medium";
  487. font-weight: 400;
  488. font-size: 20rpx;
  489. background: #1f1f1f;
  490. border-radius: 6px 6px 6px 6px;
  491. display: inline-block;
  492. margin-left: 10rpx;
  493. margin-bottom: 10rpx;
  494. padding: 6rpx 16rpx;
  495. }
  496. }
  497. }
  498. }
  499. .intro_row {
  500. width: 100%;
  501. margin-bottom: 20rpx;
  502. display: flex;
  503. align-items: center;
  504. .intro_text {
  505. color: #1f1f1f;
  506. font-size: 28rpx;
  507. font-family: "PingFang SC-Bold";
  508. font-weight: 400;
  509. padding-right: 0rpx;
  510. }
  511. .add_icon {
  512. width: 28rpx;
  513. margin-left: 10rpx;
  514. }
  515. }
  516. .bom {
  517. display: flex;
  518. align-items: center;
  519. justify-content: space-between;
  520. .follow_info {
  521. display: flex;
  522. align-items: center;
  523. justify-content: space-between;
  524. width: 340rpx;
  525. .follow-box {
  526. display: flex;
  527. flex-direction: column;
  528. align-items: center;
  529. justify-content: center;
  530. text-align: center;
  531. }
  532. .num {
  533. width: 100%;
  534. font-size: 36rpx;
  535. font-weight: bold;
  536. color: #333;
  537. }
  538. .label {
  539. width: 100%;
  540. font-size: 28rpx;
  541. color: #999;
  542. }
  543. .separator {
  544. width: 2rpx;
  545. height: 24rpx;
  546. background-color: #e5e5e5;
  547. margin: 0 30rpx;
  548. }
  549. }
  550. .points-box {
  551. display: flex;
  552. justify-content: space-between;
  553. .followTheAuthor {
  554. padding: 6rpx 40rpx 8rpx 35rpx;
  555. border-radius: 26rpx;
  556. margin-right: 16rpx;
  557. transition: all 0.6s;
  558. border: 2rpx solid transparent;
  559. &.followTheAuthor1 {
  560. color: #acf934;
  561. background: #1f1f1f;
  562. }
  563. &.followTheAuthor0 {
  564. border: 2rpx solid #1f1f1f;
  565. background: #fff;
  566. }
  567. }
  568. }
  569. }
  570. }
  571. }
  572. }
  573. .myinfo {
  574. width: 100%;
  575. display: flex;
  576. flex-direction: column;
  577. border-radius: 28rpx 28rpx 0 0;
  578. padding: 24rpx 20rpx;
  579. justify-content: flex-start;
  580. box-sizing: border-box;
  581. background: #fff;
  582. .numlist1 {
  583. display: grid;
  584. grid-template-columns: repeat(2, 1fr);
  585. }
  586. }
  587. </style>