优化代码

This commit is contained in:
Your Name 2023-03-11 13:19:40 +08:00
parent d8ce7af695
commit 19859de024
3 changed files with 192 additions and 47 deletions

View File

@ -802,6 +802,15 @@
}
}
,{
"path" : "pages/account/preStoreAccount",
"style" :
{
"navigationBarTitleText": "账户充值",
"enablePullDownRefresh": false
}
}
],
"tabBar": {
"color": "#272636",

View File

@ -1,12 +1,16 @@
<template>
<view >
<view class="tab-container bg-white">
<view class="cu-list menu">
<view class="cu-item arrow" v-if="accounts.length > 0" v-for="(item, key) in accounts" :key="key" :data-item="item" @click="myAccountDetail(item)">
<view class="cu-item arrow" v-if="accounts.length > 0" v-for="(item, key) in accounts" :key="key"
:data-item="item" @click="myAccountDetail(item)">
<view class="content padding-tb-sm">
<view>
<text class="cuIcon-rechargefill text-green margin-right-xs"></text> {{item.acctTypeName}}</view>
<text class="cuIcon-rechargefill text-green margin-right-xs"></text> {{item.acctTypeName}}
</view>
<view class="text-gray text-sm">
<text class="cuIcon-right margin-right-xs"></text>余额: {{item.amount}}</view>
<text class="cuIcon-right margin-right-xs"></text>余额: {{item.amount}}
</view>
</view>
<view class="action">
</view>
@ -14,7 +18,8 @@
<view class="cu-item arrow" @click="coupons(item)">
<view class="content padding-tb-sm">
<view>
<text class="cuIcon-ticket text-green margin-right-xs"></text>我的优惠券</view>
<text class="cuIcon-ticket text-green margin-right-xs"></text>我的优惠券
</view>
<view class="text-gray text-sm">
</view>
</view>
@ -23,13 +28,24 @@
</view>
</view>
</view>
</view>
<view class="plat-btn-black"></view>
<view class="cu-bar btn-group" style="margin-top: 30px;" >
<button @click="_toPrestoreAccount" class="cu-btn bg-orange shadow-blur round lg">账户充值</button>
</view>
</view>
</template>
<script>
// pages/account/myAccount.js
import context from '../../lib/java110/Java110Context.js';
import {queryOwnerAccount} from '../../api/user/userApi.js'
import {
queryOwnerAccount
} from '../../api/user/userApi.js'
export default {
data() {
@ -49,36 +65,12 @@
this.loadOwnerAccount();
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {},
/**
* 用户点击右上角分享
*/
@ -108,14 +100,19 @@
link: _ownerInfo.link,
communityId: _ownerInfo.communityId
}).then((data) => {
if(!data){
_that.accounts=[];
return ;
if (!data) {
_that.accounts = [];
return;
}
_that.accounts = data;
})
}
});
},
_toPrestoreAccount:function(){
uni.navigateTo({
url:'/pages/account/preStoreAccount'
})
}
}
};

View File

@ -0,0 +1,139 @@
<template>
<view>
<view class="block__title">账户充值</view>
<view class="cu-list menu">
<view class="cu-item">
<view class="content">
<text class="text-grey">账户名称</text>
</view>
<view class="action">
<text class="text-grey text-sm">{{account.acctName}}</text>
</view>
</view>
<view class="cu-item">
<view class="content">
<text class="text-grey">账户余额</text>
</view>
<view class="action">
<text class="text-grey text-sm">{{account.amount}}</text>
</view>
</view>
<view class="cu-item">
<view class="content">
<text class="text-grey">充值金额</text>
</view>
<view class="action">
<input v-model="amount" placeholder="请输入充值金额" type="number" class="text-right"></input>
</view>
</view>
</view>
<view class=" bg-white border flex justify-end" style="position: fixed;width: 100%;bottom: 0;">
<view class="action text-orange margin-right line-height">
合计{{amount}}
</view>
<view class="btn-group">
<!-- #ifdef H5 || MP-WEIXIN -->
<button class="cu-btn bg-red shadow-blur lgplus sharp" @click="onPayFee()">提交订单</button>
<!-- #endif -->
<!-- #ifdef APP-PLUS -->
<button class="cu-btn bg-red shadow-blur lgplus sharp" @click="_payWxApp()">提交订单</button>
<!-- #endif -->
</view>
</view>
</view>
</template>
<script>
// pages/account/myAccount.js
import context from '../../lib/java110/Java110Context.js';
import {
queryOwnerAccount
} from '../../api/user/userApi.js';
import {getCommunityId} from '@/api/community/communityApi.js';
import {payFeeApp,payFeeWechat} from '@/api/fee/feeApi.js';
export default {
data() {
return {
account:{},
amount:'',
appId:''
}
},
onLoad(options) {
this.loadOwnerAccount();
// #ifdef MP-WEIXIN
let accountInfo = uni.getAccountInfoSync();
this.appId = accountInfo.miniProgram.appId;
// #endif
// #ifdef H5
this.appId = uni.getStorageSync(constant.mapping.W_APP_ID)
// #endif
},
methods: {
loadOwnerAccount: function() {
let _that = this;
context.getOwner(function(_ownerInfo) {
if (_ownerInfo) {
queryOwnerAccount({
page: 1,
row: 20,
idCard: _ownerInfo.idCard,
link: _ownerInfo.link,
communityId: _ownerInfo.communityId
}).then((data) => {
if (!data) {
_that.account = {};
return;
}
_that.account = data[0];
})
}
});
},
_payWxApp: function(_data) {
let _receivedAmount = this.amount;
let _tradeType = 'APP';
payFeeApp(this,{
communityId: this.communityId,
acctId: this.account.acctId,
feeName: '账户充值',
receivedAmount: _receivedAmount,
tradeType: _tradeType,
appId: this.appId,
});
},
onPayFee: function() {
let _receivedAmount = this.amount;
let _tradeType = 'JSAPI';
payFeeWechat(this,{
business: "preStoreOnline",
communityId: getCommunityId(),
acctId: this.account.acctId,
feeName: '账户充值',
receivedAmount: _receivedAmount,
tradeType: _tradeType,
appId: this.appId,
})
}
}
}
</script>
<style lang="scss">
.block__title {
margin: 0;
font-weight: 400;
font-size: 14px;
color: rgba(69, 90, 100, .6);
padding: 40rpx 30rpx 20rpx;
}
.button_up_blank {
height: 40rpx;
}
</style>