123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448 |
- <template>
- <view class="page">
- <!-- 顶部黄色背景 -->
- <view class="top-bg"></view>
- <!-- 内容区域 -->
- <view class="content-area">
- <!-- 彩豆余额展示区 -->
- <view class="bean-balance">
- <view class="balance-header">
- <view class="title-area">
- <view class="yellow-dot"></view>
- <text class="my-bean-title">我的彩豆</text>
- </view>
- <view class="exchange-btn" @click="showExchangePopup">兑换</view>
- </view>
- <view class="bean-number">{{num_gmd}}</view>
- </view>
- <!-- 星愿打卡区域 -->
- <view class="sign-cards">
- <view class="card purple-card">
- <view class="card-title">初次见面礼</view>
- <view class="card-desc">完善个人资料可得</view>
- <view class="card-reward">奖励+100彩豆</view>
- <view class="card-progress">{{newer_bfb}}</view>
- </view>
- <view class="card yellow-card">
- <view class="card-title">每日签到</view>
- <view class="card-desc">连续签到奖励更多</view>
- <view class="sign-btn" @click="showSignPopup">立即签到</view>
- </view>
- </view>
- <!-- 每日任务列表 -->
- <view class="task-list">
- <view class="task-header">
- <text class="task-title">每日任务</text>
- <text class="task-subtitle">获取免费彩豆</text>
- </view>
- <!-- 任务项列表 -->
- <view class="task-item" v-for="(item, index) in taskList" :key="index">
- <view class="task-info">
- <view class="task-name">{{item.name}}</view>
- <view class="task-desc">{{item.content}}</view>
- </view>
- <view class="task-reward">+{{item.num}}彩豆</view>
- <view class="task-btn" :class="{'task-completed': item.status == 9}" @click="claimReward(index)">
- {{item.status == 9 ? '已领取' : '领取'}}
- </view>
- </view>
- </view>
- </view>
- <!-- 彩豆兑换弹窗 -->
- <view class="exchange-popup" v-if="showExchange">
- <view class="popup-mask" @click="hideExchangePopup"></view>
- <view class="popup-content">
- <!-- 弹窗顶部信息栏 -->
- <view class="popup-header">
- <text class="available-balance">可用M币: 14500</text>
- <text class="exchange-title">兑换彩豆</text>
- </view>
- <!-- 兑换区域主体 -->
- <view class="exchange-area">
- <view class="exchange-title-area">
- <text class="exchange-main-title">M币兑换彩豆数</text>
- <text class="exchange-subtitle">兑换彩豆数必须是10的倍数</text>
- </view>
- <view class="input-area">
- <view class="bean-icon"></view>
- <input type="number" class="exchange-input" placeholder="请输入兑换彩豆数量" v-model="exchangeAmount" />
- </view>
- <!-- 操作按钮 -->
- <view class="action-area">
- <view class="exchange-btn-large" @click="confirmExchange">立即兑换彩豆</view>
- <text class="tips-text">彩豆可用于创作(生成图片、音乐等AI创作功能)</text>
- </view>
- </view>
- </view>
- </view>
- <!-- 签到弹窗 -->
- <view class="sign-popup" v-if="showSign">
- <view class="popup-mask" @click="hideSignPopup"></view>
- <view class="sign-popup-content">
- <!-- 弹窗顶部 -->
- <view class="sign-popup-header">
- <text class="sign-popup-title">每日签到领好礼</text>
- <view class="sign-notify-switch">
- <text class="sign-notify-text">签到消息提醒</text>
- <switch class="sign-switch" color="#9C27B0" :checked="signNotify" @change="toggleSignNotify" />
- </view>
- <view class="sign-days-tag">已签到{{signInfo.signDay}}天</view>
- </view>
- <!-- VIP特权区域 -->
- <view class="vip-area">
- <view class="vip-left">
- <text class="vip-text">VIP十通会员,签到享专属好礼</text>
- </view>
- <view class="vip-right">
- <text class="vip-offer">限时优惠 ></text>
- </view>
- </view>
- <!-- 签到奖励网格布局 -->
- <view class="sign-grid">
- <view class="sign-grid-item" v-for="(item, index) in signRewards" :key="index"
- :class="{'sign-received': index < signInfo.signDay || (index === signInfo.signDay - 1 && signInfo.isSigned)}">
- <view class="sign-day-num">{{item.dayNum}}</view>
- <view class="sign-item-img"></view>
- <view class="sign-item-name">{{item.reward}}</view>
- <view class="sign-vip-tag" v-if="item.isVip">VIP</view>
- <view class="sign-received-mask" v-if="index < signInfo.signDay || (index === signInfo.signDay - 1 && signInfo.isSigned)">
- <text class="received-text">已领取</text>
- </view>
- </view>
- </view>
- <!-- 底部签到按钮 -->
- <view class="sign-btn-large"
- :class="{'sign-btn-disabled': signInfo.isSigned}"
- @click="confirmSign">
- {{signInfo.isSigned ? '今日已签到' : '签到领取奖励'}}
- </view>
- </view>
- </view>
- <!-- 提示框 -->
- <DialogBox ref="DialogBox"></DialogBox>
- </view>
- </template>
- <script>
- export default {
- components: {},
- data() {
- return {
- title: '任务中心',
- myinfo: {},
- realname: '',
- num_gmd: 0,
- newer_bfb: '',
- beanBalance: 2560,
- showExchange: false,
- exchangeAmount: '',
- mCoinBalance: 14500,
- showSign: false,
- signNotify: true,
- signRewards: [{
- dayNum: '01',
- reward: '10彩豆',
- isVip: false
- },
- {
- dayNum: '02',
- reward: '15彩豆',
- isVip: false
- },
- {
- dayNum: '03',
- reward: '20彩豆',
- isVip: false
- },
- {
- dayNum: '04',
- reward: '25彩豆',
- isVip: false
- },
- {
- dayNum: '05',
- reward: '30彩豆',
- isVip: false
- },
- {
- dayNum: '06',
- reward: '35彩豆',
- isVip: true
- },
- {
- dayNum: '07',
- reward: '50彩豆',
- isVip: true
- }
- ],
- signInfo: {
- signDay: 1,
- isSigned: false,
- reward: 0
- },
- taskList: []
- }
- },
- onLoad() {
- this.loadData();
- this.getSignInfo();
- },
- onShow() {},
- methods: {
- onBack() {},
- loadData() {
- uni.request({
- url: this.$apiHost + '/Job/getlist',
- data: {
- uuid: getApp().globalData.uuid
- },
- header: {
- "content-type": "application/json",
- 'sign': getApp().globalData.headerSign
- },
- success: (res) => {
- console.log("----:", res.data);
- this.num_gmd = res.data.num_gmd;
- this.newer_bfb = res.data.newer_bfb;
- this.taskList = res.data.list;
- },
- complete: (com) => {
- // uni.hideLoading();
- },
- fail: (e) => {
- console.log("----e:", e);
- }
- });
- },
- // 获取签到信息
- getSignInfo() {
- uni.request({
- url: this.$apiHost + '/User/sign7Day',
- data: {
- uuid: getApp().globalData.uuid,
- action: 'get'
- },
- header: {
- "content-type": "application/json",
- 'sign': getApp().globalData.headerSign
- },
- success: (res) => {
- if(res.data.success === 'yes') {
- this.signInfo = {
- signDay: res.data.data.sign_day,
- isSigned: res.data.data.is_signed,
- reward: res.data.data.reward || 0
- };
- }
- },
- fail: (e) => {
- console.log("获取签到信息失败:", e);
- }
- });
- },
- // 显示兑换弹窗
- showExchangePopup() {
- this.showExchange = true;
- },
- // 隐藏兑换弹窗
- hideExchangePopup() {
- this.showExchange = false;
- },
- // 显示签到弹窗
- showSignPopup() {
- this.showSign = true;
- },
- // 隐藏签到弹窗
- hideSignPopup() {
- this.showSign = false;
- },
- // 切换签到通知开关
- toggleSignNotify(e) {
- this.signNotify = e.detail.value;
- },
- // 确认签到
- confirmSign() {
- if(this.signInfo.isSigned) {
- uni.showToast({
- title: "今日已签到",
- icon: 'none'
- });
- return;
- }
- uni.request({
- url: this.$apiHost + '/User/sign7Day',
- data: {
- uuid: getApp().globalData.uuid,
- action: 'sign'
- },
- header: {
- "content-type": "application/json",
- 'sign': getApp().globalData.headerSign
- },
- success: (res) => {
- if(res.data.success === 'yes') {
- uni.showToast({
- title: res.data.str,
- icon: 'none'
- });
- // 更新签到信息
- this.getSignInfo();
- // 更新彩豆数量
- this.loadData();
- } else {
- uni.showToast({
- title: res.data.str,
- icon: 'none'
- });
- }
- },
- fail: (e) => {
- console.log("签到失败:", e);
- uni.showToast({
- title: "签到失败,请稍后重试",
- icon: 'none'
- });
- }
- });
- },
- // 确认兑换
- confirmExchange() {
- if (!this.exchangeAmount) {
- uni.showToast({
- title: "请输入兑换数量",
- icon: 'none'
- });
- return;
- }
- const amount = parseInt(this.exchangeAmount);
- if (isNaN(amount) || amount <= 0) {
- uni.showToast({
- title: "请输入有效数量",
- icon: 'none'
- });
- return;
- }
- if (amount % 10 !== 0) {
- uni.showToast({
- title: "兑换数量必须是10的倍数",
- icon: 'none'
- });
- return;
- }
- let that = this;
- uni.request({
- url: this.$apiHost + '/User/gmdToGMM',
- data: {
- uuid: getApp().globalData.uuid,
- num: amount
- },
- header: {
- "content-type": "application/json",
- 'sign': getApp().globalData.headerSign
- },
- success: (res) => {
- console.log("----:", res.data);
- uni.showToast({
- title: res.data.str,
- icon: 'none'
- });
- if (res.data.success == 'yes') {
- this.hideExchangePopup();
- this.exchangeAmount = '';
- setTimeout(function() {
- that.loadData();
- }, 900);
- }
- },
- complete: (com) => {
- // uni.hideLoading();
- },
- fail: (e) => {
- console.log("----e:", e);
- }
- });
- // // 模拟兑换处理
- // uni.showToast({
- // title: "兑换成功,获得" + amount + "彩豆",
- // icon: 'none'
- // });
- // this.beanBalance += amount;
- // this.hideExchangePopup();
- // this.exchangeAmount = '';
- },
- claimReward(index) {
- if (this.taskList[index].status == 9) {
- uni.showToast({
- title: "已领取该奖励",
- icon: 'none'
- });
- return;
- }
- let that = this;
- uni.request({
- url: this.$apiHost + '/Job/doAct',
- data: {
- uuid: getApp().globalData.uuid,
- id: this.taskList[index].id
- },
- header: {
- "content-type": "application/json",
- 'sign': getApp().globalData.headerSign
- },
- success: (res) => {
- console.log("----:", res.data);
- if (res.data.success == 'yes') {
- uni.showToast({
- title: res.data.str,
- icon: 'none'
- });
- setTimeout(function() {
- that.loadData();
- }, 900);
- }
- },
- complete: (com) => {
- // uni.hideLoading();
- },
- fail: (e) => {
- console.log("----e:", e);
- }
- });
- },
- }
- }
- </script>
- <style scoped lang="scss">
- @import 'job.scss';
- </style>
|