init
This commit is contained in:
128
fuintUniapp/pages/wallet/balance/log.vue
Normal file
128
fuintUniapp/pages/wallet/balance/log.vue
Normal file
@@ -0,0 +1,128 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<mescroll-body ref="mescrollRef" :sticky="true" @init="mescrollInit" :down="{ use: false }" :up="upOption"
|
||||
@up="upCallback">
|
||||
<view class="log-list">
|
||||
<view v-for="(item, index) in list.content" :key="index" class="log-item">
|
||||
<view class="item-left flex-box">
|
||||
<view class="rec-status">
|
||||
<text>{{ item.description ? item.description : '' }}</text>
|
||||
<text v-if="!item.description">{{ item.amount > 0 ? '增加金额' : '减少金额' }}</text>
|
||||
</view>
|
||||
<view class="rec-time">
|
||||
<text>{{ item.createTime | timeFormat('yyyy-mm-dd hh:MM') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item-right">
|
||||
<text>{{ item.amount > 0 ? '+' : '' }}{{ item.amount }}元</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</mescroll-body>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import MescrollBody from '@/components/mescroll-uni/mescroll-body.vue'
|
||||
import MescrollMixin from '@/components/mescroll-uni/mescroll-mixins'
|
||||
import * as LogApi from '@/api/balance'
|
||||
import { getEmptyPaginateObj, getMoreListData } from '@/utils/app'
|
||||
|
||||
const pageSize = 20
|
||||
|
||||
export default {
|
||||
components: {
|
||||
MescrollBody
|
||||
},
|
||||
mixins: [MescrollMixin],
|
||||
data() {
|
||||
return {
|
||||
// 余额账单明细列表
|
||||
list: getEmptyPaginateObj(),
|
||||
// 上拉加载配置
|
||||
upOption: {
|
||||
// 首次自动执行
|
||||
auto: true,
|
||||
// 每页数据的数量; 默认20
|
||||
page: { size: pageSize },
|
||||
// 数量要大于12条才显示无更多数据
|
||||
noMoreSize: 20,
|
||||
// 空布局
|
||||
empty: {
|
||||
tip: '亲,暂无账单明细.'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {},
|
||||
|
||||
methods: {
|
||||
|
||||
/**
|
||||
* 上拉加载的回调 (页面初始化时也会执行一次)
|
||||
* 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10
|
||||
* @param {Object} page
|
||||
*/
|
||||
upCallback(page) {
|
||||
const app = this
|
||||
// 设置列表数据
|
||||
app.getLogList(page.num)
|
||||
.then(list => {
|
||||
const curPageLen = list.content.length
|
||||
const totalSize = list.totalElements
|
||||
app.mescroll.endBySize(curPageLen, totalSize)
|
||||
})
|
||||
.catch(() => app.mescroll.endErr())
|
||||
},
|
||||
|
||||
// 获取余额账单明细列表
|
||||
getLogList(pageNo = 1) {
|
||||
const app = this
|
||||
return new Promise((resolve, reject) => {
|
||||
LogApi.list({ page: pageNo })
|
||||
.then(result => {
|
||||
// 合并新数据
|
||||
const newList = result.data.data
|
||||
app.list.content = getMoreListData(newList, app.list, pageNo)
|
||||
resolve(newList)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
page,
|
||||
.container {
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.log-list {
|
||||
padding: 0 30rpx;
|
||||
}
|
||||
|
||||
.log-item {
|
||||
font-size: 28rpx;
|
||||
padding: 20rpx 20rpx;
|
||||
line-height: 1.8;
|
||||
border-bottom: 1rpx solid rgb(238, 238, 238);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.item-right {
|
||||
color: #000;
|
||||
font-weight: bold;
|
||||
}
|
||||
.rec-status {
|
||||
color: #333;
|
||||
.rec-time {
|
||||
color: rgb(160, 160, 160);
|
||||
font-size: 26rpx;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
160
fuintUniapp/pages/wallet/index.vue
Normal file
160
fuintUniapp/pages/wallet/index.vue
Normal file
@@ -0,0 +1,160 @@
|
||||
<template>
|
||||
<view class="container" v-if="!isLoading">
|
||||
<view class="space-upper">
|
||||
<view class="wallet-account">
|
||||
<view class="wallet-account_balance">
|
||||
<text>¥{{ userInfo.balance }}</text>
|
||||
</view>
|
||||
<view class="wallet-account_lable">
|
||||
<text>余额(元)</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="space-lower">
|
||||
<view class="space-lower_item btn-recharge">
|
||||
<view class="btn-submit" @click="onTargetRecharge()">充值</view>
|
||||
</view>
|
||||
<view class="space-lower_item item-lable dis-flex flex-x-around">
|
||||
<view class="lable-text" @click="onTargetRechargeOrder()">
|
||||
<text>充值记录</text>
|
||||
</view>
|
||||
<view class="lable-text" @click="onTargetBalanceLog()">
|
||||
<text>账单详情</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as UserApi from '@/api/user'
|
||||
import * as BalanceApi from '@/api/balance'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
// 正在加载
|
||||
isLoading: true,
|
||||
// 会员信息
|
||||
userInfo: {},
|
||||
// 充值设置
|
||||
setting: {},
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
// 获取页面数据
|
||||
this.getPageData()
|
||||
},
|
||||
|
||||
methods: {
|
||||
|
||||
// 获取页面数据
|
||||
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) => {
|
||||
BalanceApi.setting()
|
||||
.then(result => {
|
||||
app.setting = result.data.data
|
||||
resolve(app.setting)
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
// 跳转充值页面
|
||||
onTargetRecharge() {
|
||||
this.$navTo('pages/wallet/recharge/index')
|
||||
},
|
||||
|
||||
// 跳转充值记录页面
|
||||
onTargetRechargeOrder() {
|
||||
this.$navTo('pages/wallet/recharge/order')
|
||||
},
|
||||
|
||||
// 跳转账单详情页面
|
||||
onTargetBalanceLog() {
|
||||
this.$navTo('pages/wallet/balance/log')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
page {
|
||||
background: #fff;
|
||||
}
|
||||
</style>
|
||||
<style lang="scss" scoped>
|
||||
.container {
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.space-upper {
|
||||
padding: 100rpx 0;
|
||||
text-align: center;
|
||||
background: $fuint-theme;
|
||||
margin: 50rpx 30rpx 10rpx 30rpx;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.wallet-account {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.wallet-account_balance {
|
||||
font-size: 52rpx;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
.wallet-account_lable {
|
||||
margin-top: 10rpx;
|
||||
color: #FFFFFF;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.space-lower {
|
||||
margin-top: 30rpx;
|
||||
padding: 0rpx 30rpx 0rpx 30rpx;
|
||||
}
|
||||
|
||||
.btn-recharge .btn-submit {
|
||||
width: 100%;
|
||||
height: 84rpx;
|
||||
line-height: 84rpx;
|
||||
margin: 100rpx auto;
|
||||
text-align: center;
|
||||
border-radius: 40rpx;
|
||||
background: linear-gradient(to right, #f9211c, #ff6335);
|
||||
color: white;
|
||||
font-size: 30rpx;
|
||||
}
|
||||
|
||||
.item-lable {
|
||||
margin-top: 80rpx;
|
||||
font-size: 26rpx;
|
||||
color: rgb(94, 94, 94);
|
||||
padding: 0 100rpx;
|
||||
}
|
||||
</style>
|
||||
294
fuintUniapp/pages/wallet/recharge/index.vue
Normal file
294
fuintUniapp/pages/wallet/recharge/index.vue
Normal file
@@ -0,0 +1,294 @@
|
||||
<template>
|
||||
<view class="container" v-if="userInfo.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-plan clearfix" v-if="setting.planList.length > 0">
|
||||
<block v-for="(item, index) in setting.planList" :key="index">
|
||||
<view class="recharge-plan_item" :class="{ active: rechargeAmount == item.rechargeAmount }" @click="onSelectPlan(item.rechargeAmount)">
|
||||
<view class="plan_money">
|
||||
<text>{{ item.rechargeAmount }}</text>
|
||||
</view>
|
||||
<view class="plan_gift" v-if="item.giveAmount > 0">
|
||||
<text>送{{ item.giveAmount }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
<!-- 手动充值输入框 -->
|
||||
<view class="recharge-input" v-if="!setting.planList || setting.planList.length < 1">
|
||||
<input type="digit" placeholder="请输入充值金额" v-model="inputValue" @input="onChangeMoney" />
|
||||
</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" v-if="setting.remark.length > 0">
|
||||
<view class="recharge-label">
|
||||
<text>充值说明</text>
|
||||
</view>
|
||||
<view class="content">
|
||||
<text space="ensp">{{setting.remark}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as UserApi from '@/api/user'
|
||||
import * as BalanceApi from '@/api/balance'
|
||||
import { wxPayment } from '@/utils/app'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
// 正在加载
|
||||
isLoading: true,
|
||||
// 会员信息
|
||||
userInfo: {},
|
||||
// 充值设置
|
||||
setting: { isOpen: false, planList: [], remark: '' },
|
||||
// 按钮禁用
|
||||
disabled: false,
|
||||
// 当前选中的套餐id
|
||||
rechargeAmount: 0,
|
||||
// 自定义金额
|
||||
inputValue: '',
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
// 获取页面数据
|
||||
this.getPageData()
|
||||
},
|
||||
|
||||
methods: {
|
||||
|
||||
/**
|
||||
* 选择充值套餐
|
||||
*/
|
||||
onSelectPlan(rechargeAmount) {
|
||||
this.rechargeAmount = rechargeAmount
|
||||
this.inputValue = ''
|
||||
},
|
||||
|
||||
// 金额输入框
|
||||
onChangeMoney(e) {
|
||||
this.inputValue = e.target.value
|
||||
this.rechargeAmount = 0
|
||||
},
|
||||
|
||||
// 获取页面数据
|
||||
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) => {
|
||||
BalanceApi.setting()
|
||||
.then(result => {
|
||||
app.setting = result.data
|
||||
console.log("app.setting = ", app.setting)
|
||||
resolve(app.setting)
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
// 立即充值
|
||||
onSubmit(e) {
|
||||
const app = this
|
||||
if (!app.setting.isOpen) {
|
||||
app.$error('当前未开启充值!')
|
||||
return false
|
||||
}
|
||||
|
||||
if (parseFloat(app.rechargeAmount) <= 0 && app.inputValue.length < 1) {
|
||||
app.$error('请确认充值金额!')
|
||||
return false
|
||||
}
|
||||
|
||||
// 按钮禁用
|
||||
app.disabled = true
|
||||
// 提交到后端
|
||||
BalanceApi.doRecharge(app.rechargeAmount, app.inputValue)
|
||||
.then(result => app.wxPayment(result.data.payment))
|
||||
.catch(err => app.$error('提交支付失败'))
|
||||
.finally(() => app.disabled = false)
|
||||
},
|
||||
|
||||
// 发起微信支付
|
||||
wxPayment(option) {
|
||||
const app = this
|
||||
wxPayment(option)
|
||||
.then(() => {
|
||||
app.$success('支付成功')
|
||||
setTimeout(() => {
|
||||
// 获取页面数据
|
||||
app.getPageData()
|
||||
}, 1500)
|
||||
})
|
||||
.catch(err => app.$error('订单未支付'))
|
||||
}
|
||||
}
|
||||
}
|
||||
</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: 8rpx;
|
||||
color: #fff;
|
||||
background: $fuint-theme;
|
||||
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: 32rpx;
|
||||
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: 5rpx;
|
||||
margin: 0 20rpx 20rpx 0;
|
||||
|
||||
&:nth-child(3n + 0) {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: #E3BE83;
|
||||
color: #FFFFFF;
|
||||
border: 1rpx solid #EDD2A9;
|
||||
.plan_money {
|
||||
color: #FFFFFF;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.plan_money {
|
||||
font-size: 32rpx;
|
||||
color: rgb(82, 82, 82);
|
||||
}
|
||||
|
||||
.plan_gift {
|
||||
font-size: 25rpx;
|
||||
}
|
||||
|
||||
.recharge-input {
|
||||
margin-top: 25rpx;
|
||||
|
||||
input {
|
||||
border: 1rpx solid rgb(228, 228, 228);
|
||||
border-radius: 10rpx;
|
||||
padding: 15rpx 16rpx;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
}
|
||||
|
||||
/* 立即充值 */
|
||||
.recharge-submit {
|
||||
margin-top: 70rpx;
|
||||
}
|
||||
|
||||
.btn-submit {
|
||||
.button {
|
||||
font-size: 30rpx;
|
||||
background: linear-gradient(to right, #f9211c, #ff6335);
|
||||
border: none;
|
||||
color: white;
|
||||
border-radius: 40rpx;
|
||||
padding: 0 120rpx;
|
||||
line-height: 3;
|
||||
}
|
||||
|
||||
.button[disabled] {
|
||||
background: #ff6335;
|
||||
border-color: #ff6335;
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
|
||||
/* 充值说明 */
|
||||
.recharge-describe {
|
||||
margin-top: 50rpx;
|
||||
padding: 0 60rpx;
|
||||
.content {
|
||||
font-size: 26rpx;
|
||||
line-height: 1.6;
|
||||
color: #888;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
132
fuintUniapp/pages/wallet/recharge/order.vue
Normal file
132
fuintUniapp/pages/wallet/recharge/order.vue
Normal file
@@ -0,0 +1,132 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<mescroll-body ref="mescrollRef" :sticky="true" @init="mescrollInit" :down="{ use: false }" :up="upOption"
|
||||
@up="upCallback">
|
||||
<view class="log-list">
|
||||
<view v-for="(item, index) in list.content" :key="index" class="log-item">
|
||||
<view class="item-left flex-box">
|
||||
<view class="rec-status">
|
||||
<text>{{ '充值成功' }}</text>
|
||||
</view>
|
||||
<view class="rec-time">
|
||||
<text>{{ item.createTime }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item-right">
|
||||
<text>+{{ item.amount }}元</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</mescroll-body>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import MescrollBody from '@/components/mescroll-uni/mescroll-body.vue'
|
||||
import MescrollMixin from '@/components/mescroll-uni/mescroll-mixins'
|
||||
import * as OrderApi from '@/api/order'
|
||||
import { getEmptyPaginateObj, getMoreListData } from '@/utils/app'
|
||||
|
||||
const pageSize = 20
|
||||
|
||||
export default {
|
||||
components: {
|
||||
MescrollBody
|
||||
},
|
||||
mixins: [MescrollMixin],
|
||||
data() {
|
||||
return {
|
||||
// 余额账单明细列表
|
||||
list: getEmptyPaginateObj(),
|
||||
// 上拉加载配置
|
||||
upOption: {
|
||||
// 首次自动执行
|
||||
auto: true,
|
||||
// 每页数据的数量; 默认10
|
||||
page: { size: pageSize },
|
||||
// 数量要大于20条才显示无更多数据
|
||||
noMoreSize: 20,
|
||||
// 空布局
|
||||
empty: {
|
||||
tip: '亲,暂无充值记录'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {},
|
||||
|
||||
methods: {
|
||||
|
||||
/**
|
||||
* 上拉加载的回调 (页面初始化时也会执行一次)
|
||||
* 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10
|
||||
* @param {Object} page
|
||||
*/
|
||||
upCallback(page) {
|
||||
const app = this
|
||||
// 设置列表数据
|
||||
app.getLogList(page.num)
|
||||
.then(list => {
|
||||
const curPageLen = list.content.length
|
||||
const totalSize = list.totalElements
|
||||
app.mescroll.endBySize(curPageLen, totalSize)
|
||||
})
|
||||
.catch(() => app.mescroll.endErr())
|
||||
},
|
||||
|
||||
// 获取余额账单明细列表
|
||||
getLogList(pageNo = 1) {
|
||||
const app = this
|
||||
return new Promise((resolve, reject) => {
|
||||
OrderApi.list({ page: pageNo, type: 'recharge', 'payStatus': 'B' })
|
||||
.then(result => {
|
||||
// 合并新数据
|
||||
const newList = result.data
|
||||
app.list.content = getMoreListData(newList, app.list, pageNo)
|
||||
resolve(newList)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
page,
|
||||
.container {
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.log-list {
|
||||
padding: 0 30rpx;
|
||||
}
|
||||
|
||||
.log-item {
|
||||
font-size: 28rpx;
|
||||
padding: 20rpx 20rpx;
|
||||
line-height: 1.8;
|
||||
border-bottom: 1rpx solid rgb(238, 238, 238);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.item-right {
|
||||
color: #000;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.rec-status {
|
||||
color: #333;
|
||||
|
||||
.rec-time {
|
||||
color: rgb(160, 160, 160);
|
||||
font-size: 26rpx;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user