diff --git a/pages/meterBalanceRecord/index.js b/pages/meterBalanceRecord/index.js index 71786ed..ae3edec 100644 --- a/pages/meterBalanceRecord/index.js +++ b/pages/meterBalanceRecord/index.js @@ -1,4 +1,8 @@ import dayjs from "../../utils/dayjs" +import { getDayCalcList } from "../../service/calc" +import { alertError } from "../../utils/index"; +import request from "../../utils/request" +const { OK } = request // pages/meterBalanceRecord/index.js Page({ @@ -9,6 +13,9 @@ Page({ data: { time: "", timeStamp: undefined, + list: [], + page: 1, + size: 999, }, /** @@ -16,11 +23,13 @@ Page({ */ onLoad(options) { const { id } = options - console.log("id---", id) + const that = this; this.setData({ id, time: dayjs().format("YYYY-MM"), timeStamp: Date.now() + }, () => { + that.getList() }) }, clickTime() { @@ -28,13 +37,35 @@ Page({ timeVisible: true }) }, + async getList() { + const { id, time, page, size } = this.data; + const { code, message, data } = await getDayCalcList({ + page, + size, + startTime: dayjs(time).subtract(1, 'month').endOf('month').format("YYYY-MM-DD"), + endTime: dayjs(time).endOf('month').format("YYYY-MM-DD"), + codeId: id, + }) + if (code !== OK) { + alertError(message) + return + } + this.setData({ + list: data?.map(item => { + item.day = dayjs(item.endTime).format("DD日") + return item; + }) + }) + }, onTimeConfirm(e) { - console.log('e', e) const { time } = e.detail; + const that = this; this.setData({ time, timeStamp: new Date(time).getTime(), timeVisible: false, + }, () => { + that.getList() }) }, onTimeCancel() { diff --git a/pages/meterBalanceRecord/index.json b/pages/meterBalanceRecord/index.json index a1cb3b6..21e1dfc 100644 --- a/pages/meterBalanceRecord/index.json +++ b/pages/meterBalanceRecord/index.json @@ -2,7 +2,11 @@ "usingComponents": { "navigator": "/components/navigator/index", "timePicker": "/components/timePicker/index", - "van-icon": "@vant/weapp/icon/index" + "van-icon": "@vant/weapp/icon/index", + "van-tag": "@vant/weapp/tag/index", + "van-row": "@vant/weapp/row/index", + "empty": "/components/empty/index", + "van-col": "@vant/weapp/col/index" }, "navigationStyle": "custom" } \ No newline at end of file diff --git a/pages/meterBalanceRecord/index.wxml b/pages/meterBalanceRecord/index.wxml index b63cca9..54a812e 100644 --- a/pages/meterBalanceRecord/index.wxml +++ b/pages/meterBalanceRecord/index.wxml @@ -9,6 +9,50 @@ + + + + + + 日期 + + + 充值金额 + + + 电费 + + + 电表余额 + + + + + + + + {{ item.day }} + + + {{ item.topFee }} + -{{ item.topFee }} + 0 + + + + 0 + + {{item.money}} + + + {{item.balance}} + + + + + + + diff --git a/pages/meterBalanceRecord/index.wxss b/pages/meterBalanceRecord/index.wxss index de2bff8..0037407 100644 --- a/pages/meterBalanceRecord/index.wxss +++ b/pages/meterBalanceRecord/index.wxss @@ -23,4 +23,64 @@ .timeText { flex: 1; - } \ No newline at end of file + } + + .table { + width: 890rpx; + +} + +.classWrapper { + width: 100vw; + overflow-x: auto; +} + +.thead { + display: flex; + flex-wrap: nowrap; + border-bottom: 1rpx solid #EEEEEE; +} + +.thead .th { + padding: 20rpx; + white-space: nowrap; + text-align: center; + box-sizing: border-box; + +} + +.tbody { + width: 890rpx; +} + +.tbody .tr { + padding: 20rpx; + border-bottom: 1rpx solid #EEEEEE; + display: flex; + align-items: center; + flex-wrap: nowrap; +} + +.tbody .th { + word-break: break-all; + text-align: center; +} + +.customTable { + margin: 20rpx 0; + padding-bottom: 30rpx; +} + +.customTableTile { + background-color: var(--light-green); + padding: 16rpx; + box-sizing: border-box; + font-weight: 700; +} + +.tableRow { + padding: 16rpx; + border: 1rpx solid #ccc; + border-top: 0rpx; + font-size: 32rpx; +} diff --git a/service/calc.js b/service/calc.js new file mode 100644 index 0000000..2479450 --- /dev/null +++ b/service/calc.js @@ -0,0 +1,9 @@ +import apis from '../utils/request'; +import { replaceSpecialIcon } from '../utils/index' +const { GET, POST, PUT, DELETE } = apis + +// 获取电表列表 +export const getDayCalcList = async function({ page, size, startTime, endTime, codeId }) { + const park = wx.getStorageSync('park') + return await GET(`/accounting/getEveryDayAccountingList?park=${park?.id}&page=${page}&size=${size}&startTime=${startTime}&endTime=${endTime}&codeId=${codeId}`); +} \ No newline at end of file