my.vue 9.9 KB

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