task.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736
  1. <template>
  2. <view class="app" :style="'min-height:'+(boxHeight)+'px;'">
  3. <u-navbar :title="$t('任务')" :height="'90rpx'" :titleStyle="{color: '#fff','fontSize':'36rpx'}"
  4. bgColor="transparent" :autoBack="false" :placeholder="true" :safeAreaInsetTop="true">
  5. <view slot="left" @click="goBack()">
  6. <u-icon class="icon" name="arrow-left" size="46" color="#fff"></u-icon>
  7. </view>
  8. <view slot="right" class="right">
  9. <view class="nav-right-btn" @click="gotoPage('/pages/task/index')">
  10. <text>{{$t('每日任务')}}</text>
  11. </view>
  12. </view>
  13. </u-navbar>
  14. <view class="main">
  15. <view class="upgrade-box">
  16. <text class="label">{{$t('当前等级')}}</text>
  17. <text class="level" v-if="userInfo.member_level>0">{{userInfo.member_level}}{{$t('级DAO者')}}</text>
  18. <text class="level" v-else>{{$t('普通用户')}}</text>
  19. <text class="btn" @click="tab=2">{{$t('去升级')}}</text>
  20. </view>
  21. <view class="count-box">
  22. <view class="counts">
  23. <view class="label">
  24. {{$t('截止昨日已空投积分')}}
  25. </view>
  26. <view class="count">
  27. {{numberFormat(counts.day_total)}}
  28. </view>
  29. <view class="label">
  30. {{$t('获得奖励积分')}}
  31. </view>
  32. <view class="count">
  33. {{numberFormat(counts.award_total)}}
  34. </view>
  35. </view>
  36. <view class="count-cricle">
  37. <echarts v-if="loadCount" class="table" :option="options" :height="'280rpx'">
  38. </echarts>
  39. </view>
  40. </view>
  41. <view class="task-box">
  42. <view class="label">
  43. {{$t('新手任务')}} ({{complete}}/{{taskList.length}})
  44. </view>
  45. <view class="task-list">
  46. <view class="empty" v-if="!taskList || taskList.length<=0">
  47. <image class="icon" src="../../static/icons/user/icon-empty.png" mode="aspectFill"></image>
  48. </view>
  49. <view class="task-list-box" v-else>
  50. <view class="task-item" v-for="(v,k) in taskList" :key="k">
  51. <view class="logo">
  52. <image class="icon" src="../../static/icons/user/icon-task.png" mode="aspectFill">
  53. </image>
  54. </view>
  55. <view class="info">
  56. <view class="name">
  57. {{$t(v.name)}} <text class="num">({{v.log_num}}/{{v.check_type==2?1:v.num}})</text>
  58. </view>
  59. <view class="power">
  60. {{v.power}}{{$t('算力')}}
  61. </view>
  62. </view>
  63. <view class="options" v-if="v.status==2">
  64. <view class="btn complete">
  65. {{$t('已完成')}}
  66. </view>
  67. </view>
  68. <view class="options" v-else>
  69. <view class="btn" @click="taskUrl(v)">
  70. {{$t('去完成')}}
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. <!-- 升级 -->
  79. <u-popup class="popup-box popup-bottom-box" :show="tab==2" @close="(tab=1)" :zIndex="999"
  80. :safeAreaInsetTop="true" bgColor="#fff" round="20rpx" :closeOnClickOverlay="true" mode="bottom"
  81. :overlayStyle="{'z-index': 998}" :mask-custom-style="{backgroundColor:'transparent !important'}"
  82. @touchmove.stop.prevent
  83. :customStyle="{overflowY: 'scroll',border:'1rpx solid #fff',borderColor:'#333',height:'480rpx'}">
  84. <view class="popup-main">
  85. <view class="popup-title">
  86. <text class="title-text">{{$t('升级DAO等级')}}</text>
  87. </view>
  88. <view class="popup-main-box">
  89. <view class="account-box">
  90. <view class="account-item">
  91. <text class="label">{{$t('USDT余额')}}:</text>
  92. <text class="account">{{userInfo.usdt||'0.00'}} USDT</text>
  93. <text class="btn"
  94. @click="gotoPage('/pages/wallet/record?type=2&ct=1')">{{$t('升级记录')}}</text>
  95. </view>
  96. <view class="account-tips">
  97. <view class="tips">
  98. {{$t('下一级需累计收益')}}:{{userInfo.next_level_profit||'0.00'}}/{{userInfo.upgrade_profit_total||'0.00'}}
  99. USDT
  100. </view>
  101. <view class="tips">{{$t('下一级需要支付')}}:{{userInfo.next_level_usdt||'0.00'}} USDT</view>
  102. </view>
  103. </view>
  104. <view class="upgrade-box">
  105. <view class="icon-box">
  106. <image class="icon" src="../../static/icons/user/icon-upgrade.png" mode="aspectFit"></image>
  107. </view>
  108. <view class="level">{{$t(userInfo.next_level_name?userInfo.next_level_name:'普通用户')}}</view>
  109. <view class="price-box">
  110. <view class="price">
  111. <text class="text">{{userInfo.next_level_usdt||'0.00'}} </text>
  112. </view>
  113. </view>
  114. </view>
  115. <view class="buy-box">
  116. <view class="btn no" v-if="userInfo.next_level <= userInfo.member_level">
  117. {{$t('购买升级')}}
  118. </view>
  119. <view class="btn" v-else @click="showPayPopup()">
  120. {{$t('购买升级')}}
  121. </view>
  122. </view>
  123. </view>
  124. </view>
  125. </u-popup>
  126. <!-- 确认 -->
  127. <u-modal class="modal-box" :show="showPayModal" :title="$t('购买确认')" @confirm="buySubmit()"
  128. :cancelText="$t('取消')" style="z-index: 996;" confirmColor="#14ECCC" :showCancelButton="true"
  129. :confirmText="$t('确认购买')" :closeOnClickOverlay="true" @cancel="showPayModal=false"
  130. @close="showPayModal=false">
  131. <view class="modal-main">
  132. <view class="modal-main-box">
  133. <view class="pay-content">
  134. {{$t('确定支付')}}<text
  135. class="money">{{params.next_level_usdt||0}}</text>{{$t('USDT购买')}}{{$t(params.next_level_name)}}?
  136. </view>
  137. <u--form labelPosition="left" :model="params" ref="form" labelWidth="140rpx">
  138. <u-form-item :label="$t('交易密码')" prop="pay_password">
  139. <u--input v-model="params.pay_password" type="password" clearable maxlength="10"
  140. border="bottom" :placeholder="$t('请输入交易密码')" :focus="true">
  141. </u--input>
  142. </u-form-item>
  143. </u--form>
  144. </view>
  145. </view>
  146. </u-modal>
  147. <u-loading-icon class="loading" :show="loading" size="48" color="#14ECCC"
  148. custom-style="position:absolute;top:40%;left:0;right:0;margin:0 auto;z-index: 10099;">
  149. </u-loading-icon>
  150. </view>
  151. </template>
  152. <script>
  153. import echarts from '../../components/echarts.vue'
  154. export default {
  155. components: {
  156. echarts
  157. },
  158. data() {
  159. return {
  160. loading: false,
  161. loadCount: false,
  162. showPayModal: false,
  163. userInfo: {},
  164. taskList: [],
  165. tab: 1,
  166. tabType: 0,
  167. complete: 0,
  168. boxHeight: 800,
  169. counts: {
  170. day_total: '0.00',
  171. award_total: '0.00',
  172. total: '0.00',
  173. xd_total: '0.00',
  174. remain_total: '0.00',
  175. },
  176. params: {
  177. level: 0,
  178. next_level_name: '',
  179. next_level_usdt: '0.00',
  180. pay_password: '',
  181. },
  182. options: {
  183. tooltip: {
  184. trigger: 'item'
  185. },
  186. color: ['#14ECCC', '#f2f2f2'],
  187. series: [{
  188. type: 'pie',
  189. radius: ['84%', '100%'],
  190. avoidLabelOverlap: false,
  191. label: {
  192. show: true,
  193. position: 'center',
  194. fontSize: '16',
  195. fontWeight: 'bold'
  196. },
  197. emphasis: {
  198. label: {
  199. show: true,
  200. fontSize: '42',
  201. fontWeight: 'bold'
  202. }
  203. },
  204. labelLine: {
  205. show: true
  206. },
  207. data: [{
  208. value: 0,
  209. name: '0.00'
  210. },
  211. {
  212. value: 0,
  213. name: '0.00'
  214. }
  215. ]
  216. }]
  217. },
  218. }
  219. },
  220. onLoad(e) {
  221. this.tab = typeof(e.tab) != 'undefined' && e.tab > 0 ? e.tab : 1;
  222. if (this.tab == 2) {
  223. this.tabType = 1;
  224. }
  225. this.getInfo()
  226. this.getCounts()
  227. this.getTaskList()
  228. const windowInfo = uni.getWindowInfo();
  229. this.boxHeight = windowInfo.windowHeight
  230. },
  231. onPullDownRefresh() {
  232. this.getInfo()
  233. this.getTaskList()
  234. this.getCounts()
  235. uni.stopPullDownRefresh()
  236. },
  237. methods: {
  238. goBack() {
  239. uni.navigateBack()
  240. },
  241. numberFormat(num) {
  242. return (num >= 100000000) ? (this.$t('1亿')) : (num >= 10000 ?
  243. parseFloat(num / 10000).toFixed(2) + this.$t('万') : parseFloat(num).toFixed(2));
  244. },
  245. // 去完成任务
  246. taskUrl(row) {
  247. switch (row.scene) {
  248. case 1: // 观看直播
  249. case 7: // 打赏直播
  250. uni.navigateTo({
  251. url: '/pages/index/index?tab=3'
  252. })
  253. break;
  254. case 2: // 观看视频
  255. case 3: // 关注用户
  256. case 6: // 点赞视频
  257. case 8: // 评论视频
  258. case 11: // 收藏视频
  259. uni.navigateTo({
  260. url: '/pages/index/index'
  261. })
  262. break;
  263. case 4: // 用户升级
  264. uni.navigateTo({
  265. url: '/pages/user/upgrade'
  266. })
  267. break;
  268. case 5: // 上传视频
  269. uni.navigateTo({
  270. url: '/pages/video/index'
  271. })
  272. break;
  273. case 9: // 星豆充值
  274. uni.navigateTo({
  275. url: '/pages/wallet/recharge/xd'
  276. })
  277. break;
  278. case 10: // USDT充值
  279. uni.navigateTo({
  280. url: '/pages/wallet/recharge/usdt'
  281. })
  282. break;
  283. }
  284. },
  285. // 用户信息
  286. async getInfo() {
  287. let _this = this
  288. this.loading = true;
  289. const res = await this.$request.api('/user/info', {
  290. 'type': 'upgrade'
  291. })
  292. this.loading = false;
  293. if (res.success == true) {
  294. this.userInfo = res.data
  295. } else if (res.code == '403') {
  296. uni.showToast({
  297. title: this.$t('请先登录'),
  298. icon: 'none'
  299. })
  300. setTimeout(function() {
  301. uni.navigateTo({
  302. url: '/pages/login/login'
  303. })
  304. }, 800)
  305. } else {
  306. let msg = typeof(res.msg) != 'undefined' ? res.msg : this.$t('请求失败')
  307. uni.showToast({
  308. title: this.$t(msg),
  309. icon: 'none'
  310. })
  311. }
  312. },
  313. // 统计数据
  314. async getCounts() {
  315. let _this = this
  316. this.loading = true;
  317. const res = await this.$request.api('/account/scoreCount', {
  318. coin_type: 4,
  319. })
  320. this.loading = false;
  321. if (res.success == true) {
  322. this.counts = typeof(res.data) != 'undefined' && res.data ? res.data : {
  323. day_total: '0.00',
  324. award_total: '0.00',
  325. total: '0.00',
  326. xl_total: '0.00',
  327. remain_total: '0.00',
  328. };
  329. console.log(this.counts)
  330. this.options.series[0].data[0].value = this.counts.total
  331. this.options.series[0].data[0].name = this.numberFormat(this.counts.xl_total)
  332. this.options.series[0].data[1].value = this.counts.xl_total
  333. this.options.series[0].data[1].name = this.numberFormat(this.counts.total)
  334. }
  335. this.loadCount = true
  336. },
  337. // 任务列表
  338. async getTaskList() {
  339. let _this = this
  340. this.loading = true;
  341. const res = await this.$request.api('/task/index', {
  342. type: 2
  343. })
  344. this.loading = false;
  345. if (res.success == true) {
  346. this.taskList = typeof(res.data.list) != 'undefined' && res.data.list ? res.data.list : []
  347. this.complete = typeof(res.data.complete) != 'undefined' && res.data.complete ? res.data.complete :
  348. 0
  349. }
  350. },
  351. // 确认
  352. showPayPopup() {
  353. let _this = this
  354. this.params = {
  355. level: this.userInfo.next_level,
  356. next_level_name: this.userInfo.next_level_name,
  357. next_level_usdt: this.userInfo.next_level_usdt,
  358. pay_password: '',
  359. },
  360. this.showPayModal = true;
  361. },
  362. // 购买节点
  363. async buySubmit() {
  364. let _this = this
  365. if (_this.params.pay_password == '') {
  366. uni.showToast({
  367. style: 'z-index:10078',
  368. title: this.$t('请输入交易密码'),
  369. icon: 'none'
  370. })
  371. return false;
  372. }
  373. this.loading = true;
  374. const res = await this.$request.api('/user/upgrade', _this.params)
  375. this.loading = false;
  376. if (res.success == true) {
  377. uni.showToast({
  378. style: 'z-index:10078',
  379. title: this.$t(res.msg),
  380. icon: 'none'
  381. })
  382. this.showPayModal = false;
  383. this.getInfo()
  384. } else if (res.code == 401) {
  385. let msg = typeof(res.msg) != 'undefined' ? res.msg : this.$tt('请求失败')
  386. uni.showToast({
  387. title: this.$t(msg),
  388. style: 'z-index:10078',
  389. icon: 'none'
  390. })
  391. setTimeout(function() {
  392. console.log('跳转设置密码')
  393. uni.navigateTo({
  394. url: '/pages/user/profile/pay_password?type=upgrade'
  395. })
  396. }, 1200)
  397. } else if (res.code == 405) {
  398. let msg = typeof(res.msg) != 'undefined' ? res.msg : this.$tt('请求失败')
  399. uni.showToast({
  400. title: this.$t(msg),
  401. style: 'z-index:10078',
  402. icon: 'none'
  403. })
  404. setTimeout(function() {
  405. console.log('跳转充值')
  406. uni.navigateTo({
  407. url: '/pages/wallet/recharge/usdt?type=upgrade'
  408. })
  409. }, 1200)
  410. } else {
  411. let msg = typeof(res.msg) != 'undefined' ? res.msg : this.$t('请求失败')
  412. uni.showToast({
  413. title: this.$t(msg),
  414. style: 'z-index:10078',
  415. icon: 'none'
  416. })
  417. }
  418. }
  419. }
  420. }
  421. </script>
  422. <style lang="scss" scoped>
  423. page {
  424. height: 100%;
  425. width: 100%;
  426. min-height: 800rpx;
  427. }
  428. .app {
  429. // height: 100%;
  430. // padding-bottom: 120rpx;
  431. background: linear-gradient(to bottom, #333, #f2f2f2);
  432. // position: fixed;
  433. width: 100%;
  434. z-index: 1;
  435. }
  436. .nav-right-btn {
  437. color: #000;
  438. font-size: 24rpx;
  439. background-color: #14ECCC;
  440. padding: 10rpx 20rpx;
  441. border-radius: 10rpx;
  442. }
  443. .main {
  444. width: 100%;
  445. height: 100%;
  446. overflow-y: scroll;
  447. // overflow: hidden;
  448. .upgrade-box {
  449. margin: 30rpx 30rpx;
  450. padding: 40rpx 30rpx;
  451. background-color: #14ECCC;
  452. color: #333;
  453. border-radius: 10rpx;
  454. font-size: 28rpx;
  455. .level {
  456. font-size: 32rpx;
  457. font-weight: bold;
  458. color: #000;
  459. margin-left: 20rpx;
  460. vertical-align: middle;
  461. }
  462. .btn {
  463. background-color: #000;
  464. color: #fff;
  465. padding: 10rpx 30rpx;
  466. text-align: center;
  467. font-size: 32rpx;
  468. border-radius: 12rpx;
  469. float: right;
  470. vertical-align: middle;
  471. margin-top: -10rpx;
  472. }
  473. }
  474. .count-box {
  475. display: flex;
  476. flex-direction: row;
  477. justify-content: left;
  478. align-items: center;
  479. position: relative;
  480. // overflow: hidden;
  481. background-color: #fff;
  482. margin: 30rpx 30rpx 0;
  483. padding: 40rpx 30rpx;
  484. border-radius: 10rpx;
  485. .counts {
  486. width: calc(100% - 240rpx);
  487. .label {
  488. color: #666;
  489. padding: 10rpx 0;
  490. }
  491. .count {
  492. color: #333;
  493. font-weight: bold;
  494. margin-bottom: 20rpx;
  495. }
  496. }
  497. .count-cricle {
  498. width: 240rpx;
  499. position: relative;
  500. .table {
  501. width: 240rpx;
  502. }
  503. }
  504. }
  505. .task-box {
  506. margin: 30rpx 30rpx;
  507. padding: 40rpx 30rpx;
  508. background-color: #fff;
  509. color: #333;
  510. border-radius: 10rpx;
  511. font-size: 28rpx;
  512. .label {
  513. font-weight: bold;
  514. }
  515. .task-list {
  516. padding: 20rpx 0rpx;
  517. .task-list-box {
  518. // height: 640rpx;
  519. // overflow-y: scroll;
  520. .task-item {
  521. padding: 10rpx 0rpx;
  522. margin-bottom: 20rpx;
  523. display: flex;
  524. flex-direction: row;
  525. align-items: center;
  526. font-size: 28rpx;
  527. .logo {
  528. width: 64rpx;
  529. height: 64rpx;
  530. text-align: center;
  531. margin-right: 20rpx;
  532. .icon {
  533. width: 100%;
  534. height: 100%;
  535. }
  536. }
  537. .info {
  538. flex: 1;
  539. .name {
  540. .num {
  541. margin-left: 10rpx;
  542. }
  543. }
  544. .power {
  545. padding: 10rpx 0;
  546. color: #999;
  547. }
  548. }
  549. .options {
  550. .btn {
  551. color: #000;
  552. background-color: #14ECCC;
  553. padding: 10rpx 20rpx;
  554. border-radius: 10rpx;
  555. }
  556. .btn.complete {
  557. color: #fff;
  558. background-color: #ccc;
  559. }
  560. }
  561. }
  562. }
  563. }
  564. }
  565. }
  566. .popup-box {
  567. .popup-title {
  568. width: 100%;
  569. padding: 30rpx 0;
  570. text-align: center;
  571. font-size: 32rpx;
  572. font-weight: bold;
  573. border-bottom: 1rpx solid #f2f2f2;
  574. }
  575. .popup-main-box {
  576. padding: 20rpx 30rpx;
  577. .account-box {
  578. margin-bottom: 40rpx;
  579. background-color: #f2f2f2;
  580. padding: 30rpx 30rpx;
  581. border-radius: 10rpx;
  582. font-size: 30rpx;
  583. font-weight: bold;
  584. .account-item {
  585. .btn {
  586. float: right;
  587. background-color: #f2f2f2;
  588. padding: 4rpx 8rpx;
  589. border-radius: 4rpx;
  590. color: #579DC1;
  591. font-size: 24rpx;
  592. }
  593. }
  594. .account-tips {
  595. margin-top: 30rpx;
  596. .tips {
  597. color: #999;
  598. font-size: 24rpx;
  599. padding-bottom: 10rpx;
  600. }
  601. }
  602. }
  603. .upgrade-box {
  604. margin-bottom: 20rpx;
  605. background-color: #14ECCC;
  606. padding: 30rpx 30rpx;
  607. display: flex;
  608. flex-direction: row;
  609. align-items: center;
  610. justify-content: left;
  611. border-radius: 10rpx;
  612. .icon-box {
  613. .icon {
  614. width: 72rpx;
  615. height: 72rpx;
  616. }
  617. }
  618. .level {
  619. margin-left: 20rpx;
  620. flex: 1;
  621. font-weight: bold;
  622. }
  623. .price-box {
  624. .price {
  625. background-color: #000;
  626. color: #fff;
  627. padding: 10rpx 30rpx;
  628. border-radius: 10rpx;
  629. font-size: 28rpx;
  630. font-weight: bold;
  631. }
  632. }
  633. }
  634. .buy-box {
  635. margin: 50rpx 0 40rpx;
  636. .btn {
  637. padding: 20rpx 0;
  638. // margin: 0 30rpx;
  639. border-radius: 10rpx;
  640. background-color: #14ECCC;
  641. text-align: center;
  642. font-size: 32rpx;
  643. font-weight: bold;
  644. }
  645. .btn.no {
  646. color: #666;
  647. background-color: #e2e2e2;
  648. }
  649. }
  650. }
  651. }
  652. .modal-box {
  653. width: auto;
  654. /deep/ .u-modal__title {
  655. padding: 30rpx 0;
  656. }
  657. /deep/ .u-popup__content {
  658. width: auto;
  659. height: auto;
  660. .modal-main {
  661. width: 100%;
  662. .money {
  663. color: #579DC1;
  664. margin: 0 4rpx;
  665. font-weight: bold;
  666. }
  667. }
  668. }
  669. }
  670. </style>