123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- <template>
- <view class="content">
- <view class="item flex">
- <view class="tit">
- 可兑换{{type == 1 ? '商城积分': '通证积分'}}
- </view>
- <input type="text" placeholder="" v-model="allNum" disabled/>
- </view>
- <view class="item flex">
- <view class="tit">
- 申请兑换数量
- </view>
- <input type="text" placeholder="请输入申请兑换数量" v-model="num" />
- </view>
- <view class="all" @click="getAll">
- 全部兑换
- </view>
- <view class="btn" @click="tradeMoney">
- 立即兑换
- </view>
- </view>
- </template>
- <script>
- // tradeMoney
- import { tradeMoney,passUser } from '@/api/zero.js'
- export default {
- data() {
- return {
- type: 0,// 0 通证-》阅读 1 商城-》复投
- num: '',
- allNum: 0,
- }
- },
- onLoad(opt) {
- this.type = opt.type
- if(this.type == 1) {
- uni.setNavigationBarTitle({
- title: '兑换复投积分'
- })
- }
- this.passUser()
- },
- onShow() {
-
- },
- onReachBottom() {
-
- },
- onReady() {
-
- },
- methods: {
- passUser() {
- passUser().then(res => {
- this.loading = false
- if(this.type == 1) {
- this.allNum = res.data.integral*1
- }else {
- this.allNum = res.data.pass ? res.data.pass:0
- }
- })
- },
- getAll() {
- this.num = this.allNum
- },
- tradeMoney() {
- //
- let that = this
- if(!that.num) {
- return that.$api.msg('请输入兑换数量')
- }
- if(that.num > that.allNum) {
- return that.$api.msg('兑换数量超出可兑换数量')
- }
- that.loading = true
- tradeMoney({
- num: that.num,
- type: that.type
- }).then(res => {
- uni.showToast({
- title:'兑换成功',
- duration:2000
- });
- this.num = ''
- this.passUser()
-
- }).catch( err => {
- that.loading = false
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- page {
- height: 100%;
- background-color: #fff;
- }
- .item {
- width: 710rpx;
- margin: auto;
- background-color: #fff;
- height: 110rpx;
- border-bottom: 1px solid #E6E6E6;
- .tit {
- line-height: 110rpx;
- font-size: 32rpx;
- }
- input {
- text-align: right;
- font-size: 36rpx;
- font-weight: bold;
- color: #333333;
- }
- }
- .all {
- padding: 20rpx;
- text-align: right;
- font-size: 26rpx;
- font-weight: 500;
- color: #FF4C4C;
- }
- .btn {
- width: 670rpx;
- line-height: 88rpx;
- background: #FF4C4C;
- border-radius: 10rpx;
-
- font-size: 32rpx;
- font-weight: bold;
- color: #FFFFFF;
- text-align: center;
- margin: 60rpx auto;
- }
- </style>
|