钱包开发

master
xindan 2021-10-17 13:44:17 +08:00
parent a2fba661ce
commit fc07b32f98
4 changed files with 332 additions and 393 deletions

View File

@ -0,0 +1,4 @@
.form-container input {
height: 120rpx !important;
line-height: 120rpx !important;
}

View File

@ -1,139 +1,124 @@
<template>
<view class="form-container">
<view class="form-gorup bg-white money-container">
<view class="form-gorup-title">充值金额</view>
<input type="digit" name="money" :value="recharge_money_value || ''" placeholder-class="cr-grey" class="cr-base" placeholder="请输入充值金额" @input="recharge_money_value_input_event" maxlength="6">
</view>
<view class="form-gorup">
<button class="bg-main" type="default" hover-class="none" :disabled="form_submit_disabled_status" @tap="form_submit_event"></button>
</view>
</view>
</template>
<script>
const app = getApp();
export default {
data() {
return {
params: null,
data_bottom_line_status: false,
data_list_loding_status: 1,
data_list_loding_msg: '',
recharge_money_value: '',
form_submit_disabled_status: false
};
},
components: {},
props: {},
onLoad(params) {
this.setData({
params: params,
recharge_money_value: params.money || ''
});
},
onShow() {
this.init();
},
methods: {
init() {
var user = app.globalData.get_user_info(this, "init");
if (user != false) {
//
if (app.globalData.user_is_need_login(user)) {
uni.redirectTo({
url: "/pages/login/login?event_callback=init"
});
this.setData({
data_list_loding_status: 2,
data_list_loding_msg: '请先绑定手机号码'
});
return false;
}
} else {
this.setData({
data_list_loding_status: 2,
data_list_loding_msg: '请先授权用户信息'
});
}
},
//
recharge_money_value_input_event(e) {
this.setData({
recharge_money_value: e.detail.value || ''
});
},
//
form_submit_event(e) {
var self = this; //
if ((self.recharge_money_value || null) == null) {
app.globalData.showToast('请输入充值金额');
return false;
}
self.setData({
form_submit_disabled_status: true
});
uni.showLoading({
title: "处理中..."
});
uni.request({
url: app.globalData.get_request_url("create", "recharge", "wallet"),
method: "POST",
data: {
money: self.recharge_money_value
},
dataType: "json",
header: {
'content-type': 'application/x-www-form-urlencoded'
},
success: res => {
self.setData({
form_submit_disabled_status: false
});
uni.hideLoading();
if (res.data.code == 0) {
uni.redirectTo({
url: '/pages/plugins/wallet/user-recharge/user-recharge?is_pay=1&recharge_id=' + res.data.data.recharge_id
});
} else {
if (app.globalData.is_login_check(res.data)) {
app.globalData.showToast(res.data.msg);
} else {
app.globalData.showToast('提交失败,请重试!');
}
}
},
fail: () => {
self.setData({
form_submit_disabled_status: false
});
uni.hideLoading();
app.globalData.showToast("服务器请求出错");
}
});
}
}
};
</script>
<style>
.form-container .money-container {
padding-top: 30rpx;
}
.form-container .money-container input {
font-size: 60rpx;
height: 130rpx;
line-height: 130rpx;
}
<template>
<view>
<view class="form-container padding-main">
<view class="form-gorup padding-vertical-main">
<input type="digit" name="money" :value="recharge_money_value || ''" placeholder-class="cr-grey" class="cr-base text-size-xxl fw-b" placeholder="请输入充值金额" @input="recharge_money_value_input_event" maxlength="6">
</view>
<view class="form-gorup form-gorup-submit">
<button class="round cr-white bg-main br-main text-size" type="default" hover-class="none" :disabled="form_submit_disabled_status" @tap="form_submit_event"></button>
</view>
</view>
</view>
</template>
<script>
const app = getApp();
export default {
data() {
return {
params: null,
data_bottom_line_status: false,
data_list_loding_status: 1,
data_list_loding_msg: '',
recharge_money_value: '',
form_submit_disabled_status: false
};
},
components: {},
props: {},
onLoad(params) {
this.setData({
params: params,
recharge_money_value: params.money || ''
});
},
onShow() {
this.init();
},
methods: {
init() {
var user = app.globalData.get_user_info(this, "init");
if (user != false) {
//
if (app.globalData.user_is_need_login(user)) {
uni.redirectTo({
url: "/pages/login/login?event_callback=init"
});
this.setData({
data_list_loding_status: 2,
data_list_loding_msg: '请先绑定手机号码'
});
return false;
}
} else {
this.setData({
data_list_loding_status: 2,
data_list_loding_msg: '请先授权用户信息'
});
}
},
//
recharge_money_value_input_event(e) {
this.setData({
recharge_money_value: e.detail.value || ''
});
},
//
form_submit_event(e) {
//
if ((this.recharge_money_value || null) == null) {
app.globalData.showToast('请输入充值金额');
return false;
}
this.setData({
form_submit_disabled_status: true
});
uni.showLoading({
title: "处理中..."
});
uni.request({
url: app.globalData.get_request_url("create", "recharge", "wallet"),
method: "POST",
data: {
money: this.recharge_money_value
},
dataType: "json",
success: res => {
this.setData({
form_submit_disabled_status: false
});
uni.hideLoading();
if (res.data.code == 0) {
uni.redirectTo({
url: '/pages/plugins/wallet/user-recharge/user-recharge?is_pay=1&recharge_id=' + res.data.data.recharge_id
});
} else {
if (app.globalData.is_login_check(res.data)) {
app.globalData.showToast(res.data.msg);
} else {
app.globalData.showToast('提交失败,请重试!');
}
}
},
fail: () => {
this.setData({
form_submit_disabled_status: false
});
uni.hideLoading();
app.globalData.showToast("服务器请求出错");
}
});
}
}
};
</script>
<style>
@import './recharge.css';
</style>

View File

@ -0,0 +1,31 @@
/*
*
*/
.submit-container {
right: 20rpx;
bottom: 20rpx;
}
.submit-container button {
display: inline-flex;
}
/*
*
*/
.nav .item {
width: calc(50% - 70rpx);
margin-bottom: 20rpx;
}
.nav .item:nth-child(2n) {
margin-right: 20rpx;
margin-left: 10rpx;
}
.nav .item:nth-child(2n+1) {
margin-left: 20rpx;
margin-right: 10rpx;
}
.nav .item image {
width: 80rpx;
height: 80rpx;
margin: 0 auto;
}

View File

@ -1,256 +1,175 @@
<template>
<view>
<!-- 钱包信息 -->
<view class="wallet bg-white">
<view class="item normal oh">
<view class="fl cr-base name">有效</view>
<view class="fl cr-main money single-text">{{user_wallet.normal_money || '0.00'}}</view>
<view class="fl cr-gray unit"></view>
</view>
<view class="item frozen oh">
<view class="fl cr-base name">冻结</view>
<view class="fl money single-text">{{user_wallet.frozen_money || '0.00'}}</view>
<view class="fl cr-gray unit"></view>
</view>
<view class="item give oh">
<view class="fl cr-base name">赠送</view>
<view class="fl money single-text">{{user_wallet.give_money || '0.00'}}</view>
<view class="fl cr-gray unit"></view>
</view>
<view class="submit">
<navigator v-if="(data_base || null) == null || data_base.is_enable_recharge == 1" url="/pages/plugins/wallet/recharge/recharge" hover-class="none" class="fl">
<button size="mini" type="default" hover-class="none" class="submit-recharge">充值</button>
</navigator>
<navigator v-if="(data_base || null) == null || data_base.is_enable_cash == 1" url="/pages/plugins/wallet/cash-auth/cash-auth" hover-class="none" class="fl">
<button size="mini" type="default" hover-class="none" class="submit-cash">提现</button>
</navigator>
</view>
</view>
<!-- 导航 -->
<view v-if="nav_list.length > 0" class="nav spacing-mt oh bg-white">
<block v-for="(item, index) in nav_list" :key="index">
<navigator :url="item.url" hover-class="none">
<view class="item fl tc">
<image :src="item.icon" mode="scaleToFill" class="dis-block"></image>
<view class="title">{{item.title}}</view>
</view>
</navigator>
</block>
</view>
<!-- 通知 -->
<view v-if="(data_base.user_center_notice || null) != null && data_base.user_center_notice.length > 0" class="tips-container spacing-mt spacing-mb">
<view class="tips">
<view v-for="(item, index) in data_base.user_center_notice" :key="index" class="item">
{{item}}
</view>
</view>
</view>
</view>
</template>
<script>
const app = getApp();
export default {
data() {
return {
data_bottom_line_status: false,
data_list_loding_status: 1,
data_list_loding_msg: '',
data_base: null,
user_wallet: null,
submit_disabled_status: false,
//
nav_list: []
};
},
components: {},
props: {},
onLoad(params) {},
onShow() {
this.set_nav_list();
this.init();
},
//
onPullDownRefresh() {
this.get_data();
},
methods: {
init(e) {
var user = app.globalData.get_user_info(this, "init"),
self = this;
if (user != false) {
//
if (app.globalData.user_is_need_login(user)) {
uni.showModal({
title: '温馨提示',
content: '绑定手机号码',
confirmText: '确认',
cancelText: '暂不',
success: result => {
uni.stopPullDownRefresh();
if (result.confirm) {
uni.navigateTo({
url: "/pages/login/login?event_callback=init"
});
}
}
});
} else {
self.get_data();
}
}
},
//
set_nav_list() {
var nav = [{
icon: "/static/images/plugins/wallet/user-center-wallet-log-icon.png",
title: "账户明细",
url: "/pages/plugins/wallet/wallet-log/wallet-log"
}, {
icon: "/static/images/plugins/wallet/user-center-recharge-icon.png",
title: "充值记录",
url: "/pages/plugins/wallet/user-recharge/user-recharge"
}, {
icon: "/static/images/plugins/wallet/user-center-cash-icon.png",
title: "提现记录",
url: "/pages/plugins/wallet/user-cash/user-cash"
}];
this.setData({
nav_list: nav
});
},
//
get_data() {
var self = this;
uni.request({
url: app.globalData.get_request_url("index", "user", "wallet"),
method: "POST",
data: {},
dataType: "json",
success: res => {
uni.stopPullDownRefresh();
if (res.data.code == 0) {
var data = res.data.data;
self.setData({
data_base: data.base || null,
user_wallet: data.user_wallet || null,
data_list_loding_msg: '',
data_list_loding_status: 0,
data_bottom_line_status: false
});
} else {
self.setData({
data_bottom_line_status: false,
data_list_loding_status: 2,
data_list_loding_msg: res.data.msg
});
if (app.globalData.is_login_check(res.data, self, 'get_data')) {
app.globalData.showToast(res.data.msg);
}
}
},
fail: () => {
uni.stopPullDownRefresh();
self.setData({
data_bottom_line_status: false,
data_list_loding_status: 2,
data_list_loding_msg: '服务器请求出错'
});
app.globalData.showToast("服务器请求出错");
}
});
}
}
};
</script>
<style>
/*
* 基础
*/
.wallet {
padding: 20rpx 10rpx;
position: relative;
}
.wallet .item {
line-height: 56rpx;
}
.wallet .money {
font-weight: 500;
font-size: 36rpx;
margin: 0 10rpx;
max-width: calc(100% - 110rpx);
}
.wallet .frozen .money {
color: #FF9800;
}
.wallet .give .money {
color: #333;
max-width: calc(100% - 360rpx);
}
.wallet .submit {
position: absolute;
right: 10rpx;
bottom: 10rpx;
}
.wallet .submit button {
font-size: 26rpx;
height: 55rpx;
line-height: 55rpx;
color: #fff;
padding: 0 20rpx;
}
.wallet .submit-recharge {
border: 1px solid #d2364c;
background-color: #d2364c;
}
.wallet .submit-cash {
border: 1px solid #5eb95e;
background-color: #5eb95e;
margin-left: 30rpx;
}
/*
* 导航
*/
.nav {
border-top: 1px solid #eee;
}
.nav .item {
padding: 30rpx 0;
width: calc(50% - 1px);
border-bottom: 1px solid #eee;
}
.nav .item:nth-child(odd) {
border-right: 1px solid #eee;
}
.nav .item image {
width: 100rpx;
height: 100rpx;
margin: 0 auto;
}
.nav .item .title {
margin-top: 20rpx;
}
/*
* 提示信息
*/
.tips-container .tips-item {
padding: 0 10rpx;
}
<template>
<view>
<!-- 钱包信息 -->
<view class="padding-main">
<view class="padding-main border-radius-main bg-white pr">
<view class="item oh">
<view class="fl cr-base">有效</view>
<view class="fl cr-main fw-b single-text margin-left-sm margin-right-sm">{{user_wallet.normal_money || '0.00'}}</view>
<view class="fl cr-gray unit"></view>
</view>
<view class="item oh margin-top-sm">
<view class="fl cr-bas">冻结</view>
<view class="fl cr-red fw-b single-text margin-left-sm margin-right-sm">{{user_wallet.frozen_money || '0.00'}}</view>
<view class="fl cr-gray unit"></view>
</view>
<view class="item oh margin-top-sm">
<view class="fl cr-base">赠送</view>
<view class="fl cr-base fw-b single-text margin-left-sm margin-right-sm">{{user_wallet.give_money || '0.00'}}</view>
<view class="fl cr-gray unit"></view>
</view>
<view class="submit-container pa">
<navigator v-if="(data_base || null) != null && (data_base.is_enable_recharge || 0) == 1" class="dis-inline" url="/pages/plugins/wallet/recharge/recharge" hover-class="none">
<button class="round cr-white bg-green br-green text-size-sm" size="mini" type="default" hover-class="none">充值</button>
</navigator>
<navigator v-if="(data_base || null) != null && (data_base.is_enable_cash || 0) == 1" class="dis-inline" url="/pages/plugins/wallet/cash-auth/cash-auth" hover-class="none">
<button class="round cr-white bg-main br-main text-size-sm margin-left-lg" size="mini" type="default" hover-class="none">提现</button>
</navigator>
</view>
</view>
</view>
<!-- 导航 -->
<view v-if="nav_list.length > 0" class="nav oh">
<block v-for="(item, index) in nav_list" :key="index">
<view class="item fl tc padding-main border-radius-main bg-white">
<navigator :url="item.url" hover-class="none">
<image :src="item.icon" mode="scaleToFill" class="dis-block"></image>
<view class="tc cr-base margin-top-lg">{{item.title}}</view>
</navigator>
</view>
</block>
</view>
<!-- 通知 -->
<view v-if="(data_base.user_center_notice || null) != null && data_base.user_center_notice.length > 0" class="padding-horizontal-main padding-bottom-main">
<view class="notice-content">
<view v-for="(item, index) in data_base.user_center_notice" :key="index" class="item">{{item}}</view>
</view>
</view>
</view>
</template>
<script>
const app = getApp();
export default {
data() {
return {
data_bottom_line_status: false,
data_list_loding_status: 1,
data_list_loding_msg: '',
data_base: null,
user_wallet: null,
submit_disabled_status: false,
//
nav_list: []
};
},
components: {},
props: {},
onLoad(params) {},
onShow() {
this.set_nav_list();
this.init();
},
//
onPullDownRefresh() {
this.get_data();
},
methods: {
init(e) {
var user = app.globalData.get_user_info(this, "init");
if (user != false) {
//
if (app.globalData.user_is_need_login(user)) {
uni.showModal({
title: '温馨提示',
content: '绑定手机号码',
confirmText: '确认',
cancelText: '暂不',
success: result => {
uni.stopPullDownRefresh();
if (result.confirm) {
uni.navigateTo({
url: "/pages/login/login?event_callback=init"
});
}
}
});
} else {
this.get_data();
}
}
},
//
set_nav_list() {
var nav = [{
icon: "/static/images/plugins/wallet/user-center-wallet-log-icon.png",
title: "账户明细",
url: "/pages/plugins/wallet/wallet-log/wallet-log"
}, {
icon: "/static/images/plugins/wallet/user-center-recharge-icon.png",
title: "充值记录",
url: "/pages/plugins/wallet/user-recharge/user-recharge"
}, {
icon: "/static/images/plugins/wallet/user-center-cash-icon.png",
title: "提现记录",
url: "/pages/plugins/wallet/user-cash/user-cash"
}];
this.setData({
nav_list: nav
});
},
//
get_data() {
uni.request({
url: app.globalData.get_request_url("index", "user", "wallet"),
method: "POST",
data: {},
dataType: "json",
success: res => {
uni.stopPullDownRefresh();
if (res.data.code == 0) {
var data = res.data.data;
this.setData({
data_base: data.base || null,
user_wallet: data.user_wallet || null,
data_list_loding_msg: '',
data_list_loding_status: 0,
data_bottom_line_status: false
});
} else {
this.setData({
data_bottom_line_status: false,
data_list_loding_status: 2,
data_list_loding_msg: res.data.msg
});
if (app.globalData.is_login_check(res.data, this, 'get_data')) {
app.globalData.showToast(res.data.msg);
}
}
},
fail: () => {
uni.stopPullDownRefresh();
this.setData({
data_bottom_line_status: false,
data_list_loding_status: 2,
data_list_loding_msg: '服务器请求出错'
});
app.globalData.showToast("服务器请求出错");
}
});
}
}
};
</script>
<style>
@import './user.css';
</style>