my.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. <template>
  2. <view class="page">
  3. <view class="topBody">
  4. <view class="header">
  5. <view class="topBg"></view>
  6. <view class="settingBtn" @click="navigateToSettings">
  7. <image src="/static/me/setting.png"></image>
  8. </view>
  9. <view class="top_num">
  10. <view class="num_1">
  11. <text>M币</text>
  12. <text>{{myinfo.num_gmd}}</text>
  13. </view>
  14. <view class="num_2">
  15. <text>彩豆</text>
  16. <text>{{myinfo.num_gmd}}</text>
  17. </view>
  18. </view>
  19. <view class="infoBg">
  20. <view class="top_row">
  21. <view class="left" @click="goPage('/pages/my/editInfo')">
  22. <image class="img" mode="aspectFill" :src="myinfo.avator"></image>
  23. </view>
  24. <view class="right" @click="goPage('/pages/my/editInfo')">
  25. <view class="nickname">
  26. <text>{{myinfo.nickname}}</text>
  27. <image src="../../static/icon/man.png" mode="widthFix" v-if="myinfo.sex_id == 1" />
  28. <image src="../../static/icon/man.png" mode="widthFix" v-else-if="myinfo.sex_id == 2" />
  29. <view class="level">Lv{{myinfo.my_level}}</view>
  30. </view>
  31. <view class="tags_list">
  32. <block v-for="(item,index) in aihao_tags">
  33. <uni-tag class="tag" type="primary" :inverted="false" :text="item" size="mini" />
  34. </block>
  35. </view>
  36. </view>
  37. </view>
  38. <view class="bottom_row">
  39. <view class="intro_row">
  40. <block v-if="myinfo.content == ''">
  41. <text class="intro_text">添加简介</text>
  42. <image src="../../static/icon/add.png" mode="widthFix" class="add_icon" />
  43. </block>
  44. <block v-else>
  45. <text class="intro_text">{{myinfo.content}}</text>
  46. </block>
  47. </view>
  48. <view class="follow_info">
  49. <text class="num">{{myinfo.num_attention}}</text>
  50. <text class="label">关注</text>
  51. <text class="separator"></text>
  52. <text class="num">{{myinfo.num_fans}}</text>
  53. <text class="label">粉丝</text>
  54. <text class="separator"></text>
  55. <text class="num">{{myinfo.num_like}}</text>
  56. <text class="label">获赞</text>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. <view class="whiteItem">
  62. <view class="btn">开启专属会员权益</view>
  63. </view>
  64. <view class="myinfo">
  65. <view class="line"></view>
  66. <view class="tablist">
  67. <view class="item" :class="{ active: activeTab === 0 }" @click="switchTab(0)">
  68. <view class="name">我的作品</view>
  69. </view>
  70. <view class="item" :class="{ active: activeTab === 1 }" @click="switchTab(1)">
  71. <view class="name">生成中</view>
  72. </view>
  73. </view>
  74. <view class="numlist2" style="margin-top: 60rpx;">
  75. <view class="item" v-for="(item,index) in worksList" :key="index">
  76. <view class="num" @click="goWork(item)">
  77. <!-- 当activeTab为0时显示图片 -->
  78. <image v-if="activeTab === 0" class="icon"
  79. :src="item.images || item.img_url || item.url || '../../static/logo.png'"
  80. mode="aspectFit" />
  81. <image v-if="activeTab === 1 && item.status == 9" class="icon"
  82. :src="item.result_images || '../../static/logo.png'" mode="aspectFit" />
  83. <!-- 当activeTab为1时显示队列状态 -->
  84. <view v-else class="queue-status">
  85. <!-- 排队中 -->
  86. <view v-if="item.status === 1" class="status-text">
  87. 排队中({{item.queue_position}}/{{item.all_position}})</view>
  88. <!-- 排队中 -->
  89. <view v-if="item.status === 3 || item.status === 4" class="status-text">
  90. 生成失败</view>
  91. <!-- 制作中 -->
  92. <view v-else-if="item.status < 9" class="status-text">制作中</view>
  93. <!-- 创作完成 -->
  94. <view v-else-if="item.status === 9" class="status-text">创作完成</view>
  95. </view>
  96. <view class="name">{{item.title || item.description || '作品'+index}}</view>
  97. <!-- 显示任务类型标签 -->
  98. <view v-if="activeTab === 1" class="task-type-tag">
  99. <text v-if="item.task_type === 1">灵感创作</text>
  100. <text v-else-if="item.task_type === 2">音乐</text>
  101. </view>
  102. </view>
  103. </view>
  104. </view>
  105. <!-- 加载更多提示 -->
  106. <view class="loading-more" v-if="isLoading">加载中...</view>
  107. <view class="no-more" v-if="!hasMore && worksList.length > 0">没有更多作品了</view>
  108. <view class="no-more" v-if="!hasMore && worksList.length === 0">暂无作品</view>
  109. </view>
  110. <view class="blankHeight"></view>
  111. <view class="blankHeight"></view>
  112. </view>
  113. <!-- 提示框 -->
  114. <DialogBox ref="DialogBox"></DialogBox>
  115. <tabbar-view :tabbars="tabbars" :currentIndex="4" ref="tabbar"></tabbar-view>
  116. </view>
  117. </template>
  118. <script>
  119. import tabbarView from "@/components/tabbar/tabbar.vue";
  120. import tabbar from "@/mixins/tabbar";
  121. export default {
  122. components: {
  123. tabbarView,
  124. },
  125. mixins: [tabbar],
  126. data() {
  127. return {
  128. title: '',
  129. sel: 1,
  130. myinfo: {
  131. avator: '../../static/logo.png',
  132. nickname: '王思思',
  133. join_name: '注册日期:2024年5月',
  134. num_1: 0,
  135. num_2: 0,
  136. num_3: 0,
  137. num_4: 0,
  138. is_login: 'no',
  139. num_history: 0,
  140. num_collection: 0,
  141. },
  142. aihao_tags: [],
  143. menu_list: [],
  144. data_list: [{
  145. url: 'https://e.zhichao.art/AI_images/a_1112_10.png',
  146. },
  147. {
  148. url: 'https://e.zhichao.art/AI_images/a_1112_108.png',
  149. },
  150. {
  151. url: 'https://e.zhichao.art/AI_images/a_1112_113.png',
  152. },
  153. {
  154. url: 'https://e.zhichao.art/AI_images/a_1112_13.png',
  155. },
  156. {
  157. url: 'https://e.zhichao.art/AI_images/a_1112_137.png',
  158. },
  159. {
  160. url: 'https://e.zhichao.art/AI_images/a_1112_141.png',
  161. },
  162. {
  163. url: 'https://e.zhichao.art/AI_images/a_1114__562.png',
  164. },
  165. {
  166. url: 'https://e.zhichao.art/AI_images/a_1114__568.png',
  167. },
  168. {
  169. url: 'https://e.zhichao.art/AI_images/a_1114__569.png',
  170. },
  171. {
  172. url: 'https://e.zhichao.art/AI_images/a_1114__570.png',
  173. },
  174. {
  175. url: 'https://e.zhichao.art/AI_images/a_1114__571.png',
  176. },
  177. {
  178. url: 'https://e.zhichao.art/AI_images/a_1114__575.png',
  179. },
  180. ],
  181. activeTab: 0,
  182. offset: 0,
  183. hasMore: true,
  184. isLoading: false,
  185. worksList: []
  186. }
  187. },
  188. onLoad() {
  189. // setTimeout(function() {
  190. // uni.setNavigationBarColor({
  191. // frontColor: '#ffffff',
  192. // backgroundColor: '#00000000',
  193. // animation: {
  194. // duration: 400,
  195. // timingFunc: 'easeIn'
  196. // }
  197. // })
  198. // }, 200);
  199. },
  200. onShow() {
  201. uni.$emit('check_login', () => {})
  202. // this.loadData();
  203. this.offset = 0;
  204. this.hasMore = true;
  205. this.worksList = [];
  206. this.loadInfo();
  207. this.loadWorksList();
  208. },
  209. onReachBottom() {
  210. if (this.hasMore && !this.isLoading) {
  211. this.loadMoreWorks();
  212. }
  213. },
  214. methods: {
  215. onBack() {},
  216. chkSel() {
  217. if (this.sel == 1) {
  218. this.sel = 0;
  219. } else {
  220. this.sel = 1;
  221. }
  222. },
  223. goPage(page) {
  224. if (page == 'kefu') {
  225. let that = this;
  226. // #ifdef APP-PLUS
  227. plus.share.getServices(res => {
  228. const wechat = res.find(i => i.id === 'weixin')
  229. if (wechat) {
  230. wechat.openCustomerServiceChat({
  231. corpid: 'wwbc06aa8311b6ac08',
  232. // url: 'https://work.weixin.qq.com/kfid/kfc4b0bcb4038d00a50'
  233. url: that.myinfo.wxkf
  234. }, src => {
  235. console.log("success:")
  236. }, err => {
  237. console.log("error:")
  238. })
  239. } else {
  240. uni.showToast({
  241. title: '没有检测到微信,请先安装',
  242. icon: "error"
  243. });
  244. }
  245. });
  246. // #endif
  247. } else if (page != '') {
  248. uni.navigateTo({
  249. url: page,
  250. })
  251. }
  252. },
  253. loadInfo() {
  254. console.log({
  255. uuid: getApp().globalData.uuid,
  256. skey: getApp().globalData.skey
  257. });
  258. uni.request({
  259. url: this.$apiHost + '/User/getinfo',
  260. data: {
  261. uuid: getApp().globalData.uuid,
  262. skey: getApp().globalData.skey
  263. },
  264. header: {
  265. "content-type": "application/json",
  266. 'sign': getApp().globalData.headerSign
  267. },
  268. success: (res) => {
  269. console.log("----:", res.data);
  270. if (res.data.need_login == "yes") {
  271. // getApp().globalData.skey = "";
  272. // getApp().globalData.uuid = "";
  273. uni.removeStorageSync("wapptoken");
  274. uni.redirectTo({
  275. url: '/pages/login/login'
  276. });
  277. return;
  278. }
  279. if (res.data.aihao) {
  280. this.aihao_tags = res.data.aihao.split(",");
  281. }
  282. this.myinfo = res.data;
  283. },
  284. complete: (com) => {
  285. // uni.hideLoading();
  286. },
  287. fail: (e) => {
  288. console.log("----e:", e);
  289. }
  290. });
  291. },
  292. onLogout() {
  293. let that = this;
  294. this.$refs['DialogBox'].confirm({
  295. title: '提示',
  296. content: '确定退出吗?',
  297. DialogType: 'inquiry',
  298. btn1: '取消',
  299. btn2: '退出',
  300. animation: 0
  301. }).then((res) => {
  302. uni.request({
  303. url: that.$apiHost + '/My/logout',
  304. data: {
  305. uuid: getApp().globalData.uuid,
  306. skey: getApp().globalData.skey
  307. },
  308. header: {
  309. "content-type": "application/json",
  310. 'sign': getApp().globalData.headerSign
  311. },
  312. success: (res) => {
  313. console.log("----:", res.data);
  314. // getApp().globalData.skey = "";
  315. // getApp().globalData.uuid = "";
  316. uni.removeStorageSync("wapptoken");
  317. uni.redirectTo({
  318. url: '/pages/login/login'
  319. })
  320. },
  321. complete: (com) => {
  322. // uni.hideLoading();
  323. },
  324. fail: (e) => {
  325. console.log("----e:", e);
  326. }
  327. });
  328. })
  329. },
  330. switchTab(index) {
  331. this.activeTab = index;
  332. this.offset = 0;
  333. this.hasMore = true;
  334. this.worksList = [];
  335. this.loadWorksList();
  336. },
  337. loadWorksList() {
  338. if (this.isLoading) return;
  339. this.isLoading = true;
  340. // 根据activeTab选择不同的API
  341. let apiUrl = '';
  342. if (this.activeTab === 0) {
  343. apiUrl = '/Work/getlist';
  344. } else {
  345. apiUrl = '/WorkAI/getMyQueueList';
  346. }
  347. uni.request({
  348. url: this.$apiHost + apiUrl,
  349. data: {
  350. uuid: getApp().globalData.uuid,
  351. skey: getApp().globalData.skey,
  352. type: 'my', // 固定为my,表示获取自己的作品
  353. offset: this.offset,
  354. status: this.activeTab === 0 ? 1 : undefined // 只有我的作品需要status参数
  355. },
  356. header: {
  357. "content-type": "application/json",
  358. 'sign': getApp().globalData.headerSign
  359. },
  360. success: (res) => {
  361. console.log("列表数据:", res.data);
  362. if (res.data.success == 'yes' && res.data.list) {
  363. if (res.data.list.length > 0) {
  364. this.worksList = [...this.worksList, ...res.data.list];
  365. this.offset += res.data.list.length;
  366. }
  367. if (res.data.list.length < 20) {
  368. this.hasMore = false;
  369. }
  370. } else {
  371. this.hasMore = false;
  372. }
  373. // 只有在"我的作品"标签下才更新data_list
  374. if (this.activeTab === 0) {
  375. this.updateDataList();
  376. }
  377. },
  378. complete: () => {
  379. this.isLoading = false;
  380. },
  381. fail: (e) => {
  382. console.log("请求列表失败:", e);
  383. this.isLoading = false;
  384. }
  385. });
  386. },
  387. loadMoreWorks() {
  388. if (this.hasMore && !this.isLoading) {
  389. this.loadWorksList();
  390. }
  391. },
  392. updateDataList() {
  393. this.data_list = this.worksList.map(item => {
  394. return {
  395. url: item.images || item.img_url || item.url || '../../static/logo.png',
  396. title: item.title || item.description || '作品',
  397. id: item.id
  398. };
  399. });
  400. },
  401. goWork(item) {
  402. uni.$emit('check_login', () => {})
  403. if (this.activeTab == 0) {
  404. uni.navigateTo({
  405. url: '/pages/index/workDetail?id=' + item.id
  406. })
  407. } else {
  408. if (item.status >= 9) {
  409. uni.navigateTo({
  410. url: '/pages/makedetail/makeDetail?id=' + item.id
  411. })
  412. }
  413. }
  414. },
  415. navigateToSettings() {
  416. uni.$emit('check_login', () => {
  417. uni.navigateTo({
  418. url: '/pages/my/setting'
  419. });
  420. })
  421. },
  422. }
  423. }
  424. </script>
  425. <style scoped lang="scss">
  426. @import 'my.scss';
  427. </style>