job.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. <template>
  2. <view class="page">
  3. <!-- 顶部黄色背景 -->
  4. <PageHeader title="" class="PageHeader">
  5. <template slot="center">
  6. 任务中心
  7. </template>
  8. </PageHeader>
  9. <view class="occupyHigh"></view>
  10. <!-- 内容区域 -->
  11. <view class="content-area">
  12. <!-- 星源余额展示区 -->
  13. <view class="person-info">
  14. <view class="person-info-left">
  15. <CircleAvatar class="avator" v-if="myinfo.avator" :src="myinfo.avator"></CircleAvatar>
  16. <view class="title-area">
  17. <text class="my-bean-title">我的星源</text>
  18. <view class="bean-number">
  19. <image src="@/static/me/job/wd_icon_xingyuan.png"></image> {{ num_gmd }}
  20. </view>
  21. </view>
  22. </view>
  23. <view class="exchange-btn" @click="openNicknamePopUpWindow()">兑换</view>
  24. </view>
  25. <!-- 星源余额展示区 -->
  26. <!-- <view class="bean-balance" >
  27. <view class="balance-header">
  28. <view class="title-area">
  29. <view class="yellow-dot"></view>
  30. <text class="my-bean-title">我的星源</text>
  31. </view>
  32. <view class="exchange-btn" @click="showExchangePopup">兑换</view>
  33. </view>
  34. <view class="bean-number">{{ num_gmd }}</view>
  35. </view> -->
  36. <view class="starWishCheckIn">
  37. <image src="@/static/me/job/rw_wenzi_01.png" class="title"></image>
  38. <view class="card purple-card">
  39. <view class="card-title">初次见面礼</view>
  40. <view class="card-desc">完善个人资料达到{{ newer_bfb }}</view>
  41. <view class="card-btn card-reward ">+100星源</view>
  42. </view>
  43. <view class="card yellow-card">
  44. <view class="card-title">每日签到</view>
  45. <view class="card-desc">签到领奖励,快来签到吧!</view>
  46. <view class="card-btn sign-btn" @click="opencheckInPopUpWindow()">立即签到</view>
  47. </view>
  48. </view>
  49. <!-- 星愿打卡区域 -->
  50. <!-- <view class="sign-cards" v-if="false">
  51. <view class="card purple-card">
  52. <view class="card-title">初次见面礼</view>
  53. <view class="card-desc">完善个人资料可得</view>
  54. <view class="card-reward">奖励+100星源</view>
  55. <view class="card-progress">{{ newer_bfb }}</view>
  56. </view>
  57. <view class="card yellow-card">
  58. <view class="card-title">每日签到</view>
  59. <view class="card-desc">连续签到奖励更多</view>
  60. <view class="sign-btn" @click="showSignPopup">立即签到</view>
  61. <view class="sign-btn" @click="opencheckInPopUpWindow()">立即签到</view>
  62. </view>
  63. </view> -->
  64. <!-- 每日任务列表 -->
  65. <view class="task-list-box">
  66. <view class="task-header">
  67. <image src="@/static/me/job/rw_wenzi_02.png"></image>
  68. <text class="task-subtitle">(获取免费星源)</text>
  69. </view>
  70. <!-- 任务项列表 -->
  71. <view class="task-item" v-for="(item, index) in taskList" :key="index">
  72. <view class="task-info">
  73. <image :src="item.image"></image>
  74. <view>
  75. <view class="task-name one-omit">{{ item.name }}</view>
  76. <view class="task-desc one-omit">{{ item.content }}</view>
  77. </view>
  78. </view>
  79. <view class="task-reward">
  80. <image src="@/static/me/job/wd_icon_xingyuan.png"></image>+{{ item.num }}
  81. </view>
  82. <view class="task-btn" :class="{ 'task-completed': item.status == 9 }" @click="claimReward(index)">
  83. {{ item.status == 9 ? "已领取" : "领取" }}
  84. </view>
  85. </view>
  86. </view>
  87. <!-- 每日任务列表
  88. <view class="task-list">
  89. <view class="task-header">
  90. <text class="task-title">每日任务</text>
  91. <text class="task-subtitle">获取免费星源</text>
  92. </view>
  93. <view class="task-item" v-for="(item, index) in taskList" :key="index">
  94. <view class="task-info">
  95. <view class="task-name">{{ item.name }}</view>
  96. <view class="task-desc">{{ item.content }}</view>
  97. </view>
  98. <view class="task-reward">+{{ item.num }}星源</view>
  99. <view class="task-btn" :class="{ 'task-completed': item.status == 9 }" @click="claimReward(index)">
  100. {{ item.status == 9 ? "已领取" : "领取" }}
  101. </view>
  102. </view>
  103. </view>-->
  104. </view>
  105. <!-- 星源兑换弹窗 -->
  106. <view class="exchange-popup" v-if="showExchange">
  107. <view class="popup-mask" @click="hideExchangePopup"></view>
  108. <view class="popup-content">
  109. <!-- 弹窗顶部信息栏 -->
  110. <view class="popup-header">
  111. <text class="available-balance">可用M币: 14500</text>
  112. <text class="exchange-title">兑换星源</text>
  113. </view>
  114. <!-- 兑换区域主体 -->
  115. <view class="exchange-area">
  116. <view class="exchange-title-area">
  117. <text class="exchange-main-title">M币兑换星源数</text>
  118. <text class="exchange-subtitle">兑换星源数必须是10的倍数</text>
  119. </view>
  120. <view class="input-area">
  121. <view class="bean-icon"></view>
  122. <input type="number" class="exchange-input" placeholder="请输入兑换星源数量" v-model="exchangeAmount" />
  123. </view>
  124. <!-- 操作按钮 -->
  125. <view class="action-area">
  126. <view class="exchange-btn-large" @click="confirmExchange">立即兑换星源</view>
  127. <text class="tips-text">星源可用于创作(生成图片、音乐等AI创作功能)</text>
  128. </view>
  129. </view>
  130. </view>
  131. </view>
  132. <checkInPopUpWindow :checkInDays="6" :signInfo="signInfo" :signNotify="signNotify"
  133. @toggleSignNotify="toggleSignNotify" ref="checkInPopUpWindow" @confirmSign="confirmSign()">
  134. </checkInPopUpWindow>
  135. <!-- 提示框 -->
  136. <DialogBox ref="DialogBox"></DialogBox>
  137. <!-- 兑换m币弹窗-->
  138. <view class="NicknamePopUpWindowBox">
  139. <NicknamePopup title="" subtitle="" class="NicknamePopUpWindow" ref="NicknamePopUpWindow">
  140. <template slot="heard">
  141. <view class="nickname-heard">
  142. <view class="available-mCoin">可用M币:{{myinfo.num_gmm}}</view>
  143. <view class="exchange-title">兑换星源</view>
  144. </view>
  145. </template>
  146. <template slot="content">
  147. <view class="content-box">
  148. <view class="prompt">
  149. M币兑换星源数<text>(兑换星源数必须是10的倍数)</text>
  150. </view>
  151. <view class="input-box">
  152. <image src="@/static/me/job/wd_icon_xingyuan.png"></image>
  153. <uv-input type="number" class="input" placeholder="请输入昵称" border="none"
  154. v-model="exchangeAmount" maxlength="20"></uv-input>
  155. </view>
  156. <view class="btn-box" @click="confirmExchange">立即兑换星源</view>
  157. </view>
  158. </template>
  159. </NicknamePopup>
  160. </view>
  161. </view>
  162. </template>
  163. <script>
  164. import checkInPopUpWindow from "@/components/checkIn-popUp-window/checkIn-popUp-window.vue";
  165. export default {
  166. components: {
  167. checkInPopUpWindow,
  168. },
  169. data() {
  170. return {
  171. title: "任务中心",
  172. myinfo: {},
  173. realname: "",
  174. num_gmd: 0,
  175. newer_bfb: "",
  176. beanBalance: 2560,
  177. showExchange: false,
  178. exchangeAmount: "",
  179. mCoinBalance: 0,
  180. signNotify: true,
  181. signRewards: [{
  182. dayNum: "01",
  183. reward: "10星源",
  184. isVip: false,
  185. },
  186. {
  187. dayNum: "02",
  188. reward: "15星源",
  189. isVip: false,
  190. },
  191. {
  192. dayNum: "03",
  193. reward: "20星源",
  194. isVip: false,
  195. },
  196. {
  197. dayNum: "04",
  198. reward: "25星源",
  199. isVip: false,
  200. },
  201. {
  202. dayNum: "05",
  203. reward: "30星源",
  204. isVip: false,
  205. },
  206. {
  207. dayNum: "06",
  208. reward: "35星源",
  209. isVip: true,
  210. },
  211. {
  212. dayNum: "07",
  213. reward: "50星源",
  214. isVip: true,
  215. },
  216. ],
  217. signInfo: {
  218. signDay: 1,
  219. isSigned: false,
  220. reward: 0,
  221. },
  222. taskList: [],
  223. };
  224. },
  225. onLoad() {
  226. this.loadData();
  227. this.getSignInfo();
  228. },
  229. onShow() {},
  230. methods: {
  231. opencheckInPopUpWindow() {
  232. this.$refs.checkInPopUpWindow.open();
  233. },
  234. closecheckInPopUpWindow() {
  235. this.$refs.checkInPopUpWindow.close();
  236. },
  237. openNicknamePopUpWindow() {
  238. this.$refs.NicknamePopUpWindow.open();
  239. },
  240. closeNicknamePopUpWindow() {
  241. this.$refs.NicknamePopUpWindow.close();
  242. },
  243. onBack() {},
  244. loadData() {
  245. uni.request({
  246. url: this.$apiHost + "/Job/getlist",
  247. data: {
  248. uuid: getApp().globalData.uuid,
  249. },
  250. header: {
  251. "content-type": "application/json",
  252. sign: getApp().globalData.headerSign,
  253. },
  254. success: (res) => {
  255. console.log("----:", res.data);
  256. this.num_gmd = res.data.num_gmd;
  257. this.newer_bfb = res.data.newer_bfb;
  258. this.taskList = res.data.list;
  259. },
  260. complete: (com) => {
  261. // uni.hideLoading();
  262. },
  263. fail: (e) => {
  264. console.log("----e:", e);
  265. },
  266. });
  267. },
  268. // 获取签到信息
  269. getSignInfo() {
  270. uni.request({
  271. url: this.$apiHost + "/User/sign7Day",
  272. data: {
  273. uuid: getApp().globalData.uuid,
  274. action: "get",
  275. },
  276. header: {
  277. "content-type": "application/json",
  278. sign: getApp().globalData.headerSign,
  279. },
  280. success: (res) => {
  281. if (res.data.success === "yes") {
  282. this.signInfo = {
  283. signDay: res.data.data.sign_day,
  284. isSigned: res.data.data.is_signed,
  285. reward: res.data.data.reward || 0,
  286. };
  287. }
  288. },
  289. fail: (e) => {
  290. console.log("获取签到信息失败:", e);
  291. },
  292. });
  293. uni.request({
  294. url: this.$apiHost + "/User/getinfo",
  295. data: {
  296. uuid: getApp().globalData.uuid,
  297. skey: getApp().globalData.skey,
  298. },
  299. header: {
  300. "content-type": "application/json",
  301. sign: getApp().globalData.headerSign,
  302. },
  303. success: (res) => {
  304. this.myinfo = res.data;
  305. },
  306. complete: (com) => {},
  307. fail: (e) => {
  308. console.log("----e:", e);
  309. },
  310. });
  311. },
  312. // 显示兑换弹窗
  313. showExchangePopup() {
  314. this.showExchange = true;
  315. },
  316. // 隐藏兑换弹窗
  317. hideExchangePopup() {
  318. this.showExchange = false;
  319. },
  320. // 切换签到通知开关
  321. toggleSignNotify(falg) {
  322. this.signNotify = falg;
  323. },
  324. // 确认签到
  325. confirmSign() {
  326. if (this.signInfo.isSigned) {
  327. uni.showToast({
  328. title: "今日已签到",
  329. icon: "none",
  330. });
  331. return;
  332. }
  333. uni.request({
  334. url: this.$apiHost + "/User/sign7Day",
  335. data: {
  336. uuid: getApp().globalData.uuid,
  337. action: "sign",
  338. },
  339. header: {
  340. "content-type": "application/json",
  341. sign: getApp().globalData.headerSign,
  342. },
  343. success: (res) => {
  344. if (res.data.success === "yes") {
  345. uni.showToast({
  346. title: res.data.str,
  347. icon: "none",
  348. });
  349. // 更新签到信息
  350. this.getSignInfo();
  351. // 更新星源数量
  352. this.loadData();
  353. } else {
  354. uni.showToast({
  355. title: res.data.str,
  356. icon: "none",
  357. });
  358. }
  359. },
  360. fail: (e) => {
  361. console.log("签到失败:", e);
  362. uni.showToast({
  363. title: "签到失败,请稍后重试",
  364. icon: "none",
  365. });
  366. },
  367. });
  368. },
  369. // 确认兑换
  370. confirmExchange() {
  371. if (!this.exchangeAmount) {
  372. uni.showToast({
  373. title: "请输入兑换数量",
  374. icon: "none",
  375. });
  376. return;
  377. }
  378. const amount = parseInt(this.exchangeAmount);
  379. if (isNaN(amount) || amount <= 0) {
  380. uni.showToast({
  381. title: "请输入有效数量",
  382. icon: "none",
  383. });
  384. return;
  385. }
  386. if (amount % 10 !== 0) {
  387. uni.showToast({
  388. title: "兑换数量必须是10的倍数",
  389. icon: "none",
  390. });
  391. return;
  392. }
  393. let that = this;
  394. uni.request({
  395. url: this.$apiHost + "/User/gmmToGMD",
  396. data: {
  397. uuid: getApp().globalData.uuid,
  398. num: amount,
  399. },
  400. header: {
  401. "content-type": "application/json",
  402. sign: getApp().globalData.headerSign,
  403. },
  404. success: (res) => {
  405. console.log("----:", res.data);
  406. uni.showToast({
  407. title: res.data.str,
  408. icon: "none",
  409. });
  410. if (res.data.success == "yes") {
  411. this.hideExchangePopup();
  412. this.exchangeAmount = "";
  413. setTimeout(function() {
  414. that.loadData();
  415. }, 900);
  416. }
  417. },
  418. complete: (com) => {
  419. // uni.hideLoading();
  420. this.closeNicknamePopUpWindow()
  421. },
  422. fail: (e) => {
  423. console.log("----e:", e);
  424. },
  425. });
  426. // // 模拟兑换处理
  427. // uni.showToast({
  428. // title: "兑换成功,获得" + amount + "星源",
  429. // icon: 'none'
  430. // });
  431. // this.beanBalance += amount;
  432. // this.hideExchangePopup();
  433. // this.exchangeAmount = '';
  434. },
  435. claimReward(index) {
  436. if (this.taskList[index].status == 9) {
  437. uni.showToast({
  438. title: "已领取该奖励",
  439. icon: "none",
  440. });
  441. return;
  442. }
  443. let that = this;
  444. uni.request({
  445. url: this.$apiHost + "/Job/doAct",
  446. data: {
  447. uuid: getApp().globalData.uuid,
  448. id: this.taskList[index].id,
  449. },
  450. header: {
  451. "content-type": "application/json",
  452. sign: getApp().globalData.headerSign,
  453. },
  454. success: (res) => {
  455. console.log("----:", res.data);
  456. if (res.data.success == "yes") {
  457. uni.showToast({
  458. title: res.data.str,
  459. icon: "none",
  460. });
  461. setTimeout(function() {
  462. that.loadData();
  463. }, 900);
  464. }
  465. },
  466. complete: (com) => {
  467. // uni.hideLoading();
  468. },
  469. fail: (e) => {
  470. console.log("----e:", e);
  471. },
  472. });
  473. },
  474. },
  475. };
  476. </script>
  477. <style scoped lang="scss">
  478. @import "job.scss";
  479. </style>