234 lines
6.3 KiB
Vue
234 lines
6.3 KiB
Vue
<template>
|
|
<s-pages :bgStyle="{ color: 'var(--color1)' }" :title="dataObj.title" :pink_bg="true">
|
|
<view class="pages p-t-28 p-x-40">
|
|
<view class="radius12 pagesTop p-y-30 p-x-28 bg24">
|
|
<view class="c0">{{ dataObj.text0 }}</view>
|
|
<view class="m-b-28 border-bottom"
|
|
><uni-easyinput
|
|
v-model="num"
|
|
type="number"
|
|
placeholder=""
|
|
placeholder-style="font-size: 92rpx;"
|
|
@confirm="submit"
|
|
:inputBorder="false"
|
|
:min="0"
|
|
@blur="blur"
|
|
:clearSize="50"
|
|
/></view>
|
|
<view class="m-b-12 line48" v-if="dataObj.text">
|
|
{{ dataObj.text }}<span>{{ point }}</span
|
|
>{{ dataObj.text1 }},
|
|
<span class="c32" @click="num = point">全部{{ dataObj.title }}</span>
|
|
</view>
|
|
<view class="size24 infotext flex-center ju-flex-start c34">
|
|
<uni-icons class="m-l-16 m-r-6" type="info" color="" />
|
|
{{ dataObj.text2 }}
|
|
</view>
|
|
<view></view>
|
|
</view>
|
|
<view class="submit-btn m-t-66" @click="submit">{{ dataObj.title }}</view>
|
|
</view>
|
|
</s-pages>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { ref, getCurrentInstance } from 'vue';
|
|
import { onShow, onLoad } from '@dcloudio/uni-app';
|
|
import sheep from '@/sheep';
|
|
import * as api from '@/sheep/api/home/pay';
|
|
import * as incrementApi from '@/sheep/api/increment/index';
|
|
import * as userApi from '@/sheep/api/member/user';
|
|
const { proxy } = getCurrentInstance();
|
|
let num = ref(0);
|
|
let point = ref(0);
|
|
let type = ref(0);
|
|
let dataObj = ref({
|
|
title: '兑换',
|
|
text0: '金种子数量',
|
|
text: '',
|
|
text1: '金种子',
|
|
text2: '兑换比例:100积分=1金种子',
|
|
num: 'point',
|
|
subUrl: api.exchangeGoldSeed,
|
|
upName: 'goldSeedAmount',
|
|
});
|
|
const submit = () => {
|
|
if (!num.value) {
|
|
sheep.$helper.toast('请输入兑换数量');
|
|
return;
|
|
}
|
|
let obj = {};
|
|
let upName = dataObj.value.upName;
|
|
// obj[upName] = num.value;
|
|
switch (type.value) {
|
|
case 0: //绿色积分兑换金种子
|
|
obj[upName] = num.value;
|
|
break;
|
|
case 1: //交易所积分兑换金种子
|
|
obj[upName] = num.value * 100;
|
|
break;
|
|
case 2: //配票 向上取整
|
|
obj[upName] = Math.ceil(num.value / 0.85);
|
|
break;
|
|
case 3: //兑换原始积分
|
|
obj[upName] = num.value;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
dataObj.value.subUrl(obj).then((res) => {
|
|
if (res.code === 0) {
|
|
num.value = 0;
|
|
getInfo();
|
|
}
|
|
console.log(res);
|
|
});
|
|
};
|
|
const blur = () => {
|
|
if (num.value < 0) {
|
|
sheep.$helper.toast('兑换数量不能小于0');
|
|
num.value = 0;
|
|
return;
|
|
}
|
|
if (num.value > point.value) {
|
|
sheep.$helper.toast('兑换数量不能大于可兑换数量');
|
|
num.value = point.value;
|
|
return;
|
|
}
|
|
};
|
|
const getInfo = () => {
|
|
dataObj.value.info().then((res) => {
|
|
console.log(res);
|
|
if (res.code === 0) {
|
|
let num = res.data[dataObj.value.num];
|
|
// dataObj.value.text = `当前积分${num}, 可兑换`
|
|
// point.value = type.value === 0 || type.value === 1 ? Math.floor(num / 100) : num;
|
|
switch (type.value) {
|
|
case 0: //绿色积分兑换金种子
|
|
point.value = Math.floor(num / 100);
|
|
break;
|
|
case 1: //交易所积分兑换金种子
|
|
point.value = Math.floor(num / 100);
|
|
break;
|
|
case 2: //配票 向下取整
|
|
point.value = Math.floor(num * 0.85);
|
|
break;
|
|
case 3: //兑换原始积分
|
|
point.value = num;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
});
|
|
};
|
|
onLoad((e) => {
|
|
// type: 0 绿色积分 1增量积分
|
|
type.value = parseInt(e.type) || 0;
|
|
switch (type.value) {
|
|
case 0: //绿色积分兑换金种子
|
|
dataObj.value = {
|
|
title: '兑换',
|
|
text0: '金种子数量',
|
|
text: '当前可兑换',
|
|
text1: '金种子',
|
|
text2: '兑换比例:100积分=1金种子',
|
|
num: 'point',
|
|
subUrl: api.exchangeGoldSeed,
|
|
info: userApi.default.getUserInfo,
|
|
upName: 'goldSeedAmount',
|
|
};
|
|
break;
|
|
case 1: //交易所积分兑换金种子
|
|
dataObj.value = {
|
|
title: '兑换',
|
|
text0: '金种子数量',
|
|
text: '当前可兑换',
|
|
text1: '金种子',
|
|
text2: '兑换比例:100积分=1金种子',
|
|
num: 'exchangePoint',
|
|
subUrl: incrementApi.exPointChangeGoldSeed,
|
|
info: incrementApi.getUserGroupInfo,
|
|
upName: 'amount',
|
|
};
|
|
break;
|
|
case 2: //配票
|
|
dataObj.value = {
|
|
title: '配票',
|
|
text0: '增量积分',
|
|
text: '当前可配票',
|
|
text1: '积分',
|
|
text2: '需要核销15%的积分',
|
|
num: 'incrementPoint',
|
|
subUrl: incrementApi.incrPointChangeIncPoint,
|
|
info: incrementApi.getUserGroupInfo,
|
|
upName: 'amount',
|
|
};
|
|
break;
|
|
case 3: //兑换
|
|
dataObj.value = {
|
|
title: '兑换积分',
|
|
text0: '增量积分',
|
|
text: '当前可兑换',
|
|
text1: '积分',
|
|
text2: '兑换比例:1增量积分=1绿色积分',
|
|
num: 'incrementPoint',
|
|
subUrl: incrementApi.incrPointChangeExPoint,
|
|
info: incrementApi.getUserGroupInfo,
|
|
upName: 'amount',
|
|
};
|
|
break;
|
|
}
|
|
getInfo();
|
|
});
|
|
onShow(() => {
|
|
// getInfo();
|
|
});
|
|
</script>
|
|
<style scoped lang="scss">
|
|
:deep(.uni-icons) {
|
|
font-size: 24rpx !important;
|
|
}
|
|
|
|
:deep(.uni-easyinput__content) {
|
|
height: 108rpx;
|
|
font-size: 92rpx;
|
|
border-color: #4c505b;
|
|
}
|
|
|
|
:deep(.uni-easyinput__content-input) {
|
|
height: 108rpx;
|
|
font-size: 92rpx;
|
|
}
|
|
|
|
:deep(.uni-easyinput__placeholder-class) {
|
|
font-size: 92rpx;
|
|
}
|
|
|
|
:deep(.uni-input-input) {
|
|
// color: #ffffff;
|
|
}
|
|
|
|
.pagesTop {
|
|
background-color: #fff;
|
|
}
|
|
|
|
.infotext {
|
|
height: 62rpx;
|
|
background: #f2f2f2;
|
|
border-radius: 12rpx;
|
|
}
|
|
|
|
.c_FA7E31 {
|
|
color: #fa7e31;
|
|
}
|
|
|
|
:deep(.uniui-left) {
|
|
font-size: 44rpx !important;
|
|
}
|
|
|
|
:deep(.uni-icons) {
|
|
font-size: 44rpx !important;
|
|
}
|
|
</style>
|