purchase-let/pages/gift/index.vue

232 lines
4.5 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="content">
<view class="head">
账户余额
<view class="num">
{{now_money}}
</view>
</view>
<view class="card">
<view class="card-head">
<view style="font-size: 32rpx;">
购买礼包
</view>
<view style="font-size: 28rpx;display: flex;align-items: center;color: #444444;"
@click="navgo('/pageQuota/Balance/index')">
购买记录<up-icon name="arrow-right"></up-icon>
</view>
</view>
<view class="card-ipt">
<text style="margin-right: 20rpx;">自定义金额</text>
<up-input placeholderStyle='font-size:32rpx' fontSize='56rpx' color='#FC452F' border='none'
v-model="money" placeholder="点击输入金额" @blur='setPrice' />
<view class="valid-text" v-if='money<300'>
最低购买300元
</view>
</view>
</view>
<view class="tips">
<view class="line"> </view>
<view class="">
<view style="font-size: 32rpx;font-weight: bold;margin-left: 20rpx;">
注意事项:
</view>
<view class='tips-li'>
1、购买礼包后的账户金额不能提现可用于消费使用
</view>
<view class='tips-li'>
2、购买礼包出现问题可联系平台客服也可拨打平台客服咨询热线08302669767
</view>
</view>
</view>
<view class="submit-btn">
<up-button text="确认购买" @click="submit" shape="circle" color="#EFCC6E"></up-button>
</view>
</view>
</template>
<script setup>
import {
rechargeApi,
rechargeAmountApi
} from "@/api/user.js";
import {
userInfoApi
} from "@/api/user.js"
import {
ref
} from "vue"
const money = ref('')
const now_money = ref(0)
const navgo = (url) => {
uni.navigateTo({
url
})
}
const setPrice = () => {
money.value = (+money.value).toFixed(2)
}
const submit = () => {
// #ifdef H5
return uni.$u.toast('当前环境不支持微信支付');
// #endif
if (money.value < 300) return uni.$u.toast('最低购买300元');
// #ifndef H5
rechargeApi({
price: money.value
}).then(res => {
uni.requestPayment({
provider: 'wxpay',
timeStamp: res.data.timeStamp,
nonceStr: res.data.nonceStr,
package: res.data.package,
signType: res.data.signType,
paySign: res.data.paySign,
success: (e) => {
if (e.errMsg == 'requestPayment:ok') {
uni.showModal({
title: '支付成功',
confirmText: '查看详情',
cancelText: '取消',
success: (e) => {
if (e.confirm) {
uni.redirectTo({
url: '/pageQuota/Balance/index'
})
} else uni.navigateBack();
}
})
} else uni.$u.toast('支付失败')
},
fail: (e) => {
uni.$u.toast('用户取消支付');
uni.redirectTo({
url: '/pages/gift/index'
})
}
})
})
// #endif
}
const getUser = () => {
userInfoApi().then(res => {
now_money.value = res.data.now_money
})
}
getUser()
</script>
<style lang='scss'>
.content {
width: 710rpx;
margin: 20rpx auto;
box-sizing: border-box;
min-height: 100vh;
.card {
background-color: white;
padding: 20rpx;
height: 300rpx;
box-sizing: border-box;
border-radius: 16rpx;
.card-head {
display: flex;
justify-content: space-between;
align-items: center;
}
.card-ipt {
display: flex;
align-items: center;
width: 630rpx;
margin: 0 auto;
height: 162rpx;
border-radius: 12rpx;
border: 2px solid #FFE5CB;
margin-top: 34rpx;
box-sizing: border-box;
padding: 0 20rpx;
color: #A26341;
position: relative;
.valid-text {
font-size: 18rpx;
color: #FC6957;
position: absolute;
top: 110rpx;
left: 170rpx;
}
}
}
.head {
background-image: url('https://lihai001.oss-cn-chengdu.aliyuncs.com/attach/44aaa202406081819375845.png');
height: 270rpx;
background-size: 100% 100%;
padding: 42rpx 30rpx;
padding-bottom: 62rpx;
box-sizing: border-box;
display: flex;
flex-direction: column;
justify-content: space-between;
font-size: 30rpx;
.num {
font-size: 64rpx;
color: #7B5232;
}
}
.tips {
margin-top: 40rpx;
position: relative;
.line {
background-color: #FF8056;
width: 6rpx;
height: 34rpx;
border-radius: 10rpx 10rpx 10rpx 10rpx;
position: absolute;
top: 5rpx;
}
.tips-li {
margin-top: 20rpx;
font-size: 24rpx;
color: #7A7A7A;
}
}
.submit-btn {
position: absolute;
width: 710rpx;
bottom: 100rpx;
}
}
</style>