job copy.vue 11 KB

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