my.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  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. <!-- 当activeTab为1时显示队列状态 -->
  82. <view v-else class="queue-status">
  83. <!-- 排队中 -->
  84. <view v-if="item.status === 1" class="status-text">
  85. 排队中({{item.queue_position}}/{{item.all_position}})</view>
  86. <!-- 制作中 -->
  87. <view v-else-if="item.status < 9" class="status-text">制作中</view>
  88. <!-- 创作完成 -->
  89. <view v-else-if="item.status === 9" class="status-text">创作完成</view>
  90. </view>
  91. <view class="name">{{item.title || item.description || '作品'+index}}</view>
  92. <!-- 显示任务类型标签 -->
  93. <view v-if="activeTab === 1" class="task-type-tag">
  94. <text v-if="item.task_type === 1">灵感创作</text>
  95. <text v-else-if="item.task_type === 2">音乐</text>
  96. </view>
  97. </view>
  98. </view>
  99. </view>
  100. <!-- 加载更多提示 -->
  101. <view class="loading-more" v-if="isLoading">加载中...</view>
  102. <view class="no-more" v-if="!hasMore && worksList.length > 0">没有更多作品了</view>
  103. <view class="no-more" v-if="!hasMore && worksList.length === 0">暂无作品</view>
  104. </view>
  105. <view class="blankHeight"></view>
  106. <view class="blankHeight"></view>
  107. </view>
  108. <!-- 提示框 -->
  109. <DialogBox ref="DialogBox"></DialogBox>
  110. <tabbar-view :tabbars="tabbars" :currentIndex="4" ref="tabbar"></tabbar-view>
  111. </view>
  112. </template>
  113. <script>
  114. import tabbarView from "@/components/tabbar/tabbar.vue";
  115. import tabbar from "@/mixins/tabbar";
  116. export default {
  117. components: {
  118. tabbarView,
  119. },
  120. mixins: [tabbar],
  121. data() {
  122. return {
  123. title: '',
  124. sel: 1,
  125. myinfo: {
  126. avator: '../../static/logo.png',
  127. nickname: '王思思',
  128. join_name: '注册日期:2024年5月',
  129. num_1: 0,
  130. num_2: 0,
  131. num_3: 0,
  132. num_4: 0,
  133. is_login: 'no',
  134. num_history: 0,
  135. num_collection: 0,
  136. },
  137. aihao_tags: [],
  138. menu_list: [],
  139. data_list: [{
  140. url: 'https://e.zhichao.art/AI_images/a_1112_10.png',
  141. },
  142. {
  143. url: 'https://e.zhichao.art/AI_images/a_1112_108.png',
  144. },
  145. {
  146. url: 'https://e.zhichao.art/AI_images/a_1112_113.png',
  147. },
  148. {
  149. url: 'https://e.zhichao.art/AI_images/a_1112_13.png',
  150. },
  151. {
  152. url: 'https://e.zhichao.art/AI_images/a_1112_137.png',
  153. },
  154. {
  155. url: 'https://e.zhichao.art/AI_images/a_1112_141.png',
  156. },
  157. {
  158. url: 'https://e.zhichao.art/AI_images/a_1114__562.png',
  159. },
  160. {
  161. url: 'https://e.zhichao.art/AI_images/a_1114__568.png',
  162. },
  163. {
  164. url: 'https://e.zhichao.art/AI_images/a_1114__569.png',
  165. },
  166. {
  167. url: 'https://e.zhichao.art/AI_images/a_1114__570.png',
  168. },
  169. {
  170. url: 'https://e.zhichao.art/AI_images/a_1114__571.png',
  171. },
  172. {
  173. url: 'https://e.zhichao.art/AI_images/a_1114__575.png',
  174. },
  175. ],
  176. activeTab: 0,
  177. offset: 0,
  178. hasMore: true,
  179. isLoading: false,
  180. worksList: []
  181. }
  182. },
  183. onLoad() {
  184. // setTimeout(function() {
  185. // uni.setNavigationBarColor({
  186. // frontColor: '#ffffff',
  187. // backgroundColor: '#00000000',
  188. // animation: {
  189. // duration: 400,
  190. // timingFunc: 'easeIn'
  191. // }
  192. // })
  193. // }, 200);
  194. },
  195. onShow() {
  196. // this.loadData();
  197. this.offset = 0;
  198. this.hasMore = true;
  199. this.worksList = [];
  200. this.loadInfo();
  201. this.loadWorksList();
  202. },
  203. onReachBottom() {
  204. if (this.hasMore && !this.isLoading) {
  205. this.loadMoreWorks();
  206. }
  207. },
  208. methods: {
  209. onBack() {},
  210. chkSel() {
  211. if (this.sel == 1) {
  212. this.sel = 0;
  213. } else {
  214. this.sel = 1;
  215. }
  216. },
  217. goPage(page) {
  218. if (page == 'kefu') {
  219. let that = this;
  220. // #ifdef APP-PLUS
  221. plus.share.getServices(res => {
  222. const wechat = res.find(i => i.id === 'weixin')
  223. if (wechat) {
  224. wechat.openCustomerServiceChat({
  225. corpid: 'wwbc06aa8311b6ac08',
  226. // url: 'https://work.weixin.qq.com/kfid/kfc4b0bcb4038d00a50'
  227. url: that.myinfo.wxkf
  228. }, src => {
  229. console.log("success:")
  230. }, err => {
  231. console.log("error:")
  232. })
  233. } else {
  234. uni.showToast({
  235. title: '没有检测到微信,请先安装',
  236. icon: "error"
  237. });
  238. }
  239. });
  240. // #endif
  241. } else if (page != '') {
  242. uni.navigateTo({
  243. url: page,
  244. })
  245. }
  246. },
  247. loadInfo() {
  248. console.log({
  249. uuid: getApp().globalData.uuid,
  250. skey: getApp().globalData.skey
  251. });
  252. uni.request({
  253. url: this.$apiHost + '/User/getinfo',
  254. data: {
  255. uuid: getApp().globalData.uuid,
  256. skey: getApp().globalData.skey
  257. },
  258. header: {
  259. "content-type": "application/json",
  260. 'sign': getApp().globalData.headerSign
  261. },
  262. success: (res) => {
  263. console.log("----:", res.data);
  264. if (res.data.need_login == "yes") {
  265. // getApp().globalData.skey = "";
  266. // getApp().globalData.uuid = "";
  267. // uni.removeStorageSync("wapptoken");
  268. // uni.redirectTo({
  269. // url: '/pages/login/login'
  270. // });
  271. // return;
  272. }
  273. if (res.data.aihao) {
  274. this.aihao_tags = res.data.aihao.split(",");
  275. }
  276. this.myinfo = res.data;
  277. },
  278. complete: (com) => {
  279. // uni.hideLoading();
  280. },
  281. fail: (e) => {
  282. console.log("----e:", e);
  283. }
  284. });
  285. },
  286. onLogout() {
  287. let that = this;
  288. this.$refs['DialogBox'].confirm({
  289. title: '提示',
  290. content: '确定退出吗?',
  291. DialogType: 'inquiry',
  292. btn1: '取消',
  293. btn2: '退出',
  294. animation: 0
  295. }).then((res) => {
  296. uni.request({
  297. url: that.$apiHost + '/My/logout',
  298. data: {
  299. uuid: getApp().globalData.uuid,
  300. skey: getApp().globalData.skey
  301. },
  302. header: {
  303. "content-type": "application/json",
  304. 'sign': getApp().globalData.headerSign
  305. },
  306. success: (res) => {
  307. console.log("----:", res.data);
  308. // getApp().globalData.skey = "";
  309. // getApp().globalData.uuid = "";
  310. uni.removeStorageSync("wapptoken");
  311. uni.redirectTo({
  312. url: '/pages/login/login'
  313. })
  314. },
  315. complete: (com) => {
  316. // uni.hideLoading();
  317. },
  318. fail: (e) => {
  319. console.log("----e:", e);
  320. }
  321. });
  322. })
  323. },
  324. switchTab(index) {
  325. this.activeTab = index;
  326. this.offset = 0;
  327. this.hasMore = true;
  328. this.worksList = [];
  329. this.loadWorksList();
  330. },
  331. loadWorksList() {
  332. if (this.isLoading) return;
  333. this.isLoading = true;
  334. // 根据activeTab选择不同的API
  335. let apiUrl = '';
  336. if (this.activeTab === 0) {
  337. apiUrl = '/Work/getlist';
  338. } else {
  339. apiUrl = '/WorkAI/getMyQueueList';
  340. }
  341. uni.request({
  342. url: this.$apiHost + apiUrl,
  343. data: {
  344. uuid: getApp().globalData.uuid,
  345. skey: getApp().globalData.skey,
  346. type: 'my', // 固定为my,表示获取自己的作品
  347. offset: this.offset,
  348. status: this.activeTab === 0 ? 1 : undefined // 只有我的作品需要status参数
  349. },
  350. header: {
  351. "content-type": "application/json",
  352. 'sign': getApp().globalData.headerSign
  353. },
  354. success: (res) => {
  355. console.log("列表数据:", res.data);
  356. if (res.data.success == 'yes' && res.data.list) {
  357. if (res.data.list.length > 0) {
  358. this.worksList = [...this.worksList, ...res.data.list];
  359. this.offset += res.data.list.length;
  360. }
  361. if (res.data.list.length < 20) {
  362. this.hasMore = false;
  363. }
  364. } else {
  365. this.hasMore = false;
  366. }
  367. // 只有在"我的作品"标签下才更新data_list
  368. if (this.activeTab === 0) {
  369. this.updateDataList();
  370. }
  371. },
  372. complete: () => {
  373. this.isLoading = false;
  374. },
  375. fail: (e) => {
  376. console.log("请求列表失败:", e);
  377. this.isLoading = false;
  378. }
  379. });
  380. },
  381. loadMoreWorks() {
  382. if (this.hasMore && !this.isLoading) {
  383. this.loadWorksList();
  384. }
  385. },
  386. updateDataList() {
  387. this.data_list = this.worksList.map(item => {
  388. return {
  389. url: item.images || item.img_url || item.url || '../../static/logo.png',
  390. title: item.title || item.description || '作品',
  391. id: item.id
  392. };
  393. });
  394. },
  395. goWork(item) {
  396. if (this.activeTab == 0) {
  397. uni.navigateTo({
  398. url: '/pages/index/workDetail?id=' + item.id
  399. })
  400. } else {
  401. if (item.status >= 9) {
  402. uni.navigateTo({
  403. url: '/pages/makedetail/makeDetail?id=' + item.id
  404. })
  405. }
  406. }
  407. },
  408. navigateToSettings() {
  409. uni.navigateTo({
  410. url: '/pages/my/setting'
  411. });
  412. },
  413. }
  414. }
  415. </script>
  416. <style scoped lang="scss">
  417. @import 'my.scss';
  418. </style>