my.vue 9.7 KB

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