task.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  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">2560</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">80%</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>
  31. </view>
  32. <!-- 每日任务列表 -->
  33. <view class="task-list">
  34. <view class="task-header">
  35. <text class="task-title">每日任务</text>
  36. <text class="task-subtitle">获取免费彩豆</text>
  37. </view>
  38. <!-- 任务项列表 -->
  39. <view class="task-item" v-for="(item, index) in taskList" :key="index">
  40. <view class="task-info">
  41. <view class="task-name">{{item.name}}</view>
  42. <view class="task-desc">{{item.desc}}</view>
  43. </view>
  44. <view class="task-reward">+{{item.reward}}彩豆</view>
  45. <view class="task-btn" :class="{'task-completed': item.completed}" @click="claimReward(index)">
  46. {{item.completed ? '已领取' : '领取'}}
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <!-- 彩豆兑换弹窗 -->
  52. <view class="exchange-popup" v-if="showExchange">
  53. <view class="popup-mask" @click="hideExchangePopup"></view>
  54. <view class="popup-content">
  55. <!-- 弹窗顶部信息栏 -->
  56. <view class="popup-header">
  57. <text class="available-balance">可用M币: 14500</text>
  58. <text class="exchange-title">兑换彩豆</text>
  59. </view>
  60. <!-- 兑换区域主体 -->
  61. <view class="exchange-area">
  62. <view class="exchange-title-area">
  63. <text class="exchange-main-title">M币兑换彩豆数</text>
  64. <text class="exchange-subtitle">兑换彩豆数必须是10的倍数</text>
  65. </view>
  66. <view class="input-area">
  67. <view class="bean-icon"></view>
  68. <input type="number" class="exchange-input" placeholder="请输入兑换彩豆数量" v-model="exchangeAmount" />
  69. </view>
  70. <!-- 操作按钮 -->
  71. <view class="action-area">
  72. <view class="exchange-btn-large" @click="confirmExchange">立即兑换彩豆</view>
  73. <text class="tips-text">彩豆可用于创作(生成图片、音乐等AI创作功能)</text>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. <!-- 签到弹窗 -->
  79. <view class="sign-popup" v-if="showSign">
  80. <view class="popup-mask" @click="hideSignPopup"></view>
  81. <view class="sign-popup-content">
  82. <!-- 弹窗顶部 -->
  83. <view class="sign-popup-header">
  84. <text class="sign-popup-title">每日签到领好礼</text>
  85. <view class="sign-notify-switch">
  86. <text class="sign-notify-text">签到消息提醒</text>
  87. <switch class="sign-switch" color="#9C27B0" :checked="signNotify" @change="toggleSignNotify" />
  88. </view>
  89. <view class="sign-days-tag">已签到1天</view>
  90. </view>
  91. <!-- VIP特权区域 -->
  92. <view class="vip-area">
  93. <view class="vip-left">
  94. <text class="vip-text">VIP十通会员,签到享专属好礼</text>
  95. </view>
  96. <view class="vip-right">
  97. <text class="vip-offer">限时优惠 ></text>
  98. </view>
  99. </view>
  100. <!-- 签到奖励网格布局 -->
  101. <view class="sign-grid">
  102. <view class="sign-grid-item" v-for="(item, index) in signRewards" :key="index"
  103. :class="{'sign-received': index === 0}">
  104. <view class="sign-day-num">{{item.dayNum}}</view>
  105. <view class="sign-item-img"></view>
  106. <view class="sign-item-name">{{item.reward}}</view>
  107. <view class="sign-vip-tag" v-if="item.isVip">VIP</view>
  108. <view class="sign-received-mask" v-if="index === 0">
  109. <text class="received-text">已领取</text>
  110. </view>
  111. </view>
  112. </view>
  113. <!-- 底部签到按钮 -->
  114. <view class="sign-btn-large" @click="confirmSign">签到领取奖励</view>
  115. </view>
  116. </view>
  117. <!-- 提示框 -->
  118. <DialogBox ref="DialogBox"></DialogBox>
  119. </view>
  120. </template>
  121. <script>
  122. export default {
  123. components: {},
  124. data() {
  125. return {
  126. title: '任务中心',
  127. myinfo: {},
  128. realname: '',
  129. idcard: '',
  130. beanBalance: 2560,
  131. showExchange: false,
  132. exchangeAmount: '',
  133. mCoinBalance: 14500,
  134. showSign: false,
  135. signNotify: true,
  136. signRewards: [
  137. { dayNum: '01', reward: '海浪*3天', isVip: false },
  138. { dayNum: '02', reward: '红玫瑰*3', isVip: false },
  139. { dayNum: '03', reward: '樱花*3', isVip: false },
  140. { dayNum: '04', reward: '星辰*7天', isVip: false },
  141. { dayNum: '05', reward: '红玫瑰*5', isVip: false },
  142. { dayNum: '06', reward: '樱花*5', isVip: true },
  143. { dayNum: '07', reward: '特别奖励', isVip: true }
  144. ],
  145. taskList: [
  146. {
  147. name: '每日首次发布作品',
  148. desc: '当日首次发布作品即可获得奖励',
  149. reward: 20,
  150. completed: false
  151. },
  152. {
  153. name: '分享作品领彩豆',
  154. desc: '分享作品到社交平台即可获得奖励',
  155. reward: 20,
  156. completed: false
  157. },
  158. {
  159. name: '邀请好友领彩豆',
  160. desc: '成功邀请一位好友注册',
  161. reward: 50,
  162. completed: false
  163. },
  164. {
  165. name: '充值赠礼',
  166. desc: '首次充值即可获得额外奖励',
  167. reward: 30,
  168. completed: false
  169. },
  170. {
  171. name: '口碑缔造者',
  172. desc: '给他人作品评论5次',
  173. reward: 20,
  174. completed: false
  175. }
  176. ]
  177. }
  178. },
  179. onLoad() {
  180. this.loadInfo();
  181. },
  182. onShow() {},
  183. methods: {
  184. onBack() {},
  185. loadInfo() {
  186. uni.request({
  187. url: this.$apiHost + '/My/idcheck',
  188. data: {
  189. uuid: getApp().globalData.uuid
  190. },
  191. header: {
  192. "content-type": "application/json",
  193. 'sign': getApp().globalData.headerSign
  194. },
  195. success: (res) => {
  196. console.log("----:", res.data);
  197. this.myinfo = res.data;
  198. },
  199. complete: (com) => {
  200. // uni.hideLoading();
  201. },
  202. fail: (e) => {
  203. console.log("----e:", e);
  204. }
  205. });
  206. },
  207. // 显示兑换弹窗
  208. showExchangePopup() {
  209. this.showExchange = true;
  210. },
  211. // 隐藏兑换弹窗
  212. hideExchangePopup() {
  213. this.showExchange = false;
  214. },
  215. // 显示签到弹窗
  216. showSignPopup() {
  217. this.showSign = true;
  218. },
  219. // 隐藏签到弹窗
  220. hideSignPopup() {
  221. this.showSign = false;
  222. },
  223. // 切换签到通知开关
  224. toggleSignNotify(e) {
  225. this.signNotify = e.detail.value;
  226. },
  227. // 确认签到
  228. confirmSign() {
  229. uni.showToast({
  230. title: "签到成功,获得今日奖励",
  231. icon: 'none'
  232. });
  233. this.hideSignPopup();
  234. },
  235. // 确认兑换
  236. confirmExchange() {
  237. if (!this.exchangeAmount) {
  238. uni.showToast({
  239. title: "请输入兑换数量",
  240. icon: 'none'
  241. });
  242. return;
  243. }
  244. const amount = parseInt(this.exchangeAmount);
  245. if (isNaN(amount) || amount <= 0) {
  246. uni.showToast({
  247. title: "请输入有效数量",
  248. icon: 'none'
  249. });
  250. return;
  251. }
  252. if (amount % 10 !== 0) {
  253. uni.showToast({
  254. title: "兑换数量必须是10的倍数",
  255. icon: 'none'
  256. });
  257. return;
  258. }
  259. // 模拟兑换处理
  260. uni.showToast({
  261. title: "兑换成功,获得" + amount + "彩豆",
  262. icon: 'none'
  263. });
  264. this.beanBalance += amount;
  265. this.hideExchangePopup();
  266. this.exchangeAmount = '';
  267. },
  268. claimReward(index) {
  269. if(this.taskList[index].completed) {
  270. uni.showToast({
  271. title: "已领取该奖励",
  272. icon: 'none'
  273. });
  274. return;
  275. }
  276. // 模拟领取奖励
  277. this.taskList[index].completed = true;
  278. this.beanBalance += this.taskList[index].reward;
  279. uni.showToast({
  280. title: "成功领取" + this.taskList[index].reward + "彩豆",
  281. icon: 'none'
  282. });
  283. },
  284. setSFZ() {
  285. if (this.realname == '') {
  286. uni.showToast({
  287. title: "请填写姓名",
  288. icon: 'none'
  289. });
  290. return;
  291. }
  292. if (this.idcard.length < 15) {
  293. uni.showToast({
  294. title: "请填写身份证号",
  295. icon: 'none'
  296. });
  297. return;
  298. }
  299. uni.request({
  300. url: this.$apiHost + '/My/setsfz',
  301. data: {
  302. uuid: getApp().globalData.uuid,
  303. realname: this.realname,
  304. idcard: this.idcard
  305. },
  306. header: {
  307. "content-type": "application/json",
  308. 'sign': getApp().globalData.headerSign
  309. },
  310. success: (res) => {
  311. console.log("----:", res.data);
  312. uni.showToast({
  313. title: res.data.str,
  314. icon: 'none'
  315. })
  316. if (res.data.success == 'yes') {
  317. this.loadInfo();
  318. }
  319. },
  320. complete: (com) => {
  321. // uni.hideLoading();
  322. },
  323. fail: (e) => {
  324. console.log("----e:", e);
  325. }
  326. });
  327. },
  328. }
  329. }
  330. </script>
  331. <style scoped lang="scss">
  332. @import 'task.scss';
  333. </style>