123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285 |
- <template>
- <view class="container">
- <navBar :show-title="true" :title="$t('home.节点认购')" url="/pages/index/index"></navBar>
- <view class="text-center border-linear-gradient">
- <image class="contentImg" src="../../static/img/nodeBg.png" mode="widthFix"></image>
- <view class="title flex-center" style="margin-top: -80rpx;">
- <view>{{$t('home.认购价')}}:</view>
- <view class="num text-linear-gradient">{{.1}}U</view>
- </view>
- <view class="title flex-center">
- <view>{{$t('home.认购数')}}:</view>
- <view class="num text-linear-gradient">10000个</view>
- </view>
- <view class="title flex-center">
- <view>{{$t('home.社区建设')}}</view>
- </view>
- <view class="buttom" @click="openPayMoney">
- {{$t('home.立即认购')}}
- </view>
- </view>
- <view class="detail border-linear-gradient">
- <view class="flex top">
- <view class="item">
- <view class="text-linear-gradient">
- {{order_num||0}}
- </view>
- <view class="tipText margin-t-20">
- {{$t('home.已认购')}}
- </view>
- </view>
- <view class="lineH">
- </view>
- <view class="item">
- <view class="text-linear-gradient">
- {{wait||0}}
- </view>
- <view class="tipText margin-t-20">
- {{$t('home.待释放')}}
- </view>
- </view>
- </view>
- <view class="flex padding-c-30 padding-v-20">
- <view class="flex">
- <view class="imageTip margin-r-10">
- <image class="nodeImg" src="../../static/img/nodeIcon.png" mode=""></image>
- </view>
- <view class="typename">
- {{$t('home.释放记录')}}
- </view>
- </view>
- <navigator url="./nodeDetail">
- <view class="flex-center">
- <view class="rightTip margin-r-10">
- {{$t('home.查看详细')}}
- </view>
- <image class="nextImg" src="../../static/img/mininext.png" mode="scaleToFill"></image>
- </view>
- </navigator>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- loadIndexs,
- creatorPoint,
- payPoint,
- pointCalculator,
- myList
- } from '@/api/index.js';
- import {
- mapMutations
- } from "vuex";
- import {
- getUserInfo
- } from '@/api/user.js';
- import navBar from "@/components/nav/nav.vue"
- export default {
- data() {
- return {
- num: '',
- order_num:'',
- wait:'',
- }
- },
- components: {
- navBar
- },
- onLoad(option) {
- this.getUserInfo();
- },
- methods: {
- ...mapMutations('user', ['setUserInfo']),
- // 获取更新用户信息
- getUserInfo() {
- getUserInfo().then((res) => {
- this.setUserInfo(res.data);
- }).catch((res) => {
- console.log(res);
- })
- loadIndexs().then((res) => {
- this.num = res.data.point_num
- }).catch((res) => {
- console.log(res);
- })
- myList().then(({data}) => {
- this.order_num = data.order_num;
- this.wait = data.wait;
- }).catch((res) => {
- console.log(res);
- })
- },
- // 报单
- openPayMoney() {
- const that = this;
- uni.showActionSheet({
- title: that.$t("home.请选择支付方式"),
- itemList: ['USDT', that.$t("home.余额")],
- success(res) {
- uni.showLoading({
- mask: true
- });
- that.creatorOrder(res.tapIndex)
- }
- })
- },
- // 生成订单
- creatorOrder(index) {
- creatorPoint({
- num: this.num * 1,
- }).then(({
- data
- }) => {
- this.payOrder(index + 1, data.id)
- }).catch((res) => {
- console.log(res);
- })
- },
- // 支付订单
- async payOrder(ind, id) {
- const that = this;
- let pushData = {
- num: this.num * 1,
- type: ind
- }
- try {
- if (ind == 1) {
- const {
- data
- } = await pointCalculator({
- id
- });
- const txHash = await ethereum.request({
- method: 'eth_sendTransaction',
- params: [{
- from: that.userInfo.address, // The user's active address.
- to: data.data.to,
- value: 0,
- data: data.data.data,
- }]
- })
- const req = await payPoint(id, {
- type: ind,
- transactionHash: txHash,
- });
- }
- if (ind == 2) {
- const req = await payPoint(id, {
- type: ind
- });
- }
- that.getUserInfo();
- uni.showToast({
- title: that.$t('home.认购成功')
- })
- } catch (e) {
- console.log(e, 'err');
- uni.showToast({
- title: that.$t('home.认购失败'),
- icon: 'error'
- })
- }
- },
- },
- }
- </script>
- <style lang="scss">
- .contentImg {
- margin: 0 auto;
- width: 100%;
- margin-top: -200rpx;
- }
- .container {
- width: 100%;
- line-height: 1;
- background-color: rgb(12, 8, 21);
- min-height: 100vh;
- }
- .detail {
- margin: 30rpx 30rpx 0 30rpx;
- border-radius: 30rpx;
- .top {
- justify-content: space-around;
- padding: 30rpx;
- color: #FFF;
- font-weight: 500;
- border-bottom: 1px solid #E1E1E1;
- margin: 0 30rpx;
- .item {
- text-align: center;
- font-weight: bold;
- font-size: 38rpx;
- .tipText {
- font-size: 22rpx;
- opacity: 0.8;
- }
- }
- .lineH {
- height: 92rpx;
- width: 2px;
- background: linear-gradient(0deg, rgba(255, 255, 255, 0), #FFFFFF, rgba(255, 255, 255, 0));
- }
- }
- .typename {
- font-size: 30rpx;
- color: #FFF;
- }
- .imageTip {
- .nodeImg {
- width: 36rpx;
- height: 33rpx;
- }
- }
- .rightTip {
- color: #FFF;
- font-size: 24rpx;
- }
- .nextImg {
- width: 8rpx;
- height: 14rpx;
- }
- }
- .text-center {
- border-radius: 30rpx;
- margin: 100rpx 30rpx 0 30rpx;
- color: #FFF;
- padding: 80rpx 50rpx;
- .title {
- font-weight: 500;
- font-size: 33rpx;
- padding-bottom: 50rpx;
- // align-items: flex-end;
- }
- .num {
- font-weight: bold;
- font-size: 52rpx;
- }
- }
- .buttom {
- font-weight: bold;
- font-size: 32rpx;
- border-radius: 20rpx;
- padding: 30rpx;
- background: linear-gradient(to right, #7D32FF 0%, #3EE0FF 100%);
- }
- </style>
|