287 lines
6.0 KiB
Vue
287 lines
6.0 KiB
Vue
<template>
|
|
<view class="container" v-if="userInfo.user_id">
|
|
<view class="account-panel dis-flex flex-y-center">
|
|
<view class="panel-lable">
|
|
<text>账户余额</text>
|
|
</view>
|
|
<view class="panel-balance flex-box">
|
|
<text>¥{{ userInfo.balance }}</text>
|
|
</view>
|
|
</view>
|
|
<view class="recharge-panel">
|
|
<!-- <view class="recharge-label">
|
|
<text>实体卡号</text>
|
|
</view> -->
|
|
<!-- 实体卡号 -->
|
|
<!-- <view class="recharge-input">
|
|
<input type="text" placeholder="请输十二位实体卡号" v-model="number" @input="onChangeNumber" />
|
|
</view>
|
|
<view class="recharge-label"></view> -->
|
|
<view class="recharge-label">
|
|
<text>卡密</text>
|
|
</view>
|
|
<view class="recharge-input">
|
|
<input type="text" placeholder="请输入十六位卡密" v-model="key" @input="onChangeKey" />
|
|
<image class="scan" src="/static/order/scan.png" @click="scanCode"></image>
|
|
</view>
|
|
<!-- 确认按钮 -->
|
|
<view class="recharge-submit btn-submit">
|
|
<form @submit="onSubmit">
|
|
<button class="button" formType="submit" :disabled="disabled">确认兑换</button>
|
|
</form>
|
|
</view>
|
|
</view>
|
|
<!-- 兑换描述 -->
|
|
<view class="recharge-describe">
|
|
<view class="recharge-label">
|
|
<text>兑换说明</text>
|
|
</view>
|
|
<view class="content">
|
|
<text space="ensp">{{ setting.describe }}</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import * as UserApi from '@/api/user'
|
|
import * as CardApi from '@/api/card'
|
|
import SettingModel from '@/common/model/Setting'
|
|
import SettingKeyEnum from '@/common/enum/setting/Key'
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
// 正在加载
|
|
isLoading: true,
|
|
// 会员信息
|
|
userInfo: {},
|
|
// 分销设置
|
|
setting: {},
|
|
// 按钮禁用
|
|
disabled: false,
|
|
// 卡号,卡密
|
|
number: '',
|
|
key: ''
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
// 获取页面数据
|
|
this.getPageData()
|
|
},
|
|
|
|
methods: {
|
|
// 卡号输入框
|
|
onChangeNumber(e) {
|
|
this.number = e.target.value
|
|
},
|
|
|
|
// 卡密输入框
|
|
onChangeKey(e) {
|
|
this.key = e.target.value
|
|
},
|
|
|
|
// 获取页面数据
|
|
getPageData() {
|
|
const app = this
|
|
app.isLoading = true
|
|
Promise.all([app.getUserInfo(), app.getSetting()])
|
|
.then(() => app.isLoading = false)
|
|
},
|
|
|
|
// 获取会员信息
|
|
getUserInfo() {
|
|
const app = this
|
|
return new Promise((resolve, reject) => {
|
|
UserApi.info()
|
|
.then(result => {
|
|
app.userInfo = result.data.userInfo
|
|
resolve(app.userInfo)
|
|
})
|
|
})
|
|
},
|
|
|
|
// 获取充值设置
|
|
getSetting() {
|
|
const app = this
|
|
return new Promise((resolve, reject) => {
|
|
SettingModel.item(SettingKeyEnum.EXCHANGE.value, false)
|
|
.then(data => {
|
|
app.setting = data
|
|
resolve(data)
|
|
})
|
|
})
|
|
},
|
|
|
|
scanCode() {
|
|
uni.scanCode({
|
|
success: (res) => {
|
|
// 处理扫码结果
|
|
this.key = res.result
|
|
},
|
|
fail: (err) => {
|
|
this.$error('扫码失败')
|
|
}
|
|
});
|
|
},
|
|
|
|
// 立即兑换
|
|
onSubmit(e) {
|
|
const app = this
|
|
// 按钮禁用
|
|
app.disabled = true
|
|
// 提交到后端
|
|
CardApi.submit({ card_number: app.number, secret_key: app.key })
|
|
.then(result => {
|
|
app.$success('兑换处理中,请稍后查看')
|
|
this.number = ''
|
|
this.key = ''
|
|
setTimeout(() => {
|
|
// 获取页面数据
|
|
app.getPageData()
|
|
}, 1500)}
|
|
)
|
|
.finally(() => app.disabled = false)
|
|
}
|
|
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
page,
|
|
.container {
|
|
background: #fff;
|
|
}
|
|
|
|
.container {
|
|
padding-bottom: 70rpx;
|
|
}
|
|
|
|
/* 账户面板 */
|
|
.account-panel {
|
|
width: 650rpx;
|
|
height: 180rpx;
|
|
margin: 50rpx auto;
|
|
padding: 0 60rpx;
|
|
box-sizing: border-box;
|
|
border-radius: 12rpx;
|
|
color: #fff;
|
|
background: linear-gradient(-125deg, #a46bff, #786cff);
|
|
box-shadow: 0 5px 22px 0 rgba(0, 0, 0, 0.26);
|
|
}
|
|
|
|
.panel-lable {
|
|
font-size: 32rpx;
|
|
}
|
|
|
|
.recharge-label {
|
|
color: rgb(51, 51, 51);
|
|
font-size: 28rpx;
|
|
margin-bottom: 25rpx;
|
|
}
|
|
|
|
.panel-balance {
|
|
text-align: right;
|
|
font-size: 46rpx;
|
|
}
|
|
|
|
.recharge-panel {
|
|
margin-top: 60rpx;
|
|
padding: 0 60rpx;
|
|
}
|
|
|
|
/* 充值套餐 */
|
|
.recharge-plan {
|
|
.recharge-plan_item {
|
|
width: 192rpx;
|
|
padding: 15rpx 0;
|
|
float: left;
|
|
text-align: center;
|
|
color: #888;
|
|
border: 1rpx solid rgb(228, 228, 228);
|
|
border-radius: 10rpx;
|
|
margin: 0 20rpx 20rpx 0;
|
|
|
|
&:nth-child(3n + 0) {
|
|
margin-right: 0;
|
|
}
|
|
|
|
&.active {
|
|
color: #786cff;
|
|
border: 1rpx solid #786cff;
|
|
|
|
.plan_money {
|
|
color: #786cff;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
.plan_money {
|
|
font-size: 32rpx;
|
|
color: rgb(82, 82, 82);
|
|
}
|
|
|
|
.plan_gift {
|
|
font-size: 25rpx;
|
|
}
|
|
|
|
.recharge-input {
|
|
margin-top: 25rpx;
|
|
display: flex;
|
|
align-items: center;
|
|
image{
|
|
width: 35px;
|
|
height: 35px;
|
|
}
|
|
input {
|
|
border: 1rpx solid rgb(228, 228, 228);
|
|
border-radius: 10rpx;
|
|
padding: 15rpx 16rpx;
|
|
font-size: 26rpx;
|
|
flex: 1;
|
|
}
|
|
}
|
|
|
|
/* 立即充值 */
|
|
.recharge-submit {
|
|
margin-top: 70rpx;
|
|
}
|
|
|
|
.btn-submit {
|
|
.button {
|
|
font-size: 30rpx;
|
|
background: #786cff;
|
|
border: none;
|
|
color: white;
|
|
border-radius: 50rpx;
|
|
padding: 0 120rpx;
|
|
line-height: 3;
|
|
}
|
|
|
|
.button[disabled] {
|
|
background: #a098ff;
|
|
border-color: #a098ff;
|
|
color: white;
|
|
}
|
|
}
|
|
|
|
/* 充值说明 */
|
|
.recharge-describe {
|
|
margin-top: 50rpx;
|
|
padding: 0 60rpx;
|
|
|
|
.content {
|
|
font-size: 26rpx;
|
|
line-height: 1.6;
|
|
color: #888;
|
|
}
|
|
}
|
|
</style>
|