job.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. <template>
  2. <view class="page">
  3. <!-- 顶部黄色背景 -->
  4. <PageHeader class="PageHeader">
  5. <template slot="center"> 任务中心 </template>
  6. <template slot="right">
  7. <DropdownMenu :options="dropdownOptions" @select="handleDropdownSelect" />
  8. </template>
  9. </PageHeader>
  10. <view class="occupyHigh"></view>
  11. <!-- 内容区域 -->
  12. <view class="content-area">
  13. <!-- 星源余额展示区 -->
  14. <view class="person-info">
  15. <view class="person-info-left">
  16. <CircleAvatar class="avator" v-if="myinfo.avator" :src="myinfo.avator"></CircleAvatar>
  17. <view class="title-area">
  18. <text class="my-bean-title">我的星源</text>
  19. <view class="bean-number">
  20. <image src="@/static/me/job/wd_icon_xingyuan.png"></image>
  21. {{ num_gmd | formatNumberToK }}
  22. </view>
  23. </view>
  24. </view>
  25. <view class="exchange-btn" @click="openNicknamePopUpWindow()">兑换</view>
  26. </view>
  27. <!-- 星源余额展示区 -->
  28. <!-- <view class="bean-balance" >
  29. <view class="balance-header">
  30. <view class="title-area">
  31. <view class="yellow-dot"></view>
  32. <text class="my-bean-title">我的星源</text>
  33. </view>
  34. <view class="exchange-btn" @click="showExchangePopup">兑换</view>
  35. </view>
  36. <view class="bean-number">{{ num_gmd }}</view>
  37. </view> -->
  38. <view class="starWishCheckIn">
  39. <image src="@/static/me/job/rw_wenzi_01.png" class="title"></image>
  40. <view class="card purple-card" @click="newer_bfb == 'finish' ? '' : goPage('/pages/my/editInfo')">
  41. <view class="bg-box" v-if="newer_bfb == 'finish'">
  42. <image src="@/static/me/job/sy_icon_yilingqu.png" class="bg"></image>
  43. </view>
  44. <view class="card-title">初次见面礼</view>
  45. <view class="card-desc">完善个人资料领取星源奖励</view>
  46. <view class="card-btn card-reward" v-if="newer_bfb != 'finish'">+20星源</view>
  47. <view class="card-btn card-reward" v-else>已领取</view>
  48. </view>
  49. <view class="card yellow-card">
  50. <view class="card-title">每日签到</view>
  51. <view class="card-desc">签到领奖励,快来签到吧!</view>
  52. <view class="card-btn sign-btn" @click="opencheckInPopUpWindow()">
  53. <template v-if="signInfo.isSigned">已签到</template>
  54. <template v-else>立即签到</template>
  55. </view>
  56. </view>
  57. </view>
  58. <!-- 星愿打卡区域 -->
  59. <!-- <view class="sign-cards" v-if="false">
  60. <view class="card purple-card">
  61. <view class="card-title">初次见面礼</view>
  62. <view class="card-desc">完善个人资料可得</view>
  63. <view class="card-reward">奖励+100星源</view>
  64. <view class="card-progress">{{ newer_bfb }}</view>
  65. </view>
  66. <view class="card yellow-card">
  67. <view class="card-title">每日签到</view>
  68. <view class="card-desc">连续签到奖励更多</view>
  69. <view class="sign-btn" @click="showSignPopup">立即签到</view>
  70. <view class="sign-btn" @click="opencheckInPopUpWindow()">立即签到</view>
  71. </view>
  72. </view> -->
  73. <!-- 每日任务列表 -->
  74. <view class="task-list-box">
  75. <view class="task-header">
  76. <image src="@/static/me/job/rw_wenzi_02.png"></image>
  77. <text class="task-subtitle">(获取免费星源)</text>
  78. </view>
  79. <!-- 任务项列表 -->
  80. <view class="task-item" v-for="(item, index) in taskList" :key="index">
  81. <view class="task-info">
  82. <image :src="item.image"></image>
  83. <view>
  84. <view class="task-name one-omit">{{ item.name }}</view>
  85. <view class="task-desc one-omit">{{ item.content }}</view>
  86. </view>
  87. </view>
  88. <view class="task-reward">
  89. <image src="@/static/me/job/wd_icon_xingyuan.png"></image>+{{
  90. item.num
  91. }}
  92. </view>
  93. <view class="task-btn" :class="{ 'task-completed': item.status == 9 || item.status == 1 }"
  94. @click="claimReward(index, item)">
  95. <text v-if="item.status == 1">未完成</text>
  96. <text v-if="item.status == 2">领取</text>
  97. <text v-if="item.status == 9">已领取</text>
  98. </view>
  99. </view>
  100. </view>
  101. <!-- 每日任务列表
  102. <view class="task-list">
  103. <view class="task-header">
  104. <text class="task-title">每日任务</text>
  105. <text class="task-subtitle">获取免费星源</text>
  106. </view>
  107. <view class="task-item" v-for="(item, index) in taskList" :key="index">
  108. <view class="task-info">
  109. <view class="task-name">{{ item.name }}</view>
  110. <view class="task-desc">{{ item.content }}</view>
  111. </view>
  112. <view class="task-reward">+{{ item.num }}星源</view>
  113. <view class="task-btn" :class="{ 'task-completed': item.status == 9 }" @click="claimReward(index)">
  114. {{ item.status == 9 ? "已领取" : "领取" }}
  115. </view>
  116. </view>
  117. </view>-->
  118. </view>
  119. <!-- 星源兑换弹窗 -->
  120. <view class="exchange-popup" v-if="showExchange">
  121. <view class="popup-mask" @click="hideExchangePopup"></view>
  122. <view class="popup-content">
  123. <!-- 弹窗顶部信息栏 -->
  124. <view class="popup-header">
  125. <text class="available-balance">可用M币: 14500</text>
  126. <text class="exchange-title">兑换星源</text>
  127. </view>
  128. <!-- 兑换区域主体 -->
  129. <view class="exchange-area">
  130. <view class="exchange-title-area">
  131. <text class="exchange-main-title">M币兑换星源数</text>
  132. <text class="exchange-subtitle">兑换星源数必须是10的倍数</text>
  133. </view>
  134. <view class="input-area">
  135. <view class="bean-icon"></view>
  136. <input type="number" class="exchange-input" placeholder="请输入兑换星源数量" v-model="exchangeAmount" />
  137. </view>
  138. <!-- 操作按钮 -->
  139. <view class="action-area">
  140. <view class="exchange-btn-large" @click="confirmExchange">立即兑换星源</view>
  141. <text class="tips-text">星源可用于创作(生成图片、音乐等AI创作功能)</text>
  142. </view>
  143. </view>
  144. </view>
  145. </view>
  146. <checkInPopUpWindow :checkInDays="6" :signInfo="signInfo" :signNotify="signNotify"
  147. @toggleSignNotify="toggleSignNotify" ref="checkInPopUpWindow" @confirmSign="confirmSign()">
  148. </checkInPopUpWindow>
  149. <!-- 提示框 -->
  150. <DialogBox ref="DialogBox"></DialogBox>
  151. <!-- 兑换m币弹窗-->
  152. <view class="NicknamePopUpWindowBox">
  153. <NicknamePopup title="" subtitle="" class="NicknamePopUpWindow" ref="NicknamePopUpWindow">
  154. <template slot="heard">
  155. <view class="nickname-heard">
  156. <view class="available-mCoin">可用M币:{{ myinfo.num_gmm | formatNumberToK }}</view>
  157. <view class="exchange-title">兑换星源</view>
  158. </view>
  159. </template>
  160. <template slot="content">
  161. <view class="content-box">
  162. <view class="prompt">
  163. M币兑换星源数<text>(兑换星源数必须是10的倍数)</text>
  164. </view>
  165. <view class="input-box">
  166. <image src="@/static/me/job/wd_icon_xingyuan.png"></image>
  167. <uv-input type="number" class="input" placeholder="请输入昵称" border="none"
  168. v-model="exchangeAmount" maxlength="20"></uv-input>
  169. </view>
  170. <view class="btn-box" @click="showExchangeConfirm">立即兑换星源</view>
  171. <text class="tips-text">星源可用于创作(生成图片、音乐等AI创作功能)</text>
  172. </view>
  173. </template>
  174. </NicknamePopup>
  175. </view>
  176. </view>
  177. </template>
  178. <script>
  179. import checkInPopUpWindow from "@/components/checkIn-popUp-window/checkIn-popUp-window.vue";
  180. import DropdownMenu from "@/components/DropdownMenu.vue";
  181. export default {
  182. components: {
  183. checkInPopUpWindow,
  184. DropdownMenu,
  185. },
  186. data() {
  187. return {
  188. title: "任务中心",
  189. myinfo: {},
  190. realname: "",
  191. num_gmd: 0,
  192. newer_bfb: "",
  193. beanBalance: 2560,
  194. showExchange: false,
  195. exchangeAmount: "",
  196. mCoinBalance: 0,
  197. signNotify: true,
  198. signRewards: [{
  199. dayNum: "01",
  200. reward: "10星源",
  201. isVip: false,
  202. },
  203. {
  204. dayNum: "02",
  205. reward: "15星源",
  206. isVip: false,
  207. },
  208. {
  209. dayNum: "03",
  210. reward: "20星源",
  211. isVip: false,
  212. },
  213. {
  214. dayNum: "04",
  215. reward: "25星源",
  216. isVip: false,
  217. },
  218. {
  219. dayNum: "05",
  220. reward: "30星源",
  221. isVip: false,
  222. },
  223. {
  224. dayNum: "06",
  225. reward: "35星源",
  226. isVip: true,
  227. },
  228. {
  229. dayNum: "07",
  230. reward: "50星源",
  231. isVip: true,
  232. },
  233. ],
  234. signInfo: {
  235. signDay: 1,
  236. isSigned: false,
  237. reward: 0,
  238. },
  239. taskList: [],
  240. dropdownOptions: [{
  241. label: "星源记录",
  242. type: "starSourceRecord"
  243. }],
  244. isRefreshing: false,
  245. };
  246. },
  247. onPullDownRefresh() {
  248. if (this.isRefreshing) return;
  249. this.isRefreshing = true;
  250. this.refreshData();
  251. },
  252. onLoad(e) {
  253. if (e && e.type == "recharge") {
  254. setTimeout(() => {
  255. this.openNicknamePopUpWindow();
  256. }, 0);
  257. }
  258. this.loadData();
  259. this.getSignInfo();
  260. },
  261. onShow() { },
  262. methods: {
  263. opencheckInPopUpWindow() {
  264. this.$refs.checkInPopUpWindow.open();
  265. },
  266. closecheckInPopUpWindow() {
  267. this.$refs.checkInPopUpWindow.close();
  268. },
  269. openNicknamePopUpWindow() {
  270. this.$refs.NicknamePopUpWindow.open();
  271. },
  272. closeNicknamePopUpWindow() {
  273. this.$refs.NicknamePopUpWindow.close();
  274. },
  275. onBack() { },
  276. loadData() {
  277. return new Promise((resolve, reject) => {
  278. uni.request({
  279. url: this.$apiHost + "/Job/getlist",
  280. data: {
  281. uuid: getApp().globalData.uuid,
  282. },
  283. header: {
  284. "content-type": "application/json",
  285. sign: getApp().globalData.headerSign,
  286. },
  287. success: (res) => {
  288. console.log("----:", res.data);
  289. this.num_gmd = res.data.num_gmd;
  290. this.newer_bfb = res.data.newer_bfb;
  291. this.taskList = res.data.list;
  292. resolve(res);
  293. },
  294. complete: (com) => {
  295. // uni.hideLoading();
  296. },
  297. fail: (e) => {
  298. console.log("----e:", e);
  299. reject(e);
  300. },
  301. });
  302. });
  303. },
  304. getSignInfo() {
  305. return new Promise((resolve, reject) => {
  306. uni.request({
  307. url: this.$apiHost + "/User/sign7Day",
  308. data: {
  309. uuid: getApp().globalData.uuid,
  310. action: "get",
  311. },
  312. header: {
  313. "content-type": "application/json",
  314. sign: getApp().globalData.headerSign,
  315. },
  316. success: (res) => {
  317. if (res.data.success === "yes") {
  318. this.signInfo = {
  319. signDay: res.data.data.sign_day,
  320. isSigned: res.data.data.is_signed,
  321. reward: res.data.data.reward || 0,
  322. };
  323. }
  324. resolve(res);
  325. },
  326. fail: (e) => {
  327. console.log("获取签到信息失败:", e);
  328. reject(e);
  329. },
  330. });
  331. uni.request({
  332. url: this.$apiHost + "/User/getinfo",
  333. data: {
  334. uuid: getApp().globalData.uuid,
  335. skey: getApp().globalData.skey,
  336. },
  337. header: {
  338. "content-type": "application/json",
  339. sign: getApp().globalData.headerSign,
  340. },
  341. success: (res) => {
  342. this.myinfo = res.data;
  343. resolve(res);
  344. },
  345. complete: (com) => { },
  346. fail: (e) => {
  347. console.log("----e:", e);
  348. reject(e);
  349. },
  350. });
  351. });
  352. },
  353. showExchangePopup() {
  354. this.showExchange = true;
  355. },
  356. hideExchangePopup() {
  357. this.showExchange = false;
  358. },
  359. toggleSignNotify(falg) {
  360. this.signNotify = falg;
  361. },
  362. confirmSign(type) {
  363. if (this.signInfo.isSigned) {
  364. uni.showToast({
  365. title: "今日已签到,明天再来吧",
  366. icon: "none",
  367. });
  368. return;
  369. }
  370. uni.request({
  371. url: this.$apiHost + "/User/sign7Day",
  372. data: {
  373. uuid: getApp().globalData.uuid,
  374. action: "sign",
  375. },
  376. header: {
  377. "content-type": "application/json",
  378. sign: getApp().globalData.headerSign,
  379. },
  380. success: (res) => {
  381. if (res.data.success === "yes") {
  382. uni.showToast({
  383. title: res.data.str,
  384. icon: "none",
  385. });
  386. this.getSignInfo();
  387. this.loadData();
  388. } else {
  389. uni.showToast({
  390. title: res.data.str,
  391. icon: "none",
  392. });
  393. }
  394. },
  395. fail: (e) => {
  396. console.log("签到失败:", e);
  397. uni.showToast({
  398. title: "签到失败,请稍后重试",
  399. icon: "none",
  400. });
  401. },
  402. });
  403. },
  404. confirmExchange() {
  405. console.log(123465);
  406. if (!this.exchangeAmount) {
  407. uni.showToast({
  408. title: "请输入兑换数量",
  409. icon: "none",
  410. });
  411. return;
  412. }
  413. const amount = parseInt(this.exchangeAmount);
  414. if (isNaN(amount) || amount <= 0) {
  415. uni.showToast({
  416. title: "请输入有效数量",
  417. icon: "none",
  418. });
  419. return;
  420. }
  421. if (amount % 10 !== 0) {
  422. uni.showToast({
  423. title: "兑换数量必须是10的倍数",
  424. icon: "none",
  425. });
  426. return;
  427. }
  428. let that = this;
  429. uni.request({
  430. url: this.$apiHost + "/User/gmmToGMD",
  431. data: {
  432. uuid: getApp().globalData.uuid,
  433. num: amount,
  434. },
  435. header: {
  436. "content-type": "application/json",
  437. sign: getApp().globalData.headerSign,
  438. },
  439. success: (res) => {
  440. console.log("----:", res.data);
  441. uni.showToast({
  442. title: res.data.str,
  443. icon: "none",
  444. });
  445. if (res.data.success == "yes") {
  446. this.hideExchangePopup();
  447. this.exchangeAmount = "";
  448. setTimeout(function () {
  449. that.loadData();
  450. }, 900);
  451. }
  452. },
  453. complete: (com) => {
  454. this.closeNicknamePopUpWindow();
  455. },
  456. fail: (e) => {
  457. console.log("----e:", e);
  458. },
  459. });
  460. },
  461. jumpTask(item) {
  462. let url = "";
  463. switch (item.id) {
  464. case 1:
  465. uni.switchTab({
  466. url: "/pages/make/index"
  467. })
  468. break;
  469. case 2:
  470. uni.switchTab({
  471. url: "/pages/my/my"
  472. })
  473. break;
  474. case 3:
  475. uni.switchTab({
  476. url: "/pages/index/index"
  477. })
  478. break;
  479. case 4:
  480. uni.switchTab({
  481. url: "/pages/make/index"
  482. })
  483. break;
  484. case 5:
  485. uni.navigateTo({
  486. url: "/pages/vip/index"
  487. });
  488. break;
  489. }
  490. var arr = [
  491. {
  492. "id": 3,
  493. "image": "https://e.zhichao.art/images/job/newer.png",
  494. "rule": "newer",
  495. "type": "all",
  496. "name": "邀请好友领星源",
  497. "content": "成功邀请一位好友注册",
  498. "num": 50,
  499. "status": 1
  500. },
  501. {
  502. "id": 1,
  503. "image": "https://e.zhichao.art/images/job/fabu.png",
  504. "rule": "fabu",
  505. "type": "day",
  506. "name": "每日首次发布作品",
  507. "content": "当日首次发布作品即可获得奖励",
  508. "num": 20,
  509. "status": 1
  510. },
  511. {
  512. "id": 2,
  513. "image": "https://e.zhichao.art/images/job/share.png",
  514. "rule": "share",
  515. "type": "day",
  516. "name": "分享作品领星源",
  517. "content": "分享作品到社交平台即可获得奖励",
  518. "num": 20,
  519. "status": 1
  520. },
  521. {
  522. "id": 5,
  523. "image": "https://e.zhichao.art/images/job/zan.png",
  524. "rule": "zan",
  525. "type": "day",
  526. "name": "口碑缔造者",
  527. "content": "给他人作品评论5次",
  528. "num": 20,
  529. "status": 1
  530. },
  531. {
  532. "id": 4,
  533. "image": "https://e.zhichao.art/images/job/congzi.png",
  534. "rule": "congzi",
  535. "type": "day",
  536. "name": "充值赠礼",
  537. "content": "首次充值即可获得额外奖励",
  538. "num": 30,
  539. "status": 1
  540. }
  541. ]
  542. },
  543. claimReward(index, item) {
  544. if (item.status == 9) {
  545. uni.showToast({
  546. title: "已领取该奖励",
  547. icon: "none",
  548. });
  549. return;
  550. }
  551. if (item.status == 1) {
  552. uni.showToast({
  553. title: "还没有完成该任务",
  554. icon: "none",
  555. });
  556. this.$refs["DialogBox"]
  557. .confirm({
  558. title: "任务提示",
  559. content: item.content,
  560. DialogType: "inquiry",
  561. btn1: "暂时不完成",
  562. btn2: "去完成任务",
  563. animation: 0,
  564. })
  565. .then((res) => {
  566. if (res.isConfirm) {
  567. this.jumpTask(item);
  568. }
  569. });
  570. return;
  571. }
  572. let that = this;
  573. uni.request({
  574. url: this.$apiHost + "/Job/doAct",
  575. data: {
  576. uuid: getApp().globalData.uuid,
  577. id: this.taskList[index].id,
  578. },
  579. header: {
  580. "content-type": "application/json",
  581. sign: getApp().globalData.headerSign,
  582. },
  583. success: (res) => {
  584. console.log("----:", res.data);
  585. if (res.data.success == "yes") {
  586. uni.showToast({
  587. title: res.data.str,
  588. icon: "none",
  589. });
  590. setTimeout(function () {
  591. that.loadData();
  592. }, 900);
  593. }
  594. },
  595. complete: (com) => {
  596. // uni.hideLoading();
  597. },
  598. fail: (e) => {
  599. console.log("----e:", e);
  600. },
  601. });
  602. },
  603. handleDropdownSelect(item) {
  604. switch (item.type) {
  605. case "starSourceRecord":
  606. uni.navigateTo({
  607. url: "/pages/vip/record?type=star",
  608. });
  609. break;
  610. }
  611. },
  612. showExchangeConfirm() {
  613. this.$refs["DialogBox"]
  614. .confirm({
  615. title: "确认兑换",
  616. content: "确定要兑换" + this.exchangeAmount + "星源吗?",
  617. DialogType: "inquiry",
  618. btn1: "再考虑一下",
  619. btn2: "确认兑换",
  620. animation: 0,
  621. })
  622. .then((res) => {
  623. if (res.isConfirm) {
  624. this.confirmExchange();
  625. }
  626. });
  627. },
  628. refreshData() {
  629. Promise.all([this.loadData(), this.getSignInfo()])
  630. .then(() => {
  631. this.isRefreshing = false;
  632. uni.stopPullDownRefresh();
  633. })
  634. .catch(() => {
  635. this.isRefreshing = false;
  636. uni.stopPullDownRefresh();
  637. });
  638. },
  639. goPage(page) {
  640. uni.navigateTo({
  641. url: page,
  642. });
  643. },
  644. },
  645. };
  646. </script>
  647. <style scoped lang="scss">
  648. @import "job.scss";
  649. </style>