账户调整

This commit is contained in:
2023-02-08 20:57:17 +08:00
parent 668a387554
commit eb071d6546
5 changed files with 25 additions and 26 deletions

View File

@@ -3,6 +3,7 @@ Page({
data: { data: {
sid: -1, sid: -1,
showSetMoney: false, showSetMoney: false,
currentMoney: 0,
currentMoneyText: 0, currentMoneyText: 0,
expendBalance: 0, expendBalance: 0,
incomeBalance: 0, incomeBalance: 0,
@@ -17,18 +18,18 @@ Page({
}, },
onLoad: function (options) { onLoad: function (options) {
let sid = options.sid let sid = options.sid
let currentMoney = options.balance
let currentMoneyText = options.balance let currentMoneyText = options.balance
this.setData({sid,currentMoneyText}) this.setData({sid,currentMoney,currentMoneyText})
let dateRange = [new Date().getTime()- 24 * 60 * 60 * 1000,new Date().getTime()] let dateRange = [new Date().getTime()- 24 * 60 * 60 * 1000,new Date().getTime()]
let dateRangeText = app.$utils.formatDate(new Date(dateRange[0])) + '至' + let dateRangeText = app.$utils.formatDate(new Date(dateRange[0])) + '至' +
(dateRange[1] ? app.$utils.formatDate(new Date(dateRange[1])) : app.$utils.formatDate(new Date())); (dateRange[1] ? app.$utils.formatDate(new Date(dateRange[1])) : app.$utils.formatDate(new Date()));
this.setData({dateRange,dateRangeText}) this.setData({dateRange,dateRangeText})
}, },
onShow() { onShow() {
app.$api.listBillByAccount({ app.$api.listBillByAccount({
id:this.data.sid, sid:this.data.sid,
dateRangeText:this.data.dateRangeText, dateRange:this.data.dateRangeText,
}).then(res => { }).then(res => {
if (res.data){ if (res.data){
let incomeList = res.data.incomeList; let incomeList = res.data.incomeList;
@@ -59,28 +60,31 @@ Page({
showDialog() { showDialog() {
this.setData({ this.setData({
showSetMoney: true, showSetMoney: true,
currentMoneyText: this.data.currentMoneyText currentMoney: this.data.currentMoneyText
}) })
}, },
onPriceInput(e) { onPriceInput(e) {
this.setData({ this.setData({
currentMoneyText: e.detail.value currentMoney: e.detail.value
}) })
}, },
onConfirm () { onConfirm () {
const isNumber = /^\d+(\.\d+)?$/.test(this.data.currentMoneyText); const isNumber = /^\d+(\.\d+)?$/.test(this.data.currentMoney);
if (!isNumber) { if (!isNumber) {
this.setData({ this.setData({
priceError: true priceError: true
}) })
return; return;
} }
app.$api.editAccount({});
this.setData({ this.setData({
currentMoneyText: this.data.currentMoneyText, currentMoneyText:this.data.currentMoney,
priceError: false priceError: false
}) })
app.$api.editAccount({sid:this.data.sid,balance:this.data.currentMoney}).then(res => {
if (res){
this.closeDialog() this.closeDialog()
}
})
}, },
closeDialog() { closeDialog() {
this.setData({ this.setData({

View File

@@ -53,5 +53,5 @@
bind:confirm="onConfirm" bind:confirm="onConfirm"
bind:cancel="closeDialog" bind:cancel="closeDialog"
> >
<t-input bindchange="onPriceInput" value="{{currentMoneyText}}" tips="{{priceError ? '请输入正确金额' : ''}}" slot="content" type="number" placeholder="0.00"/> <t-input bindchange="onPriceInput" value="{{currentMoney}}" tips="{{priceError ? '请输入正确金额' : ''}}" slot="content" type="number" placeholder="0.00"/>
</t-dialog> </t-dialog>

View File

@@ -1,3 +1,4 @@
const app = getApp();
Page({ Page({
data: { data: {
noMoney : "****", noMoney : "****",
@@ -5,13 +6,8 @@ Page({
sumBalance: 0, sumBalance: 0,
cashBalance: 0, cashBalance: 0,
oweBalance: 0, oweBalance: 0,
cashAccountList : [ cashAccountList : [],
{"name":"现金","money":"2000.00"}, oweAccountList : []
{"name":"银行卡","money":"30500.03"}
],
oweAccountList : [
{"name":"信用卡","money":"-200.00"},
]
}, },
onLoad: function (options) { onLoad: function (options) {

View File

@@ -13,7 +13,7 @@
<t-cell wx:for="{{incomeList}}" wx:key="index" <t-cell wx:for="{{incomeList}}" wx:key="index"
title="{{item.name}}" title="{{item.name}}"
align="top" align="top"
image="/image/bill/11.png" image="{{item.icon}}"
note="{{item.money}}" note="{{item.money}}"
url="../edit/index?isAccount=0&isIncome=1&isAdd=0&id={{item.id}}" url="../edit/index?isAccount=0&isIncome=1&isAdd=0&id={{item.id}}"
/> />

View File

@@ -1,22 +1,21 @@
import utils from './util' import utils from './util'
//testURL //testURL
const BASE_URL = 'http://127.0.0.1:8080/wx'; // const BASE_URL = 'http://127.0.0.1:8080/wx';
const LOGIN_URL = 'https://api.weixin.qq.com/sns/jscode2session'; //devURL
// const BASE_URL = 'https://lmqhznn.goho.co/wx';
//prodURL //prodURL
// const BASE_URL = 'https://www.qnforever.top/wx'; const BASE_URL = 'https://www.qnforever.top/wx';
function buildURL(url, needToken) { function buildURL(url, needToken) {
let userId = wx.getStorageSync('userId'); let userId = wx.getStorageSync('userId');
if (!userId && url != '/user/login') { if (!userId && url != '/user/login') {
wx.redirectTo({ wx.redirectTo({
url: '../myself/index' url: '../myself/index'
}) })
wx.showLoading({ wx.showToast({
title: '请先登录', title: '请先登录',
mask: true, mask: true,
duration: 2000
}) })
setTimeout(function () {
wx.hideLoading()
}, 2000)
return; return;
} }
if (url != '/user/login'){ if (url != '/user/login'){