job.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  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'">+100星源</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)">
  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. if (!this.exchangeAmount) {
  406. uni.showToast({
  407. title: "请输入兑换数量",
  408. icon: "none",
  409. });
  410. return;
  411. }
  412. const amount = parseInt(this.exchangeAmount);
  413. if (isNaN(amount) || amount <= 0) {
  414. uni.showToast({
  415. title: "请输入有效数量",
  416. icon: "none",
  417. });
  418. return;
  419. }
  420. if (amount % 10 !== 0) {
  421. uni.showToast({
  422. title: "兑换数量必须是10的倍数",
  423. icon: "none",
  424. });
  425. return;
  426. }
  427. let that = this;
  428. uni.request({
  429. url: this.$apiHost + "/User/gmmToGMD",
  430. data: {
  431. uuid: getApp().globalData.uuid,
  432. num: amount,
  433. },
  434. header: {
  435. "content-type": "application/json",
  436. sign: getApp().globalData.headerSign,
  437. },
  438. success: (res) => {
  439. console.log("----:", res.data);
  440. uni.showToast({
  441. title: res.data.str,
  442. icon: "none",
  443. });
  444. if (res.data.success == "yes") {
  445. this.hideExchangePopup();
  446. this.exchangeAmount = "";
  447. setTimeout(function() {
  448. that.loadData();
  449. }, 900);
  450. }
  451. },
  452. complete: (com) => {
  453. this.closeNicknamePopUpWindow();
  454. },
  455. fail: (e) => {
  456. console.log("----e:", e);
  457. },
  458. });
  459. },
  460. claimReward(index) {
  461. if (this.taskList[index].status == 9) {
  462. uni.showToast({
  463. title: "已领取该奖励",
  464. icon: "none",
  465. });
  466. return;
  467. }
  468. let that = this;
  469. uni.request({
  470. url: this.$apiHost + "/Job/doAct",
  471. data: {
  472. uuid: getApp().globalData.uuid,
  473. id: this.taskList[index].id,
  474. },
  475. header: {
  476. "content-type": "application/json",
  477. sign: getApp().globalData.headerSign,
  478. },
  479. success: (res) => {
  480. console.log("----:", res.data);
  481. if (res.data.success == "yes") {
  482. uni.showToast({
  483. title: res.data.str,
  484. icon: "none",
  485. });
  486. setTimeout(function() {
  487. that.loadData();
  488. }, 900);
  489. }
  490. },
  491. complete: (com) => {
  492. // uni.hideLoading();
  493. },
  494. fail: (e) => {
  495. console.log("----e:", e);
  496. },
  497. });
  498. },
  499. handleDropdownSelect(item) {
  500. switch (item.type) {
  501. case "starSourceRecord":
  502. uni.navigateTo({
  503. url: "/pages/vip/record?type=star",
  504. });
  505. break;
  506. }
  507. },
  508. showExchangeConfirm() {
  509. this.$refs["DialogBox"]
  510. .confirm({
  511. title: "确认兑换",
  512. content: "确定要兑换" + this.exchangeAmount + "星源吗?",
  513. DialogType: "inquiry",
  514. btn1: "再考虑一下",
  515. btn2: "确认兑换",
  516. animation: 0,
  517. })
  518. .then((res) => {
  519. if (res.confirm) {
  520. this.confirmExchange();
  521. }
  522. });
  523. },
  524. refreshData() {
  525. Promise.all([this.loadData(), this.getSignInfo()])
  526. .then(() => {
  527. this.isRefreshing = false;
  528. uni.stopPullDownRefresh();
  529. })
  530. .catch(() => {
  531. this.isRefreshing = false;
  532. uni.stopPullDownRefresh();
  533. });
  534. },
  535. goPage(page) {
  536. uni.navigateTo({
  537. url: page,
  538. });
  539. },
  540. },
  541. };
  542. </script>
  543. <style scoped lang="scss">
  544. @import "job.scss";
  545. </style>